gevent-1.1.0/0000755000076500000000000000000012666555433013540 5ustar jmaddenwheel00000000000000gevent-1.1.0/.pep80000644000076500000000000000036312666555342014416 0ustar jmaddenwheel00000000000000[pep8] ignore=E702,E265,E402,E731,E266,E261,W503,E129 max_line_length=160 exclude=.runtimes,.eggs,.tox,.git,build,2.6,2.7,2.7pypy,3.3,3.5,test_support.py,test_queue.py,patched_tests_setup.py,test_threading_2.py,lock_tests.py,_sslgte279.py,3.4 gevent-1.1.0/.travis.yml0000644000076500000000000000151612666555342015653 0ustar jmaddenwheel00000000000000# .travis.yml based on https://github.com/DRMacIver/hypothesis/blob/master/.travis.yml language: c sudo: false env: global: - BUILD_RUNTIMES=$HOME/.runtimes matrix: # These are ordered to get as much diversity in the # first group of parallel runs (4) as posible - TASK=test-pypy - TASK=lint-py27 - TASK=test-py35 - TASK=test-py26 - TASK=test-py27 - TASK=test-py33 - TASK=test-py34 - TASK=test-py27-cffi matrix: fast_finish: true script: - make $TASK notifications: email: false # cache: pip seems not to work if `install` is replaced (https://github.com/travis-ci/travis-ci/issues/3239) cache: directories: - $HOME/.cache/pip - $HOME/.venv - $HOME/.runtimes - $HOME/.wheelhouse before_cache: - rm -f $HOME/.cache/pip/log/debug.log gevent-1.1.0/appveyor/0000755000076500000000000000000012666555432015404 5ustar jmaddenwheel00000000000000gevent-1.1.0/appveyor/install.ps10000644000076500000000000001603312666555342017502 0ustar jmaddenwheel00000000000000# Sample script to install Python and pip under Windows # Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer # License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ $MINICONDA_URL = "http://repo.continuum.io/miniconda/" $BASE_URL = "https://www.python.org/ftp/python/" $GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" $GET_PIP_PATH = "C:\get-pip.py" $PYTHON_PRERELEASE_REGEX = @" (?x) (?\d+) \. (?\d+) \. (?\d+) (?[a-z]{1,2}\d+) "@ function Download ($filename, $url) { $webclient = New-Object System.Net.WebClient $basedir = $pwd.Path + "\" $filepath = $basedir + $filename if (Test-Path $filename) { Write-Host "Reusing" $filepath return $filepath } # Download and retry up to 3 times in case of network transient errors. Write-Host "Downloading" $filename "from" $url $retry_attempts = 2 for ($i = 0; $i -lt $retry_attempts; $i++) { try { $webclient.DownloadFile($url, $filepath) break } Catch [Exception]{ Start-Sleep 1 } } if (Test-Path $filepath) { Write-Host "File saved at" $filepath } else { # Retry once to get the error message if any at the last try $webclient.DownloadFile($url, $filepath) } return $filepath } function ParsePythonVersion ($python_version) { if ($python_version -match $PYTHON_PRERELEASE_REGEX) { return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro, $matches.prerelease) } $version_obj = [version]$python_version return ($version_obj.major, $version_obj.minor, $version_obj.build, "") } function DownloadPython ($python_version, $platform_suffix) { $major, $minor, $micro, $prerelease = ParsePythonVersion $python_version if (($major -le 2 -and $micro -eq 0) ` -or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) ` ) { $dir = "$major.$minor" $python_version = "$major.$minor$prerelease" } else { $dir = "$major.$minor.$micro" } if ($prerelease) { if (($major -le 2) ` -or ($major -eq 3 -and $minor -eq 1) ` -or ($major -eq 3 -and $minor -eq 2) ` -or ($major -eq 3 -and $minor -eq 3) ` ) { $dir = "$dir/prev" } } if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) { $ext = "msi" if ($platform_suffix) { $platform_suffix = ".$platform_suffix" } } else { $ext = "exe" if ($platform_suffix) { $platform_suffix = "-$platform_suffix" } } $filename = "python-$python_version$platform_suffix.$ext" $url = "$BASE_URL$dir/$filename" $filepath = Download $filename $url return $filepath } function InstallPython ($python_version, $architecture, $python_home) { Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home if (Test-Path $python_home) { Write-Host $python_home "already exists, skipping." return $false } if ($architecture -eq "32") { $platform_suffix = "" } else { $platform_suffix = "amd64" } $installer_path = DownloadPython $python_version $platform_suffix $installer_ext = [System.IO.Path]::GetExtension($installer_path) Write-Host "Installing $installer_path to $python_home" $install_log = $python_home + ".log" if ($installer_ext -eq '.msi') { InstallPythonMSI $installer_path $python_home $install_log } else { InstallPythonEXE $installer_path $python_home $install_log } if (Test-Path $python_home) { Write-Host "Python $python_version ($architecture) installation complete" } else { Write-Host "Failed to install Python in $python_home" Get-Content -Path $install_log Exit 1 } } function InstallPythonEXE ($exepath, $python_home, $install_log) { $install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home" RunCommand $exepath $install_args } function InstallPythonMSI ($msipath, $python_home, $install_log) { $install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home" $uninstall_args = "/qn /x $msipath" RunCommand "msiexec.exe" $install_args if (-not(Test-Path $python_home)) { Write-Host "Python seems to be installed else-where, reinstalling." RunCommand "msiexec.exe" $uninstall_args RunCommand "msiexec.exe" $install_args } } function RunCommand ($command, $command_args) { Write-Host $command $command_args Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru } function InstallPip ($python_home) { $pip_path = $python_home + "\Scripts\pip.exe" $python_path = $python_home + "\python.exe" if (-not(Test-Path $pip_path)) { Write-Host "Installing pip..." $webclient = New-Object System.Net.WebClient $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) Write-Host "Executing:" $python_path $GET_PIP_PATH & $python_path $GET_PIP_PATH } else { Write-Host "pip already installed." } } function DownloadMiniconda ($python_version, $platform_suffix) { if ($python_version -eq "3.4") { $filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe" } else { $filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe" } $url = $MINICONDA_URL + $filename $filepath = Download $filename $url return $filepath } function InstallMiniconda ($python_version, $architecture, $python_home) { Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home if (Test-Path $python_home) { Write-Host $python_home "already exists, skipping." return $false } if ($architecture -eq "32") { $platform_suffix = "x86" } else { $platform_suffix = "x86_64" } $filepath = DownloadMiniconda $python_version $platform_suffix Write-Host "Installing" $filepath "to" $python_home $install_log = $python_home + ".log" $args = "/S /D=$python_home" Write-Host $filepath $args Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru if (Test-Path $python_home) { Write-Host "Python $python_version ($architecture) installation complete" } else { Write-Host "Failed to install Python in $python_home" Get-Content -Path $install_log Exit 1 } } function InstallMinicondaPip ($python_home) { $pip_path = $python_home + "\Scripts\pip.exe" $conda_path = $python_home + "\Scripts\conda.exe" if (-not(Test-Path $pip_path)) { Write-Host "Installing pip..." $args = "install --yes pip" Write-Host $conda_path $args Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru } else { Write-Host "pip already installed." } } function main () { InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON InstallPip $env:PYTHON } main gevent-1.1.0/appveyor/make.cmd0000644000076500000000000000051712666555342017011 0ustar jmaddenwheel00000000000000IF "%PYTHON_EXE%" == "python" ( %PYEXE% util/cythonpp.py -o gevent.corecext.c gevent/corecext.ppyx type gevent\\callbacks.c >> gevent.corecext.c move gevent.corecext.* gevent ) cython -o gevent.ares.c gevent/ares.pyx move gevent.ares.* gevent cython -o gevent._semaphore.c gevent/_semaphore.py move gevent._semaphore.* gevent gevent-1.1.0/appveyor/run_with_env.cmd0000644000076500000000000000644612666555342020612 0ustar jmaddenwheel00000000000000:: To build extensions for 64 bit Python 3, we need to configure environment :: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: :: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) :: :: To build extensions for 64 bit Python 2, we need to configure environment :: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: :: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) :: :: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific :: environment configurations. :: :: Note: this script needs to be run with the /E:ON and /V:ON flags for the :: cmd interpreter, at least for (SDK v7.0) :: :: More details at: :: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows :: http://stackoverflow.com/a/13751649/163740 :: :: Author: Olivier Grisel :: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ :: :: Notes about batch files for Python people: :: :: Quotes in values are literally part of the values: :: SET FOO="bar" :: FOO is now five characters long: " b a r " :: If you don't want quotes, don't include them on the right-hand side. :: :: The CALL lines at the end of this file look redundant, but if you move them :: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y :: case, I don't know why. @ECHO OFF SET COMMAND_TO_RUN=%* SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf :: Extract the major and minor versions, and allow for the minor version to be :: more than 9. This requires the version number to have two dots in it. SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1% IF "%PYTHON_VERSION:~3,1%" == "." ( SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1% ) ELSE ( SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2% ) :: Based on the Python version, determine what SDK version to use, and whether :: to set the SDK for 64-bit. IF %MAJOR_PYTHON_VERSION% == 2 ( SET WINDOWS_SDK_VERSION="v7.0" SET SET_SDK_64=Y ) ELSE ( IF %MAJOR_PYTHON_VERSION% == 3 ( SET WINDOWS_SDK_VERSION="v7.1" IF %MINOR_PYTHON_VERSION% LEQ 4 ( SET SET_SDK_64=Y ) ELSE ( SET SET_SDK_64=N IF EXIST "%WIN_WDK%" ( :: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/ REN "%WIN_WDK%" 0wdf ) ) ) ELSE ( ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%" EXIT 1 ) ) IF %PYTHON_ARCH% == 64 ( IF %SET_SDK_64% == Y ( ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture SET DISTUTILS_USE_SDK=1 SET MSSdk=1 "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release ECHO Executing: %COMMAND_TO_RUN% call %COMMAND_TO_RUN% || EXIT 1 ) ELSE ( ECHO Using default MSVC build environment for 64 bit architecture ECHO Executing: %COMMAND_TO_RUN% call %COMMAND_TO_RUN% || EXIT 1 ) ) ELSE ( ECHO Using default MSVC build environment for 32 bit architecture ECHO Executing: %COMMAND_TO_RUN% call %COMMAND_TO_RUN% || EXIT 1 ) gevent-1.1.0/appveyor.yml0000644000076500000000000001364412666555342016137 0ustar jmaddenwheel00000000000000environment: global: # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the # /E:ON and /V:ON options are not enabled in the batch script intepreter # See: http://stackoverflow.com/a/13751649/163740 CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd" matrix: # Pre-installed Python versions, which Appveyor may upgrade to # a later point release. # XXX: Sadly, PyPy won't link CFFI on Win32 # - PYTHON: "C:\\pypy-4.0.1-win32" # PYTHON_ID: "pypy" # PYTHON_EXE: pypy # PYTHON_VERSION: "2.7.x" # PYTHON_ARCH: "32" - PYTHON: "C:\\Python34-x64" PYTHON_VERSION: "3.4.x" # currently 3.4.3 PYTHON_ARCH: "64" PYTHON_EXE: python - PYTHON: "C:\\Python27-x64" PYTHON_VERSION: "2.7.x" # currently 2.7.11 PYTHON_ARCH: "64" PYTHON_EXE: python - PYTHON: "C:\\Python35-x64" PYTHON_VERSION: "3.5.x" # currently 3.5.1 PYTHON_ARCH: "64" PYTHON_EXE: python - PYTHON: "C:\\Python33-x64" PYTHON_VERSION: "3.3.x" # currently 3.3.5 PYTHON_ARCH: "64" PYTHON_EXE: python - PYTHON: "C:\\Python35" PYTHON_VERSION: "3.5.x" # currently 3.5.0 PYTHON_ARCH: "32" PYTHON_EXE: python - PYTHON: "C:\\Python27" PYTHON_VERSION: "2.7.x" # currently 2.7.11 PYTHON_ARCH: "32" PYTHON_EXE: python - PYTHON: "C:\\Python33" PYTHON_VERSION: "3.3.x" # currently 3.3.5 PYTHON_ARCH: "32" PYTHON_EXE: python - PYTHON: "C:\\Python34" PYTHON_VERSION: "3.4.x" # currently 3.4.3 PYTHON_ARCH: "32" PYTHON_EXE: python # Also test a Python version not pre-installed # See: https://github.com/ogrisel/python-appveyor-demo/issues/10 # - PYTHON: "C:\\Python266" # PYTHON_VERSION: "2.6.6" # PYTHON_ARCH: "32" # PYTHON_EXE: python install: # If there is a newer build queued for the same PR, cancel this one. # The AppVeyor 'rollout builds' option is supposed to serve the same # purpose but it is problematic because it tends to cancel builds pushed # directly to master instead of just PR builds (or the converse). # credits: JuliaLang developers. - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` throw "There are newer queued builds for this pull request, failing early." } - ECHO "Filesystem root:" - ps: "ls \"C:/\"" - ECHO "Installed SDKs:" - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\"" # Install Python (from the official .msi of http://python.org) and pip when # not already installed. # PyPy portion based on https://github.com/wbond/asn1crypto/blob/master/appveyor.yml - ps: $env:PYTMP = "${env:TMP}\py"; if (!(Test-Path "$env:PYTMP")) { New-Item -ItemType directory -Path "$env:PYTMP" | Out-Null; } if ("${env:PYTHON_ID}" -eq "pypy") { if (!(Test-Path "${env:PYTMP}\pypy-4.0.1-win32.zip")) { (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy-4.0.1-win32.zip', "${env:PYTMP}\pypy-4.0.1-win32.zip"); } 7z x -y "${env:PYTMP}\pypy-4.0.1-win32.zip" -oC:\ | Out-Null; if (!(Test-Path "${env:PYTMP}\get-pip.py")) { (New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "${env:PYTMP}\get-pip.py"); } & "${env:PYTHON}\pypy.exe" "${env:PYTMP}\get-pip.py"; } elseif (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1; } # Prepend newly installed Python to the PATH of this build (this cannot be # done from inside the powershell script as it would require to restart # the parent CMD process). - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\bin;%PATH%" - "SET PYEXE=%PYTHON%\\%PYTHON_EXE%.exe" # Check that we have the expected version and architecture for Python - "%PYEXE% --version" - "%PYEXE% -c \"import struct; print(struct.calcsize('P') * 8)\"" # Upgrade to the latest version of pip to avoid it displaying warnings # about it being out of date. - "%CMD_IN_ENV% pip install --disable-pip-version-check --user --upgrade pip" # Install the build dependencies of the project. If some dependencies contain # compiled extensions and are not provided as pre-built wheel packages, # pip will build them from source using the MSVC compiler matching the # target Python version and architecture # NOTE: psutil won't install under PyPy. - "%CMD_IN_ENV% pip install -U wheel cython greenlet psutil" - ps: "if(Test-Path(\"${env:PYTHON}\\bin\")) {ls ${env:PYTHON}\\bin;}" - ps: "if(Test-Path(\"${env:PYTHON}\\Scripts\")) {ls ${env:PYTHON}\\Scripts;}" cache: - "%TMP%\\py\\" build_script: # Build the compiled extension - "%CMD_IN_ENV% %PYEXE% setup.py bdist_wheel bdist_wininst" - ps: "ls dist" # Now install the wheel. # I couldn't get wildcards to work for pip install, so stuff it # into a variable, using python to glob. - "%PYEXE% -c \"import glob; print(glob.glob('dist/*whl')[0])\" > whl.txt" - set /p PYWHL= /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish libc5-based Linux systems. Only include it on system that are known to require it! */ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ defined(ANDROID) || defined(__ANDROID__) #include #endif #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) #include #endif #if defined(WATT32) # include # include # include #elif defined(_WIN32_WCE) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # include #elif defined(WIN32) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # include # include #else # include # include #endif #ifdef __cplusplus extern "C" { #endif /* ** c-ares external API function linkage decorations. */ #ifdef CARES_STATICLIB # define CARES_EXTERN #elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) # if defined(CARES_BUILDING_LIBRARY) # define CARES_EXTERN __declspec(dllexport) # else # define CARES_EXTERN __declspec(dllimport) # endif #elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING) # define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN #else # define CARES_EXTERN #endif #define ARES_SUCCESS 0 /* Server error codes (ARES_ENODATA indicates no relevant answer) */ #define ARES_ENODATA 1 #define ARES_EFORMERR 2 #define ARES_ESERVFAIL 3 #define ARES_ENOTFOUND 4 #define ARES_ENOTIMP 5 #define ARES_EREFUSED 6 /* Locally generated error codes */ #define ARES_EBADQUERY 7 #define ARES_EBADNAME 8 #define ARES_EBADFAMILY 9 #define ARES_EBADRESP 10 #define ARES_ECONNREFUSED 11 #define ARES_ETIMEOUT 12 #define ARES_EOF 13 #define ARES_EFILE 14 #define ARES_ENOMEM 15 #define ARES_EDESTRUCTION 16 #define ARES_EBADSTR 17 /* ares_getnameinfo error codes */ #define ARES_EBADFLAGS 18 /* ares_getaddrinfo error codes */ #define ARES_ENONAME 19 #define ARES_EBADHINTS 20 /* Uninitialized library error code */ #define ARES_ENOTINITIALIZED 21 /* introduced in 1.7.0 */ /* ares_library_init error codes */ #define ARES_ELOADIPHLPAPI 22 /* introduced in 1.7.0 */ #define ARES_EADDRGETNETWORKPARAMS 23 /* introduced in 1.7.0 */ /* More error codes */ #define ARES_ECANCELLED 24 /* introduced in 1.7.0 */ /* Flag values */ #define ARES_FLAG_USEVC (1 << 0) #define ARES_FLAG_PRIMARY (1 << 1) #define ARES_FLAG_IGNTC (1 << 2) #define ARES_FLAG_NORECURSE (1 << 3) #define ARES_FLAG_STAYOPEN (1 << 4) #define ARES_FLAG_NOSEARCH (1 << 5) #define ARES_FLAG_NOALIASES (1 << 6) #define ARES_FLAG_NOCHECKRESP (1 << 7) #define ARES_FLAG_EDNS (1 << 8) /* Option mask values */ #define ARES_OPT_FLAGS (1 << 0) #define ARES_OPT_TIMEOUT (1 << 1) #define ARES_OPT_TRIES (1 << 2) #define ARES_OPT_NDOTS (1 << 3) #define ARES_OPT_UDP_PORT (1 << 4) #define ARES_OPT_TCP_PORT (1 << 5) #define ARES_OPT_SERVERS (1 << 6) #define ARES_OPT_DOMAINS (1 << 7) #define ARES_OPT_LOOKUPS (1 << 8) #define ARES_OPT_SOCK_STATE_CB (1 << 9) #define ARES_OPT_SORTLIST (1 << 10) #define ARES_OPT_SOCK_SNDBUF (1 << 11) #define ARES_OPT_SOCK_RCVBUF (1 << 12) #define ARES_OPT_TIMEOUTMS (1 << 13) #define ARES_OPT_ROTATE (1 << 14) #define ARES_OPT_EDNSPSZ (1 << 15) /* Nameinfo flag values */ #define ARES_NI_NOFQDN (1 << 0) #define ARES_NI_NUMERICHOST (1 << 1) #define ARES_NI_NAMEREQD (1 << 2) #define ARES_NI_NUMERICSERV (1 << 3) #define ARES_NI_DGRAM (1 << 4) #define ARES_NI_TCP 0 #define ARES_NI_UDP ARES_NI_DGRAM #define ARES_NI_SCTP (1 << 5) #define ARES_NI_DCCP (1 << 6) #define ARES_NI_NUMERICSCOPE (1 << 7) #define ARES_NI_LOOKUPHOST (1 << 8) #define ARES_NI_LOOKUPSERVICE (1 << 9) /* Reserved for future use */ #define ARES_NI_IDN (1 << 10) #define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11) #define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12) /* Addrinfo flag values */ #define ARES_AI_CANONNAME (1 << 0) #define ARES_AI_NUMERICHOST (1 << 1) #define ARES_AI_PASSIVE (1 << 2) #define ARES_AI_NUMERICSERV (1 << 3) #define ARES_AI_V4MAPPED (1 << 4) #define ARES_AI_ALL (1 << 5) #define ARES_AI_ADDRCONFIG (1 << 6) /* Reserved for future use */ #define ARES_AI_IDN (1 << 10) #define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11) #define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12) #define ARES_AI_CANONIDN (1 << 13) #define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \ ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \ ARES_AI_ADDRCONFIG) #define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this many sockets */ #define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num))) #define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \ ARES_GETSOCK_MAXNUM))) /* c-ares library initialization flag values */ #define ARES_LIB_INIT_NONE (0) #define ARES_LIB_INIT_WIN32 (1 << 0) #define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32) /* * Typedef our socket type */ #ifndef ares_socket_typedef #ifdef WIN32 typedef SOCKET ares_socket_t; #define ARES_SOCKET_BAD INVALID_SOCKET #else typedef int ares_socket_t; #define ARES_SOCKET_BAD -1 #endif #define ares_socket_typedef #endif /* ares_socket_typedef */ typedef void (*ares_sock_state_cb)(void *data, ares_socket_t socket_fd, int readable, int writable); struct apattern; /* NOTE about the ares_options struct to users and developers. This struct will remain looking like this. It will not be extended nor shrunk in future releases, but all new options will be set by ares_set_*() options instead of with the ares_init_options() function. Eventually (in a galaxy far far away), all options will be settable by ares_set_*() options and the ares_init_options() function will become deprecated. When new options are added to c-ares, they are not added to this struct. And they are not "saved" with the ares_save_options() function but instead we encourage the use of the ares_dup() function. Needless to say, if you add config options to c-ares you need to make sure ares_dup() duplicates this new option. */ struct ares_options { int flags; int timeout; /* in seconds or milliseconds, depending on options */ int tries; int ndots; unsigned short udp_port; unsigned short tcp_port; int socket_send_buffer_size; int socket_receive_buffer_size; struct in_addr *servers; int nservers; char **domains; int ndomains; char *lookups; ares_sock_state_cb sock_state_cb; void *sock_state_cb_data; struct apattern *sortlist; int nsort; int ednspsz; }; struct hostent; struct timeval; struct sockaddr; struct ares_channeldata; typedef struct ares_channeldata *ares_channel; typedef void (*ares_callback)(void *arg, int status, int timeouts, unsigned char *abuf, int alen); typedef void (*ares_host_callback)(void *arg, int status, int timeouts, struct hostent *hostent); typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts, char *node, char *service); typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd, int type, void *data); CARES_EXTERN int ares_library_init(int flags); CARES_EXTERN void ares_library_cleanup(void); CARES_EXTERN const char *ares_version(int *version); CARES_EXTERN int ares_init(ares_channel *channelptr); CARES_EXTERN int ares_init_options(ares_channel *channelptr, struct ares_options *options, int optmask); CARES_EXTERN int ares_save_options(ares_channel channel, struct ares_options *options, int *optmask); CARES_EXTERN void ares_destroy_options(struct ares_options *options); CARES_EXTERN int ares_dup(ares_channel *dest, ares_channel src); CARES_EXTERN void ares_destroy(ares_channel channel); CARES_EXTERN void ares_cancel(ares_channel channel); /* These next 3 configure local binding for the out-going socket * connection. Use these to specify source IP and/or network device * on multi-homed systems. */ CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip); /* local_ip6 should be 16 bytes in length */ CARES_EXTERN void ares_set_local_ip6(ares_channel channel, const unsigned char* local_ip6); /* local_dev_name should be null terminated. */ CARES_EXTERN void ares_set_local_dev(ares_channel channel, const char* local_dev_name); CARES_EXTERN void ares_set_socket_callback(ares_channel channel, ares_sock_create_callback callback, void *user_data); CARES_EXTERN void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, ares_callback callback, void *arg); CARES_EXTERN void ares_query(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg); CARES_EXTERN void ares_search(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg); CARES_EXTERN void ares_gethostbyname(ares_channel channel, const char *name, int family, ares_host_callback callback, void *arg); CARES_EXTERN int ares_gethostbyname_file(ares_channel channel, const char *name, int family, struct hostent **host); CARES_EXTERN void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, int family, ares_host_callback callback, void *arg); CARES_EXTERN void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, ares_socklen_t salen, int flags, ares_nameinfo_callback callback, void *arg); CARES_EXTERN int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds); CARES_EXTERN int ares_getsock(ares_channel channel, ares_socket_t *socks, int numsocks); CARES_EXTERN struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv, struct timeval *tv); CARES_EXTERN void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds); CARES_EXTERN void ares_process_fd(ares_channel channel, ares_socket_t read_fd, ares_socket_t write_fd); CARES_EXTERN int ares_create_query(const char *name, int dnsclass, int type, unsigned short id, int rd, unsigned char **buf, int *buflen, int max_udp_size); CARES_EXTERN int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id, int rd, unsigned char **buf, int *buflen); CARES_EXTERN int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen); CARES_EXTERN int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf, int alen, unsigned char **s, long *enclen); /* * NOTE: before c-ares 1.7.0 we would most often use the system in6_addr * struct below when ares itself was built, but many apps would use this * private version since the header checked a HAVE_* define for it. Starting * with 1.7.0 we always declare and use our own to stop relying on the * system's one. */ struct ares_in6_addr { union { unsigned char _S6_u8[16]; } _S6_un; }; struct ares_addrttl { struct in_addr ipaddr; int ttl; }; struct ares_addr6ttl { struct ares_in6_addr ip6addr; int ttl; }; struct ares_srv_reply { struct ares_srv_reply *next; char *host; unsigned short priority; unsigned short weight; unsigned short port; }; struct ares_mx_reply { struct ares_mx_reply *next; char *host; unsigned short priority; }; struct ares_txt_reply { struct ares_txt_reply *next; unsigned char *txt; size_t length; /* length excludes null termination */ }; struct ares_naptr_reply { struct ares_naptr_reply *next; unsigned char *flags; unsigned char *service; unsigned char *regexp; char *replacement; unsigned short order; unsigned short preference; }; struct ares_soa_reply { char *nsname; char *hostmaster; unsigned int serial; unsigned int refresh; unsigned int retry; unsigned int expire; unsigned int minttl; }; /* ** Parse the buffer, starting at *abuf and of length alen bytes, previously ** obtained from an ares_search call. Put the results in *host, if nonnull. ** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with ** their TTLs in that array, and set *naddrttls to the number of addresses ** so written. */ CARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addrttl *addrttls, int *naddrttls); CARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addr6ttl *addrttls, int *naddrttls); CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, int addrlen, int family, struct hostent **host); CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf, int alen, struct hostent **host); CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf, int alen, struct ares_srv_reply** srv_out); CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf, int alen, struct ares_mx_reply** mx_out); CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf, int alen, struct ares_txt_reply** txt_out); CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf, int alen, struct ares_naptr_reply** naptr_out); CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf, int alen, struct ares_soa_reply** soa_out); CARES_EXTERN void ares_free_string(void *str); CARES_EXTERN void ares_free_hostent(struct hostent *host); CARES_EXTERN void ares_free_data(void *dataptr); CARES_EXTERN const char *ares_strerror(int code); /* TODO: Hold port here as well. */ struct ares_addr_node { struct ares_addr_node *next; int family; union { struct in_addr addr4; struct ares_in6_addr addr6; } addr; }; CARES_EXTERN int ares_set_servers(ares_channel channel, struct ares_addr_node *servers); /* Incomming string format: host[:port][,host[:port]]... */ CARES_EXTERN int ares_set_servers_csv(ares_channel channel, const char* servers); CARES_EXTERN int ares_get_servers(ares_channel channel, struct ares_addr_node **servers); CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size); CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst); #ifdef __cplusplus } #endif #endif /* ARES__H */ gevent-1.1.0/c-ares/ares__close_sockets.c0000644000076500000000000000362312666555342021072 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_private.h" void ares__close_sockets(ares_channel channel, struct server_state *server) { struct send_request *sendreq; /* Free all pending output buffers. */ while (server->qhead) { /* Advance server->qhead; pull out query as we go. */ sendreq = server->qhead; server->qhead = sendreq->next; if (sendreq->data_storage != NULL) free(sendreq->data_storage); free(sendreq); } server->qtail = NULL; /* Reset any existing input buffer. */ if (server->tcp_buffer) free(server->tcp_buffer); server->tcp_buffer = NULL; server->tcp_lenbuf_pos = 0; /* Reset brokenness */ server->is_broken = 0; /* Close the TCP and UDP sockets. */ if (server->tcp_socket != ARES_SOCKET_BAD) { SOCK_STATE_CALLBACK(channel, server->tcp_socket, 0, 0); sclose(server->tcp_socket); server->tcp_socket = ARES_SOCKET_BAD; server->tcp_connection_generation = ++channel->tcp_connection_generation; } if (server->udp_socket != ARES_SOCKET_BAD) { SOCK_STATE_CALLBACK(channel, server->udp_socket, 0, 0); sclose(server->udp_socket); server->udp_socket = ARES_SOCKET_BAD; } } gevent-1.1.0/c-ares/ares__get_hostent.c0000644000076500000000000001525312666555342020557 0ustar jmaddenwheel00000000000000 /* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #include "ares.h" #include "ares_inet_net_pton.h" #include "ares_nowarn.h" #include "ares_private.h" int ares__get_hostent(FILE *fp, int family, struct hostent **host) { char *line = NULL, *p, *q, **alias; char *txtaddr, *txthost, *txtalias; int status; size_t addrlen, linesize, naliases; struct ares_addr addr; struct hostent *hostent = NULL; *host = NULL; /* Assume failure */ /* Validate family */ switch (family) { case AF_INET: case AF_INET6: case AF_UNSPEC: break; default: return ARES_EBADFAMILY; } while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { /* Trim line comment. */ p = line; while (*p && (*p != '#')) p++; *p = '\0'; /* Trim trailing whitespace. */ q = p - 1; while ((q >= line) && ISSPACE(*q)) q--; *++q = '\0'; /* Skip leading whitespace. */ p = line; while (*p && ISSPACE(*p)) p++; if (!*p) /* Ignore line if empty. */ continue; /* Pointer to start of IPv4 or IPv6 address part. */ txtaddr = p; /* Advance past address part. */ while (*p && !ISSPACE(*p)) p++; if (!*p) /* Ignore line if reached end of line. */ continue; /* Null terminate address part. */ *p = '\0'; /* Advance to host name */ p++; while (*p && ISSPACE(*p)) p++; if (!*p) /* Ignore line if reached end of line. */ continue; /* Pointer to start of host name. */ txthost = p; /* Advance past host name. */ while (*p && !ISSPACE(*p)) p++; /* Pointer to start of first alias. */ txtalias = NULL; if (*p) { q = p + 1; while (*q && ISSPACE(*q)) q++; if (*q) txtalias = q; } /* Null terminate host name. */ *p = '\0'; /* find out number of aliases. */ naliases = 0; if (txtalias) { p = txtalias; while (*p) { while (*p && !ISSPACE(*p)) p++; while (*p && ISSPACE(*p)) p++; naliases++; } } /* Convert address string to network address for the requested family. */ addrlen = 0; addr.family = AF_UNSPEC; addr.addrV4.s_addr = INADDR_NONE; if ((family == AF_INET) || (family == AF_UNSPEC)) { addr.addrV4.s_addr = inet_addr(txtaddr); if (addr.addrV4.s_addr != INADDR_NONE) { /* Actual network address family and length. */ addr.family = AF_INET; addrlen = sizeof(addr.addrV4); } } if ((family == AF_INET6) || ((family == AF_UNSPEC) && (!addrlen))) { if (ares_inet_pton(AF_INET6, txtaddr, &addr.addrV6) > 0) { /* Actual network address family and length. */ addr.family = AF_INET6; addrlen = sizeof(addr.addrV6); } } if (!addrlen) /* Ignore line if invalid address string for the requested family. */ continue; /* ** Actual address family possible values are AF_INET and AF_INET6 only. */ /* Allocate memory for the hostent structure. */ hostent = malloc(sizeof(struct hostent)); if (!hostent) break; /* Initialize fields for out of memory condition. */ hostent->h_aliases = NULL; hostent->h_addr_list = NULL; /* Copy official host name. */ hostent->h_name = strdup(txthost); if (!hostent->h_name) break; /* Copy network address. */ hostent->h_addr_list = malloc(2 * sizeof(char *)); if (!hostent->h_addr_list) break; hostent->h_addr_list[1] = NULL; hostent->h_addr_list[0] = malloc(addrlen); if (!hostent->h_addr_list[0]) break; if (addr.family == AF_INET) memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(addr.addrV4)); else memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6)); /* Copy aliases. */ hostent->h_aliases = malloc((naliases + 1) * sizeof(char *)); if (!hostent->h_aliases) break; alias = hostent->h_aliases; while (naliases) *(alias + naliases--) = NULL; *alias = NULL; while (txtalias) { p = txtalias; while (*p && !ISSPACE(*p)) p++; q = p; while (*q && ISSPACE(*q)) q++; *p = '\0'; if ((*alias = strdup(txtalias)) == NULL) break; alias++; txtalias = *q ? q : NULL; } if (txtalias) /* Alias memory allocation failure. */ break; /* Copy actual network address family and length. */ hostent->h_addrtype = aresx_sitoss(addr.family); hostent->h_length = aresx_uztoss(addrlen); /* Free line buffer. */ free(line); /* Return hostent successfully */ *host = hostent; return ARES_SUCCESS; } /* If allocated, free line buffer. */ if (line) free(line); if (status == ARES_SUCCESS) { /* Memory allocation failure; clean up. */ if (hostent) { if (hostent->h_name) free((char *) hostent->h_name); if (hostent->h_aliases) { for (alias = hostent->h_aliases; *alias; alias++) free(*alias); free(hostent->h_aliases); } if (hostent->h_addr_list) { if (hostent->h_addr_list[0]) free(hostent->h_addr_list[0]); free(hostent->h_addr_list); } free(hostent); } return ARES_ENOMEM; } return status; } gevent-1.1.0/c-ares/ares__read_line.c0000644000076500000000000000407612666555342020157 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_nowarn.h" #include "ares_private.h" /* This is an internal function. Its contract is to read a line from * a file into a dynamically allocated buffer, zeroing the trailing * newline if there is one. The calling routine may call * ares__read_line multiple times with the same buf and bufsize * pointers; *buf will be reallocated and *bufsize adjusted as * appropriate. The initial value of *buf should be NULL. After the * calling routine is done reading lines, it should free *buf. */ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) { char *newbuf; size_t offset = 0; size_t len; if (*buf == NULL) { *buf = malloc(128); if (!*buf) return ARES_ENOMEM; *bufsize = 128; } for (;;) { int bytestoread = aresx_uztosi(*bufsize - offset); if (!fgets(*buf + offset, bytestoread, fp)) return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF; len = offset + strlen(*buf + offset); if ((*buf)[len - 1] == '\n') { (*buf)[len - 1] = 0; break; } offset = len; if(len < *bufsize - 1) continue; /* Allocate more space. */ newbuf = realloc(*buf, *bufsize * 2); if (!newbuf) return ARES_ENOMEM; *buf = newbuf; *bufsize *= 2; } return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares__timeval.c0000644000076500000000000000602512666555342017672 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2008 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_private.h" #if defined(WIN32) && !defined(MSDOS) struct timeval ares__tvnow(void) { /* ** GetTickCount() is available on _all_ Windows versions from W95 up ** to nowadays. Returns milliseconds elapsed since last system boot, ** increases monotonically and wraps once 49.7 days have elapsed. */ struct timeval now; DWORD milliseconds = GetTickCount(); now.tv_sec = milliseconds / 1000; now.tv_usec = (milliseconds % 1000) * 1000; return now; } #elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) struct timeval ares__tvnow(void) { /* ** clock_gettime() is granted to be increased monotonically when the ** monotonic clock is queried. Time starting point is unspecified, it ** could be the system start-up time, the Epoch, or something else, ** in any case the time starting point does not change once that the ** system has started up. */ struct timeval now; struct timespec tsnow; if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) { now.tv_sec = tsnow.tv_sec; now.tv_usec = tsnow.tv_nsec / 1000; } /* ** Even when the configure process has truly detected monotonic clock ** availability, it might happen that it is not actually available at ** run-time. When this occurs simply fallback to other time source. */ #ifdef HAVE_GETTIMEOFDAY else (void)gettimeofday(&now, NULL); #else else { now.tv_sec = (long)time(NULL); now.tv_usec = 0; } #endif return now; } #elif defined(HAVE_GETTIMEOFDAY) struct timeval ares__tvnow(void) { /* ** gettimeofday() is not granted to be increased monotonically, due to ** clock drifting and external source time synchronization it can jump ** forward or backward in time. */ struct timeval now; (void)gettimeofday(&now, NULL); return now; } #else struct timeval ares__tvnow(void) { /* ** time() returns the value of time in seconds since the Epoch. */ struct timeval now; now.tv_sec = (long)time(NULL); now.tv_usec = 0; return now; } #endif #if 0 /* Not used */ /* * Make sure that the first argument is the more recent time, as otherwise * we'll get a weird negative time-diff back... * * Returns: the time difference in number of milliseconds. */ long ares__tvdiff(struct timeval newer, struct timeval older) { return (newer.tv_sec-older.tv_sec)*1000+ (newer.tv_usec-older.tv_usec)/1000; } #endif gevent-1.1.0/c-ares/ares_build.h0000644000076500000000000002125712666555342017202 0ustar jmaddenwheel00000000000000#ifndef __CARES_BUILD_H #define __CARES_BUILD_H /* Copyright (C) 2009 - 2013 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* ================================================================ */ /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ /* ================================================================ */ /* * NOTE 1: * ------- * * See file ares_build.h.in, run configure, and forget that this file * exists it is only used for non-configure systems. * But you can keep reading if you want ;-) * */ /* ================================================================ */ /* NOTES FOR NON-CONFIGURE SYSTEMS */ /* ================================================================ */ /* * NOTE 1: * ------- * * Nothing in this file is intended to be modified or adjusted by the * c-ares library user nor by the c-ares library builder. * * If you think that something actually needs to be changed, adjusted * or fixed in this file, then, report it on the c-ares development * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ * * Try to keep one section per platform, compiler and architecture, * otherwise, if an existing section is reused for a different one and * later on the original is adjusted, probably the piggybacking one can * be adversely changed. * * In order to differentiate between platforms/compilers/architectures * use only compiler built in predefined preprocessor symbols. * * This header file shall only export symbols which are 'cares' or 'CARES' * prefixed, otherwise public name space would be polluted. * * NOTE 2: * ------- * * Right now you might be staring at file ares_build.h.dist or ares_build.h, * this is due to the following reason: file ares_build.h.dist is renamed * to ares_build.h when the c-ares source code distribution archive file is * created. * * File ares_build.h.dist is not included in the distribution archive. * File ares_build.h is not present in the git tree. * * The distributed ares_build.h file is only intended to be used on systems * which can not run the also distributed configure script. * * On systems capable of running the configure script, the configure process * will overwrite the distributed ares_build.h file with one that is suitable * and specific to the library being configured and built, which is generated * from the ares_build.h.in template file. * * If you check out from git on a non-configure platform, you must run the * appropriate buildconf* script to set up ares_build.h and other local files. * */ /* ================================================================ */ /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ /* ================================================================ */ #ifdef CARES_SIZEOF_LONG # error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined #endif #ifdef CARES_TYPEOF_ARES_SOCKLEN_T # error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined #endif #ifdef CARES_SIZEOF_ARES_SOCKLEN_T # error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined #endif /* ================================================================ */ /* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ /* ================================================================ */ #if defined(__DJGPP__) || defined(__GO32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__SALFORDC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__BORLANDC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__TURBOC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__WATCOMC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__POCC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__LCC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__SYMBIAN32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__MWERKS__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(_WIN32_WCE) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__MINGW32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__VMS) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__OS400__) # if defined(__ILEC400__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(__MVS__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) # define CARES_SIZEOF_LONG 4 # elif defined(_LP64) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(__370__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) # define CARES_SIZEOF_LONG 4 # elif defined(_LP64) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(TPF) # define CARES_SIZEOF_LONG 8 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 /* ===================================== */ /* KEEP MSVC THE PENULTIMATE ENTRY */ /* ===================================== */ #elif defined(_MSC_VER) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 /* ===================================== */ /* KEEP GENERIC GCC THE LAST ENTRY */ /* ===================================== */ #elif defined(__GNUC__) # if defined(__ILP32__) || \ defined(__i386__) || defined(__ppc__) || defined(__arm__) # define CARES_SIZEOF_LONG 4 # elif defined(__LP64__) || \ defined(__x86_64__) || defined(__ppc64__) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 #else # error "Unknown non-configure build target!" Error Compilation_aborted_Unknown_non_configure_build_target #endif /* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ /* sys/types.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_TYPES_H # include #endif /* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ /* sys/socket.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_SOCKET_H # include #endif /* Data type definition of ares_socklen_t. */ #ifdef CARES_TYPEOF_ARES_SOCKLEN_T typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; #endif #endif /* __CARES_BUILD_H */ gevent-1.1.0/c-ares/ares_build.h.dist0000644000076500000000000002113612666555342020140 0ustar jmaddenwheel00000000000000#ifndef __CARES_BUILD_H #define __CARES_BUILD_H /* Copyright (C) 2009 - 2010 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* ================================================================ */ /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ /* ================================================================ */ /* * NOTE 1: * ------- * * See file ares_build.h.in, run configure, and forget that this file * exists it is only used for non-configure systems. * But you can keep reading if you want ;-) * */ /* ================================================================ */ /* NOTES FOR NON-CONFIGURE SYSTEMS */ /* ================================================================ */ /* * NOTE 1: * ------- * * Nothing in this file is intended to be modified or adjusted by the * c-ares library user nor by the c-ares library builder. * * If you think that something actually needs to be changed, adjusted * or fixed in this file, then, report it on the c-ares development * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ * * Try to keep one section per platform, compiler and architecture, * otherwise, if an existing section is reused for a different one and * later on the original is adjusted, probably the piggybacking one can * be adversely changed. * * In order to differentiate between platforms/compilers/architectures * use only compiler built in predefined preprocessor symbols. * * This header file shall only export symbols which are 'cares' or 'CARES' * prefixed, otherwise public name space would be polluted. * * NOTE 2: * ------- * * Right now you might be staring at file ares_build.h.dist or ares_build.h, * this is due to the following reason: file ares_build.h.dist is renamed * to ares_build.h when the c-ares source code distribution archive file is * created. * * File ares_build.h.dist is not included in the distribution archive. * File ares_build.h is not present in the git tree. * * The distributed ares_build.h file is only intended to be used on systems * which can not run the also distributed configure script. * * On systems capable of running the configure script, the configure process * will overwrite the distributed ares_build.h file with one that is suitable * and specific to the library being configured and built, which is generated * from the ares_build.h.in template file. * * If you check out from git on a non-configure platform, you must run the * appropriate buildconf* script to set up ares_build.h and other local files. * */ /* ================================================================ */ /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ /* ================================================================ */ #ifdef CARES_SIZEOF_LONG # error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined #endif #ifdef CARES_TYPEOF_ARES_SOCKLEN_T # error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined #endif #ifdef CARES_SIZEOF_ARES_SOCKLEN_T # error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined #endif /* ================================================================ */ /* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ /* ================================================================ */ #if defined(__DJGPP__) || defined(__GO32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__SALFORDC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__BORLANDC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__TURBOC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__WATCOMC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__POCC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__LCC__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__SYMBIAN32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__MWERKS__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(_WIN32_WCE) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__MINGW32__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__VMS) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 #elif defined(__OS400__) # if defined(__ILEC400__) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(__MVS__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) # define CARES_SIZEOF_LONG 4 # elif defined(_LP64) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(__370__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) # define CARES_SIZEOF_LONG 4 # elif defined(_LP64) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 # endif #elif defined(TPF) # define CARES_SIZEOF_LONG 8 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 /* ===================================== */ /* KEEP MSVC THE PENULTIMATE ENTRY */ /* ===================================== */ #elif defined(_MSC_VER) # define CARES_SIZEOF_LONG 4 # define CARES_TYPEOF_ARES_SOCKLEN_T int # define CARES_SIZEOF_ARES_SOCKLEN_T 4 /* ===================================== */ /* KEEP GENERIC GCC THE LAST ENTRY */ /* ===================================== */ #elif defined(__GNUC__) # if defined(__i386__) || defined(__ppc__) # define CARES_SIZEOF_LONG 4 # elif defined(__x86_64__) || defined(__ppc64__) # define CARES_SIZEOF_LONG 8 # endif # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t # define CARES_SIZEOF_ARES_SOCKLEN_T 4 # define CARES_PULL_SYS_TYPES_H 1 # define CARES_PULL_SYS_SOCKET_H 1 #else # error "Unknown non-configure build target!" Error Compilation_aborted_Unknown_non_configure_build_target #endif /* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ /* sys/types.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_TYPES_H # include #endif /* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ /* sys/socket.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_SOCKET_H # include #endif /* Data type definition of ares_socklen_t. */ #ifdef CARES_TYPEOF_ARES_SOCKLEN_T typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; #endif #endif /* __CARES_BUILD_H */ gevent-1.1.0/c-ares/ares_build.h.in0000644000076500000000000000777612666555342017621 0ustar jmaddenwheel00000000000000#ifndef __CARES_BUILD_H #define __CARES_BUILD_H /* Copyright (C) 2009 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* ================================================================ */ /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ /* ================================================================ */ /* * NOTE 1: * ------- * * Nothing in this file is intended to be modified or adjusted by the * c-ares library user nor by the c-ares library builder. * * If you think that something actually needs to be changed, adjusted * or fixed in this file, then, report it on the c-ares development * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ * * This header file shall only export symbols which are 'cares' or 'CARES' * prefixed, otherwise public name space would be polluted. * * NOTE 2: * ------- * * Right now you might be staring at file ares_build.h.in or ares_build.h, * this is due to the following reason: * * On systems capable of running the configure script, the configure process * will overwrite the distributed ares_build.h file with one that is suitable * and specific to the library being configured and built, which is generated * from the ares_build.h.in template file. * */ /* ================================================================ */ /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ /* ================================================================ */ #ifdef CARES_SIZEOF_LONG # error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined #endif #ifdef CARES_TYPEOF_ARES_SOCKLEN_T # error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined #endif #ifdef CARES_SIZEOF_ARES_SOCKLEN_T # error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined #endif /* ================================================================ */ /* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ /* ================================================================ */ /* Configure process defines this to 1 when it finds out that system */ /* header file ws2tcpip.h must be included by the external interface. */ #undef CARES_PULL_WS2TCPIP_H #ifdef CARES_PULL_WS2TCPIP_H # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # include # include #endif /* Configure process defines this to 1 when it finds out that system */ /* header file sys/types.h must be included by the external interface. */ #undef CARES_PULL_SYS_TYPES_H #ifdef CARES_PULL_SYS_TYPES_H # include #endif /* Configure process defines this to 1 when it finds out that system */ /* header file sys/socket.h must be included by the external interface. */ #undef CARES_PULL_SYS_SOCKET_H #ifdef CARES_PULL_SYS_SOCKET_H # include #endif /* The size of `long', as computed by sizeof. */ #undef CARES_SIZEOF_LONG /* Integral data type used for ares_socklen_t. */ #undef CARES_TYPEOF_ARES_SOCKLEN_T /* The size of `ares_socklen_t', as computed by sizeof. */ #undef CARES_SIZEOF_ARES_SOCKLEN_T /* Data type definition of ares_socklen_t. */ typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; #endif /* __CARES_BUILD_H */ gevent-1.1.0/c-ares/ares_cancel.c0000644000076500000000000000426512666555342017323 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2004 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include #include "ares.h" #include "ares_private.h" /* * ares_cancel() cancels all ongoing requests/resolves that might be going on * on the given channel. It does NOT kill the channel, use ares_destroy() for * that. */ void ares_cancel(ares_channel channel) { struct query *query; struct list_node list_head_copy; struct list_node* list_head; struct list_node* list_node; int i; if (!ares__is_list_empty(&(channel->all_queries))) { /* Swap list heads, so that only those queries which were present on entry * into this function are cancelled. New queries added by callbacks of * queries being cancelled will not be cancelled themselves. */ list_head = &(channel->all_queries); list_head_copy.prev = list_head->prev; list_head_copy.next = list_head->next; list_head_copy.prev->next = &list_head_copy; list_head_copy.next->prev = &list_head_copy; list_head->prev = list_head; list_head->next = list_head; for (list_node = list_head_copy.next; list_node != &list_head_copy; ) { query = list_node->data; list_node = list_node->next; /* since we're deleting the query */ query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0); ares__free_query(query); } } if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries))) { if (channel->servers) { for (i = 0; i < channel->nservers; i++) ares__close_sockets(channel, &channel->servers[i]); } } } gevent-1.1.0/c-ares/ares_config.h.in0000644000076500000000000003311512666555342017751 0ustar jmaddenwheel00000000000000/* ares_config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* define this if ares is built for a big endian system */ #undef ARES_BIG_ENDIAN /* when building as static part of libcurl */ #undef BUILDING_LIBCURL /* Definition to make a library symbol externally visible. */ #undef CARES_SYMBOL_SCOPE_EXTERN /* if a /etc/inet dir is being used */ #undef ETC_INET /* Define to the type of arg 2 for gethostname. */ #undef GETHOSTNAME_TYPE_ARG2 /* Define to the type qualifier of arg 1 for getnameinfo. */ #undef GETNAMEINFO_QUAL_ARG1 /* Define to the type of arg 1 for getnameinfo. */ #undef GETNAMEINFO_TYPE_ARG1 /* Define to the type of arg 2 for getnameinfo. */ #undef GETNAMEINFO_TYPE_ARG2 /* Define to the type of args 4 and 6 for getnameinfo. */ #undef GETNAMEINFO_TYPE_ARG46 /* Define to the type of arg 7 for getnameinfo. */ #undef GETNAMEINFO_TYPE_ARG7 /* Specifies the number of arguments to getservbyport_r */ #undef GETSERVBYPORT_R_ARGS /* Specifies the size of the buffer to pass to getservbyport_r */ #undef GETSERVBYPORT_R_BUFSIZE /* Define to 1 if you have AF_INET6. */ #undef HAVE_AF_INET6 /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_COMPAT_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_H /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H /* Define to 1 if you have the `bitncmp' function. */ #undef HAVE_BITNCMP /* Define to 1 if bool is an available type. */ #undef HAVE_BOOL_T /* Define to 1 if you have the clock_gettime function and monotonic timer. */ #undef HAVE_CLOCK_GETTIME_MONOTONIC /* Define to 1 if you have the closesocket function. */ #undef HAVE_CLOSESOCKET /* Define to 1 if you have the CloseSocket camel case function. */ #undef HAVE_CLOSESOCKET_CAMEL /* Define to 1 if you have the connect function. */ #undef HAVE_CONNECT /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the fcntl function. */ #undef HAVE_FCNTL /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have a working fcntl O_NONBLOCK function. */ #undef HAVE_FCNTL_O_NONBLOCK /* Define to 1 if you have the freeaddrinfo function. */ #undef HAVE_FREEADDRINFO /* Define to 1 if you have a working getaddrinfo function. */ #undef HAVE_GETADDRINFO /* Define to 1 if the getaddrinfo function is threadsafe. */ #undef HAVE_GETADDRINFO_THREADSAFE /* Define to 1 if you have the getenv function. */ #undef HAVE_GETENV /* Define to 1 if you have the gethostbyaddr function. */ #undef HAVE_GETHOSTBYADDR /* Define to 1 if you have the gethostbyname function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if you have the gethostname function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the getnameinfo function. */ #undef HAVE_GETNAMEINFO /* Define to 1 if you have the getservbyport_r function. */ #undef HAVE_GETSERVBYPORT_R /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the `if_indextoname' function. */ #undef HAVE_IF_INDEXTONAME /* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ #undef HAVE_INET_NET_PTON /* Define to 1 if you have a IPv6 capable working inet_ntop function. */ #undef HAVE_INET_NTOP /* Define to 1 if you have a IPv6 capable working inet_pton function. */ #undef HAVE_INET_PTON /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the ioctl function. */ #undef HAVE_IOCTL /* Define to 1 if you have the ioctlsocket function. */ #undef HAVE_IOCTLSOCKET /* Define to 1 if you have the IoctlSocket camel case function. */ #undef HAVE_IOCTLSOCKET_CAMEL /* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */ #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO /* Define to 1 if you have a working ioctlsocket FIONBIO function. */ #undef HAVE_IOCTLSOCKET_FIONBIO /* Define to 1 if you have a working ioctl FIONBIO function. */ #undef HAVE_IOCTL_FIONBIO /* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ #undef HAVE_IOCTL_SIOCGIFADDR /* Define to 1 if you have the `resolve' library (-lresolve). */ #undef HAVE_LIBRESOLVE /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* if your compiler supports LL */ #undef HAVE_LL /* Define to 1 if the compiler supports the 'long long' data type. */ #undef HAVE_LONGLONG /* Define to 1 if you have the malloc.h header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the memory.h header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the MSG_NOSIGNAL flag. */ #undef HAVE_MSG_NOSIGNAL /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H /* Define to 1 if you have PF_INET6. */ #undef HAVE_PF_INET6 /* Define to 1 if you have the recv function. */ #undef HAVE_RECV /* Define to 1 if you have the recvfrom function. */ #undef HAVE_RECVFROM /* Define to 1 if you have the send function. */ #undef HAVE_SEND /* Define to 1 if you have the setsockopt function. */ #undef HAVE_SETSOCKOPT /* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ #undef HAVE_SETSOCKOPT_SO_NONBLOCK /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if sig_atomic_t is an available typedef. */ #undef HAVE_SIG_ATOMIC_T /* Define to 1 if sig_atomic_t is already defined as volatile. */ #undef HAVE_SIG_ATOMIC_T_VOLATILE /* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ #undef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID /* Define to 1 if you have the socket function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the strcasecmp function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the strcmpi function. */ #undef HAVE_STRCMPI /* Define to 1 if you have the strdup function. */ #undef HAVE_STRDUP /* Define to 1 if you have the stricmp function. */ #undef HAVE_STRICMP /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the strncasecmp function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the strncmpi function. */ #undef HAVE_STRNCMPI /* Define to 1 if you have the strnicmp function. */ #undef HAVE_STRNICMP /* Define to 1 if you have the header file. */ #undef HAVE_STROPTS_H /* Define to 1 if you have struct addrinfo. */ #undef HAVE_STRUCT_ADDRINFO /* Define to 1 if you have struct in6_addr. */ #undef HAVE_STRUCT_IN6_ADDR /* Define to 1 if you have struct sockaddr_in6. */ #undef HAVE_STRUCT_SOCKADDR_IN6 /* if struct sockaddr_storage is defined */ #undef HAVE_STRUCT_SOCKADDR_STORAGE /* Define to 1 if you have the timeval struct. */ #undef HAVE_STRUCT_TIMEVAL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UIO_H /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the windows.h header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if you have the winsock2.h header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the winsock.h header file. */ #undef HAVE_WINSOCK_H /* Define to 1 if you have the writev function. */ #undef HAVE_WRITEV /* Define to 1 if you have the ws2tcpip.h header file. */ #undef HAVE_WS2TCPIP_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if you need the malloc.h header file even with stdlib.h */ #undef NEED_MALLOC_H /* Define to 1 if you need the memory.h header file even with stdlib.h */ #undef NEED_MEMORY_H /* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ #undef NEED_REENTRANT /* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */ #undef NEED_THREAD_SAFE /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* cpu-machine-OS */ #undef OS /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* a suitable file/device to read random data from */ #undef RANDOM_FILE /* Define to the type qualifier pointed by arg 5 for recvfrom. */ #undef RECVFROM_QUAL_ARG5 /* Define to the type of arg 1 for recvfrom. */ #undef RECVFROM_TYPE_ARG1 /* Define to the type pointed by arg 2 for recvfrom. */ #undef RECVFROM_TYPE_ARG2 /* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ #undef RECVFROM_TYPE_ARG2_IS_VOID /* Define to the type of arg 3 for recvfrom. */ #undef RECVFROM_TYPE_ARG3 /* Define to the type of arg 4 for recvfrom. */ #undef RECVFROM_TYPE_ARG4 /* Define to the type pointed by arg 5 for recvfrom. */ #undef RECVFROM_TYPE_ARG5 /* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ #undef RECVFROM_TYPE_ARG5_IS_VOID /* Define to the type pointed by arg 6 for recvfrom. */ #undef RECVFROM_TYPE_ARG6 /* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ #undef RECVFROM_TYPE_ARG6_IS_VOID /* Define to the function return type for recvfrom. */ #undef RECVFROM_TYPE_RETV /* Define to the type of arg 1 for recv. */ #undef RECV_TYPE_ARG1 /* Define to the type of arg 2 for recv. */ #undef RECV_TYPE_ARG2 /* Define to the type of arg 3 for recv. */ #undef RECV_TYPE_ARG3 /* Define to the type of arg 4 for recv. */ #undef RECV_TYPE_ARG4 /* Define to the function return type for recv. */ #undef RECV_TYPE_RETV /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to the type qualifier of arg 2 for send. */ #undef SEND_QUAL_ARG2 /* Define to the type of arg 1 for send. */ #undef SEND_TYPE_ARG1 /* Define to the type of arg 2 for send. */ #undef SEND_TYPE_ARG2 /* Define to the type of arg 3 for send. */ #undef SEND_TYPE_ARG3 /* Define to the type of arg 4 for send. */ #undef SEND_TYPE_ARG4 /* Define to the function return type for send. */ #undef SEND_TYPE_RETV /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* The size of `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T /* The size of `struct in6_addr', as computed by sizeof. */ #undef SIZEOF_STRUCT_IN6_ADDR /* The size of `struct in_addr', as computed by sizeof. */ #undef SIZEOF_STRUCT_IN_ADDR /* The size of `time_t', as computed by sizeof. */ #undef SIZEOF_TIME_T /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to disable non-blocking sockets. */ #undef USE_BLOCKING_SOCKETS /* Version number of package */ #undef VERSION /* Define to avoid automatic inclusion of winsock.h */ #undef WIN32_LEAN_AND_MEAN /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to 1 if OS is AIX. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Type to use in place of in_addr_t when system does not provide it. */ #undef in_addr_t /* Define to `unsigned int' if does not define. */ #undef size_t /* the signed version of size_t */ #undef ssize_t gevent-1.1.0/c-ares/ares_create_query.c0000644000076500000000000001515712666555342020570 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_private.h" #ifndef T_OPT # define T_OPT 41 /* EDNS0 option (meta-RR) */ #endif /* Header format, from RFC 1035: * 1 1 1 1 1 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | ID | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * |QR| Opcode |AA|TC|RD|RA| Z | RCODE | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | QDCOUNT | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | ANCOUNT | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | NSCOUNT | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | ARCOUNT | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * * AA, TC, RA, and RCODE are only set in responses. Brief description * of the remaining fields: * ID Identifier to match responses with queries * QR Query (0) or response (1) * Opcode For our purposes, always QUERY * RD Recursion desired * Z Reserved (zero) * QDCOUNT Number of queries * ANCOUNT Number of answers * NSCOUNT Number of name server records * ARCOUNT Number of additional records * * Question format, from RFC 1035: * 1 1 1 1 1 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | | * / QNAME / * / / * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | QTYPE | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * | QCLASS | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * * The query name is encoded as a series of labels, each represented * as a one-byte length (maximum 63) followed by the text of the * label. The list is terminated by a label of length zero (which can * be thought of as the root domain). */ int ares_create_query(const char *name, int dnsclass, int type, unsigned short id, int rd, unsigned char **buf, int *buflen, int max_udp_size) { int len; unsigned char *q; const char *p; /* Set our results early, in case we bail out early with an error. */ *buflen = 0; *buf = NULL; /* Compute the length of the encoded name so we can check buflen. * Start counting at 1 for the zero-length label at the end. */ len = 1; for (p = name; *p; p++) { if (*p == '\\' && *(p + 1) != 0) p++; len++; } /* If there are n periods in the name, there are n + 1 labels, and * thus n + 1 length fields, unless the name is empty or ends with a * period. So add 1 unless name is empty or ends with a period. */ if (*name && *(p - 1) != '.') len++; /* Immediately reject names that are longer than the maximum of 255 * bytes that's specified in RFC 1035 ("To simplify implementations, * the total length of a domain name (i.e., label octets and label * length octets) is restricted to 255 octets or less."). We aren't * doing this just to be a stickler about RFCs. For names that are * too long, 'dnscache' closes its TCP connection to us immediately * (when using TCP) and ignores the request when using UDP, and * BIND's named returns ServFail (TCP or UDP). Sending a request * that we know will cause 'dnscache' to close the TCP connection is * painful, since that makes any other outstanding requests on that * connection fail. And sending a UDP request that we know * 'dnscache' will ignore is bad because resources will be tied up * until we time-out the request. */ if (len > MAXCDNAME) return ARES_EBADNAME; *buflen = len + HFIXEDSZ + QFIXEDSZ + (max_udp_size ? EDNSFIXEDSZ : 0); *buf = malloc(*buflen); if (!*buf) return ARES_ENOMEM; /* Set up the header. */ q = *buf; memset(q, 0, HFIXEDSZ); DNS_HEADER_SET_QID(q, id); DNS_HEADER_SET_OPCODE(q, QUERY); if (rd) { DNS_HEADER_SET_RD(q, 1); } else { DNS_HEADER_SET_RD(q, 0); } DNS_HEADER_SET_QDCOUNT(q, 1); if (max_udp_size) { DNS_HEADER_SET_ARCOUNT(q, 1); } /* A name of "." is a screw case for the loop below, so adjust it. */ if (strcmp(name, ".") == 0) name++; /* Start writing out the name after the header. */ q += HFIXEDSZ; while (*name) { if (*name == '.') return ARES_EBADNAME; /* Count the number of bytes in this label. */ len = 0; for (p = name; *p && *p != '.'; p++) { if (*p == '\\' && *(p + 1) != 0) p++; len++; } if (len > MAXLABEL) return ARES_EBADNAME; /* Encode the length and copy the data. */ *q++ = (unsigned char)len; for (p = name; *p && *p != '.'; p++) { if (*p == '\\' && *(p + 1) != 0) p++; *q++ = *p; } /* Go to the next label and repeat, unless we hit the end. */ if (!*p) break; name = p + 1; } /* Add the zero-length label at the end. */ *q++ = 0; /* Finish off the question with the type and class. */ DNS_QUESTION_SET_TYPE(q, type); DNS_QUESTION_SET_CLASS(q, dnsclass); if (max_udp_size) { q += QFIXEDSZ; memset(q, 0, EDNSFIXEDSZ); q++; DNS_RR_SET_TYPE(q, T_OPT); DNS_RR_SET_CLASS(q, max_udp_size); } return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_data.c0000644000076500000000000001276012666555342017006 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2009-2013 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include #include "ares.h" #include "ares_data.h" #include "ares_private.h" /* ** ares_free_data() - c-ares external API function. ** ** This function must be used by the application to free data memory that ** has been internally allocated by some c-ares function and for which a ** pointer has already been returned to the calling application. The list ** of c-ares functions returning pointers that must be free'ed using this ** function is: ** ** ares_get_servers() ** ares_parse_srv_reply() ** ares_parse_txt_reply() */ void ares_free_data(void *dataptr) { struct ares_data *ptr; if (!dataptr) return; #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:1684) /* 1684: conversion from pointer to same-sized integral type */ #endif ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data)); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif if (ptr->mark != ARES_DATATYPE_MARK) return; switch (ptr->type) { case ARES_DATATYPE_MX_REPLY: if (ptr->data.mx_reply.next) ares_free_data(ptr->data.mx_reply.next); if (ptr->data.mx_reply.host) free(ptr->data.mx_reply.host); break; case ARES_DATATYPE_SRV_REPLY: if (ptr->data.srv_reply.next) ares_free_data(ptr->data.srv_reply.next); if (ptr->data.srv_reply.host) free(ptr->data.srv_reply.host); break; case ARES_DATATYPE_TXT_REPLY: if (ptr->data.txt_reply.next) ares_free_data(ptr->data.txt_reply.next); if (ptr->data.txt_reply.txt) free(ptr->data.txt_reply.txt); break; case ARES_DATATYPE_ADDR_NODE: if (ptr->data.addr_node.next) ares_free_data(ptr->data.addr_node.next); break; case ARES_DATATYPE_NAPTR_REPLY: if (ptr->data.naptr_reply.next) ares_free_data(ptr->data.naptr_reply.next); if (ptr->data.naptr_reply.flags) free(ptr->data.naptr_reply.flags); if (ptr->data.naptr_reply.service) free(ptr->data.naptr_reply.service); if (ptr->data.naptr_reply.regexp) free(ptr->data.naptr_reply.regexp); if (ptr->data.naptr_reply.replacement) free(ptr->data.naptr_reply.replacement); break; case ARES_DATATYPE_SOA_REPLY: if (ptr->data.soa_reply.nsname) free(ptr->data.soa_reply.nsname); if (ptr->data.soa_reply.hostmaster) free(ptr->data.soa_reply.hostmaster); break; default: return; } free(ptr); } /* ** ares_malloc_data() - c-ares internal helper function. ** ** This function allocates memory for a c-ares private ares_data struct ** for the specified ares_datatype, initializes c-ares private fields ** and zero initializes those which later might be used from the public ** API. It returns an interior pointer which can be passed by c-ares ** functions to the calling application, and that must be free'ed using ** c-ares external API function ares_free_data(). */ void *ares_malloc_data(ares_datatype type) { struct ares_data *ptr; ptr = malloc(sizeof(struct ares_data)); if (!ptr) return NULL; switch (type) { case ARES_DATATYPE_MX_REPLY: ptr->data.mx_reply.next = NULL; ptr->data.mx_reply.host = NULL; ptr->data.mx_reply.priority = 0; break; case ARES_DATATYPE_SRV_REPLY: ptr->data.srv_reply.next = NULL; ptr->data.srv_reply.host = NULL; ptr->data.srv_reply.priority = 0; ptr->data.srv_reply.weight = 0; ptr->data.srv_reply.port = 0; break; case ARES_DATATYPE_TXT_REPLY: ptr->data.txt_reply.next = NULL; ptr->data.txt_reply.txt = NULL; ptr->data.txt_reply.length = 0; break; case ARES_DATATYPE_ADDR_NODE: ptr->data.addr_node.next = NULL; ptr->data.addr_node.family = 0; memset(&ptr->data.addr_node.addrV6, 0, sizeof(ptr->data.addr_node.addrV6)); break; case ARES_DATATYPE_NAPTR_REPLY: ptr->data.naptr_reply.next = NULL; ptr->data.naptr_reply.flags = NULL; ptr->data.naptr_reply.service = NULL; ptr->data.naptr_reply.regexp = NULL; ptr->data.naptr_reply.replacement = NULL; ptr->data.naptr_reply.order = 0; ptr->data.naptr_reply.preference = 0; break; case ARES_DATATYPE_SOA_REPLY: ptr->data.soa_reply.nsname = NULL; ptr->data.soa_reply.hostmaster = NULL; ptr->data.soa_reply.serial = 0; ptr->data.soa_reply.refresh = 0; ptr->data.soa_reply.retry = 0; ptr->data.soa_reply.expire = 0; ptr->data.soa_reply.minttl = 0; break; default: free(ptr); return NULL; } ptr->mark = ARES_DATATYPE_MARK; ptr->type = type; return &ptr->data; } gevent-1.1.0/c-ares/ares_data.h0000644000076500000000000000545412666555342017015 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2009-2013 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ typedef enum { ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */ ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */ ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */ ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */ ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */ ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */ ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */ #if 0 ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */ ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */ ARES_DATATYPE_HOSTENT, /* struct hostent */ ARES_DATATYPE_OPTIONS, /* struct ares_options */ #endif ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */ } ares_datatype; #define ARES_DATATYPE_MARK 0xbead /* * ares_data struct definition is internal to c-ares and shall not * be exposed by the public API in order to allow future changes * and extensions to it without breaking ABI. This will be used * internally by c-ares as the container of multiple types of data * dynamically allocated for which a reference will be returned * to the calling application. * * c-ares API functions returning a pointer to c-ares internally * allocated data will actually be returning an interior pointer * into this ares_data struct. * * All this is 'invisible' to the calling application, the only * requirement is that this kind of data must be free'ed by the * calling application using ares_free_data() with the pointer * it has received from a previous c-ares function call. */ struct ares_data { ares_datatype type; /* Actual data type identifier. */ unsigned int mark; /* Private ares_data signature. */ union { struct ares_txt_reply txt_reply; struct ares_srv_reply srv_reply; struct ares_addr_node addr_node; struct ares_mx_reply mx_reply; struct ares_naptr_reply naptr_reply; struct ares_soa_reply soa_reply; } data; }; void *ares_malloc_data(ares_datatype type); gevent-1.1.0/c-ares/ares_destroy.c0000644000076500000000000000550312666555342017563 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004-2011 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include #include "ares.h" #include "ares_private.h" void ares_destroy_options(struct ares_options *options) { int i; if(options->servers) free(options->servers); for (i = 0; i < options->ndomains; i++) free(options->domains[i]); if(options->domains) free(options->domains); if(options->sortlist) free(options->sortlist); if(options->lookups) free(options->lookups); } void ares_destroy(ares_channel channel) { int i; struct query *query; struct list_node* list_head; struct list_node* list_node; if (!channel) return; list_head = &(channel->all_queries); for (list_node = list_head->next; list_node != list_head; ) { query = list_node->data; list_node = list_node->next; /* since we're deleting the query */ query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL, 0); ares__free_query(query); } #ifndef NDEBUG /* Freeing the query should remove it from all the lists in which it sits, * so all query lists should be empty now. */ assert(ares__is_list_empty(&(channel->all_queries))); for (i = 0; i < ARES_QID_TABLE_SIZE; i++) { assert(ares__is_list_empty(&(channel->queries_by_qid[i]))); } for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++) { assert(ares__is_list_empty(&(channel->queries_by_timeout[i]))); } #endif ares__destroy_servers_state(channel); if (channel->domains) { for (i = 0; i < channel->ndomains; i++) free(channel->domains[i]); free(channel->domains); } if(channel->sortlist) free(channel->sortlist); if (channel->lookups) free(channel->lookups); free(channel); } void ares__destroy_servers_state(ares_channel channel) { struct server_state *server; int i; if (channel->servers) { for (i = 0; i < channel->nservers; i++) { server = &channel->servers[i]; ares__close_sockets(channel, server); assert(ares__is_list_empty(&server->queries_to_server)); } free(channel->servers); channel->servers = NULL; } channel->nservers = -1; } gevent-1.1.0/c-ares/ares_dns.h0000644000076500000000000001227212666555342016664 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_DNS_H #define HEADER_CARES_DNS_H /* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* * Macro DNS__16BIT reads a network short (16 bit) given in network * byte order, and returns its value as an unsigned short. */ #define DNS__16BIT(p) ((unsigned short)((unsigned int) 0xffff & \ (((unsigned int)((unsigned char)(p)[0]) << 8U) | \ ((unsigned int)((unsigned char)(p)[1]))))) /* * Macro DNS__32BIT reads a network long (32 bit) given in network * byte order, and returns its value as an unsigned int. */ #define DNS__32BIT(p) ((unsigned int) \ (((unsigned int)((unsigned char)(p)[0]) << 24U) | \ ((unsigned int)((unsigned char)(p)[1]) << 16U) | \ ((unsigned int)((unsigned char)(p)[2]) << 8U) | \ ((unsigned int)((unsigned char)(p)[3])))) #define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \ ((p)[1] = (unsigned char)((v) & 0xff))) #define DNS__SET32BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 24) & 0xff)), \ ((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \ ((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \ ((p)[3] = (unsigned char)((v) & 0xff))) #if 0 /* we cannot use this approach on systems where we can't access 16/32 bit data on un-aligned addresses */ #define DNS__16BIT(p) ntohs(*(unsigned short*)(p)) #define DNS__32BIT(p) ntohl(*(unsigned long*)(p)) #define DNS__SET16BIT(p, v) *(unsigned short*)(p) = htons(v) #define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v) #endif /* Macros for parsing a DNS header */ #define DNS_HEADER_QID(h) DNS__16BIT(h) #define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1) #define DNS_HEADER_OPCODE(h) (((h)[2] >> 3) & 0xf) #define DNS_HEADER_AA(h) (((h)[2] >> 2) & 0x1) #define DNS_HEADER_TC(h) (((h)[2] >> 1) & 0x1) #define DNS_HEADER_RD(h) ((h)[2] & 0x1) #define DNS_HEADER_RA(h) (((h)[3] >> 7) & 0x1) #define DNS_HEADER_Z(h) (((h)[3] >> 4) & 0x7) #define DNS_HEADER_RCODE(h) ((h)[3] & 0xf) #define DNS_HEADER_QDCOUNT(h) DNS__16BIT((h) + 4) #define DNS_HEADER_ANCOUNT(h) DNS__16BIT((h) + 6) #define DNS_HEADER_NSCOUNT(h) DNS__16BIT((h) + 8) #define DNS_HEADER_ARCOUNT(h) DNS__16BIT((h) + 10) /* Macros for constructing a DNS header */ #define DNS_HEADER_SET_QID(h, v) DNS__SET16BIT(h, v) #define DNS_HEADER_SET_QR(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 7)) #define DNS_HEADER_SET_OPCODE(h, v) ((h)[2] |= (unsigned char)(((v) & 0xf) << 3)) #define DNS_HEADER_SET_AA(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 2)) #define DNS_HEADER_SET_TC(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 1)) #define DNS_HEADER_SET_RD(h, v) ((h)[2] |= (unsigned char)((v) & 0x1)) #define DNS_HEADER_SET_RA(h, v) ((h)[3] |= (unsigned char)(((v) & 0x1) << 7)) #define DNS_HEADER_SET_Z(h, v) ((h)[3] |= (unsigned char)(((v) & 0x7) << 4)) #define DNS_HEADER_SET_RCODE(h, v) ((h)[3] |= (unsigned char)((v) & 0xf)) #define DNS_HEADER_SET_QDCOUNT(h, v) DNS__SET16BIT((h) + 4, v) #define DNS_HEADER_SET_ANCOUNT(h, v) DNS__SET16BIT((h) + 6, v) #define DNS_HEADER_SET_NSCOUNT(h, v) DNS__SET16BIT((h) + 8, v) #define DNS_HEADER_SET_ARCOUNT(h, v) DNS__SET16BIT((h) + 10, v) /* Macros for parsing the fixed part of a DNS question */ #define DNS_QUESTION_TYPE(q) DNS__16BIT(q) #define DNS_QUESTION_CLASS(q) DNS__16BIT((q) + 2) /* Macros for constructing the fixed part of a DNS question */ #define DNS_QUESTION_SET_TYPE(q, v) DNS__SET16BIT(q, v) #define DNS_QUESTION_SET_CLASS(q, v) DNS__SET16BIT((q) + 2, v) /* Macros for parsing the fixed part of a DNS resource record */ #define DNS_RR_TYPE(r) DNS__16BIT(r) #define DNS_RR_CLASS(r) DNS__16BIT((r) + 2) #define DNS_RR_TTL(r) DNS__32BIT((r) + 4) #define DNS_RR_LEN(r) DNS__16BIT((r) + 8) /* Macros for constructing the fixed part of a DNS resource record */ #define DNS_RR_SET_TYPE(r, v) DNS__SET16BIT(r, v) #define DNS_RR_SET_CLASS(r, v) DNS__SET16BIT((r) + 2, v) #define DNS_RR_SET_TTL(r, v) DNS__SET32BIT((r) + 4, v) #define DNS_RR_SET_LEN(r, v) DNS__SET16BIT((r) + 8, v) #endif /* HEADER_CARES_DNS_H */ gevent-1.1.0/c-ares/ares_expand_name.c0000644000076500000000000001341212666555342020347 0ustar jmaddenwheel00000000000000 /* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_nowarn.h" #include "ares_private.h" /* for the memdebug */ static int name_length(const unsigned char *encoded, const unsigned char *abuf, int alen); /* Expand an RFC1035-encoded domain name given by encoded. The * containing message is given by abuf and alen. The result given by * *s, which is set to a NUL-terminated allocated buffer. *enclen is * set to the length of the encoded name (not the length of the * expanded name; the goal is to tell the caller how many bytes to * move forward to get past the encoded name). * * In the simple case, an encoded name is a series of labels, each * composed of a one-byte length (limited to values between 0 and 63 * inclusive) followed by the label contents. The name is terminated * by a zero-length label. * * In the more complicated case, a label may be terminated by an * indirection pointer, specified by two bytes with the high bits of * the first byte (corresponding to INDIR_MASK) set to 11. With the * two high bits of the first byte stripped off, the indirection * pointer gives an offset from the beginning of the containing * message with more labels to decode. Indirection can happen an * arbitrary number of times, so we have to detect loops. * * Since the expanded name uses '.' as a label separator, we use * backslashes to escape periods or backslashes in the expanded name. */ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen) { int len, indir = 0; char *q; const unsigned char *p; union { ssize_t sig; size_t uns; } nlen; nlen.sig = name_length(encoded, abuf, alen); if (nlen.sig < 0) return ARES_EBADNAME; *s = malloc(nlen.uns + 1); if (!*s) return ARES_ENOMEM; q = *s; if (nlen.uns == 0) { /* RFC2181 says this should be ".": the root of the DNS tree. * Since this function strips trailing dots though, it becomes "" */ q[0] = '\0'; /* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but valid) */ if ((*encoded & INDIR_MASK) == INDIR_MASK) *enclen = 2L; else *enclen = 1L; /* the caller should move one byte to get past this */ return ARES_SUCCESS; } /* No error-checking necessary; it was all done by name_length(). */ p = encoded; while (*p) { if ((*p & INDIR_MASK) == INDIR_MASK) { if (!indir) { *enclen = aresx_uztosl(p + 2U - encoded); indir = 1; } p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1)); } else { len = *p; p++; while (len--) { if (*p == '.' || *p == '\\') *q++ = '\\'; *q++ = *p; p++; } *q++ = '.'; } } if (!indir) *enclen = aresx_uztosl(p + 1U - encoded); /* Nuke the trailing period if we wrote one. */ if (q > *s) *(q - 1) = 0; else *q = 0; /* zero terminate */ return ARES_SUCCESS; } /* Return the length of the expansion of an encoded domain name, or * -1 if the encoding is invalid. */ static int name_length(const unsigned char *encoded, const unsigned char *abuf, int alen) { int n = 0, offset, indir = 0; /* Allow the caller to pass us abuf + alen and have us check for it. */ if (encoded >= abuf + alen) return -1; while (*encoded) { if ((*encoded & INDIR_MASK) == INDIR_MASK) { /* Check the offset and go there. */ if (encoded + 1 >= abuf + alen) return -1; offset = (*encoded & ~INDIR_MASK) << 8 | *(encoded + 1); if (offset >= alen) return -1; encoded = abuf + offset; /* If we've seen more indirects than the message length, * then there's a loop. */ if (++indir > alen) return -1; } else { offset = *encoded; if (encoded + offset + 1 >= abuf + alen) return -1; encoded++; while (offset--) { n += (*encoded == '.' || *encoded == '\\') ? 2 : 1; encoded++; } n++; } } /* If there were any labels at all, then the number of dots is one * less than the number of labels, so subtract one. */ return (n) ? n - 1 : n; } /* Like ares_expand_name but returns EBADRESP in case of invalid input. */ int ares__expand_name_for_response(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen) { int status = ares_expand_name(encoded, abuf, alen, s, enclen); if (status == ARES_EBADNAME) status = ARES_EBADRESP; return status; } gevent-1.1.0/c-ares/ares_expand_string.c0000644000076500000000000000350212666555342020734 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #include "ares.h" #include "ares_private.h" /* for the memdebug */ /* Simply decodes a length-encoded character string. The first byte of the * input is the length of the string to be returned and the bytes thereafter * are the characters of the string. The returned result will be NULL * terminated. */ int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf, int alen, unsigned char **s, long *enclen) { unsigned char *q; union { ssize_t sig; size_t uns; } elen; if (encoded == abuf+alen) return ARES_EBADSTR; elen.uns = *encoded; if (encoded+elen.sig+1 > abuf+alen) return ARES_EBADSTR; encoded++; *s = malloc(elen.uns+1); if (*s == NULL) return ARES_ENOMEM; q = *s; strncpy((char *)q, (char *)encoded, elen.uns); q[elen.uns] = '\0'; *s = q; *enclen = (long)(elen.sig+1); return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_fds.c0000644000076500000000000000365712666555342016656 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_nowarn.h" #include "ares_private.h" int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds) { struct server_state *server; ares_socket_t nfds; int i; /* Are there any active queries? */ int active_queries = !ares__is_list_empty(&(channel->all_queries)); nfds = 0; for (i = 0; i < channel->nservers; i++) { server = &channel->servers[i]; /* We only need to register interest in UDP sockets if we have * outstanding queries. */ if (active_queries && server->udp_socket != ARES_SOCKET_BAD) { FD_SET(server->udp_socket, read_fds); if (server->udp_socket >= nfds) nfds = server->udp_socket + 1; } /* We always register for TCP events, because we want to know * when the other side closes the connection, so we don't waste * time trying to use a broken connection. */ if (server->tcp_socket != ARES_SOCKET_BAD) { FD_SET(server->tcp_socket, read_fds); if (server->qhead) FD_SET(server->tcp_socket, write_fds); if (server->tcp_socket >= nfds) nfds = server->tcp_socket + 1; } } return (int)nfds; } gevent-1.1.0/c-ares/ares_free_hostent.c0000644000076500000000000000232012666555342020551 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETDB_H #include #endif #include "ares.h" #include "ares_private.h" /* for memdebug */ void ares_free_hostent(struct hostent *host) { char **p; if (!host) return; free((char *)(host->h_name)); for (p = host->h_aliases; *p; p++) free(*p); free(host->h_aliases); free(host->h_addr_list[0]); /* no matter if there is one or many entries, there is only one malloc for all of them */ free(host->h_addr_list); free(host); } gevent-1.1.0/c-ares/ares_free_string.c0000644000076500000000000000147212666555342020402 0ustar jmaddenwheel00000000000000 /* Copyright 2000 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_private.h" void ares_free_string(void *str) { free(str); } gevent-1.1.0/c-ares/ares_getenv.c0000644000076500000000000000154212666555342017361 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares_getenv.h" #ifndef HAVE_GETENV char *ares_getenv(const char *name) { #ifdef _WIN32_WCE return NULL; #endif } #endif gevent-1.1.0/c-ares/ares_getenv.h0000644000076500000000000000160312666555342017364 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_GETENV_H #define HEADER_CARES_GETENV_H /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifndef HAVE_GETENV extern char *ares_getenv(const char *name); #endif #endif /* HEADER_CARES_GETENV_H */ gevent-1.1.0/c-ares/ares_gethostbyaddr.c0000644000076500000000000002067512666555342020744 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" #include "ares_private.h" #ifdef WATT32 #undef WIN32 #endif struct addr_query { /* Arguments passed to ares_gethostbyaddr() */ ares_channel channel; struct ares_addr addr; ares_host_callback callback; void *arg; const char *remaining_lookups; int timeouts; }; static void next_lookup(struct addr_query *aquery); static void addr_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); static void end_aquery(struct addr_query *aquery, int status, struct hostent *host); static int file_lookup(struct ares_addr *addr, struct hostent **host); static void ptr_rr_name(char *name, const struct ares_addr *addr); void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, int family, ares_host_callback callback, void *arg) { struct addr_query *aquery; if (family != AF_INET && family != AF_INET6) { callback(arg, ARES_ENOTIMP, 0, NULL); return; } if ((family == AF_INET && addrlen != sizeof(aquery->addr.addrV4)) || (family == AF_INET6 && addrlen != sizeof(aquery->addr.addrV6))) { callback(arg, ARES_ENOTIMP, 0, NULL); return; } aquery = malloc(sizeof(struct addr_query)); if (!aquery) { callback(arg, ARES_ENOMEM, 0, NULL); return; } aquery->channel = channel; if (family == AF_INET) memcpy(&aquery->addr.addrV4, addr, sizeof(aquery->addr.addrV4)); else memcpy(&aquery->addr.addrV6, addr, sizeof(aquery->addr.addrV6)); aquery->addr.family = family; aquery->callback = callback; aquery->arg = arg; aquery->remaining_lookups = channel->lookups; aquery->timeouts = 0; next_lookup(aquery); } static void next_lookup(struct addr_query *aquery) { const char *p; char name[128]; int status; struct hostent *host; for (p = aquery->remaining_lookups; *p; p++) { switch (*p) { case 'b': ptr_rr_name(name, &aquery->addr); aquery->remaining_lookups = p + 1; ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback, aquery); return; case 'f': status = file_lookup(&aquery->addr, &host); /* this status check below previously checked for !ARES_ENOTFOUND, but we should not assume that this single error code is the one that can occur, as that is in fact no longer the case */ if (status == ARES_SUCCESS) { end_aquery(aquery, status, host); return; } break; } } end_aquery(aquery, ARES_ENOTFOUND, NULL); } static void addr_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct addr_query *aquery = (struct addr_query *) arg; struct hostent *host; size_t addrlen; aquery->timeouts += timeouts; if (status == ARES_SUCCESS) { if (aquery->addr.family == AF_INET) { addrlen = sizeof(aquery->addr.addrV4); status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4, (int)addrlen, AF_INET, &host); } else { addrlen = sizeof(aquery->addr.addrV6); status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6, (int)addrlen, AF_INET6, &host); } end_aquery(aquery, status, host); } else if (status == ARES_EDESTRUCTION) end_aquery(aquery, status, NULL); else next_lookup(aquery); } static void end_aquery(struct addr_query *aquery, int status, struct hostent *host) { aquery->callback(aquery->arg, status, aquery->timeouts, host); if (host) ares_free_hostent(host); free(aquery); } static int file_lookup(struct ares_addr *addr, struct hostent **host) { FILE *fp; int status; int error; #ifdef WIN32 char PATH_HOSTS[MAX_PATH]; win_platform platform; PATH_HOSTS[0] = '\0'; platform = ares__getplatform(); if (platform == WIN_NT) { char tmp[MAX_PATH]; HKEY hkeyHosts; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts) == ERROR_SUCCESS) { DWORD dwLength = MAX_PATH; RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, &dwLength); ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); RegCloseKey(hkeyHosts); } } else if (platform == WIN_9X) GetWindowsDirectory(PATH_HOSTS, MAX_PATH); else return ARES_ENOTFOUND; strcat(PATH_HOSTS, WIN_PATH_HOSTS); #elif defined(WATT32) extern const char *_w32_GetHostsFile (void); const char *PATH_HOSTS = _w32_GetHostsFile(); if (!PATH_HOSTS) return ARES_ENOTFOUND; #endif fp = fopen(PATH_HOSTS, "r"); if (!fp) { error = ERRNO; switch(error) { case ENOENT: case ESRCH: return ARES_ENOTFOUND; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", PATH_HOSTS)); *host = NULL; return ARES_EFILE; } } while ((status = ares__get_hostent(fp, addr->family, host)) == ARES_SUCCESS) { if (addr->family != (*host)->h_addrtype) { ares_free_hostent(*host); continue; } if (addr->family == AF_INET) { if (memcmp((*host)->h_addr, &addr->addrV4, sizeof(addr->addrV4)) == 0) break; } else if (addr->family == AF_INET6) { if (memcmp((*host)->h_addr, &addr->addrV6, sizeof(addr->addrV6)) == 0) break; } ares_free_hostent(*host); } fclose(fp); if (status == ARES_EOF) status = ARES_ENOTFOUND; if (status != ARES_SUCCESS) *host = NULL; return status; } static void ptr_rr_name(char *name, const struct ares_addr *addr) { if (addr->family == AF_INET) { unsigned long laddr = ntohl(addr->addrV4.s_addr); unsigned long a1 = (laddr >> 24UL) & 0xFFUL; unsigned long a2 = (laddr >> 16UL) & 0xFFUL; unsigned long a3 = (laddr >> 8UL) & 0xFFUL; unsigned long a4 = laddr & 0xFFUL; sprintf(name, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1); } else { unsigned char *bytes = (unsigned char *)&addr->addrV6; /* There are too many arguments to do this in one line using * minimally C89-compliant compilers */ sprintf(name, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.", bytes[15]&0xf, bytes[15] >> 4, bytes[14]&0xf, bytes[14] >> 4, bytes[13]&0xf, bytes[13] >> 4, bytes[12]&0xf, bytes[12] >> 4, bytes[11]&0xf, bytes[11] >> 4, bytes[10]&0xf, bytes[10] >> 4, bytes[9]&0xf, bytes[9] >> 4, bytes[8]&0xf, bytes[8] >> 4); sprintf(name+strlen(name), "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa", bytes[7]&0xf, bytes[7] >> 4, bytes[6]&0xf, bytes[6] >> 4, bytes[5]&0xf, bytes[5] >> 4, bytes[4]&0xf, bytes[4] >> 4, bytes[3]&0xf, bytes[3] >> 4, bytes[2]&0xf, bytes[2] >> 4, bytes[1]&0xf, bytes[1] >> 4, bytes[0]&0xf, bytes[0] >> 4); } } gevent-1.1.0/c-ares/ares_gethostbyname.c0000644000076500000000000003610312666555342020743 0ustar jmaddenwheel00000000000000 /* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H #include #endif #include "ares.h" #include "ares_inet_net_pton.h" #include "bitncmp.h" #include "ares_platform.h" #include "ares_nowarn.h" #include "ares_private.h" #ifdef WATT32 #undef WIN32 #endif struct host_query { /* Arguments passed to ares_gethostbyname() */ ares_channel channel; char *name; ares_host_callback callback; void *arg; int sent_family; /* this family is what was is being used */ int want_family; /* this family is what is asked for in the API */ const char *remaining_lookups; int timeouts; }; static void next_lookup(struct host_query *hquery, int status_code); static void host_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); static void end_hquery(struct host_query *hquery, int status, struct hostent *host); static int fake_hostent(const char *name, int family, ares_host_callback callback, void *arg); static int file_lookup(const char *name, int family, struct hostent **host); static void sort_addresses(struct hostent *host, const struct apattern *sortlist, int nsort); static void sort6_addresses(struct hostent *host, const struct apattern *sortlist, int nsort); static int get_address_index(const struct in_addr *addr, const struct apattern *sortlist, int nsort); static int get6_address_index(const struct ares_in6_addr *addr, const struct apattern *sortlist, int nsort); void ares_gethostbyname(ares_channel channel, const char *name, int family, ares_host_callback callback, void *arg) { struct host_query *hquery; /* Right now we only know how to look up Internet addresses - and unspec means try both basically. */ switch (family) { case AF_INET: case AF_INET6: case AF_UNSPEC: break; default: callback(arg, ARES_ENOTIMP, 0, NULL); return; } if (fake_hostent(name, family, callback, arg)) return; /* Allocate and fill in the host query structure. */ hquery = malloc(sizeof(struct host_query)); if (!hquery) { callback(arg, ARES_ENOMEM, 0, NULL); return; } hquery->channel = channel; hquery->name = strdup(name); hquery->want_family = family; hquery->sent_family = -1; /* nothing is sent yet */ if (!hquery->name) { free(hquery); callback(arg, ARES_ENOMEM, 0, NULL); return; } hquery->callback = callback; hquery->arg = arg; hquery->remaining_lookups = channel->lookups; hquery->timeouts = 0; /* Start performing lookups according to channel->lookups. */ next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */); } static void next_lookup(struct host_query *hquery, int status_code) { const char *p; struct hostent *host; int status = status_code; for (p = hquery->remaining_lookups; *p; p++) { switch (*p) { case 'b': /* DNS lookup */ hquery->remaining_lookups = p + 1; if ((hquery->want_family == AF_INET6) || (hquery->want_family == AF_UNSPEC)) { /* if inet6 or unspec, start out with AAAA */ hquery->sent_family = AF_INET6; ares_search(hquery->channel, hquery->name, C_IN, T_AAAA, host_callback, hquery); } else { hquery->sent_family = AF_INET; ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback, hquery); } return; case 'f': /* Host file lookup */ status = file_lookup(hquery->name, hquery->want_family, &host); /* this status check below previously checked for !ARES_ENOTFOUND, but we should not assume that this single error code is the one that can occur, as that is in fact no longer the case */ if (status == ARES_SUCCESS) { end_hquery(hquery, status, host); return; } status = status_code; /* Use original status code */ break; } } end_hquery(hquery, status, NULL); } static void host_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct host_query *hquery = (struct host_query *) arg; ares_channel channel = hquery->channel; struct hostent *host = NULL; hquery->timeouts += timeouts; if (status == ARES_SUCCESS) { if (hquery->sent_family == AF_INET) { status = ares_parse_a_reply(abuf, alen, &host, NULL, NULL); if (host && channel->nsort) sort_addresses(host, channel->sortlist, channel->nsort); } else if (hquery->sent_family == AF_INET6) { status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL); if ((status == ARES_ENODATA || status == ARES_EBADRESP) && hquery->want_family == AF_UNSPEC) { /* The query returned something but either there were no AAAA records (e.g. just CNAME) or the response was malformed. Try looking up A instead. */ hquery->sent_family = AF_INET; ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback, hquery); return; } if (host && channel->nsort) sort6_addresses(host, channel->sortlist, channel->nsort); } end_hquery(hquery, status, host); } else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 && hquery->want_family == AF_UNSPEC)) { /* The AAAA query yielded no useful result. Now look up an A instead. */ hquery->sent_family = AF_INET; ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback, hquery); } else if (status == ARES_EDESTRUCTION) end_hquery(hquery, status, NULL); else next_lookup(hquery, status); } static void end_hquery(struct host_query *hquery, int status, struct hostent *host) { hquery->callback(hquery->arg, status, hquery->timeouts, host); if (host) ares_free_hostent(host); free(hquery->name); free(hquery); } /* If the name looks like an IP address, fake up a host entry, end the * query immediately, and return true. Otherwise return false. */ static int fake_hostent(const char *name, int family, ares_host_callback callback, void *arg) { struct hostent hostent; char *aliases[1] = { NULL }; char *addrs[2]; int result = 0; struct in_addr in; struct ares_in6_addr in6; if (family == AF_INET || family == AF_INET6) { /* It only looks like an IP address if it's all numbers and dots. */ int numdots = 0, valid = 1; const char *p; for (p = name; *p; p++) { if (!ISDIGIT(*p) && *p != '.') { valid = 0; break; } else if (*p == '.') { numdots++; } } /* if we don't have 3 dots, it is illegal * (although inet_addr doesn't think so). */ if (numdots != 3 || !valid) result = 0; else result = ((in.s_addr = inet_addr(name)) == INADDR_NONE ? 0 : 1); if (result) family = AF_INET; } if (family == AF_INET6) result = (ares_inet_pton(AF_INET6, name, &in6) < 1 ? 0 : 1); if (!result) return 0; if (family == AF_INET) { hostent.h_length = (int)sizeof(struct in_addr); addrs[0] = (char *)∈ } else if (family == AF_INET6) { hostent.h_length = (int)sizeof(struct ares_in6_addr); addrs[0] = (char *)&in6; } /* Duplicate the name, to avoid a constness violation. */ hostent.h_name = strdup(name); if (!hostent.h_name) { callback(arg, ARES_ENOMEM, 0, NULL); return 1; } /* Fill in the rest of the host structure and terminate the query. */ addrs[1] = NULL; hostent.h_aliases = aliases; hostent.h_addrtype = aresx_sitoss(family); hostent.h_addr_list = addrs; callback(arg, ARES_SUCCESS, 0, &hostent); free((char *)(hostent.h_name)); return 1; } /* This is an API method */ int ares_gethostbyname_file(ares_channel channel, const char *name, int family, struct hostent **host) { int result; /* We only take the channel to ensure that ares_init() been called. */ if(channel == NULL) { /* Anything will do, really. This seems fine, and is consistent with other error cases. */ *host = NULL; return ARES_ENOTFOUND; } /* Just chain to the internal implementation we use here; it's exactly * what we want. */ result = file_lookup(name, family, host); if(result != ARES_SUCCESS) { /* We guarantee a NULL hostent on failure. */ *host = NULL; } return result; } static int file_lookup(const char *name, int family, struct hostent **host) { FILE *fp; char **alias; int status; int error; #ifdef WIN32 char PATH_HOSTS[MAX_PATH]; win_platform platform; PATH_HOSTS[0] = '\0'; platform = ares__getplatform(); if (platform == WIN_NT) { char tmp[MAX_PATH]; HKEY hkeyHosts; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts) == ERROR_SUCCESS) { DWORD dwLength = MAX_PATH; RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, &dwLength); ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); RegCloseKey(hkeyHosts); } } else if (platform == WIN_9X) GetWindowsDirectory(PATH_HOSTS, MAX_PATH); else return ARES_ENOTFOUND; strcat(PATH_HOSTS, WIN_PATH_HOSTS); #elif defined(WATT32) extern const char *_w32_GetHostsFile (void); const char *PATH_HOSTS = _w32_GetHostsFile(); if (!PATH_HOSTS) return ARES_ENOTFOUND; #endif fp = fopen(PATH_HOSTS, "r"); if (!fp) { error = ERRNO; switch(error) { case ENOENT: case ESRCH: return ARES_ENOTFOUND; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", PATH_HOSTS)); *host = NULL; return ARES_EFILE; } } while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS) { if (strcasecmp((*host)->h_name, name) == 0) break; for (alias = (*host)->h_aliases; *alias; alias++) { if (strcasecmp(*alias, name) == 0) break; } if (*alias) break; ares_free_hostent(*host); } fclose(fp); if (status == ARES_EOF) status = ARES_ENOTFOUND; if (status != ARES_SUCCESS) *host = NULL; return status; } static void sort_addresses(struct hostent *host, const struct apattern *sortlist, int nsort) { struct in_addr a1, a2; int i1, i2, ind1, ind2; /* This is a simple insertion sort, not optimized at all. i1 walks * through the address list, with the loop invariant that everything * to the left of i1 is sorted. In the loop body, the value at i1 is moved * back through the list (via i2) until it is in sorted order. */ for (i1 = 0; host->h_addr_list[i1]; i1++) { memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr)); ind1 = get_address_index(&a1, sortlist, nsort); for (i2 = i1 - 1; i2 >= 0; i2--) { memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr)); ind2 = get_address_index(&a2, sortlist, nsort); if (ind2 <= ind1) break; memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr)); } memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr)); } } /* Find the first entry in sortlist which matches addr. Return nsort * if none of them match. */ static int get_address_index(const struct in_addr *addr, const struct apattern *sortlist, int nsort) { int i; for (i = 0; i < nsort; i++) { if (sortlist[i].family != AF_INET) continue; if (sortlist[i].type == PATTERN_MASK) { if ((addr->s_addr & sortlist[i].mask.addr4.s_addr) == sortlist[i].addrV4.s_addr) break; } else { if (!ares__bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr, sortlist[i].mask.bits)) break; } } return i; } static void sort6_addresses(struct hostent *host, const struct apattern *sortlist, int nsort) { struct ares_in6_addr a1, a2; int i1, i2, ind1, ind2; /* This is a simple insertion sort, not optimized at all. i1 walks * through the address list, with the loop invariant that everything * to the left of i1 is sorted. In the loop body, the value at i1 is moved * back through the list (via i2) until it is in sorted order. */ for (i1 = 0; host->h_addr_list[i1]; i1++) { memcpy(&a1, host->h_addr_list[i1], sizeof(struct ares_in6_addr)); ind1 = get6_address_index(&a1, sortlist, nsort); for (i2 = i1 - 1; i2 >= 0; i2--) { memcpy(&a2, host->h_addr_list[i2], sizeof(struct ares_in6_addr)); ind2 = get6_address_index(&a2, sortlist, nsort); if (ind2 <= ind1) break; memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct ares_in6_addr)); } memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct ares_in6_addr)); } } /* Find the first entry in sortlist which matches addr. Return nsort * if none of them match. */ static int get6_address_index(const struct ares_in6_addr *addr, const struct apattern *sortlist, int nsort) { int i; for (i = 0; i < nsort; i++) { if (sortlist[i].family != AF_INET6) continue; if (!ares__bitncmp(addr, &sortlist[i].addrV6, sortlist[i].mask.bits)) break; } return i; } gevent-1.1.0/c-ares/ares_getnameinfo.c0000644000076500000000000003054012666555342020365 0ustar jmaddenwheel00000000000000 /* Copyright 2005 by Dominick Meglio * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_GETSERVBYPORT_R # if !defined(GETSERVBYPORT_R_ARGS) || \ (GETSERVBYPORT_R_ARGS < 4) || (GETSERVBYPORT_R_ARGS > 6) # error "you MUST specifiy a valid number of arguments for getservbyport_r" # endif #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_NET_IF_H #include #endif #include "ares.h" #include "ares_ipv6.h" #include "ares_nowarn.h" #include "ares_private.h" struct nameinfo_query { ares_nameinfo_callback callback; void *arg; union { struct sockaddr_in addr4; struct sockaddr_in6 addr6; } addr; int family; int flags; int timeouts; }; #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID #define IPBUFSIZ \ (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") + IF_NAMESIZE) #else #define IPBUFSIZ \ (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")) #endif static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host); static char *lookup_service(unsigned short port, int flags, char *buf, size_t buflen); #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid, char *buf, size_t buflen); #endif static char *ares_striendstr(const char *s1, const char *s2); void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, ares_socklen_t salen, int flags, ares_nameinfo_callback callback, void *arg) { struct sockaddr_in *addr = NULL; struct sockaddr_in6 *addr6 = NULL; struct nameinfo_query *niquery; unsigned int port = 0; /* Validate socket address family and length */ if ((sa->sa_family == AF_INET) && (salen == sizeof(struct sockaddr_in))) { addr = (struct sockaddr_in *)sa; port = addr->sin_port; } else if ((sa->sa_family == AF_INET6) && (salen == sizeof(struct sockaddr_in6))) { addr6 = (struct sockaddr_in6 *)sa; port = addr6->sin6_port; } else { callback(arg, ARES_ENOTIMP, 0, NULL, NULL); return; } /* If neither, assume they want a host */ if (!(flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST)) flags |= ARES_NI_LOOKUPHOST; /* All they want is a service, no need for DNS */ if ((flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST)) { char buf[33], *service; service = lookup_service((unsigned short)(port & 0xffff), flags, buf, sizeof(buf)); callback(arg, ARES_SUCCESS, 0, NULL, service); return; } /* They want a host lookup */ if ((flags & ARES_NI_LOOKUPHOST)) { /* A numeric host can be handled without DNS */ if ((flags & ARES_NI_NUMERICHOST)) { char ipbuf[IPBUFSIZ]; char srvbuf[33]; char *service = NULL; ipbuf[0] = 0; /* Specifying not to lookup a host, but then saying a host * is required has to be illegal. */ if (flags & ARES_NI_NAMEREQD) { callback(arg, ARES_EBADFLAGS, 0, NULL, NULL); return; } if (salen == sizeof(struct sockaddr_in6)) { ares_inet_ntop(AF_INET6, &addr6->sin6_addr, ipbuf, IPBUFSIZ); /* If the system supports scope IDs, use it */ #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID append_scopeid(addr6, flags, ipbuf, sizeof(ipbuf)); #endif } else { ares_inet_ntop(AF_INET, &addr->sin_addr, ipbuf, IPBUFSIZ); } /* They also want a service */ if (flags & ARES_NI_LOOKUPSERVICE) service = lookup_service((unsigned short)(port & 0xffff), flags, srvbuf, sizeof(srvbuf)); callback(arg, ARES_SUCCESS, 0, ipbuf, service); return; } /* This is where a DNS lookup becomes necessary */ else { niquery = malloc(sizeof(struct nameinfo_query)); if (!niquery) { callback(arg, ARES_ENOMEM, 0, NULL, NULL); return; } niquery->callback = callback; niquery->arg = arg; niquery->flags = flags; niquery->timeouts = 0; if (sa->sa_family == AF_INET) { niquery->family = AF_INET; memcpy(&niquery->addr.addr4, addr, sizeof(niquery->addr.addr4)); ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), AF_INET, nameinfo_callback, niquery); } else { niquery->family = AF_INET6; memcpy(&niquery->addr.addr6, addr6, sizeof(niquery->addr.addr6)); ares_gethostbyaddr(channel, &addr6->sin6_addr, sizeof(struct ares_in6_addr), AF_INET6, nameinfo_callback, niquery); } } } } static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host) { struct nameinfo_query *niquery = (struct nameinfo_query *) arg; char srvbuf[33]; char *service = NULL; niquery->timeouts += timeouts; if (status == ARES_SUCCESS) { /* They want a service too */ if (niquery->flags & ARES_NI_LOOKUPSERVICE) { if (niquery->family == AF_INET) service = lookup_service(niquery->addr.addr4.sin_port, niquery->flags, srvbuf, sizeof(srvbuf)); else service = lookup_service(niquery->addr.addr6.sin6_port, niquery->flags, srvbuf, sizeof(srvbuf)); } /* NOFQDN means we have to strip off the domain name portion. We do this by determining our own domain name, then searching the string for this domain name and removing it. */ #ifdef HAVE_GETHOSTNAME if (niquery->flags & ARES_NI_NOFQDN) { char buf[255]; char *domain; gethostname(buf, 255); if ((domain = strchr(buf, '.')) != NULL) { char *end = ares_striendstr(host->h_name, domain); if (end) *end = 0; } } #endif niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, (char *)(host->h_name), service); free(niquery); return; } /* We couldn't find the host, but it's OK, we can use the IP */ else if (status == ARES_ENOTFOUND && !(niquery->flags & ARES_NI_NAMEREQD)) { char ipbuf[IPBUFSIZ]; if (niquery->family == AF_INET) ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf, IPBUFSIZ); else { ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf, IPBUFSIZ); #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf, sizeof(ipbuf)); #endif } /* They want a service too */ if (niquery->flags & ARES_NI_LOOKUPSERVICE) { if (niquery->family == AF_INET) service = lookup_service(niquery->addr.addr4.sin_port, niquery->flags, srvbuf, sizeof(srvbuf)); else service = lookup_service(niquery->addr.addr6.sin6_port, niquery->flags, srvbuf, sizeof(srvbuf)); } niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf, service); free(niquery); return; } niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL); free(niquery); } static char *lookup_service(unsigned short port, int flags, char *buf, size_t buflen) { const char *proto; struct servent *sep; #ifdef HAVE_GETSERVBYPORT_R struct servent se; #endif char tmpbuf[4096]; if (port) { if (flags & ARES_NI_NUMERICSERV) sep = NULL; else { if (flags & ARES_NI_UDP) proto = "udp"; else if (flags & ARES_NI_SCTP) proto = "sctp"; else if (flags & ARES_NI_DCCP) proto = "dccp"; else proto = "tcp"; #ifdef HAVE_GETSERVBYPORT_R sep = &se; memset(tmpbuf, 0, sizeof(tmpbuf)); #if GETSERVBYPORT_R_ARGS == 6 if (getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf), &sep) != 0) sep = NULL; #elif GETSERVBYPORT_R_ARGS == 5 sep = getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf)); #elif GETSERVBYPORT_R_ARGS == 4 if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0) sep = NULL; #else /* Lets just hope the OS uses TLS! */ sep = getservbyport(port, proto); #endif #else /* Lets just hope the OS uses TLS! */ #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) sep = getservbyport(port, (char*)proto); #else sep = getservbyport(port, proto); #endif #endif } if (sep && sep->s_name) /* get service name */ strcpy(tmpbuf, sep->s_name); else /* get port as a string */ sprintf(tmpbuf, "%u", (unsigned int)ntohs(port)); if (strlen(tmpbuf) < buflen) /* return it if buffer big enough */ strcpy(buf, tmpbuf); else /* avoid reusing previous one */ buf[0] = '\0'; return buf; } buf[0] = '\0'; return NULL; } #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, char *buf, size_t buflen) { #ifdef HAVE_IF_INDEXTONAME int is_ll, is_mcll; #endif static const char fmt_u[] = "%u"; static const char fmt_lu[] = "%lu"; char tmpbuf[IF_NAMESIZE + 2]; size_t bufl; const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))? fmt_lu:fmt_u; tmpbuf[0] = '%'; #ifdef HAVE_IF_INDEXTONAME is_ll = IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr); is_mcll = IN6_IS_ADDR_MC_LINKLOCAL(&addr6->sin6_addr); if ((flags & ARES_NI_NUMERICSCOPE) || (!is_ll && !is_mcll)) { sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); } else { if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL) sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); } #else sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); (void) flags; #endif tmpbuf[IF_NAMESIZE + 1] = '\0'; bufl = strlen(buf); if(bufl + strlen(tmpbuf) < buflen) /* only append the scopeid string if it fits in the target buffer */ strcpy(&buf[bufl], tmpbuf); } #endif /* Determines if s1 ends with the string in s2 (case-insensitive) */ static char *ares_striendstr(const char *s1, const char *s2) { const char *c1, *c2, *c1_begin; int lo1, lo2; size_t s1_len = strlen(s1), s2_len = strlen(s2); /* If the substr is longer than the full str, it can't match */ if (s2_len > s1_len) return NULL; /* Jump to the end of s1 minus the length of s2 */ c1_begin = s1+s1_len-s2_len; c1 = (const char *)c1_begin; c2 = s2; while (c2 < s2+s2_len) { lo1 = TOLOWER(*c1); lo2 = TOLOWER(*c2); if (lo1 != lo2) return NULL; else { c1++; c2++; } } if (c2 == c1 && c2 == NULL) return (char *)c1_begin; return NULL; } gevent-1.1.0/c-ares/ares_getopt.c0000644000076500000000000001072112666555342017372 0ustar jmaddenwheel00000000000000/* * Original file name getopt.c Initial import into the c-ares source tree * on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with * the modified BSD license, BSD license without the advertising clause. * */ /* * getopt.c -- * * Standard UNIX getopt function. Code is from BSD. * * Copyright (c) 1987-2001 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * A. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * B. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * C. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* #if !defined(lint) * static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94"; * #endif */ #include #include #include #include "ares_getopt.h" int opterr = 1, /* if error message should be printed */ optind = 1; /* index into parent argv vector */ int optopt = 0; /* character checked for validity */ static int optreset; /* reset getopt */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' #define EMSG (char *)"" /* * ares_getopt -- * Parse argc/argv argument vector. */ int ares_getopt(int nargc, char * const nargv[], const char *ostr) { static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return (EOF); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; return (EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || (oli = strchr(ostr, optopt)) == NULL) { /* * if the user didn't specify '-' as an option, * assume it means EOF. */ if (optopt == (int)'-') return (EOF); if (!*place) ++optind; if (opterr && *ostr != ':') (void)fprintf(stderr, "%s: illegal option -- %c\n", __FILE__, optopt); return (BADCH); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (*ostr == ':') return (BADARG); if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __FILE__, optopt); return (BADCH); } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return (optopt); /* dump back option letter */ } gevent-1.1.0/c-ares/ares_getopt.h0000644000076500000000000000400512666555342017375 0ustar jmaddenwheel00000000000000#ifndef ARES_GETOPT_H #define ARES_GETOPT_H /* * Copyright (c) 1987-2001 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * A. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * B. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * C. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ int ares_getopt(int nargc, char * const nargv[], const char *ostr); #undef optarg #undef optind #undef opterr #undef optopt #undef optreset #define optarg ares_optarg #define optind ares_optind #define opterr ares_opterr #define optopt ares_optopt #define optreset ares_optreset extern char *optarg; extern int optind; extern int opterr; extern int optopt; #endif /* ARES_GETOPT_H */ gevent-1.1.0/c-ares/ares_getsock.c0000644000076500000000000000435512666555342017535 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2005 - 2010, Daniel Stenberg * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_private.h" int ares_getsock(ares_channel channel, ares_socket_t *socks, int numsocks) /* size of the 'socks' array */ { struct server_state *server; int i; int sockindex=0; int bitmap = 0; unsigned int setbits = 0xffffffff; /* Are there any active queries? */ int active_queries = !ares__is_list_empty(&(channel->all_queries)); for (i = 0; (i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM); i++) { server = &channel->servers[i]; /* We only need to register interest in UDP sockets if we have * outstanding queries. */ if (active_queries && server->udp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) break; socks[sockindex] = server->udp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); sockindex++; } /* We always register for TCP events, because we want to know * when the other side closes the connection, so we don't waste * time trying to use a broken connection. */ if (server->tcp_socket != ARES_SOCKET_BAD) { if(sockindex >= numsocks) break; socks[sockindex] = server->tcp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); if (server->qhead && active_queries) /* then the tcp socket is also writable! */ bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex); sockindex++; } } return bitmap; } gevent-1.1.0/c-ares/ares_inet_net_pton.h0000644000076500000000000000172612666555342020747 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_INET_NET_PTON_H #define HEADER_CARES_INET_NET_PTON_H /* Copyright (C) 2005-2013 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifdef HAVE_INET_NET_PTON #define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) #else int ares_inet_net_pton(int af, const char *src, void *dst, size_t size); #endif #endif /* HEADER_CARES_INET_NET_PTON_H */ gevent-1.1.0/c-ares/ares_init.c0000644000076500000000000015160412666555342017041 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2007-2013 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #if defined(ANDROID) || defined(__ANDROID__) #include /* From the Bionic sources */ #define DNS_PROP_NAME_PREFIX "net.dns" #define MAX_DNS_PROPERTIES 8 #endif #include "ares.h" #include "ares_inet_net_pton.h" #include "ares_library_init.h" #include "ares_nowarn.h" #include "ares_platform.h" #include "ares_private.h" #ifdef WATT32 #undef WIN32 /* Redefined in MingW/MSVC headers */ #endif static int init_by_options(ares_channel channel, const struct ares_options *options, int optmask); static int init_by_environment(ares_channel channel); static int init_by_resolv_conf(ares_channel channel); static int init_by_defaults(ares_channel channel); #ifndef WATT32 static int config_nameserver(struct server_state **servers, int *nservers, char *str); #endif static int set_search(ares_channel channel, const char *str); static int set_options(ares_channel channel, const char *str); static const char *try_option(const char *p, const char *q, const char *opt); static int init_id_key(rc4_key* key,int key_data_len); #if !defined(WIN32) && !defined(WATT32) && \ !defined(ANDROID) && !defined(__ANDROID__) static int sortlist_alloc(struct apattern **sortlist, int *nsort, struct apattern *pat); static int ip_addr(const char *s, ssize_t len, struct in_addr *addr); static void natural_mask(struct apattern *pat); static int config_domain(ares_channel channel, char *str); static int config_lookup(ares_channel channel, const char *str, const char *bindch, const char *filech); static int config_sortlist(struct apattern **sortlist, int *nsort, const char *str); static char *try_config(char *s, const char *opt, char scc); #endif #define ARES_CONFIG_CHECK(x) (x->lookups && x->nsort > -1 && \ x->nservers > -1 && \ x->ndomains > -1 && \ x->ndots > -1 && x->timeout > -1 && \ x->tries > -1) int ares_init(ares_channel *channelptr) { return ares_init_options(channelptr, NULL, 0); } int ares_init_options(ares_channel *channelptr, struct ares_options *options, int optmask) { ares_channel channel; int i; int status = ARES_SUCCESS; struct timeval now; #ifdef CURLDEBUG const char *env = getenv("CARES_MEMDEBUG"); if (env) curl_memdebug(env); env = getenv("CARES_MEMLIMIT"); if (env) { char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) curl_memlimit(num); } #endif if (ares_library_initialized() != ARES_SUCCESS) return ARES_ENOTINITIALIZED; channel = malloc(sizeof(struct ares_channeldata)); if (!channel) { *channelptr = NULL; return ARES_ENOMEM; } now = ares__tvnow(); /* Set everything to distinguished values so we know they haven't * been set yet. */ channel->flags = -1; channel->timeout = -1; channel->tries = -1; channel->ndots = -1; channel->rotate = -1; channel->udp_port = -1; channel->tcp_port = -1; channel->ednspsz = -1; channel->socket_send_buffer_size = -1; channel->socket_receive_buffer_size = -1; channel->nservers = -1; channel->ndomains = -1; channel->nsort = -1; channel->tcp_connection_generation = 0; channel->lookups = NULL; channel->domains = NULL; channel->sortlist = NULL; channel->servers = NULL; channel->sock_state_cb = NULL; channel->sock_state_cb_data = NULL; channel->sock_create_cb = NULL; channel->sock_create_cb_data = NULL; channel->last_server = 0; channel->last_timeout_processed = (time_t)now.tv_sec; memset(&channel->local_dev_name, 0, sizeof(channel->local_dev_name)); channel->local_ip4 = 0; memset(&channel->local_ip6, 0, sizeof(channel->local_ip6)); /* Initialize our lists of queries */ ares__init_list_head(&(channel->all_queries)); for (i = 0; i < ARES_QID_TABLE_SIZE; i++) { ares__init_list_head(&(channel->queries_by_qid[i])); } for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++) { ares__init_list_head(&(channel->queries_by_timeout[i])); } /* Initialize configuration by each of the four sources, from highest * precedence to lowest. */ if (status == ARES_SUCCESS) { status = init_by_options(channel, options, optmask); if (status != ARES_SUCCESS) DEBUGF(fprintf(stderr, "Error: init_by_options failed: %s\n", ares_strerror(status))); } if (status == ARES_SUCCESS) { status = init_by_environment(channel); if (status != ARES_SUCCESS) DEBUGF(fprintf(stderr, "Error: init_by_environment failed: %s\n", ares_strerror(status))); } if (status == ARES_SUCCESS) { status = init_by_resolv_conf(channel); if (status != ARES_SUCCESS) DEBUGF(fprintf(stderr, "Error: init_by_resolv_conf failed: %s\n", ares_strerror(status))); } /* * No matter what failed or succeeded, seed defaults to provide * useful behavior for things that we missed. */ status = init_by_defaults(channel); if (status != ARES_SUCCESS) DEBUGF(fprintf(stderr, "Error: init_by_defaults failed: %s\n", ares_strerror(status))); /* Generate random key */ if (status == ARES_SUCCESS) { status = init_id_key(&channel->id_key, ARES_ID_KEY_LEN); if (status == ARES_SUCCESS) channel->next_id = ares__generate_new_id(&channel->id_key); else DEBUGF(fprintf(stderr, "Error: init_id_key failed: %s\n", ares_strerror(status))); } if (status != ARES_SUCCESS) { /* Something failed; clean up memory we may have allocated. */ if (channel->servers) free(channel->servers); if (channel->domains) { for (i = 0; i < channel->ndomains; i++) free(channel->domains[i]); free(channel->domains); } if (channel->sortlist) free(channel->sortlist); if(channel->lookups) free(channel->lookups); free(channel); return status; } /* Trim to one server if ARES_FLAG_PRIMARY is set. */ if ((channel->flags & ARES_FLAG_PRIMARY) && channel->nservers > 1) channel->nservers = 1; ares__init_servers_state(channel); *channelptr = channel; return ARES_SUCCESS; } /* ares_dup() duplicates a channel handle with all its options and returns a new channel handle */ int ares_dup(ares_channel *dest, ares_channel src) { struct ares_options opts; struct ares_addr_node *servers; int ipv6_nservers = 0; int i, rc; int optmask; *dest = NULL; /* in case of failure return NULL explicitly */ /* First get the options supported by the old ares_save_options() function, which is most of them */ rc = ares_save_options(src, &opts, &optmask); if(rc) return rc; /* Then create the new channel with those options */ rc = ares_init_options(dest, &opts, optmask); /* destroy the options copy to not leak any memory */ ares_destroy_options(&opts); if(rc) return rc; /* Now clone the options that ares_save_options() doesn't support. */ (*dest)->sock_create_cb = src->sock_create_cb; (*dest)->sock_create_cb_data = src->sock_create_cb_data; strncpy((*dest)->local_dev_name, src->local_dev_name, sizeof(src->local_dev_name)); (*dest)->local_ip4 = src->local_ip4; memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6)); /* Full name server cloning required when not all are IPv4 */ for (i = 0; i < src->nservers; i++) { if (src->servers[i].addr.family != AF_INET) { ipv6_nservers++; break; } } if (ipv6_nservers) { rc = ares_get_servers(src, &servers); if (rc != ARES_SUCCESS) return rc; rc = ares_set_servers(*dest, servers); ares_free_data(servers); if (rc != ARES_SUCCESS) return rc; } return ARES_SUCCESS; /* everything went fine */ } /* Save options from initialized channel */ int ares_save_options(ares_channel channel, struct ares_options *options, int *optmask) { int i, j; int ipv4_nservers = 0; /* Zero everything out */ memset(options, 0, sizeof(struct ares_options)); if (!ARES_CONFIG_CHECK(channel)) return ARES_ENODATA; /* Traditionally the optmask wasn't saved in the channel struct so it was recreated here. ROTATE is the first option that has no struct field of its own in the public config struct */ (*optmask) = (ARES_OPT_FLAGS|ARES_OPT_TRIES|ARES_OPT_NDOTS| ARES_OPT_UDP_PORT|ARES_OPT_TCP_PORT|ARES_OPT_SOCK_STATE_CB| ARES_OPT_SERVERS|ARES_OPT_DOMAINS|ARES_OPT_LOOKUPS| ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS) | (channel->optmask & ARES_OPT_ROTATE); /* Copy easy stuff */ options->flags = channel->flags; /* We return full millisecond resolution but that's only because we don't set the ARES_OPT_TIMEOUT anymore, only the new ARES_OPT_TIMEOUTMS */ options->timeout = channel->timeout; options->tries = channel->tries; options->ndots = channel->ndots; options->udp_port = ntohs(aresx_sitous(channel->udp_port)); options->tcp_port = ntohs(aresx_sitous(channel->tcp_port)); options->sock_state_cb = channel->sock_state_cb; options->sock_state_cb_data = channel->sock_state_cb_data; /* Copy IPv4 servers */ if (channel->nservers) { for (i = 0; i < channel->nservers; i++) { if (channel->servers[i].addr.family == AF_INET) ipv4_nservers++; } if (ipv4_nservers) { options->servers = malloc(ipv4_nservers * sizeof(struct in_addr)); if (!options->servers) return ARES_ENOMEM; for (i = j = 0; i < channel->nservers; i++) { if (channel->servers[i].addr.family == AF_INET) memcpy(&options->servers[j++], &channel->servers[i].addr.addrV4, sizeof(channel->servers[i].addr.addrV4)); } } } options->nservers = ipv4_nservers; /* copy domains */ if (channel->ndomains) { options->domains = malloc(channel->ndomains * sizeof(char *)); if (!options->domains) return ARES_ENOMEM; for (i = 0; i < channel->ndomains; i++) { options->ndomains = i; options->domains[i] = strdup(channel->domains[i]); if (!options->domains[i]) return ARES_ENOMEM; } } options->ndomains = channel->ndomains; /* copy lookups */ if (channel->lookups) { options->lookups = strdup(channel->lookups); if (!options->lookups && channel->lookups) return ARES_ENOMEM; } /* copy sortlist */ if (channel->nsort) { options->sortlist = malloc(channel->nsort * sizeof(struct apattern)); if (!options->sortlist) return ARES_ENOMEM; for (i = 0; i < channel->nsort; i++) options->sortlist[i] = channel->sortlist[i]; } options->nsort = channel->nsort; return ARES_SUCCESS; } static int init_by_options(ares_channel channel, const struct ares_options *options, int optmask) { int i; /* Easy stuff. */ if ((optmask & ARES_OPT_FLAGS) && channel->flags == -1) channel->flags = options->flags; if ((optmask & ARES_OPT_TIMEOUTMS) && channel->timeout == -1) channel->timeout = options->timeout; else if ((optmask & ARES_OPT_TIMEOUT) && channel->timeout == -1) channel->timeout = options->timeout * 1000; if ((optmask & ARES_OPT_TRIES) && channel->tries == -1) channel->tries = options->tries; if ((optmask & ARES_OPT_NDOTS) && channel->ndots == -1) channel->ndots = options->ndots; if ((optmask & ARES_OPT_ROTATE) && channel->rotate == -1) channel->rotate = 1; if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1) channel->udp_port = htons(options->udp_port); if ((optmask & ARES_OPT_TCP_PORT) && channel->tcp_port == -1) channel->tcp_port = htons(options->tcp_port); if ((optmask & ARES_OPT_SOCK_STATE_CB) && channel->sock_state_cb == NULL) { channel->sock_state_cb = options->sock_state_cb; channel->sock_state_cb_data = options->sock_state_cb_data; } if ((optmask & ARES_OPT_SOCK_SNDBUF) && channel->socket_send_buffer_size == -1) channel->socket_send_buffer_size = options->socket_send_buffer_size; if ((optmask & ARES_OPT_SOCK_RCVBUF) && channel->socket_receive_buffer_size == -1) channel->socket_receive_buffer_size = options->socket_receive_buffer_size; if ((optmask & ARES_OPT_EDNSPSZ) && channel->ednspsz == -1) channel->ednspsz = options->ednspsz; /* Copy the IPv4 servers, if given. */ if ((optmask & ARES_OPT_SERVERS) && channel->nservers == -1) { /* Avoid zero size allocations at any cost */ if (options->nservers > 0) { channel->servers = malloc(options->nservers * sizeof(struct server_state)); if (!channel->servers) return ARES_ENOMEM; for (i = 0; i < options->nservers; i++) { channel->servers[i].addr.family = AF_INET; memcpy(&channel->servers[i].addr.addrV4, &options->servers[i], sizeof(channel->servers[i].addr.addrV4)); } } channel->nservers = options->nservers; } /* Copy the domains, if given. Keep channel->ndomains consistent so * we can clean up in case of error. */ if ((optmask & ARES_OPT_DOMAINS) && channel->ndomains == -1) { /* Avoid zero size allocations at any cost */ if (options->ndomains > 0) { channel->domains = malloc(options->ndomains * sizeof(char *)); if (!channel->domains) return ARES_ENOMEM; for (i = 0; i < options->ndomains; i++) { channel->ndomains = i; channel->domains[i] = strdup(options->domains[i]); if (!channel->domains[i]) return ARES_ENOMEM; } } channel->ndomains = options->ndomains; } /* Set lookups, if given. */ if ((optmask & ARES_OPT_LOOKUPS) && !channel->lookups) { channel->lookups = strdup(options->lookups); if (!channel->lookups) return ARES_ENOMEM; } /* copy sortlist */ if ((optmask & ARES_OPT_SORTLIST) && (channel->nsort == -1) && (options->nsort>0)) { channel->sortlist = malloc(options->nsort * sizeof(struct apattern)); if (!channel->sortlist) return ARES_ENOMEM; for (i = 0; i < options->nsort; i++) channel->sortlist[i] = options->sortlist[i]; channel->nsort = options->nsort; } channel->optmask = optmask; return ARES_SUCCESS; } static int init_by_environment(ares_channel channel) { const char *localdomain, *res_options; int status; localdomain = getenv("LOCALDOMAIN"); if (localdomain && channel->ndomains == -1) { status = set_search(channel, localdomain); if (status != ARES_SUCCESS) return status; } res_options = getenv("RES_OPTIONS"); if (res_options) { status = set_options(channel, res_options); if (status != ARES_SUCCESS) return status; } return ARES_SUCCESS; } #ifdef WIN32 /* * get_REG_SZ() * * Given a 'hKey' handle to an open registry key and a 'leafKeyName' pointer * to the name of the registry leaf key to be queried, fetch it's string * value and return a pointer in *outptr to a newly allocated memory area * holding it as a null-terminated string. * * Returns 0 and nullifies *outptr upon inability to return a string value. * * Returns 1 and sets *outptr when returning a dynamically allocated string. * * Supported on Windows NT 3.5 and newer. */ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) { DWORD size = 0; int res; *outptr = NULL; /* Find out size of string stored in registry */ res = RegQueryValueEx(hKey, leafKeyName, 0, NULL, NULL, &size); if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) return 0; /* Allocate buffer of indicated size plus one given that string might have been stored without null termination */ *outptr = malloc(size+1); if (!*outptr) return 0; /* Get the value for real */ res = RegQueryValueEx(hKey, leafKeyName, 0, NULL, (unsigned char *)*outptr, &size); if ((res != ERROR_SUCCESS) || (size == 1)) { free(*outptr); *outptr = NULL; return 0; } /* Null terminate buffer allways */ *(*outptr + size) = '\0'; return 1; } /* * get_REG_SZ_9X() * * Functionally identical to get_REG_SZ() * * Supported on Windows 95, 98 and ME. */ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr) { DWORD dataType = 0; DWORD size = 0; int res; *outptr = NULL; /* Find out size of string stored in registry */ res = RegQueryValueEx(hKey, leafKeyName, 0, &dataType, NULL, &size); if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) return 0; /* Allocate buffer of indicated size plus one given that string might have been stored without null termination */ *outptr = malloc(size+1); if (!*outptr) return 0; /* Get the value for real */ res = RegQueryValueEx(hKey, leafKeyName, 0, &dataType, (unsigned char *)*outptr, &size); if ((res != ERROR_SUCCESS) || (size == 1)) { free(*outptr); *outptr = NULL; return 0; } /* Null terminate buffer allways */ *(*outptr + size) = '\0'; return 1; } /* * get_enum_REG_SZ() * * Given a 'hKeyParent' handle to an open registry key and a 'leafKeyName' * pointer to the name of the registry leaf key to be queried, parent key * is enumerated searching in child keys for given leaf key name and its * associated string value. When located, this returns a pointer in *outptr * to a newly allocated memory area holding it as a null-terminated string. * * Returns 0 and nullifies *outptr upon inability to return a string value. * * Returns 1 and sets *outptr when returning a dynamically allocated string. * * Supported on Windows NT 3.5 and newer. */ static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName, char **outptr) { char enumKeyName[256]; DWORD enumKeyNameBuffSize; DWORD enumKeyIdx = 0; HKEY hKeyEnum; int gotString; int res; *outptr = NULL; for(;;) { enumKeyNameBuffSize = sizeof(enumKeyName); res = RegEnumKeyEx(hKeyParent, enumKeyIdx++, enumKeyName, &enumKeyNameBuffSize, 0, NULL, NULL, NULL); if (res != ERROR_SUCCESS) break; res = RegOpenKeyEx(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE, &hKeyEnum); if (res != ERROR_SUCCESS) continue; gotString = get_REG_SZ(hKeyEnum, leafKeyName, outptr); RegCloseKey(hKeyEnum); if (gotString) break; } if (!*outptr) return 0; return 1; } /* * get_DNS_Registry_9X() * * Functionally identical to get_DNS_Registry() * * Implementation supports Windows 95, 98 and ME. */ static int get_DNS_Registry_9X(char **outptr) { HKEY hKey_VxD_MStcp; int gotString; int res; *outptr = NULL; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ, &hKey_VxD_MStcp); if (res != ERROR_SUCCESS) return 0; gotString = get_REG_SZ_9X(hKey_VxD_MStcp, NAMESERVER, outptr); RegCloseKey(hKey_VxD_MStcp); if (!gotString || !*outptr) return 0; return 1; } /* * get_DNS_Registry_NT() * * Functionally identical to get_DNS_Registry() * * Refs: Microsoft Knowledge Base articles KB120642 and KB314053. * * Implementation supports Windows NT 3.5 and newer. */ static int get_DNS_Registry_NT(char **outptr) { HKEY hKey_Interfaces = NULL; HKEY hKey_Tcpip_Parameters; int gotString; int res; *outptr = NULL; res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hKey_Tcpip_Parameters); if (res != ERROR_SUCCESS) return 0; /* ** Global DNS settings override adapter specific parameters when both ** are set. Additionally static DNS settings override DHCP-configured ** parameters when both are set. */ /* Global DNS static parameters */ gotString = get_REG_SZ(hKey_Tcpip_Parameters, NAMESERVER, outptr); if (gotString) goto done; /* Global DNS DHCP-configured parameters */ gotString = get_REG_SZ(hKey_Tcpip_Parameters, DHCPNAMESERVER, outptr); if (gotString) goto done; /* Try adapter specific parameters */ res = RegOpenKeyEx(hKey_Tcpip_Parameters, "Interfaces", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey_Interfaces); if (res != ERROR_SUCCESS) { hKey_Interfaces = NULL; goto done; } /* Adapter specific DNS static parameters */ gotString = get_enum_REG_SZ(hKey_Interfaces, NAMESERVER, outptr); if (gotString) goto done; /* Adapter specific DNS DHCP-configured parameters */ gotString = get_enum_REG_SZ(hKey_Interfaces, DHCPNAMESERVER, outptr); done: if (hKey_Interfaces) RegCloseKey(hKey_Interfaces); RegCloseKey(hKey_Tcpip_Parameters); if (!gotString || !*outptr) return 0; return 1; } /* * get_DNS_Registry() * * Locates DNS info in the registry. When located, this returns a pointer * in *outptr to a newly allocated memory area holding a null-terminated * string with a space or comma seperated list of DNS IP addresses. * * Returns 0 and nullifies *outptr upon inability to return DNSes string. * * Returns 1 and sets *outptr when returning a dynamically allocated string. */ static int get_DNS_Registry(char **outptr) { win_platform platform; int gotString = 0; *outptr = NULL; platform = ares__getplatform(); if (platform == WIN_NT) gotString = get_DNS_Registry_NT(outptr); else if (platform == WIN_9X) gotString = get_DNS_Registry_9X(outptr); if (!gotString) return 0; return 1; } /* * commajoin() * * RTF code. */ static void commajoin(char **dst, const char *src) { char *tmp; if (*dst) { tmp = malloc(strlen(*dst) + strlen(src) + 2); if (!tmp) return; sprintf(tmp, "%s,%s", *dst, src); free(*dst); *dst = tmp; } else { *dst = malloc(strlen(src) + 1); if (!*dst) return; strcpy(*dst, src); } } /* * get_DNS_NetworkParams() * * Locates DNS info using GetNetworkParams() function from the Internet * Protocol Helper (IP Helper) API. When located, this returns a pointer * in *outptr to a newly allocated memory area holding a null-terminated * string with a space or comma seperated list of DNS IP addresses. * * Returns 0 and nullifies *outptr upon inability to return DNSes string. * * Returns 1 and sets *outptr when returning a dynamically allocated string. * * Implementation supports Windows 98 and newer. * * Note: Ancient PSDK required in order to build a W98 target. */ static int get_DNS_NetworkParams(char **outptr) { FIXED_INFO *fi, *newfi; struct ares_addr namesrvr; char *txtaddr; IP_ADDR_STRING *ipAddr; int res; DWORD size = sizeof (*fi); *outptr = NULL; /* Verify run-time availability of GetNetworkParams() */ if (ares_fpGetNetworkParams == ZERO_NULL) return 0; fi = malloc(size); if (!fi) return 0; res = (*ares_fpGetNetworkParams) (fi, &size); if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) goto done; newfi = realloc(fi, size); if (!newfi) goto done; fi = newfi; res = (*ares_fpGetNetworkParams) (fi, &size); if (res != ERROR_SUCCESS) goto done; for (ipAddr = &fi->DnsServerList; ipAddr; ipAddr = ipAddr->Next) { txtaddr = &ipAddr->IpAddress.String[0]; /* Validate converting textual address to binary format. */ if (ares_inet_pton(AF_INET, txtaddr, &namesrvr.addrV4) == 1) { if ((namesrvr.addrV4.S_un.S_addr == INADDR_ANY) || (namesrvr.addrV4.S_un.S_addr == INADDR_NONE)) continue; } else if (ares_inet_pton(AF_INET6, txtaddr, &namesrvr.addrV6) == 1) { if (memcmp(&namesrvr.addrV6, &ares_in6addr_any, sizeof(namesrvr.addrV6)) == 0) continue; } else continue; commajoin(outptr, txtaddr); if (!*outptr) break; } done: if (fi) free(fi); if (!*outptr) return 0; return 1; } /* * get_DNS_AdaptersAddresses() * * Locates DNS info using GetAdaptersAddresses() function from the Internet * Protocol Helper (IP Helper) API. When located, this returns a pointer * in *outptr to a newly allocated memory area holding a null-terminated * string with a space or comma seperated list of DNS IP addresses. * * Returns 0 and nullifies *outptr upon inability to return DNSes string. * * Returns 1 and sets *outptr when returning a dynamically allocated string. * * Implementation supports Windows XP and newer. */ #define IPAA_INITIAL_BUF_SZ 15 * 1024 #define IPAA_MAX_TRIES 3 static int get_DNS_AdaptersAddresses(char **outptr) { IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr; IP_ADAPTER_ADDRESSES *ipaa, *newipaa, *ipaaEntry; ULONG ReqBufsz = IPAA_INITIAL_BUF_SZ; ULONG Bufsz = IPAA_INITIAL_BUF_SZ; ULONG AddrFlags = 0; int trying = IPAA_MAX_TRIES; int res; union { struct sockaddr *sa; struct sockaddr_in *sa4; struct sockaddr_in6 *sa6; } namesrvr; char txtaddr[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; *outptr = NULL; /* Verify run-time availability of GetAdaptersAddresses() */ if (ares_fpGetAdaptersAddresses == ZERO_NULL) return 0; ipaa = malloc(Bufsz); if (!ipaa) return 0; /* Usually this call suceeds with initial buffer size */ res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz); if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) goto done; while ((res == ERROR_BUFFER_OVERFLOW) && (--trying)) { if (Bufsz < ReqBufsz) { newipaa = realloc(ipaa, ReqBufsz); if (!newipaa) goto done; Bufsz = ReqBufsz; ipaa = newipaa; } res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz); if (res == ERROR_SUCCESS) break; } if (res != ERROR_SUCCESS) goto done; for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next) { for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; ipaDNSAddr; ipaDNSAddr = ipaDNSAddr->Next) { namesrvr.sa = ipaDNSAddr->Address.lpSockaddr; if (namesrvr.sa->sa_family == AF_INET) { if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) || (namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_NONE)) continue; if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, txtaddr, sizeof(txtaddr))) continue; } else if (namesrvr.sa->sa_family == AF_INET6) { if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, sizeof(namesrvr.sa6->sin6_addr)) == 0) continue; if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, txtaddr, sizeof(txtaddr))) continue; } else continue; commajoin(outptr, txtaddr); if (!*outptr) goto done; } } done: if (ipaa) free(ipaa); if (!*outptr) return 0; return 1; } /* * get_DNS_Windows() * * Locates DNS info from Windows employing most suitable methods available at * run-time no matter which Windows version it is. When located, this returns * a pointer in *outptr to a newly allocated memory area holding a string with * a space or comma seperated list of DNS IP addresses, null-terminated. * * Returns 0 and nullifies *outptr upon inability to return DNSes string. * * Returns 1 and sets *outptr when returning a dynamically allocated string. * * Implementation supports Windows 95 and newer. */ static int get_DNS_Windows(char **outptr) { /* Try using IP helper API GetAdaptersAddresses() */ if (get_DNS_AdaptersAddresses(outptr)) return 1; /* Try using IP helper API GetNetworkParams() */ if (get_DNS_NetworkParams(outptr)) return 1; /* Fall-back to registry information */ return get_DNS_Registry(outptr); } #endif static int init_by_resolv_conf(ares_channel channel) { #if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32) char *line = NULL; #endif int status = -1, nservers = 0, nsort = 0; struct server_state *servers = NULL; struct apattern *sortlist = NULL; #ifdef WIN32 if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */ return ARES_SUCCESS; if (get_DNS_Windows(&line)) { status = config_nameserver(&servers, &nservers, line); free(line); } if (status == ARES_SUCCESS) status = ARES_EOF; else /* Catch the case when all the above checks fail (which happens when there is no network card or the cable is unplugged) */ status = ARES_EFILE; #elif defined(__riscos__) /* Under RISC OS, name servers are listed in the system variable Inet$Resolvers, space separated. */ line = getenv("Inet$Resolvers"); status = ARES_EOF; if (line) { char *resolvers = strdup(line), *pos, *space; if (!resolvers) return ARES_ENOMEM; pos = resolvers; do { space = strchr(pos, ' '); if (space) *space = '\0'; status = config_nameserver(&servers, &nservers, pos); if (status != ARES_SUCCESS) break; pos = space + 1; } while (space); if (status == ARES_SUCCESS) status = ARES_EOF; free(resolvers); } #elif defined(WATT32) int i; sock_init(); for (i = 0; def_nameservers[i]; i++) ; if (i == 0) return ARES_SUCCESS; /* use localhost DNS server */ nservers = i; servers = calloc(i, sizeof(struct server_state)); if (!servers) return ARES_ENOMEM; for (i = 0; def_nameservers[i]; i++) { servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]); servers[i].addr.family = AF_INET; } status = ARES_EOF; #elif defined(ANDROID) || defined(__ANDROID__) unsigned int i; char propname[PROP_NAME_MAX]; char propvalue[PROP_VALUE_MAX]=""; for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); if (__system_property_get(propname, propvalue) < 1) { status = ARES_EOF; break; } status = config_nameserver(&servers, &nservers, propvalue); if (status != ARES_SUCCESS) break; status = ARES_EOF; } #else { char *p; FILE *fp; size_t linesize; int error; /* Don't read resolv.conf and friends if we don't have to */ if (ARES_CONFIG_CHECK(channel)) return ARES_SUCCESS; fp = fopen(PATH_RESOLV_CONF, "r"); if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { if ((p = try_config(line, "domain", ';'))) status = config_domain(channel, p); else if ((p = try_config(line, "lookup", ';')) && !channel->lookups) status = config_lookup(channel, p, "bind", "file"); else if ((p = try_config(line, "search", ';'))) status = set_search(channel, p); else if ((p = try_config(line, "nameserver", ';')) && channel->nservers == -1) status = config_nameserver(&servers, &nservers, p); else if ((p = try_config(line, "sortlist", ';')) && channel->nsort == -1) status = config_sortlist(&sortlist, &nsort, p); else if ((p = try_config(line, "options", ';'))) status = set_options(channel, p); else status = ARES_SUCCESS; if (status != ARES_SUCCESS) break; } fclose(fp); } else { error = ERRNO; switch(error) { case ENOENT: case ESRCH: status = ARES_EOF; break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", PATH_RESOLV_CONF)); status = ARES_EFILE; } } if ((status == ARES_EOF) && (!channel->lookups)) { /* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */ fp = fopen("/etc/nsswitch.conf", "r"); if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) /* ignore errors */ (void)config_lookup(channel, p, "dns", "files"); } fclose(fp); } else { error = ERRNO; switch(error) { case ENOENT: case ESRCH: status = ARES_EOF; break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/nsswitch.conf")); status = ARES_EFILE; } } } if ((status == ARES_EOF) && (!channel->lookups)) { /* Linux / GNU libc 2.x and possibly others have host.conf */ fp = fopen("/etc/host.conf", "r"); if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { if ((p = try_config(line, "order", '\0')) && !channel->lookups) /* ignore errors */ (void)config_lookup(channel, p, "bind", "hosts"); } fclose(fp); } else { error = ERRNO; switch(error) { case ENOENT: case ESRCH: status = ARES_EOF; break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/host.conf")); status = ARES_EFILE; } } } if ((status == ARES_EOF) && (!channel->lookups)) { /* Tru64 uses /etc/svc.conf */ fp = fopen("/etc/svc.conf", "r"); if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) /* ignore errors */ (void)config_lookup(channel, p, "bind", "local"); } fclose(fp); } else { error = ERRNO; switch(error) { case ENOENT: case ESRCH: status = ARES_EOF; break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf")); status = ARES_EFILE; } } } if(line) free(line); } #endif /* Handle errors. */ if (status != ARES_EOF) { if (servers != NULL) free(servers); if (sortlist != NULL) free(sortlist); return status; } /* If we got any name server entries, fill them in. */ if (servers) { channel->servers = servers; channel->nservers = nservers; } /* If we got any sortlist entries, fill them in. */ if (sortlist) { channel->sortlist = sortlist; channel->nsort = nsort; } return ARES_SUCCESS; } static int init_by_defaults(ares_channel channel) { char *hostname = NULL; int rc = ARES_SUCCESS; #ifdef HAVE_GETHOSTNAME char *dot; #endif if (channel->flags == -1) channel->flags = 0; if (channel->timeout == -1) channel->timeout = DEFAULT_TIMEOUT; if (channel->tries == -1) channel->tries = DEFAULT_TRIES; if (channel->ndots == -1) channel->ndots = 1; if (channel->rotate == -1) channel->rotate = 0; if (channel->udp_port == -1) channel->udp_port = htons(NAMESERVER_PORT); if (channel->tcp_port == -1) channel->tcp_port = htons(NAMESERVER_PORT); if (channel->ednspsz == -1) channel->ednspsz = EDNSPACKETSZ; if (channel->nservers == -1) { /* If nobody specified servers, try a local named. */ channel->servers = malloc(sizeof(struct server_state)); if (!channel->servers) { rc = ARES_ENOMEM; goto error; } channel->servers[0].addr.family = AF_INET; channel->servers[0].addr.addrV4.s_addr = htonl(INADDR_LOOPBACK); channel->nservers = 1; } #if defined(USE_WINSOCK) #define toolong(x) (x == -1) && (SOCKERRNO == WSAEFAULT) #elif defined(ENAMETOOLONG) #define toolong(x) (x == -1) && ((SOCKERRNO == ENAMETOOLONG) || \ (SOCKERRNO == EINVAL)) #else #define toolong(x) (x == -1) && (SOCKERRNO == EINVAL) #endif if (channel->ndomains == -1) { /* Derive a default domain search list from the kernel hostname, * or set it to empty if the hostname isn't helpful. */ #ifndef HAVE_GETHOSTNAME channel->ndomains = 0; /* default to none */ #else GETHOSTNAME_TYPE_ARG2 lenv = 64; size_t len = 64; int res; channel->ndomains = 0; /* default to none */ hostname = malloc(len); if(!hostname) { rc = ARES_ENOMEM; goto error; } do { res = gethostname(hostname, lenv); if(toolong(res)) { char *p; len *= 2; lenv *= 2; p = realloc(hostname, len); if(!p) { rc = ARES_ENOMEM; goto error; } hostname = p; continue; } else if(res) { rc = ARES_EBADNAME; goto error; } } WHILE_FALSE; dot = strchr(hostname, '.'); if (dot) { /* a dot was found */ channel->domains = malloc(sizeof(char *)); if (!channel->domains) { rc = ARES_ENOMEM; goto error; } channel->domains[0] = strdup(dot + 1); if (!channel->domains[0]) { rc = ARES_ENOMEM; goto error; } channel->ndomains = 1; } #endif } if (channel->nsort == -1) { channel->sortlist = NULL; channel->nsort = 0; } if (!channel->lookups) { channel->lookups = strdup("fb"); if (!channel->lookups) rc = ARES_ENOMEM; } error: if(rc) { if(channel->servers) { free(channel->servers); channel->servers = NULL; } if(channel->domains && channel->domains[0]) free(channel->domains[0]); if(channel->domains) { free(channel->domains); channel->domains = NULL; } if(channel->lookups) { free(channel->lookups); channel->lookups = NULL; } } if(hostname) free(hostname); return rc; } #if !defined(WIN32) && !defined(WATT32) && \ !defined(ANDROID) && !defined(__ANDROID__) static int config_domain(ares_channel channel, char *str) { char *q; /* Set a single search domain. */ q = str; while (*q && !ISSPACE(*q)) q++; *q = '\0'; return set_search(channel, str); } #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 910) && \ defined(__OPTIMIZE__) && defined(__unix__) && defined(__i386__) /* workaround icc 9.1 optimizer issue */ # define vqualifier volatile #else # define vqualifier #endif static int config_lookup(ares_channel channel, const char *str, const char *bindch, const char *filech) { char lookups[3], *l; const char *vqualifier p; /* Set the lookup order. Only the first letter of each work * is relevant, and it has to be "b" for DNS or "f" for the * host file. Ignore everything else. */ l = lookups; p = str; while (*p) { if ((*p == *bindch || *p == *filech) && l < lookups + 2) { if (*p == *bindch) *l++ = 'b'; else *l++ = 'f'; } while (*p && !ISSPACE(*p) && (*p != ',')) p++; while (*p && (ISSPACE(*p) || (*p == ','))) p++; } *l = '\0'; channel->lookups = strdup(lookups); return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM; } #endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ #ifndef WATT32 static int config_nameserver(struct server_state **servers, int *nservers, char *str) { struct ares_addr host; struct server_state *newserv; char *p, *txtaddr; /* On Windows, there may be more than one nameserver specified in the same * registry key, so we parse input as a space or comma seperated list. */ for (p = str; p;) { /* Skip whitespace and commas. */ while (*p && (ISSPACE(*p) || (*p == ','))) p++; if (!*p) /* No more input, done. */ break; /* Pointer to start of IPv4 or IPv6 address part. */ txtaddr = p; /* Advance past this address. */ while (*p && !ISSPACE(*p) && (*p != ',')) p++; if (*p) /* Null terminate this address. */ *p++ = '\0'; else /* Reached end of input, done when this address is processed. */ p = NULL; /* Convert textual address to binary format. */ if (ares_inet_pton(AF_INET, txtaddr, &host.addrV4) == 1) host.family = AF_INET; else if (ares_inet_pton(AF_INET6, txtaddr, &host.addrV6) == 1) host.family = AF_INET6; else continue; /* Resize servers state array. */ newserv = realloc(*servers, (*nservers + 1) * sizeof(struct server_state)); if (!newserv) return ARES_ENOMEM; /* Store address data. */ newserv[*nservers].addr.family = host.family; if (host.family == AF_INET) memcpy(&newserv[*nservers].addr.addrV4, &host.addrV4, sizeof(host.addrV4)); else memcpy(&newserv[*nservers].addr.addrV6, &host.addrV6, sizeof(host.addrV6)); /* Update arguments. */ *servers = newserv; *nservers += 1; } return ARES_SUCCESS; } #if !defined(WIN32) && !defined(ANDROID) && !defined(__ANDROID__) static int config_sortlist(struct apattern **sortlist, int *nsort, const char *str) { struct apattern pat; const char *q; /* Add sortlist entries. */ while (*str && *str != ';') { int bits; char ipbuf[16], ipbufpfx[32]; /* Find just the IP */ q = str; while (*q && *q != '/' && *q != ';' && !ISSPACE(*q)) q++; memcpy(ipbuf, str, q-str); ipbuf[q-str] = '\0'; /* Find the prefix */ if (*q == '/') { const char *str2 = q+1; while (*q && *q != ';' && !ISSPACE(*q)) q++; memcpy(ipbufpfx, str, q-str); ipbufpfx[q-str] = '\0'; str = str2; } else ipbufpfx[0] = '\0'; /* Lets see if it is CIDR */ /* First we'll try IPv6 */ if ((bits = ares_inet_net_pton(AF_INET6, ipbufpfx[0] ? ipbufpfx : ipbuf, &pat.addrV6, sizeof(pat.addrV6))) > 0) { pat.type = PATTERN_CIDR; pat.mask.bits = (unsigned short)bits; pat.family = AF_INET6; if (!sortlist_alloc(sortlist, nsort, &pat)) return ARES_ENOMEM; } else if (ipbufpfx[0] && (bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4, sizeof(pat.addrV4))) > 0) { pat.type = PATTERN_CIDR; pat.mask.bits = (unsigned short)bits; pat.family = AF_INET; if (!sortlist_alloc(sortlist, nsort, &pat)) return ARES_ENOMEM; } /* See if it is just a regular IP */ else if (ip_addr(ipbuf, q-str, &pat.addrV4) == 0) { if (ipbufpfx[0]) { memcpy(ipbuf, str, q-str); ipbuf[q-str] = '\0'; if (ip_addr(ipbuf, q-str, &pat.mask.addr4) != 0) natural_mask(&pat); } else natural_mask(&pat); pat.family = AF_INET; pat.type = PATTERN_MASK; if (!sortlist_alloc(sortlist, nsort, &pat)) return ARES_ENOMEM; } else { while (*q && *q != ';' && !ISSPACE(*q)) q++; } str = q; while (ISSPACE(*str)) str++; } return ARES_SUCCESS; } #endif /* !WIN32 & !ANDROID & !__ANDROID__ */ #endif /* !WATT32 */ static int set_search(ares_channel channel, const char *str) { int n; const char *p, *q; if(channel->ndomains != -1) { /* if we already have some domains present, free them first */ for(n=0; n < channel->ndomains; n++) free(channel->domains[n]); free(channel->domains); channel->domains = NULL; channel->ndomains = -1; } /* Count the domains given. */ n = 0; p = str; while (*p) { while (*p && !ISSPACE(*p)) p++; while (ISSPACE(*p)) p++; n++; } if (!n) { channel->ndomains = 0; return ARES_SUCCESS; } channel->domains = malloc(n * sizeof(char *)); if (!channel->domains) return ARES_ENOMEM; /* Now copy the domains. */ n = 0; p = str; while (*p) { channel->ndomains = n; q = p; while (*q && !ISSPACE(*q)) q++; channel->domains[n] = malloc(q - p + 1); if (!channel->domains[n]) return ARES_ENOMEM; memcpy(channel->domains[n], p, q - p); channel->domains[n][q - p] = 0; p = q; while (ISSPACE(*p)) p++; n++; } channel->ndomains = n; return ARES_SUCCESS; } static int set_options(ares_channel channel, const char *str) { const char *p, *q, *val; p = str; while (*p) { q = p; while (*q && !ISSPACE(*q)) q++; val = try_option(p, q, "ndots:"); if (val && channel->ndots == -1) channel->ndots = aresx_sltosi(strtol(val, NULL, 10)); val = try_option(p, q, "retrans:"); if (val && channel->timeout == -1) channel->timeout = aresx_sltosi(strtol(val, NULL, 10)); val = try_option(p, q, "retry:"); if (val && channel->tries == -1) channel->tries = aresx_sltosi(strtol(val, NULL, 10)); val = try_option(p, q, "rotate"); if (val && channel->rotate == -1) channel->rotate = 1; p = q; while (ISSPACE(*p)) p++; } return ARES_SUCCESS; } static const char *try_option(const char *p, const char *q, const char *opt) { size_t len = strlen(opt); return ((size_t)(q - p) >= len && !strncmp(p, opt, len)) ? &p[len] : NULL; } #if !defined(WIN32) && !defined(WATT32) && \ !defined(ANDROID) && !defined(__ANDROID__) static char *try_config(char *s, const char *opt, char scc) { size_t len; char *p; char *q; if (!s || !opt) /* no line or no option */ return NULL; /* Hash '#' character is always used as primary comment char, additionally a not-NUL secondary comment char will be considered when specified. */ /* trim line comment */ p = s; if(scc) while (*p && (*p != '#') && (*p != scc)) p++; else while (*p && (*p != '#')) p++; *p = '\0'; /* trim trailing whitespace */ q = p - 1; while ((q >= s) && ISSPACE(*q)) q--; *++q = '\0'; /* skip leading whitespace */ p = s; while (*p && ISSPACE(*p)) p++; if (!*p) /* empty line */ return NULL; if ((len = strlen(opt)) == 0) /* empty option */ return NULL; if (strncmp(p, opt, len) != 0) /* line and option do not match */ return NULL; /* skip over given option name */ p += len; if (!*p) /* no option value */ return NULL; if ((opt[len-1] != ':') && (opt[len-1] != '=') && !ISSPACE(*p)) /* whitespace between option name and value is mandatory for given option names which do not end with ':' or '=' */ return NULL; /* skip over whitespace */ while (*p && ISSPACE(*p)) p++; if (!*p) /* no option value */ return NULL; /* return pointer to option value */ return p; } static int sortlist_alloc(struct apattern **sortlist, int *nsort, struct apattern *pat) { struct apattern *newsort; newsort = realloc(*sortlist, (*nsort + 1) * sizeof(struct apattern)); if (!newsort) return 0; newsort[*nsort] = *pat; *sortlist = newsort; (*nsort)++; return 1; } static int ip_addr(const char *ipbuf, ssize_t len, struct in_addr *addr) { /* Four octets and three periods yields at most 15 characters. */ if (len > 15) return -1; addr->s_addr = inet_addr(ipbuf); if (addr->s_addr == INADDR_NONE && strcmp(ipbuf, "255.255.255.255") != 0) return -1; return 0; } static void natural_mask(struct apattern *pat) { struct in_addr addr; /* Store a host-byte-order copy of pat in a struct in_addr. Icky, * but portable. */ addr.s_addr = ntohl(pat->addrV4.s_addr); /* This is out of date in the CIDR world, but some people might * still rely on it. */ if (IN_CLASSA(addr.s_addr)) pat->mask.addr4.s_addr = htonl(IN_CLASSA_NET); else if (IN_CLASSB(addr.s_addr)) pat->mask.addr4.s_addr = htonl(IN_CLASSB_NET); else pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET); } #endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ /* initialize an rc4 key. If possible a cryptographically secure random key is generated using a suitable function (for example win32's RtlGenRandom as described in http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx otherwise the code defaults to cross-platform albeit less secure mechanism using rand */ static void randomize_key(unsigned char* key,int key_data_len) { int randomized = 0; int counter=0; #ifdef WIN32 BOOLEAN res; if (ares_fpSystemFunction036) { res = (*ares_fpSystemFunction036) (key, key_data_len); if (res) randomized = 1; } #else /* !WIN32 */ #ifdef RANDOM_FILE FILE *f = fopen(RANDOM_FILE, "rb"); if(f) { counter = aresx_uztosi(fread(key, 1, key_data_len, f)); fclose(f); } #endif #endif /* WIN32 */ if (!randomized) { for (;counterstate[0]; for(counter = 0; counter < 256; counter++) /* unnecessary AND but it keeps some compilers happier */ state[counter] = (unsigned char)(counter & 0xff); randomize_key(key->state,key_data_len); key->x = 0; key->y = 0; index1 = 0; index2 = 0; for(counter = 0; counter < 256; counter++) { index2 = (unsigned char)((key_data_ptr[index1] + state[counter] + index2) % 256); ARES_SWAP_BYTE(&state[counter], &state[index2]); index1 = (unsigned char)((index1 + 1) % key_data_len); } free(key_data_ptr); return ARES_SUCCESS; } void ares_set_local_ip4(ares_channel channel, unsigned int local_ip) { channel->local_ip4 = local_ip; } /* local_ip6 should be 16 bytes in length */ void ares_set_local_ip6(ares_channel channel, const unsigned char* local_ip6) { memcpy(&channel->local_ip6, local_ip6, sizeof(channel->local_ip6)); } /* local_dev_name should be null terminated. */ void ares_set_local_dev(ares_channel channel, const char* local_dev_name) { strncpy(channel->local_dev_name, local_dev_name, sizeof(channel->local_dev_name)); channel->local_dev_name[sizeof(channel->local_dev_name) - 1] = 0; } void ares_set_socket_callback(ares_channel channel, ares_sock_create_callback cb, void *data) { channel->sock_create_cb = cb; channel->sock_create_cb_data = data; } void ares__init_servers_state(ares_channel channel) { struct server_state *server; int i; for (i = 0; i < channel->nservers; i++) { server = &channel->servers[i]; server->udp_socket = ARES_SOCKET_BAD; server->tcp_socket = ARES_SOCKET_BAD; server->tcp_connection_generation = ++channel->tcp_connection_generation; server->tcp_lenbuf_pos = 0; server->tcp_buffer_pos = 0; server->tcp_buffer = NULL; server->tcp_length = 0; server->qhead = NULL; server->qtail = NULL; ares__init_list_head(&server->queries_to_server); server->channel = channel; server->is_broken = 0; } } gevent-1.1.0/c-ares/ares_iphlpapi.h0000644000076500000000000001346612666555342017714 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_IPHLPAPI_H #define HEADER_CARES_IPHLPAPI_H /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004 - 2011 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #if defined(USE_WINSOCK) #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 22 #endif #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 65 #endif /* ---------------------------------- */ #if !defined(_WS2DEF_) && \ !defined(__CSADDR_DEFINED__) && \ !defined(__CSADDR_T_DEFINED) /* ---------------------------------- */ typedef struct _SOCKET_ADDRESS { LPSOCKADDR lpSockaddr; INT iSockaddrLength; } SOCKET_ADDRESS, *PSOCKET_ADDRESS; typedef struct _CSADDR_INFO { SOCKET_ADDRESS LocalAddr; SOCKET_ADDRESS RemoteAddr; INT iSocketType; INT iProtocol; } CSADDR_INFO, *PCSADDR_INFO; /* --------------------------------- */ #endif /* ! _WS2DEF_ && \ */ /* ! __CSADDR_DEFINED__ && \ */ /* ! __CSADDR_T_DEFINED */ /* --------------------------------- */ /* ------------------------------- */ #if !defined(IP_ADAPTER_DDNS_ENABLED) /* ------------------------------- */ #define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x0001 #define IP_ADAPTER_ADDRESS_TRANSIENT 0x0002 #define IP_ADAPTER_DDNS_ENABLED 0x0001 #define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x0002 #define IP_ADAPTER_DHCP_ENABLED 0x0004 #define IP_ADAPTER_RECEIVE_ONLY 0x0008 #define IP_ADAPTER_NO_MULTICAST 0x0010 #define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x0020 #define GAA_FLAG_SKIP_UNICAST 0x0001 #define GAA_FLAG_SKIP_ANYCAST 0x0002 #define GAA_FLAG_SKIP_MULTICAST 0x0004 #define GAA_FLAG_SKIP_DNS_SERVER 0x0008 #define GAA_FLAG_INCLUDE_PREFIX 0x0010 #define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020 typedef enum { IpPrefixOriginOther = 0, IpPrefixOriginManual, IpPrefixOriginWellKnown, IpPrefixOriginDhcp, IpPrefixOriginRouterAdvertisement } IP_PREFIX_ORIGIN; typedef enum { IpSuffixOriginOther = 0, IpSuffixOriginManual, IpSuffixOriginWellKnown, IpSuffixOriginDhcp, IpSuffixOriginLinkLayerAddress, IpSuffixOriginRandom } IP_SUFFIX_ORIGIN; typedef enum { IpDadStateInvalid = 0, IpDadStateTentative, IpDadStateDuplicate, IpDadStateDeprecated, IpDadStatePreferred } IP_DAD_STATE; typedef enum { IfOperStatusUp = 1, IfOperStatusDown, IfOperStatusTesting, IfOperStatusUnknown, IfOperStatusDormant, IfOperStatusNotPresent, IfOperStatusLowerLayerDown } IF_OPER_STATUS; typedef enum { ScopeLevelInterface = 0x0001, ScopeLevelLink = 0x0002, ScopeLevelSubnet = 0x0003, ScopeLevelAdmin = 0x0004, ScopeLevelSite = 0x0005, ScopeLevelOrganization = 0x0008, ScopeLevelGlobal = 0x000E } SCOPE_LEVEL; typedef struct _IP_ADAPTER_UNICAST_ADDRESS { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; } s; } u; struct _IP_ADAPTER_UNICAST_ADDRESS *Next; SOCKET_ADDRESS Address; IP_PREFIX_ORIGIN PrefixOrigin; IP_SUFFIX_ORIGIN SuffixOrigin; IP_DAD_STATE DadState; ULONG ValidLifetime; ULONG PreferredLifetime; ULONG LeaseLifetime; } IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS; typedef struct _IP_ADAPTER_ANYCAST_ADDRESS { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; } s; } u; struct _IP_ADAPTER_ANYCAST_ADDRESS *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS; typedef struct _IP_ADAPTER_MULTICAST_ADDRESS { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; } s; } u; struct _IP_ADAPTER_MULTICAST_ADDRESS *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS; typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Reserved; } s; } u; struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS; typedef struct _IP_ADAPTER_PREFIX { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; } s; } u; struct _IP_ADAPTER_PREFIX *Next; SOCKET_ADDRESS Address; ULONG PrefixLength; } IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX; typedef struct _IP_ADAPTER_ADDRESSES { union { ULONGLONG Alignment; struct { ULONG Length; DWORD IfIndex; } s; } u; struct _IP_ADAPTER_ADDRESSES *Next; PCHAR AdapterName; PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress; PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress; PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress; PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress; PWCHAR DnsSuffix; PWCHAR Description; PWCHAR FriendlyName; BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH]; DWORD PhysicalAddressLength; DWORD Flags; DWORD Mtu; DWORD IfType; IF_OPER_STATUS OperStatus; DWORD Ipv6IfIndex; DWORD ZoneIndices[16]; PIP_ADAPTER_PREFIX FirstPrefix; } IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES; /* -------------------------------- */ #endif /* ! IP_ADAPTER_DDNS_ENABLED */ /* -------------------------------- */ #endif /* USE_WINSOCK */ #endif /* HEADER_CARES_IPHLPAPI_H */ gevent-1.1.0/c-ares/ares_ipv6.h0000644000076500000000000000363612666555342016770 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2005 by Dominick Meglio * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifndef ARES_IPV6_H #define ARES_IPV6_H #ifndef HAVE_PF_INET6 #define PF_INET6 AF_INET6 #endif #ifndef HAVE_STRUCT_SOCKADDR_IN6 struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned long sin6_flowinfo; struct ares_in6_addr sin6_addr; unsigned int sin6_scope_id; }; #endif #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; ares_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */ char *ai_canonname; struct sockaddr *ai_addr; struct addrinfo *ai_next; }; #endif #ifndef NS_IN6ADDRSZ #if SIZEOF_STRUCT_IN6_ADDR == 0 /* We cannot have it set to zero, so we pick a fixed value here */ #define NS_IN6ADDRSZ 16 #else #define NS_IN6ADDRSZ SIZEOF_STRUCT_IN6_ADDR #endif #endif #ifndef NS_INADDRSZ #define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR #endif #ifndef NS_INT16SZ #define NS_INT16SZ 2 #endif #ifndef IF_NAMESIZE #ifdef IFNAMSIZ #define IF_NAMESIZE IFNAMSIZ #else #define IF_NAMESIZE 256 #endif #endif /* Defined in ares_net_pton.c for no particular reason. */ extern const struct ares_in6_addr ares_in6addr_any; /* :: */ #endif /* ARES_IPV6_H */ gevent-1.1.0/c-ares/ares_library_init.c0000644000076500000000000000665012666555342020565 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004-2009 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_library_init.h" #include "ares_private.h" /* library-private global and unique instance vars */ #ifdef USE_WINSOCK fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL; fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL; fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL; #endif /* library-private global vars with source visibility restricted to this file */ static unsigned int ares_initialized; static int ares_init_flags; #ifdef USE_WINSOCK static HMODULE hnd_iphlpapi; static HMODULE hnd_advapi32; #endif static int ares_win32_init(void) { #ifdef USE_WINSOCK hnd_iphlpapi = 0; hnd_iphlpapi = LoadLibrary("iphlpapi.dll"); if (!hnd_iphlpapi) return ARES_ELOADIPHLPAPI; ares_fpGetNetworkParams = (fpGetNetworkParams_t) GetProcAddress(hnd_iphlpapi, "GetNetworkParams"); if (!ares_fpGetNetworkParams) { FreeLibrary(hnd_iphlpapi); return ARES_EADDRGETNETWORKPARAMS; } ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t) GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses"); if (!ares_fpGetAdaptersAddresses) { /* This can happen on clients before WinXP, I don't think it should be an error, unless we don't want to support Windows 2000 anymore */ } /* * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036, * also known as RtlGenRandom, which is the case for Windows versions prior * to WinXP then c-ares uses portable rand() function. Then don't error here. */ hnd_advapi32 = 0; hnd_advapi32 = LoadLibrary("advapi32.dll"); if (hnd_advapi32) { ares_fpSystemFunction036 = (fpSystemFunction036_t) GetProcAddress(hnd_advapi32, "SystemFunction036"); } #endif return ARES_SUCCESS; } static void ares_win32_cleanup(void) { #ifdef USE_WINSOCK if (hnd_advapi32) FreeLibrary(hnd_advapi32); if (hnd_iphlpapi) FreeLibrary(hnd_iphlpapi); #endif } int ares_library_init(int flags) { int res; if (ares_initialized) { ares_initialized++; return ARES_SUCCESS; } ares_initialized++; if (flags & ARES_LIB_INIT_WIN32) { res = ares_win32_init(); if (res != ARES_SUCCESS) return res; } ares_init_flags = flags; return ARES_SUCCESS; } void ares_library_cleanup(void) { if (!ares_initialized) return; ares_initialized--; if (ares_initialized) return; if (ares_init_flags & ARES_LIB_INIT_WIN32) ares_win32_cleanup(); ares_init_flags = ARES_LIB_INIT_NONE; } int ares_library_initialized(void) { #ifdef USE_WINSOCK if (!ares_initialized) return ARES_ENOTINITIALIZED; #endif return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_library_init.h0000644000076500000000000000300312666555342020557 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_LIBRARY_INIT_H #define HEADER_CARES_LIBRARY_INIT_H /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004-2011 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef USE_WINSOCK #include #include typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*); typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG); typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* ); /* Forward-declaration of variables defined in ares_library_init.c */ /* that are global and unique instances for whole c-ares library. */ extern fpGetNetworkParams_t ares_fpGetNetworkParams; extern fpSystemFunction036_t ares_fpSystemFunction036; extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses; #endif /* USE_WINSOCK */ #endif /* HEADER_CARES_LIBRARY_INIT_H */ gevent-1.1.0/c-ares/ares_llist.c0000644000076500000000000000350712666555342017223 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_private.h" /* Routines for managing doubly-linked circular linked lists with a * dummy head. */ /* Initialize a new head node */ void ares__init_list_head(struct list_node* head) { head->prev = head; head->next = head; head->data = NULL; } /* Initialize a list node */ void ares__init_list_node(struct list_node* node, void* d) { node->prev = NULL; node->next = NULL; node->data = d; } /* Returns true iff the given list is empty */ int ares__is_list_empty(struct list_node* head) { return ((head->next == head) && (head->prev == head)); } /* Inserts new_node before old_node */ void ares__insert_in_list(struct list_node* new_node, struct list_node* old_node) { new_node->next = old_node; new_node->prev = old_node->prev; old_node->prev->next = new_node; old_node->prev = new_node; } /* Removes the node from the list it's in, if any */ void ares__remove_from_list(struct list_node* node) { if (node->next != NULL) { node->prev->next = node->next; node->next->prev = node->prev; node->prev = NULL; node->next = NULL; } } gevent-1.1.0/c-ares/ares_llist.h0000644000076500000000000000234512666555342017227 0ustar jmaddenwheel00000000000000#ifndef __ARES_LLIST_H #define __ARES_LLIST_H /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* Node definition for circular, doubly-linked list */ struct list_node { struct list_node *prev; struct list_node *next; void* data; }; void ares__init_list_head(struct list_node* head); void ares__init_list_node(struct list_node* node, void* d); int ares__is_list_empty(struct list_node* head); void ares__insert_in_list(struct list_node* new_node, struct list_node* old_node); void ares__remove_from_list(struct list_node* node); #endif /* __ARES_LLIST_H */ gevent-1.1.0/c-ares/ares_mkquery.c0000644000076500000000000000170412666555342017566 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id, int rd, unsigned char **buf, int *buflen) { return ares_create_query(name, dnsclass, type, id, rd, buf, buflen, 0); } gevent-1.1.0/c-ares/ares_nowarn.c0000644000076500000000000001443212666555342017377 0ustar jmaddenwheel00000000000000 /* Copyright (C) 2010-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_ASSERT_H # include #endif #if defined(__INTEL_COMPILER) && defined(__unix__) #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #endif /* __INTEL_COMPILER && __unix__ */ #define BUILDING_ARES_NOWARN_C 1 #include "ares_nowarn.h" #if (SIZEOF_SHORT == 2) # define CARES_MASK_SSHORT 0x7FFF # define CARES_MASK_USHORT 0xFFFF #elif (SIZEOF_SHORT == 4) # define CARES_MASK_SSHORT 0x7FFFFFFF # define CARES_MASK_USHORT 0xFFFFFFFF #elif (SIZEOF_SHORT == 8) # define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF # define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF #else # error "SIZEOF_SHORT not defined" #endif #if (SIZEOF_INT == 2) # define CARES_MASK_SINT 0x7FFF # define CARES_MASK_UINT 0xFFFF #elif (SIZEOF_INT == 4) # define CARES_MASK_SINT 0x7FFFFFFF # define CARES_MASK_UINT 0xFFFFFFFF #elif (SIZEOF_INT == 8) # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF #elif (SIZEOF_INT == 16) # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF #else # error "SIZEOF_INT not defined" #endif #if (CARES_SIZEOF_LONG == 2) # define CARES_MASK_SLONG 0x7FFFL # define CARES_MASK_ULONG 0xFFFFUL #elif (CARES_SIZEOF_LONG == 4) # define CARES_MASK_SLONG 0x7FFFFFFFL # define CARES_MASK_ULONG 0xFFFFFFFFUL #elif (CARES_SIZEOF_LONG == 8) # define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFL # define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL #elif (CARES_SIZEOF_LONG == 16) # define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL # define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL #else # error "CARES_SIZEOF_LONG not defined" #endif /* ** unsigned size_t to signed long */ long aresx_uztosl(size_t uznum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif return (long)(uznum & (size_t) CARES_MASK_SLONG); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** unsigned size_t to signed int */ int aresx_uztosi(size_t uznum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif return (int)(uznum & (size_t) CARES_MASK_SINT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** unsigned size_t to signed short */ short aresx_uztoss(size_t uznum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif return (short)(uznum & (size_t) CARES_MASK_SSHORT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** signed int to signed short */ short aresx_sitoss(int sinum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sinum >= 0); return (short)(sinum & (int) CARES_MASK_SSHORT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** signed long to signed int */ int aresx_sltosi(long slnum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(slnum >= 0); return (int)(slnum & (long) CARES_MASK_SINT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** signed ssize_t to signed int */ int aresx_sztosi(ssize_t sznum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sznum >= 0); return (int)(sznum & (ssize_t) CARES_MASK_SINT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** signed ssize_t to unsigned int */ unsigned int aresx_sztoui(ssize_t sznum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sznum >= 0); return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } /* ** signed int to unsigned short */ unsigned short aresx_sitous(int sinum) { #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sinum >= 0); return (unsigned short)(sinum & (int) CARES_MASK_USHORT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } #if defined(__INTEL_COMPILER) && defined(__unix__) int aresx_FD_ISSET(int fd, fd_set *fdset) { #pragma warning(push) #pragma warning(disable:1469) /* clobber ignored */ return FD_ISSET(fd, fdset); #pragma warning(pop) } void aresx_FD_SET(int fd, fd_set *fdset) { #pragma warning(push) #pragma warning(disable:1469) /* clobber ignored */ FD_SET(fd, fdset); #pragma warning(pop) } void aresx_FD_ZERO(fd_set *fdset) { #pragma warning(push) #pragma warning(disable:593) /* variable was set but never used */ FD_ZERO(fdset); #pragma warning(pop) } unsigned short aresx_htons(unsigned short usnum) { #if (__INTEL_COMPILER == 910) && defined(__i386__) return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF)); #else #pragma warning(push) #pragma warning(disable:810) /* conversion may lose significant bits */ return htons(usnum); #pragma warning(pop) #endif } unsigned short aresx_ntohs(unsigned short usnum) { #if (__INTEL_COMPILER == 910) && defined(__i386__) return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF)); #else #pragma warning(push) #pragma warning(disable:810) /* conversion may lose significant bits */ return ntohs(usnum); #pragma warning(pop) #endif } #endif /* __INTEL_COMPILER && __unix__ */ gevent-1.1.0/c-ares/ares_nowarn.h0000644000076500000000000000330412666555342017400 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_NOWARN_H #define HEADER_CARES_NOWARN_H /* Copyright (C) 2010-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ long aresx_uztosl(size_t uznum); int aresx_uztosi(size_t uznum); short aresx_uztoss(size_t uznum); short aresx_sitoss(int sinum); int aresx_sltosi(long slnum); int aresx_sztosi(ssize_t sznum); unsigned int aresx_sztoui(ssize_t sznum); unsigned short aresx_sitous(int sinum); #if defined(__INTEL_COMPILER) && defined(__unix__) int aresx_FD_ISSET(int fd, fd_set *fdset); void aresx_FD_SET(int fd, fd_set *fdset); void aresx_FD_ZERO(fd_set *fdset); unsigned short aresx_htons(unsigned short usnum); unsigned short aresx_ntohs(unsigned short usnum); #ifndef BUILDING_ARES_NOWARN_C # undef FD_ISSET # define FD_ISSET(a,b) aresx_FD_ISSET((a),(b)) # undef FD_SET # define FD_SET(a,b) aresx_FD_SET((a),(b)) # undef FD_ZERO # define FD_ZERO(a) aresx_FD_ZERO((a)) # undef htons # define htons(a) aresx_htons((a)) # undef ntohs # define ntohs(a) aresx_ntohs((a)) #endif #endif /* __INTEL_COMPILER && __unix__ */ #endif /* HEADER_CARES_NOWARN_H */ gevent-1.1.0/c-ares/ares_options.c0000644000076500000000000001655612666555342017577 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2008-2013 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_ARPA_INET_H # include #endif #include "ares.h" #include "ares_data.h" #include "ares_inet_net_pton.h" #include "ares_private.h" int ares_get_servers(ares_channel channel, struct ares_addr_node **servers) { struct ares_addr_node *srvr_head = NULL; struct ares_addr_node *srvr_last = NULL; struct ares_addr_node *srvr_curr; int status = ARES_SUCCESS; int i; if (!channel) return ARES_ENODATA; for (i = 0; i < channel->nservers; i++) { /* Allocate storage for this server node appending it to the list */ srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE); if (!srvr_curr) { status = ARES_ENOMEM; break; } if (srvr_last) { srvr_last->next = srvr_curr; } else { srvr_head = srvr_curr; } srvr_last = srvr_curr; /* Fill this server node data */ srvr_curr->family = channel->servers[i].addr.family; if (srvr_curr->family == AF_INET) memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4, sizeof(srvr_curr->addrV4)); else memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6, sizeof(srvr_curr->addrV6)); } if (status != ARES_SUCCESS) { if (srvr_head) { ares_free_data(srvr_head); srvr_head = NULL; } } *servers = srvr_head; return status; } int ares_set_servers(ares_channel channel, struct ares_addr_node *servers) { struct ares_addr_node *srvr; int num_srvrs = 0; int i; if (ares_library_initialized() != ARES_SUCCESS) return ARES_ENOTINITIALIZED; if (!channel) return ARES_ENODATA; ares__destroy_servers_state(channel); for (srvr = servers; srvr; srvr = srvr->next) { num_srvrs++; } if (num_srvrs > 0) { /* Allocate storage for servers state */ channel->servers = malloc(num_srvrs * sizeof(struct server_state)); if (!channel->servers) { return ARES_ENOMEM; } channel->nservers = num_srvrs; /* Fill servers state address data */ for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next) { channel->servers[i].addr.family = srvr->family; if (srvr->family == AF_INET) memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4, sizeof(srvr->addrV4)); else memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6, sizeof(srvr->addrV6)); } /* Initialize servers state remaining data */ ares__init_servers_state(channel); } return ARES_SUCCESS; } /* Incomming string format: host[:port][,host[:port]]... */ /* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */ int ares_set_servers_csv(ares_channel channel, const char* _csv) { size_t i; char* csv = NULL; char* ptr; char* start_host; int cc = 0; int rv = ARES_SUCCESS; struct ares_addr_node *servers = NULL; struct ares_addr_node *last = NULL; if (ares_library_initialized() != ARES_SUCCESS) return ARES_ENOTINITIALIZED; if (!channel) return ARES_ENODATA; ares__destroy_servers_state(channel); i = strlen(_csv); if (i == 0) return ARES_SUCCESS; /* blank all servers */ csv = malloc(i + 2); strcpy(csv, _csv); if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */ csv[i] = ','; csv[i+1] = 0; } start_host = csv; for (ptr = csv; *ptr; ptr++) { if (*ptr == ':') { /* count colons to determine if we have an IPv6 number or IPv4 with port */ cc++; } else if (*ptr == '[') { /* move start_host if an open square bracket is found wrapping an IPv6 address */ start_host = ptr + 1; } else if (*ptr == ',') { char* pp = ptr - 1; char* p = ptr; struct in_addr in4; struct ares_in6_addr in6; struct ares_addr_node *s = NULL; *ptr = 0; /* null terminate host:port string */ /* Got an entry..see if the port was specified. */ if (cc > 0) { while (pp > start_host) { /* a single close square bracket followed by a colon, ']:' indicates an IPv6 address with port */ if ((*pp == ']') && (*p == ':')) break; /* found port */ /* a single colon, ':' indicates an IPv4 address with port */ if ((*pp == ':') && (cc == 1)) break; /* found port */ if (!(ISDIGIT(*pp) || (*pp == ':'))) { /* Found end of digits before we found :, so wasn't a port */ /* must allow ':' for IPv6 case of ']:' indicates we found a port */ pp = p = ptr; break; } pp--; p--; } if ((pp != start_host) && ((pp + 1) < ptr)) { /* Found it. Parse over the port number */ /* when an IPv6 address is wrapped with square brackets the port starts at pp + 2 */ if (*pp == ']') p++; /* move p before ':' */ /* p will point to the start of the port */ (void)strtol(p, NULL, 10); *pp = 0; /* null terminate host */ } } /* resolve host, try ipv4 first, rslt is in network byte order */ rv = ares_inet_pton(AF_INET, start_host, &in4); if (!rv) { /* Ok, try IPv6 then */ rv = ares_inet_pton(AF_INET6, start_host, &in6); if (!rv) { rv = ARES_EBADSTR; goto out; } /* was ipv6, add new server */ s = malloc(sizeof(*s)); if (!s) { rv = ARES_ENOMEM; goto out; } s->family = AF_INET6; memcpy(&s->addr, &in6, sizeof(struct ares_in6_addr)); } else { /* was ipv4, add new server */ s = malloc(sizeof(*s)); if (!s) { rv = ARES_ENOMEM; goto out; } s->family = AF_INET; memcpy(&s->addr, &in4, sizeof(struct in_addr)); } if (s) { /* TODO: Add port to ares_addr_node and assign it here. */ s->next = NULL; if (last) { last->next = s; /* need to move last to maintain the linked list */ last = last->next; } else { servers = s; last = s; } } /* Set up for next one */ start_host = ptr + 1; cc = 0; } } rv = ares_set_servers(channel, servers); out: if (csv) free(csv); while (servers) { struct ares_addr_node *s = servers; servers = servers->next; free(s); } return rv; } gevent-1.1.0/c-ares/ares_parse_a_reply.c0000644000076500000000000001653612666555342020727 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_LIMITS_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_private.h" int ares_parse_a_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addrttl *addrttls, int *naddrttls) { unsigned int qdcount, ancount; int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs; int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */ int naliases; long len; const unsigned char *aptr; char *hostname, *rr_name, *rr_data, **aliases; struct in_addr *addrs; struct hostent *hostent; const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0; /* Set *host to NULL for all failure cases. */ if (host) *host = NULL; /* Same with *naddrttls. */ if (naddrttls) *naddrttls = 0; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); if (qdcount != 1) return ARES_EBADRESP; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free(hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; if (host) { /* Allocate addresses and aliases; ancount gives an upper bound for both. */ addrs = malloc(ancount * sizeof(struct in_addr)); if (!addrs) { free(hostname); return ARES_ENOMEM; } aliases = malloc((ancount + 1) * sizeof(char *)); if (!aliases) { free(hostname); free(addrs); return ARES_ENOMEM; } } else { addrs = NULL; aliases = NULL; } naddrs = 0; naliases = 0; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < (int)ancount; i++) { /* Decode the RR up to the data field. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) break; aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE(aptr); rr_class = DNS_RR_CLASS(aptr); rr_len = DNS_RR_LEN(aptr); rr_ttl = DNS_RR_TTL(aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } if (rr_class == C_IN && rr_type == T_A && rr_len == sizeof(struct in_addr) && strcasecmp(rr_name, hostname) == 0) { if (addrs) { if (aptr + sizeof(struct in_addr) > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr)); } if (naddrs < max_addr_ttls) { struct ares_addrttl * const at = &addrttls[naddrs]; if (aptr + sizeof(struct in_addr) > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } memcpy(&at->ipaddr, aptr, sizeof(struct in_addr)); at->ttl = rr_ttl; } naddrs++; status = ARES_SUCCESS; } if (rr_class == C_IN && rr_type == T_CNAME) { /* Record the RR name as an alias. */ if (aliases) aliases[naliases] = rr_name; else free(rr_name); naliases++; /* Decode the RR data and replace the hostname with it. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, &len); if (status != ARES_SUCCESS) break; free(hostname); hostname = rr_data; /* Take the min of the TTLs we see in the CNAME chain. */ if (cname_ttl > rr_ttl) cname_ttl = rr_ttl; } else free(rr_name); aptr += rr_len; if (aptr > abuf + alen) { status = ARES_EBADRESP; break; } } if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0) /* the check for naliases to be zero is to make sure CNAME responses don't get caught here */ status = ARES_ENODATA; if (status == ARES_SUCCESS) { /* We got our answer. */ if (naddrttls) { const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls; for (i = 0; i < n; i++) { /* Ensure that each A TTL is no larger than the CNAME TTL. */ if (addrttls[i].ttl > cname_ttl) addrttls[i].ttl = cname_ttl; } *naddrttls = n; } if (aliases) aliases[naliases] = NULL; if (host) { /* Allocate memory to build the host entry. */ hostent = malloc(sizeof(struct hostent)); if (hostent) { hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *)); if (hostent->h_addr_list) { /* Fill in the hostent and return successfully. */ hostent->h_name = hostname; hostent->h_aliases = aliases; hostent->h_addrtype = AF_INET; hostent->h_length = sizeof(struct in_addr); for (i = 0; i < naddrs; i++) hostent->h_addr_list[i] = (char *) &addrs[i]; hostent->h_addr_list[naddrs] = NULL; if (!naddrs && addrs) free(addrs); *host = hostent; return ARES_SUCCESS; } free(hostent); } status = ARES_ENOMEM; } } if (aliases) { for (i = 0; i < naliases; i++) free(aliases[i]); free(aliases); } free(addrs); free(hostname); return status; } gevent-1.1.0/c-ares/ares_parse_aaaa_reply.c0000644000076500000000000001671512666555342021371 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright 2005 Dominick Meglio * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_LIMITS_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_inet_net_pton.h" #include "ares_private.h" int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addr6ttl *addrttls, int *naddrttls) { unsigned int qdcount, ancount; int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs; int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */ int naliases; long len; const unsigned char *aptr; char *hostname, *rr_name, *rr_data, **aliases; struct ares_in6_addr *addrs; struct hostent *hostent; const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0; /* Set *host to NULL for all failure cases. */ if (host) *host = NULL; /* Same with *naddrttls. */ if (naddrttls) *naddrttls = 0; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); if (qdcount != 1) return ARES_EBADRESP; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free(hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Allocate addresses and aliases; ancount gives an upper bound for both. */ if (host) { addrs = malloc(ancount * sizeof(struct ares_in6_addr)); if (!addrs) { free(hostname); return ARES_ENOMEM; } aliases = malloc((ancount + 1) * sizeof(char *)); if (!aliases) { free(hostname); free(addrs); return ARES_ENOMEM; } } else { addrs = NULL; aliases = NULL; } naddrs = 0; naliases = 0; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < (int)ancount; i++) { /* Decode the RR up to the data field. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) break; aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE(aptr); rr_class = DNS_RR_CLASS(aptr); rr_len = DNS_RR_LEN(aptr); rr_ttl = DNS_RR_TTL(aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } if (rr_class == C_IN && rr_type == T_AAAA && rr_len == sizeof(struct ares_in6_addr) && strcasecmp(rr_name, hostname) == 0) { if (addrs) { if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } memcpy(&addrs[naddrs], aptr, sizeof(struct ares_in6_addr)); } if (naddrs < max_addr_ttls) { struct ares_addr6ttl * const at = &addrttls[naddrs]; if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } memcpy(&at->ip6addr, aptr, sizeof(struct ares_in6_addr)); at->ttl = rr_ttl; } naddrs++; status = ARES_SUCCESS; } if (rr_class == C_IN && rr_type == T_CNAME) { /* Record the RR name as an alias. */ if (aliases) aliases[naliases] = rr_name; else free(rr_name); naliases++; /* Decode the RR data and replace the hostname with it. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, &len); if (status != ARES_SUCCESS) break; free(hostname); hostname = rr_data; /* Take the min of the TTLs we see in the CNAME chain. */ if (cname_ttl > rr_ttl) cname_ttl = rr_ttl; } else free(rr_name); aptr += rr_len; if (aptr > abuf + alen) { status = ARES_EBADRESP; break; } } /* the check for naliases to be zero is to make sure CNAME responses don't get caught here */ if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0) status = ARES_ENODATA; if (status == ARES_SUCCESS) { /* We got our answer. */ if (naddrttls) { const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls; for (i = 0; i < n; i++) { /* Ensure that each A TTL is no larger than the CNAME TTL. */ if (addrttls[i].ttl > cname_ttl) addrttls[i].ttl = cname_ttl; } *naddrttls = n; } if (aliases) aliases[naliases] = NULL; if (host) { /* Allocate memory to build the host entry. */ hostent = malloc(sizeof(struct hostent)); if (hostent) { hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *)); if (hostent->h_addr_list) { /* Fill in the hostent and return successfully. */ hostent->h_name = hostname; hostent->h_aliases = aliases; hostent->h_addrtype = AF_INET6; hostent->h_length = sizeof(struct ares_in6_addr); for (i = 0; i < naddrs; i++) hostent->h_addr_list[i] = (char *) &addrs[i]; hostent->h_addr_list[naddrs] = NULL; if (!naddrs && addrs) free(addrs); *host = hostent; return ARES_SUCCESS; } free(hostent); } status = ARES_ENOMEM; } } if (aliases) { for (i = 0; i < naliases; i++) free(aliases[i]); free(aliases); } free(addrs); free(hostname); return status; } gevent-1.1.0/c-ares/ares_parse_mx_reply.c0000644000076500000000000001055712666555342021130 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2010 Jeremy Lal * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_data.h" #include "ares_private.h" int ares_parse_mx_reply (const unsigned char *abuf, int alen, struct ares_mx_reply **mx_out) { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; int status, rr_type, rr_class, rr_len; long len; char *hostname = NULL, *rr_name = NULL; struct ares_mx_reply *mx_head = NULL; struct ares_mx_reply *mx_last = NULL; struct ares_mx_reply *mx_curr; /* Set *mx_out to NULL for all failure cases. */ *mx_out = NULL; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT (abuf); ancount = DNS_HEADER_ANCOUNT (abuf); if (qdcount != 1) return ARES_EBADRESP; if (ancount == 0) return ARES_ENODATA; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares_expand_name (aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < ancount; i++) { /* Decode the RR up to the data field. */ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) { break; } aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { status = ARES_EBADRESP; break; } /* Check if we are really looking at a MX record */ if (rr_class == C_IN && rr_type == T_MX) { /* parse the MX record itself */ if (rr_len < 2) { status = ARES_EBADRESP; break; } /* Allocate storage for this MX answer appending it to the list */ mx_curr = ares_malloc_data(ARES_DATATYPE_MX_REPLY); if (!mx_curr) { status = ARES_ENOMEM; break; } if (mx_last) { mx_last->next = mx_curr; } else { mx_head = mx_curr; } mx_last = mx_curr; vptr = aptr; mx_curr->priority = DNS__16BIT(vptr); vptr += sizeof(unsigned short); status = ares_expand_name (vptr, abuf, alen, &mx_curr->host, &len); if (status != ARES_SUCCESS) break; } /* Don't lose memory in the next iteration */ free (rr_name); rr_name = NULL; /* Move on to the next record */ aptr += rr_len; } if (hostname) free (hostname); if (rr_name) free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) { if (mx_head) ares_free_data (mx_head); return status; } /* everything looks fine, return the data */ *mx_out = mx_head; return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_parse_naptr_reply.c0000644000076500000000000001203512666555342021621 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2009 by Jakub Hrozek * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_data.h" #include "ares_private.h" /* AIX portability check */ #ifndef T_NAPTR #define T_NAPTR 35 /* naming authority pointer */ #endif int ares_parse_naptr_reply (const unsigned char *abuf, int alen, struct ares_naptr_reply **naptr_out) { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; int status, rr_type, rr_class, rr_len; long len; char *hostname = NULL, *rr_name = NULL; struct ares_naptr_reply *naptr_head = NULL; struct ares_naptr_reply *naptr_last = NULL; struct ares_naptr_reply *naptr_curr; /* Set *naptr_out to NULL for all failure cases. */ *naptr_out = NULL; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT (abuf); ancount = DNS_HEADER_ANCOUNT (abuf); if (qdcount != 1) return ARES_EBADRESP; if (ancount == 0) return ARES_ENODATA; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares_expand_name (aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < ancount; i++) { /* Decode the RR up to the data field. */ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) { break; } aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { status = ARES_EBADRESP; break; } /* Check if we are really looking at a NAPTR record */ if (rr_class == C_IN && rr_type == T_NAPTR) { /* parse the NAPTR record itself */ /* Allocate storage for this NAPTR answer appending it to the list */ naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); if (!naptr_curr) { status = ARES_ENOMEM; break; } if (naptr_last) { naptr_last->next = naptr_curr; } else { naptr_head = naptr_curr; } naptr_last = naptr_curr; vptr = aptr; naptr_curr->order = DNS__16BIT(vptr); vptr += sizeof(unsigned short); naptr_curr->preference = DNS__16BIT(vptr); vptr += sizeof(unsigned short); status = ares_expand_string(vptr, abuf, alen, &naptr_curr->flags, &len); if (status != ARES_SUCCESS) break; vptr += len; status = ares_expand_string(vptr, abuf, alen, &naptr_curr->service, &len); if (status != ARES_SUCCESS) break; vptr += len; status = ares_expand_string(vptr, abuf, alen, &naptr_curr->regexp, &len); if (status != ARES_SUCCESS) break; vptr += len; status = ares_expand_name(vptr, abuf, alen, &naptr_curr->replacement, &len); if (status != ARES_SUCCESS) break; } /* Don't lose memory in the next iteration */ free (rr_name); rr_name = NULL; /* Move on to the next record */ aptr += rr_len; } if (hostname) free (hostname); if (rr_name) free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) { if (naptr_head) ares_free_data (naptr_head); return status; } /* everything looks fine, return the data */ *naptr_out = naptr_head; return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_parse_ns_reply.c0000644000076500000000000001152112666555342021114 0ustar jmaddenwheel00000000000000/* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* * ares_parse_ns_reply created by Vlad Dinulescu * on behalf of AVIRA Gmbh - http://www.avira.com */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_private.h" int ares_parse_ns_reply( const unsigned char* abuf, int alen, struct hostent** host ) { unsigned int qdcount, ancount; int status, i, rr_type, rr_class, rr_len; int nameservers_num; long len; const unsigned char *aptr; char* hostname, *rr_name, *rr_data, **nameservers; struct hostent *hostent; /* Set *host to NULL for all failure cases. */ *host = NULL; /* Give up if abuf doesn't have room for a header. */ if ( alen < HFIXEDSZ ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT( abuf ); ancount = DNS_HEADER_ANCOUNT( abuf ); if ( qdcount != 1 ) return ARES_EBADRESP; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares__expand_name_for_response( aptr, abuf, alen, &hostname, &len); if ( status != ARES_SUCCESS ) return status; if ( aptr + len + QFIXEDSZ > abuf + alen ) { free( hostname ); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Allocate nameservers array; ancount gives an upper bound */ nameservers = malloc( ( ancount + 1 ) * sizeof( char * ) ); if ( !nameservers ) { free( hostname ); return ARES_ENOMEM; } nameservers_num = 0; /* Examine each answer resource record (RR) in turn. */ for ( i = 0; i < ( int ) ancount; i++ ) { /* Decode the RR up to the data field. */ status = ares__expand_name_for_response( aptr, abuf, alen, &rr_name, &len ); if ( status != ARES_SUCCESS ) break; aptr += len; if ( aptr + RRFIXEDSZ > abuf + alen ) { status = ARES_EBADRESP; free(rr_name); break; } rr_type = DNS_RR_TYPE( aptr ); rr_class = DNS_RR_CLASS( aptr ); rr_len = DNS_RR_LEN( aptr ); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } if ( rr_class == C_IN && rr_type == T_NS ) { /* Decode the RR data and add it to the nameservers list */ status = ares__expand_name_for_response( aptr, abuf, alen, &rr_data, &len); if ( status != ARES_SUCCESS ) { free(rr_name); break; } nameservers[nameservers_num] = malloc(strlen(rr_data)+1); if (nameservers[nameservers_num]==NULL) { free(rr_name); free(rr_data); status=ARES_ENOMEM; break; } strcpy(nameservers[nameservers_num],rr_data); free(rr_data); nameservers_num++; } free( rr_name ); aptr += rr_len; if ( aptr > abuf + alen ) { status = ARES_EBADRESP; break; } } if ( status == ARES_SUCCESS && nameservers_num == 0 ) { status = ARES_ENODATA; } if ( status == ARES_SUCCESS ) { /* We got our answer. Allocate memory to build the host entry. */ nameservers[nameservers_num] = NULL; hostent = malloc( sizeof( struct hostent ) ); if ( hostent ) { hostent->h_addr_list = malloc( 1 * sizeof( char * ) ); if ( hostent->h_addr_list ) { /* Fill in the hostent and return successfully. */ hostent->h_name = hostname; hostent->h_aliases = nameservers; hostent->h_addrtype = AF_INET; hostent->h_length = sizeof( struct in_addr ); hostent->h_addr_list[0] = NULL; *host = hostent; return ARES_SUCCESS; } free( hostent ); } status = ARES_ENOMEM; } for ( i = 0; i < nameservers_num; i++ ) free( nameservers[i] ); free( nameservers ); free( hostname ); return status; } gevent-1.1.0/c-ares/ares_parse_ptr_reply.c0000644000076500000000000001463712666555342021314 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_nowarn.h" #include "ares_private.h" int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, int addrlen, int family, struct hostent **host) { unsigned int qdcount, ancount; int status, i, rr_type, rr_class, rr_len; long len; const unsigned char *aptr; char *ptrname, *hostname, *rr_name, *rr_data; struct hostent *hostent; int aliascnt = 0; int alias_alloc = 8; char ** aliases; /* Set *host to NULL for all failure cases. */ *host = NULL; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); if (qdcount != 1) return ARES_EBADRESP; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares__expand_name_for_response(aptr, abuf, alen, &ptrname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free(ptrname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ hostname = NULL; aliases = malloc(alias_alloc * sizeof(char *)); if (!aliases) { free(ptrname); return ARES_ENOMEM; } for (i = 0; i < (int)ancount; i++) { /* Decode the RR up to the data field. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) break; aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE(aptr); rr_class = DNS_RR_CLASS(aptr); rr_len = DNS_RR_LEN(aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { free(rr_name); status = ARES_EBADRESP; break; } if (rr_class == C_IN && rr_type == T_PTR && strcasecmp(rr_name, ptrname) == 0) { /* Decode the RR data and set hostname to it. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, &len); if (status != ARES_SUCCESS) { free(rr_name); break; } if (hostname) free(hostname); hostname = rr_data; aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char)); if (!aliases[aliascnt]) { free(rr_name); status = ARES_ENOMEM; break; } strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1); aliascnt++; if (aliascnt >= alias_alloc) { char **ptr; alias_alloc *= 2; ptr = realloc(aliases, alias_alloc * sizeof(char *)); if(!ptr) { free(rr_name); status = ARES_ENOMEM; break; } aliases = ptr; } } if (rr_class == C_IN && rr_type == T_CNAME) { /* Decode the RR data and replace ptrname with it. */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, &len); if (status != ARES_SUCCESS) { free(rr_name); break; } free(ptrname); ptrname = rr_data; } free(rr_name); aptr += rr_len; if (aptr > abuf + alen) { status = ARES_EBADRESP; break; } } if (status == ARES_SUCCESS && !hostname) status = ARES_ENODATA; if (status == ARES_SUCCESS) { /* We got our answer. Allocate memory to build the host entry. */ hostent = malloc(sizeof(struct hostent)); if (hostent) { hostent->h_addr_list = malloc(2 * sizeof(char *)); if (hostent->h_addr_list) { hostent->h_addr_list[0] = malloc(addrlen); if (hostent->h_addr_list[0]) { hostent->h_aliases = malloc((aliascnt+1) * sizeof (char *)); if (hostent->h_aliases) { /* Fill in the hostent and return successfully. */ hostent->h_name = hostname; for (i=0 ; ih_aliases[i] = aliases[i]; hostent->h_aliases[aliascnt] = NULL; hostent->h_addrtype = aresx_sitoss(family); hostent->h_length = aresx_sitoss(addrlen); memcpy(hostent->h_addr_list[0], addr, addrlen); hostent->h_addr_list[1] = NULL; *host = hostent; free(aliases); free(ptrname); return ARES_SUCCESS; } free(hostent->h_addr_list[0]); } free(hostent->h_addr_list); } free(hostent); } status = ARES_ENOMEM; } for (i=0 ; i * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_data.h" #include "ares_private.h" int ares_parse_soa_reply(const unsigned char *abuf, int alen, struct ares_soa_reply **soa_out) { const unsigned char *aptr; long len; char *qname = NULL, *rr_name = NULL; struct ares_soa_reply *soa = NULL; int qdcount, ancount; int status; if (alen < HFIXEDSZ) return ARES_EBADRESP; /* parse message header */ qdcount = DNS_HEADER_QDCOUNT(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); if (qdcount != 1 || ancount != 1) return ARES_EBADRESP; aptr = abuf + HFIXEDSZ; /* query name */ status = ares__expand_name_for_response(aptr, abuf, alen, &qname, &len); if (status != ARES_SUCCESS) goto failed_stat; aptr += len; /* skip qtype & qclass */ if (aptr + QFIXEDSZ > abuf + alen) goto failed; aptr += QFIXEDSZ; /* rr_name */ status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) goto failed_stat; aptr += len; /* skip rr_type, rr_class, rr_ttl, rr_rdlen */ if (aptr + RRFIXEDSZ > abuf + alen) goto failed; aptr += RRFIXEDSZ; /* allocate result struct */ soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); if (!soa) return ARES_ENOMEM; /* nsname */ status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, &len); if (status != ARES_SUCCESS) goto failed_stat; aptr += len; /* hostmaster */ status = ares__expand_name_for_response(aptr, abuf, alen, &soa->hostmaster, &len); if (status != ARES_SUCCESS) goto failed_stat; aptr += len; /* integer fields */ if (aptr + 5 * 4 > abuf + alen) goto failed; soa->serial = DNS__32BIT(aptr + 0 * 4); soa->refresh = DNS__32BIT(aptr + 1 * 4); soa->retry = DNS__32BIT(aptr + 2 * 4); soa->expire = DNS__32BIT(aptr + 3 * 4); soa->minttl = DNS__32BIT(aptr + 4 * 4); free(qname); free(rr_name); *soa_out = soa; return ARES_SUCCESS; failed: status = ARES_EBADRESP; failed_stat: ares_free_data(soa); if (qname) free(qname); if (rr_name) free(rr_name); return status; } gevent-1.1.0/c-ares/ares_parse_srv_reply.c0000644000076500000000000001124112666555342021305 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2009 by Jakub Hrozek * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_data.h" #include "ares_private.h" /* AIX portability check */ #ifndef T_SRV # define T_SRV 33 /* server selection */ #endif int ares_parse_srv_reply (const unsigned char *abuf, int alen, struct ares_srv_reply **srv_out) { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; int status, rr_type, rr_class, rr_len; long len; char *hostname = NULL, *rr_name = NULL; struct ares_srv_reply *srv_head = NULL; struct ares_srv_reply *srv_last = NULL; struct ares_srv_reply *srv_curr; /* Set *srv_out to NULL for all failure cases. */ *srv_out = NULL; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT (abuf); ancount = DNS_HEADER_ANCOUNT (abuf); if (qdcount != 1) return ARES_EBADRESP; if (ancount == 0) return ARES_ENODATA; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares_expand_name (aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < ancount; i++) { /* Decode the RR up to the data field. */ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) { break; } aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { status = ARES_EBADRESP; break; } /* Check if we are really looking at a SRV record */ if (rr_class == C_IN && rr_type == T_SRV) { /* parse the SRV record itself */ if (rr_len < 6) { status = ARES_EBADRESP; break; } /* Allocate storage for this SRV answer appending it to the list */ srv_curr = ares_malloc_data(ARES_DATATYPE_SRV_REPLY); if (!srv_curr) { status = ARES_ENOMEM; break; } if (srv_last) { srv_last->next = srv_curr; } else { srv_head = srv_curr; } srv_last = srv_curr; vptr = aptr; srv_curr->priority = DNS__16BIT(vptr); vptr += sizeof(unsigned short); srv_curr->weight = DNS__16BIT(vptr); vptr += sizeof(unsigned short); srv_curr->port = DNS__16BIT(vptr); vptr += sizeof(unsigned short); status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len); if (status != ARES_SUCCESS) break; } /* Don't lose memory in the next iteration */ free (rr_name); rr_name = NULL; /* Move on to the next record */ aptr += rr_len; } if (hostname) free (hostname); if (rr_name) free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) { if (srv_head) ares_free_data (srv_head); return status; } /* everything looks fine, return the data */ *srv_out = srv_head; return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_parse_txt_reply.c0000644000076500000000000001244412666555342021320 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2009 by Jakub Hrozek * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_data.h" #include "ares_private.h" int ares_parse_txt_reply (const unsigned char *abuf, int alen, struct ares_txt_reply **txt_out) { size_t substr_len; unsigned int qdcount, ancount, i; const unsigned char *aptr; const unsigned char *strptr; int status, rr_type, rr_class, rr_len; long len; char *hostname = NULL, *rr_name = NULL; struct ares_txt_reply *txt_head = NULL; struct ares_txt_reply *txt_last = NULL; struct ares_txt_reply *txt_curr; /* Set *txt_out to NULL for all failure cases. */ *txt_out = NULL; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) return ARES_EBADRESP; /* Fetch the question and answer count from the header. */ qdcount = DNS_HEADER_QDCOUNT (abuf); ancount = DNS_HEADER_ANCOUNT (abuf); if (qdcount != 1) return ARES_EBADRESP; if (ancount == 0) return ARES_ENODATA; /* Expand the name from the question, and skip past the question. */ aptr = abuf + HFIXEDSZ; status = ares_expand_name (aptr, abuf, alen, &hostname, &len); if (status != ARES_SUCCESS) return status; if (aptr + len + QFIXEDSZ > abuf + alen) { free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ for (i = 0; i < ancount; i++) { /* Decode the RR up to the data field. */ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len); if (status != ARES_SUCCESS) { break; } aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { status = ARES_EBADRESP; break; } /* Check if we are really looking at a TXT record */ if (rr_class == C_IN && rr_type == T_TXT) { /* * There may be multiple substrings in a single TXT record. Each * substring may be up to 255 characters in length, with a * "length byte" indicating the size of the substring payload. * RDATA contains both the length-bytes and payloads of all * substrings contained therein. */ strptr = aptr; while (strptr < (aptr + rr_len)) { substr_len = (unsigned char)*strptr; if (strptr + substr_len + 1 > aptr + rr_len) { status = ARES_EBADRESP; break; } ++strptr; /* Allocate storage for this TXT answer appending it to the list */ txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY); if (!txt_curr) { status = ARES_ENOMEM; break; } if (txt_last) { txt_last->next = txt_curr; } else { txt_head = txt_curr; } txt_last = txt_curr; txt_curr->length = substr_len; txt_curr->txt = malloc (substr_len + 1/* Including null byte */); if (txt_curr->txt == NULL) { status = ARES_ENOMEM; break; } memcpy ((char *) txt_curr->txt, strptr, substr_len); /* Make sure we NULL-terminate */ txt_curr->txt[substr_len] = 0; strptr += substr_len; } } /* Don't lose memory in the next iteration */ free (rr_name); rr_name = NULL; /* Move on to the next record */ aptr += rr_len; } if (hostname) free (hostname); if (rr_name) free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) { if (txt_head) ares_free_data (txt_head); return status; } /* everything looks fine, return the data */ *txt_out = txt_head; return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_platform.c0000644000076500000000000170261012666555342017722 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004 - 2011 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #include "ares_platform.h" #include "ares_nowarn.h" #include "ares_private.h" #if defined(WIN32) && !defined(MSDOS) #define V_PLATFORM_WIN32s 0 #define V_PLATFORM_WIN32_WINDOWS 1 #define V_PLATFORM_WIN32_NT 2 #define V_PLATFORM_WIN32_CE 3 win_platform ares__getplatform(void) { OSVERSIONINFOEX OsvEx; memset(&OsvEx, 0, sizeof(OsvEx)); OsvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!GetVersionEx((void *)&OsvEx)) { memset(&OsvEx, 0, sizeof(OsvEx)); OsvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx((void *)&OsvEx)) return WIN_UNKNOWN; } switch(OsvEx.dwPlatformId) { case V_PLATFORM_WIN32s: return WIN_3X; case V_PLATFORM_WIN32_WINDOWS: return WIN_9X; case V_PLATFORM_WIN32_NT: return WIN_NT; case V_PLATFORM_WIN32_CE: return WIN_CE; default: return WIN_UNKNOWN; } } #endif /* WIN32 && ! MSDOS */ #if defined(_WIN32_WCE) /* IANA Well Known Ports are in range 0-1023 */ #define USE_IANA_WELL_KNOWN_PORTS 1 /* IANA Registered Ports are in range 1024-49151 */ #define USE_IANA_REGISTERED_PORTS 1 struct pvt_servent { char *s_name; char **s_aliases; unsigned short s_port; char *s_proto; }; /* * Ref: http://www.iana.org/assignments/port-numbers */ static struct pvt_servent IANAports[] = { #ifdef USE_IANA_WELL_KNOWN_PORTS {"tcpmux", {NULL}, 1, "tcp"}, {"tcpmux", {NULL}, 1, "udp"}, {"compressnet", {NULL}, 2, "tcp"}, {"compressnet", {NULL}, 2, "udp"}, {"compressnet", {NULL}, 3, "tcp"}, {"compressnet", {NULL}, 3, "udp"}, {"rje", {NULL}, 5, "tcp"}, {"rje", {NULL}, 5, "udp"}, {"echo", {NULL}, 7, "tcp"}, {"echo", {NULL}, 7, "udp"}, {"discard", {NULL}, 9, "tcp"}, {"discard", {NULL}, 9, "udp"}, {"discard", {NULL}, 9, "sctp"}, {"discard", {NULL}, 9, "dccp"}, {"systat", {NULL}, 11, "tcp"}, {"systat", {NULL}, 11, "udp"}, {"daytime", {NULL}, 13, "tcp"}, {"daytime", {NULL}, 13, "udp"}, {"qotd", {NULL}, 17, "tcp"}, {"qotd", {NULL}, 17, "udp"}, {"msp", {NULL}, 18, "tcp"}, {"msp", {NULL}, 18, "udp"}, {"chargen", {NULL}, 19, "tcp"}, {"chargen", {NULL}, 19, "udp"}, {"ftp-data", {NULL}, 20, "tcp"}, {"ftp-data", {NULL}, 20, "udp"}, {"ftp-data", {NULL}, 20, "sctp"}, {"ftp", {NULL}, 21, "tcp"}, {"ftp", {NULL}, 21, "udp"}, {"ftp", {NULL}, 21, "sctp"}, {"ssh", {NULL}, 22, "tcp"}, {"ssh", {NULL}, 22, "udp"}, {"ssh", {NULL}, 22, "sctp"}, {"telnet", {NULL}, 23, "tcp"}, {"telnet", {NULL}, 23, "udp"}, {"smtp", {NULL}, 25, "tcp"}, {"smtp", {NULL}, 25, "udp"}, {"nsw-fe", {NULL}, 27, "tcp"}, {"nsw-fe", {NULL}, 27, "udp"}, {"msg-icp", {NULL}, 29, "tcp"}, {"msg-icp", {NULL}, 29, "udp"}, {"msg-auth", {NULL}, 31, "tcp"}, {"msg-auth", {NULL}, 31, "udp"}, {"dsp", {NULL}, 33, "tcp"}, {"dsp", {NULL}, 33, "udp"}, {"time", {NULL}, 37, "tcp"}, {"time", {NULL}, 37, "udp"}, {"rap", {NULL}, 38, "tcp"}, {"rap", {NULL}, 38, "udp"}, {"rlp", {NULL}, 39, "tcp"}, {"rlp", {NULL}, 39, "udp"}, {"graphics", {NULL}, 41, "tcp"}, {"graphics", {NULL}, 41, "udp"}, {"name", {NULL}, 42, "tcp"}, {"name", {NULL}, 42, "udp"}, {"nameserver", {NULL}, 42, "tcp"}, {"nameserver", {NULL}, 42, "udp"}, {"nicname", {NULL}, 43, "tcp"}, {"nicname", {NULL}, 43, "udp"}, {"mpm-flags", {NULL}, 44, "tcp"}, {"mpm-flags", {NULL}, 44, "udp"}, {"mpm", {NULL}, 45, "tcp"}, {"mpm", {NULL}, 45, "udp"}, {"mpm-snd", {NULL}, 46, "tcp"}, {"mpm-snd", {NULL}, 46, "udp"}, {"ni-ftp", {NULL}, 47, "tcp"}, {"ni-ftp", {NULL}, 47, "udp"}, {"auditd", {NULL}, 48, "tcp"}, {"auditd", {NULL}, 48, "udp"}, {"tacacs", {NULL}, 49, "tcp"}, {"tacacs", {NULL}, 49, "udp"}, {"re-mail-ck", {NULL}, 50, "tcp"}, {"re-mail-ck", {NULL}, 50, "udp"}, {"la-maint", {NULL}, 51, "tcp"}, {"la-maint", {NULL}, 51, "udp"}, {"xns-time", {NULL}, 52, "tcp"}, {"xns-time", {NULL}, 52, "udp"}, {"domain", {NULL}, 53, "tcp"}, {"domain", {NULL}, 53, "udp"}, {"xns-ch", {NULL}, 54, "tcp"}, {"xns-ch", {NULL}, 54, "udp"}, {"isi-gl", {NULL}, 55, "tcp"}, {"isi-gl", {NULL}, 55, "udp"}, {"xns-auth", {NULL}, 56, "tcp"}, {"xns-auth", {NULL}, 56, "udp"}, {"xns-mail", {NULL}, 58, "tcp"}, {"xns-mail", {NULL}, 58, "udp"}, {"ni-mail", {NULL}, 61, "tcp"}, {"ni-mail", {NULL}, 61, "udp"}, {"acas", {NULL}, 62, "tcp"}, {"acas", {NULL}, 62, "udp"}, {"whois++", {NULL}, 63, "tcp"}, {"whois++", {NULL}, 63, "udp"}, {"covia", {NULL}, 64, "tcp"}, {"covia", {NULL}, 64, "udp"}, {"tacacs-ds", {NULL}, 65, "tcp"}, {"tacacs-ds", {NULL}, 65, "udp"}, {"sql*net", {NULL}, 66, "tcp"}, {"sql*net", {NULL}, 66, "udp"}, {"bootps", {NULL}, 67, "tcp"}, {"bootps", {NULL}, 67, "udp"}, {"bootpc", {NULL}, 68, "tcp"}, {"bootpc", {NULL}, 68, "udp"}, {"tftp", {NULL}, 69, "tcp"}, {"tftp", {NULL}, 69, "udp"}, {"gopher", {NULL}, 70, "tcp"}, {"gopher", {NULL}, 70, "udp"}, {"netrjs-1", {NULL}, 71, "tcp"}, {"netrjs-1", {NULL}, 71, "udp"}, {"netrjs-2", {NULL}, 72, "tcp"}, {"netrjs-2", {NULL}, 72, "udp"}, {"netrjs-3", {NULL}, 73, "tcp"}, {"netrjs-3", {NULL}, 73, "udp"}, {"netrjs-4", {NULL}, 74, "tcp"}, {"netrjs-4", {NULL}, 74, "udp"}, {"deos", {NULL}, 76, "tcp"}, {"deos", {NULL}, 76, "udp"}, {"vettcp", {NULL}, 78, "tcp"}, {"vettcp", {NULL}, 78, "udp"}, {"finger", {NULL}, 79, "tcp"}, {"finger", {NULL}, 79, "udp"}, {"http", {NULL}, 80, "tcp"}, {"http", {NULL}, 80, "udp"}, {"www", {NULL}, 80, "tcp"}, {"www", {NULL}, 80, "udp"}, {"www-http", {NULL}, 80, "tcp"}, {"www-http", {NULL}, 80, "udp"}, {"http", {NULL}, 80, "sctp"}, {"xfer", {NULL}, 82, "tcp"}, {"xfer", {NULL}, 82, "udp"}, {"mit-ml-dev", {NULL}, 83, "tcp"}, {"mit-ml-dev", {NULL}, 83, "udp"}, {"ctf", {NULL}, 84, "tcp"}, {"ctf", {NULL}, 84, "udp"}, {"mit-ml-dev", {NULL}, 85, "tcp"}, {"mit-ml-dev", {NULL}, 85, "udp"}, {"mfcobol", {NULL}, 86, "tcp"}, {"mfcobol", {NULL}, 86, "udp"}, {"kerberos", {NULL}, 88, "tcp"}, {"kerberos", {NULL}, 88, "udp"}, {"su-mit-tg", {NULL}, 89, "tcp"}, {"su-mit-tg", {NULL}, 89, "udp"}, {"dnsix", {NULL}, 90, "tcp"}, {"dnsix", {NULL}, 90, "udp"}, {"mit-dov", {NULL}, 91, "tcp"}, {"mit-dov", {NULL}, 91, "udp"}, {"npp", {NULL}, 92, "tcp"}, {"npp", {NULL}, 92, "udp"}, {"dcp", {NULL}, 93, "tcp"}, {"dcp", {NULL}, 93, "udp"}, {"objcall", {NULL}, 94, "tcp"}, {"objcall", {NULL}, 94, "udp"}, {"supdup", {NULL}, 95, "tcp"}, {"supdup", {NULL}, 95, "udp"}, {"dixie", {NULL}, 96, "tcp"}, {"dixie", {NULL}, 96, "udp"}, {"swift-rvf", {NULL}, 97, "tcp"}, {"swift-rvf", {NULL}, 97, "udp"}, {"tacnews", {NULL}, 98, "tcp"}, {"tacnews", {NULL}, 98, "udp"}, {"metagram", {NULL}, 99, "tcp"}, {"metagram", {NULL}, 99, "udp"}, {"newacct", {NULL}, 100, "tcp"}, {"hostname", {NULL}, 101, "tcp"}, {"hostname", {NULL}, 101, "udp"}, {"iso-tsap", {NULL}, 102, "tcp"}, {"iso-tsap", {NULL}, 102, "udp"}, {"gppitnp", {NULL}, 103, "tcp"}, {"gppitnp", {NULL}, 103, "udp"}, {"acr-nema", {NULL}, 104, "tcp"}, {"acr-nema", {NULL}, 104, "udp"}, {"cso", {NULL}, 105, "tcp"}, {"cso", {NULL}, 105, "udp"}, {"csnet-ns", {NULL}, 105, "tcp"}, {"csnet-ns", {NULL}, 105, "udp"}, {"3com-tsmux", {NULL}, 106, "tcp"}, {"3com-tsmux", {NULL}, 106, "udp"}, {"rtelnet", {NULL}, 107, "tcp"}, {"rtelnet", {NULL}, 107, "udp"}, {"snagas", {NULL}, 108, "tcp"}, {"snagas", {NULL}, 108, "udp"}, {"pop2", {NULL}, 109, "tcp"}, {"pop2", {NULL}, 109, "udp"}, {"pop3", {NULL}, 110, "tcp"}, {"pop3", {NULL}, 110, "udp"}, {"sunrpc", {NULL}, 111, "tcp"}, {"sunrpc", {NULL}, 111, "udp"}, {"mcidas", {NULL}, 112, "tcp"}, {"mcidas", {NULL}, 112, "udp"}, {"ident", {NULL}, 113, "tcp"}, {"auth", {NULL}, 113, "tcp"}, {"auth", {NULL}, 113, "udp"}, {"sftp", {NULL}, 115, "tcp"}, {"sftp", {NULL}, 115, "udp"}, {"ansanotify", {NULL}, 116, "tcp"}, {"ansanotify", {NULL}, 116, "udp"}, {"uucp-path", {NULL}, 117, "tcp"}, {"uucp-path", {NULL}, 117, "udp"}, {"sqlserv", {NULL}, 118, "tcp"}, {"sqlserv", {NULL}, 118, "udp"}, {"nntp", {NULL}, 119, "tcp"}, {"nntp", {NULL}, 119, "udp"}, {"cfdptkt", {NULL}, 120, "tcp"}, {"cfdptkt", {NULL}, 120, "udp"}, {"erpc", {NULL}, 121, "tcp"}, {"erpc", {NULL}, 121, "udp"}, {"smakynet", {NULL}, 122, "tcp"}, {"smakynet", {NULL}, 122, "udp"}, {"ntp", {NULL}, 123, "tcp"}, {"ntp", {NULL}, 123, "udp"}, {"ansatrader", {NULL}, 124, "tcp"}, {"ansatrader", {NULL}, 124, "udp"}, {"locus-map", {NULL}, 125, "tcp"}, {"locus-map", {NULL}, 125, "udp"}, {"nxedit", {NULL}, 126, "tcp"}, {"nxedit", {NULL}, 126, "udp"}, {"locus-con", {NULL}, 127, "tcp"}, {"locus-con", {NULL}, 127, "udp"}, {"gss-xlicen", {NULL}, 128, "tcp"}, {"gss-xlicen", {NULL}, 128, "udp"}, {"pwdgen", {NULL}, 129, "tcp"}, {"pwdgen", {NULL}, 129, "udp"}, {"cisco-fna", {NULL}, 130, "tcp"}, {"cisco-fna", {NULL}, 130, "udp"}, {"cisco-tna", {NULL}, 131, "tcp"}, {"cisco-tna", {NULL}, 131, "udp"}, {"cisco-sys", {NULL}, 132, "tcp"}, {"cisco-sys", {NULL}, 132, "udp"}, {"statsrv", {NULL}, 133, "tcp"}, {"statsrv", {NULL}, 133, "udp"}, {"ingres-net", {NULL}, 134, "tcp"}, {"ingres-net", {NULL}, 134, "udp"}, {"epmap", {NULL}, 135, "tcp"}, {"epmap", {NULL}, 135, "udp"}, {"profile", {NULL}, 136, "tcp"}, {"profile", {NULL}, 136, "udp"}, {"netbios-ns", {NULL}, 137, "tcp"}, {"netbios-ns", {NULL}, 137, "udp"}, {"netbios-dgm", {NULL}, 138, "tcp"}, {"netbios-dgm", {NULL}, 138, "udp"}, {"netbios-ssn", {NULL}, 139, "tcp"}, {"netbios-ssn", {NULL}, 139, "udp"}, {"emfis-data", {NULL}, 140, "tcp"}, {"emfis-data", {NULL}, 140, "udp"}, {"emfis-cntl", {NULL}, 141, "tcp"}, {"emfis-cntl", {NULL}, 141, "udp"}, {"bl-idm", {NULL}, 142, "tcp"}, {"bl-idm", {NULL}, 142, "udp"}, {"imap", {NULL}, 143, "tcp"}, {"imap", {NULL}, 143, "udp"}, {"uma", {NULL}, 144, "tcp"}, {"uma", {NULL}, 144, "udp"}, {"uaac", {NULL}, 145, "tcp"}, {"uaac", {NULL}, 145, "udp"}, {"iso-tp0", {NULL}, 146, "tcp"}, {"iso-tp0", {NULL}, 146, "udp"}, {"iso-ip", {NULL}, 147, "tcp"}, {"iso-ip", {NULL}, 147, "udp"}, {"jargon", {NULL}, 148, "tcp"}, {"jargon", {NULL}, 148, "udp"}, {"aed-512", {NULL}, 149, "tcp"}, {"aed-512", {NULL}, 149, "udp"}, {"sql-net", {NULL}, 150, "tcp"}, {"sql-net", {NULL}, 150, "udp"}, {"hems", {NULL}, 151, "tcp"}, {"hems", {NULL}, 151, "udp"}, {"bftp", {NULL}, 152, "tcp"}, {"bftp", {NULL}, 152, "udp"}, {"sgmp", {NULL}, 153, "tcp"}, {"sgmp", {NULL}, 153, "udp"}, {"netsc-prod", {NULL}, 154, "tcp"}, {"netsc-prod", {NULL}, 154, "udp"}, {"netsc-dev", {NULL}, 155, "tcp"}, {"netsc-dev", {NULL}, 155, "udp"}, {"sqlsrv", {NULL}, 156, "tcp"}, {"sqlsrv", {NULL}, 156, "udp"}, {"knet-cmp", {NULL}, 157, "tcp"}, {"knet-cmp", {NULL}, 157, "udp"}, {"pcmail-srv", {NULL}, 158, "tcp"}, {"pcmail-srv", {NULL}, 158, "udp"}, {"nss-routing", {NULL}, 159, "tcp"}, {"nss-routing", {NULL}, 159, "udp"}, {"sgmp-traps", {NULL}, 160, "tcp"}, {"sgmp-traps", {NULL}, 160, "udp"}, {"snmp", {NULL}, 161, "tcp"}, {"snmp", {NULL}, 161, "udp"}, {"snmptrap", {NULL}, 162, "tcp"}, {"snmptrap", {NULL}, 162, "udp"}, {"cmip-man", {NULL}, 163, "tcp"}, {"cmip-man", {NULL}, 163, "udp"}, {"cmip-agent", {NULL}, 164, "tcp"}, {"cmip-agent", {NULL}, 164, "udp"}, {"xns-courier", {NULL}, 165, "tcp"}, {"xns-courier", {NULL}, 165, "udp"}, {"s-net", {NULL}, 166, "tcp"}, {"s-net", {NULL}, 166, "udp"}, {"namp", {NULL}, 167, "tcp"}, {"namp", {NULL}, 167, "udp"}, {"rsvd", {NULL}, 168, "tcp"}, {"rsvd", {NULL}, 168, "udp"}, {"send", {NULL}, 169, "tcp"}, {"send", {NULL}, 169, "udp"}, {"print-srv", {NULL}, 170, "tcp"}, {"print-srv", {NULL}, 170, "udp"}, {"multiplex", {NULL}, 171, "tcp"}, {"multiplex", {NULL}, 171, "udp"}, {"cl/1", {NULL}, 172, "tcp"}, {"cl/1", {NULL}, 172, "udp"}, {"xyplex-mux", {NULL}, 173, "tcp"}, {"xyplex-mux", {NULL}, 173, "udp"}, {"mailq", {NULL}, 174, "tcp"}, {"mailq", {NULL}, 174, "udp"}, {"vmnet", {NULL}, 175, "tcp"}, {"vmnet", {NULL}, 175, "udp"}, {"genrad-mux", {NULL}, 176, "tcp"}, {"genrad-mux", {NULL}, 176, "udp"}, {"xdmcp", {NULL}, 177, "tcp"}, {"xdmcp", {NULL}, 177, "udp"}, {"nextstep", {NULL}, 178, "tcp"}, {"nextstep", {NULL}, 178, "udp"}, {"bgp", {NULL}, 179, "tcp"}, {"bgp", {NULL}, 179, "udp"}, {"bgp", {NULL}, 179, "sctp"}, {"ris", {NULL}, 180, "tcp"}, {"ris", {NULL}, 180, "udp"}, {"unify", {NULL}, 181, "tcp"}, {"unify", {NULL}, 181, "udp"}, {"audit", {NULL}, 182, "tcp"}, {"audit", {NULL}, 182, "udp"}, {"ocbinder", {NULL}, 183, "tcp"}, {"ocbinder", {NULL}, 183, "udp"}, {"ocserver", {NULL}, 184, "tcp"}, {"ocserver", {NULL}, 184, "udp"}, {"remote-kis", {NULL}, 185, "tcp"}, {"remote-kis", {NULL}, 185, "udp"}, {"kis", {NULL}, 186, "tcp"}, {"kis", {NULL}, 186, "udp"}, {"aci", {NULL}, 187, "tcp"}, {"aci", {NULL}, 187, "udp"}, {"mumps", {NULL}, 188, "tcp"}, {"mumps", {NULL}, 188, "udp"}, {"qft", {NULL}, 189, "tcp"}, {"qft", {NULL}, 189, "udp"}, {"gacp", {NULL}, 190, "tcp"}, {"gacp", {NULL}, 190, "udp"}, {"prospero", {NULL}, 191, "tcp"}, {"prospero", {NULL}, 191, "udp"}, {"osu-nms", {NULL}, 192, "tcp"}, {"osu-nms", {NULL}, 192, "udp"}, {"srmp", {NULL}, 193, "tcp"}, {"srmp", {NULL}, 193, "udp"}, {"irc", {NULL}, 194, "tcp"}, {"irc", {NULL}, 194, "udp"}, {"dn6-nlm-aud", {NULL}, 195, "tcp"}, {"dn6-nlm-aud", {NULL}, 195, "udp"}, {"dn6-smm-red", {NULL}, 196, "tcp"}, {"dn6-smm-red", {NULL}, 196, "udp"}, {"dls", {NULL}, 197, "tcp"}, {"dls", {NULL}, 197, "udp"}, {"dls-mon", {NULL}, 198, "tcp"}, {"dls-mon", {NULL}, 198, "udp"}, {"smux", {NULL}, 199, "tcp"}, {"smux", {NULL}, 199, "udp"}, {"src", {NULL}, 200, "tcp"}, {"src", {NULL}, 200, "udp"}, {"at-rtmp", {NULL}, 201, "tcp"}, {"at-rtmp", {NULL}, 201, "udp"}, {"at-nbp", {NULL}, 202, "tcp"}, {"at-nbp", {NULL}, 202, "udp"}, {"at-3", {NULL}, 203, "tcp"}, {"at-3", {NULL}, 203, "udp"}, {"at-echo", {NULL}, 204, "tcp"}, {"at-echo", {NULL}, 204, "udp"}, {"at-5", {NULL}, 205, "tcp"}, {"at-5", {NULL}, 205, "udp"}, {"at-zis", {NULL}, 206, "tcp"}, {"at-zis", {NULL}, 206, "udp"}, {"at-7", {NULL}, 207, "tcp"}, {"at-7", {NULL}, 207, "udp"}, {"at-8", {NULL}, 208, "tcp"}, {"at-8", {NULL}, 208, "udp"}, {"qmtp", {NULL}, 209, "tcp"}, {"qmtp", {NULL}, 209, "udp"}, {"z39.50", {NULL}, 210, "tcp"}, {"z39.50", {NULL}, 210, "udp"}, {"914c/g", {NULL}, 211, "tcp"}, {"914c/g", {NULL}, 211, "udp"}, {"anet", {NULL}, 212, "tcp"}, {"anet", {NULL}, 212, "udp"}, {"ipx", {NULL}, 213, "tcp"}, {"ipx", {NULL}, 213, "udp"}, {"vmpwscs", {NULL}, 214, "tcp"}, {"vmpwscs", {NULL}, 214, "udp"}, {"softpc", {NULL}, 215, "tcp"}, {"softpc", {NULL}, 215, "udp"}, {"CAIlic", {NULL}, 216, "tcp"}, {"CAIlic", {NULL}, 216, "udp"}, {"dbase", {NULL}, 217, "tcp"}, {"dbase", {NULL}, 217, "udp"}, {"mpp", {NULL}, 218, "tcp"}, {"mpp", {NULL}, 218, "udp"}, {"uarps", {NULL}, 219, "tcp"}, {"uarps", {NULL}, 219, "udp"}, {"imap3", {NULL}, 220, "tcp"}, {"imap3", {NULL}, 220, "udp"}, {"fln-spx", {NULL}, 221, "tcp"}, {"fln-spx", {NULL}, 221, "udp"}, {"rsh-spx", {NULL}, 222, "tcp"}, {"rsh-spx", {NULL}, 222, "udp"}, {"cdc", {NULL}, 223, "tcp"}, {"cdc", {NULL}, 223, "udp"}, {"masqdialer", {NULL}, 224, "tcp"}, {"masqdialer", {NULL}, 224, "udp"}, {"direct", {NULL}, 242, "tcp"}, {"direct", {NULL}, 242, "udp"}, {"sur-meas", {NULL}, 243, "tcp"}, {"sur-meas", {NULL}, 243, "udp"}, {"inbusiness", {NULL}, 244, "tcp"}, {"inbusiness", {NULL}, 244, "udp"}, {"link", {NULL}, 245, "tcp"}, {"link", {NULL}, 245, "udp"}, {"dsp3270", {NULL}, 246, "tcp"}, {"dsp3270", {NULL}, 246, "udp"}, {"subntbcst_tftp", {NULL}, 247, "tcp"}, {"subntbcst_tftp", {NULL}, 247, "udp"}, {"bhfhs", {NULL}, 248, "tcp"}, {"bhfhs", {NULL}, 248, "udp"}, {"rap", {NULL}, 256, "tcp"}, {"rap", {NULL}, 256, "udp"}, {"set", {NULL}, 257, "tcp"}, {"set", {NULL}, 257, "udp"}, {"esro-gen", {NULL}, 259, "tcp"}, {"esro-gen", {NULL}, 259, "udp"}, {"openport", {NULL}, 260, "tcp"}, {"openport", {NULL}, 260, "udp"}, {"nsiiops", {NULL}, 261, "tcp"}, {"nsiiops", {NULL}, 261, "udp"}, {"arcisdms", {NULL}, 262, "tcp"}, {"arcisdms", {NULL}, 262, "udp"}, {"hdap", {NULL}, 263, "tcp"}, {"hdap", {NULL}, 263, "udp"}, {"bgmp", {NULL}, 264, "tcp"}, {"bgmp", {NULL}, 264, "udp"}, {"x-bone-ctl", {NULL}, 265, "tcp"}, {"x-bone-ctl", {NULL}, 265, "udp"}, {"sst", {NULL}, 266, "tcp"}, {"sst", {NULL}, 266, "udp"}, {"td-service", {NULL}, 267, "tcp"}, {"td-service", {NULL}, 267, "udp"}, {"td-replica", {NULL}, 268, "tcp"}, {"td-replica", {NULL}, 268, "udp"}, {"manet", {NULL}, 269, "tcp"}, {"manet", {NULL}, 269, "udp"}, {"gist", {NULL}, 270, "udp"}, {"http-mgmt", {NULL}, 280, "tcp"}, {"http-mgmt", {NULL}, 280, "udp"}, {"personal-link", {NULL}, 281, "tcp"}, {"personal-link", {NULL}, 281, "udp"}, {"cableport-ax", {NULL}, 282, "tcp"}, {"cableport-ax", {NULL}, 282, "udp"}, {"rescap", {NULL}, 283, "tcp"}, {"rescap", {NULL}, 283, "udp"}, {"corerjd", {NULL}, 284, "tcp"}, {"corerjd", {NULL}, 284, "udp"}, {"fxp", {NULL}, 286, "tcp"}, {"fxp", {NULL}, 286, "udp"}, {"k-block", {NULL}, 287, "tcp"}, {"k-block", {NULL}, 287, "udp"}, {"novastorbakcup", {NULL}, 308, "tcp"}, {"novastorbakcup", {NULL}, 308, "udp"}, {"entrusttime", {NULL}, 309, "tcp"}, {"entrusttime", {NULL}, 309, "udp"}, {"bhmds", {NULL}, 310, "tcp"}, {"bhmds", {NULL}, 310, "udp"}, {"asip-webadmin", {NULL}, 311, "tcp"}, {"asip-webadmin", {NULL}, 311, "udp"}, {"vslmp", {NULL}, 312, "tcp"}, {"vslmp", {NULL}, 312, "udp"}, {"magenta-logic", {NULL}, 313, "tcp"}, {"magenta-logic", {NULL}, 313, "udp"}, {"opalis-robot", {NULL}, 314, "tcp"}, {"opalis-robot", {NULL}, 314, "udp"}, {"dpsi", {NULL}, 315, "tcp"}, {"dpsi", {NULL}, 315, "udp"}, {"decauth", {NULL}, 316, "tcp"}, {"decauth", {NULL}, 316, "udp"}, {"zannet", {NULL}, 317, "tcp"}, {"zannet", {NULL}, 317, "udp"}, {"pkix-timestamp", {NULL}, 318, "tcp"}, {"pkix-timestamp", {NULL}, 318, "udp"}, {"ptp-event", {NULL}, 319, "tcp"}, {"ptp-event", {NULL}, 319, "udp"}, {"ptp-general", {NULL}, 320, "tcp"}, {"ptp-general", {NULL}, 320, "udp"}, {"pip", {NULL}, 321, "tcp"}, {"pip", {NULL}, 321, "udp"}, {"rtsps", {NULL}, 322, "tcp"}, {"rtsps", {NULL}, 322, "udp"}, {"texar", {NULL}, 333, "tcp"}, {"texar", {NULL}, 333, "udp"}, {"pdap", {NULL}, 344, "tcp"}, {"pdap", {NULL}, 344, "udp"}, {"pawserv", {NULL}, 345, "tcp"}, {"pawserv", {NULL}, 345, "udp"}, {"zserv", {NULL}, 346, "tcp"}, {"zserv", {NULL}, 346, "udp"}, {"fatserv", {NULL}, 347, "tcp"}, {"fatserv", {NULL}, 347, "udp"}, {"csi-sgwp", {NULL}, 348, "tcp"}, {"csi-sgwp", {NULL}, 348, "udp"}, {"mftp", {NULL}, 349, "tcp"}, {"mftp", {NULL}, 349, "udp"}, {"matip-type-a", {NULL}, 350, "tcp"}, {"matip-type-a", {NULL}, 350, "udp"}, {"matip-type-b", {NULL}, 351, "tcp"}, {"matip-type-b", {NULL}, 351, "udp"}, {"bhoetty", {NULL}, 351, "tcp"}, {"bhoetty", {NULL}, 351, "udp"}, {"dtag-ste-sb", {NULL}, 352, "tcp"}, {"dtag-ste-sb", {NULL}, 352, "udp"}, {"bhoedap4", {NULL}, 352, "tcp"}, {"bhoedap4", {NULL}, 352, "udp"}, {"ndsauth", {NULL}, 353, "tcp"}, {"ndsauth", {NULL}, 353, "udp"}, {"bh611", {NULL}, 354, "tcp"}, {"bh611", {NULL}, 354, "udp"}, {"datex-asn", {NULL}, 355, "tcp"}, {"datex-asn", {NULL}, 355, "udp"}, {"cloanto-net-1", {NULL}, 356, "tcp"}, {"cloanto-net-1", {NULL}, 356, "udp"}, {"bhevent", {NULL}, 357, "tcp"}, {"bhevent", {NULL}, 357, "udp"}, {"shrinkwrap", {NULL}, 358, "tcp"}, {"shrinkwrap", {NULL}, 358, "udp"}, {"nsrmp", {NULL}, 359, "tcp"}, {"nsrmp", {NULL}, 359, "udp"}, {"scoi2odialog", {NULL}, 360, "tcp"}, {"scoi2odialog", {NULL}, 360, "udp"}, {"semantix", {NULL}, 361, "tcp"}, {"semantix", {NULL}, 361, "udp"}, {"srssend", {NULL}, 362, "tcp"}, {"srssend", {NULL}, 362, "udp"}, {"rsvp_tunnel", {NULL}, 363, "tcp"}, {"rsvp_tunnel", {NULL}, 363, "udp"}, {"aurora-cmgr", {NULL}, 364, "tcp"}, {"aurora-cmgr", {NULL}, 364, "udp"}, {"dtk", {NULL}, 365, "tcp"}, {"dtk", {NULL}, 365, "udp"}, {"odmr", {NULL}, 366, "tcp"}, {"odmr", {NULL}, 366, "udp"}, {"mortgageware", {NULL}, 367, "tcp"}, {"mortgageware", {NULL}, 367, "udp"}, {"qbikgdp", {NULL}, 368, "tcp"}, {"qbikgdp", {NULL}, 368, "udp"}, {"rpc2portmap", {NULL}, 369, "tcp"}, {"rpc2portmap", {NULL}, 369, "udp"}, {"codaauth2", {NULL}, 370, "tcp"}, {"codaauth2", {NULL}, 370, "udp"}, {"clearcase", {NULL}, 371, "tcp"}, {"clearcase", {NULL}, 371, "udp"}, {"ulistproc", {NULL}, 372, "tcp"}, {"ulistproc", {NULL}, 372, "udp"}, {"legent-1", {NULL}, 373, "tcp"}, {"legent-1", {NULL}, 373, "udp"}, {"legent-2", {NULL}, 374, "tcp"}, {"legent-2", {NULL}, 374, "udp"}, {"hassle", {NULL}, 375, "tcp"}, {"hassle", {NULL}, 375, "udp"}, {"nip", {NULL}, 376, "tcp"}, {"nip", {NULL}, 376, "udp"}, {"tnETOS", {NULL}, 377, "tcp"}, {"tnETOS", {NULL}, 377, "udp"}, {"dsETOS", {NULL}, 378, "tcp"}, {"dsETOS", {NULL}, 378, "udp"}, {"is99c", {NULL}, 379, "tcp"}, {"is99c", {NULL}, 379, "udp"}, {"is99s", {NULL}, 380, "tcp"}, {"is99s", {NULL}, 380, "udp"}, {"hp-collector", {NULL}, 381, "tcp"}, {"hp-collector", {NULL}, 381, "udp"}, {"hp-managed-node", {NULL}, 382, "tcp"}, {"hp-managed-node", {NULL}, 382, "udp"}, {"hp-alarm-mgr", {NULL}, 383, "tcp"}, {"hp-alarm-mgr", {NULL}, 383, "udp"}, {"arns", {NULL}, 384, "tcp"}, {"arns", {NULL}, 384, "udp"}, {"ibm-app", {NULL}, 385, "tcp"}, {"ibm-app", {NULL}, 385, "udp"}, {"asa", {NULL}, 386, "tcp"}, {"asa", {NULL}, 386, "udp"}, {"aurp", {NULL}, 387, "tcp"}, {"aurp", {NULL}, 387, "udp"}, {"unidata-ldm", {NULL}, 388, "tcp"}, {"unidata-ldm", {NULL}, 388, "udp"}, {"ldap", {NULL}, 389, "tcp"}, {"ldap", {NULL}, 389, "udp"}, {"uis", {NULL}, 390, "tcp"}, {"uis", {NULL}, 390, "udp"}, {"synotics-relay", {NULL}, 391, "tcp"}, {"synotics-relay", {NULL}, 391, "udp"}, {"synotics-broker", {NULL}, 392, "tcp"}, {"synotics-broker", {NULL}, 392, "udp"}, {"meta5", {NULL}, 393, "tcp"}, {"meta5", {NULL}, 393, "udp"}, {"embl-ndt", {NULL}, 394, "tcp"}, {"embl-ndt", {NULL}, 394, "udp"}, {"netcp", {NULL}, 395, "tcp"}, {"netcp", {NULL}, 395, "udp"}, {"netware-ip", {NULL}, 396, "tcp"}, {"netware-ip", {NULL}, 396, "udp"}, {"mptn", {NULL}, 397, "tcp"}, {"mptn", {NULL}, 397, "udp"}, {"kryptolan", {NULL}, 398, "tcp"}, {"kryptolan", {NULL}, 398, "udp"}, {"iso-tsap-c2", {NULL}, 399, "tcp"}, {"iso-tsap-c2", {NULL}, 399, "udp"}, {"osb-sd", {NULL}, 400, "tcp"}, {"osb-sd", {NULL}, 400, "udp"}, {"ups", {NULL}, 401, "tcp"}, {"ups", {NULL}, 401, "udp"}, {"genie", {NULL}, 402, "tcp"}, {"genie", {NULL}, 402, "udp"}, {"decap", {NULL}, 403, "tcp"}, {"decap", {NULL}, 403, "udp"}, {"nced", {NULL}, 404, "tcp"}, {"nced", {NULL}, 404, "udp"}, {"ncld", {NULL}, 405, "tcp"}, {"ncld", {NULL}, 405, "udp"}, {"imsp", {NULL}, 406, "tcp"}, {"imsp", {NULL}, 406, "udp"}, {"timbuktu", {NULL}, 407, "tcp"}, {"timbuktu", {NULL}, 407, "udp"}, {"prm-sm", {NULL}, 408, "tcp"}, {"prm-sm", {NULL}, 408, "udp"}, {"prm-nm", {NULL}, 409, "tcp"}, {"prm-nm", {NULL}, 409, "udp"}, {"decladebug", {NULL}, 410, "tcp"}, {"decladebug", {NULL}, 410, "udp"}, {"rmt", {NULL}, 411, "tcp"}, {"rmt", {NULL}, 411, "udp"}, {"synoptics-trap", {NULL}, 412, "tcp"}, {"synoptics-trap", {NULL}, 412, "udp"}, {"smsp", {NULL}, 413, "tcp"}, {"smsp", {NULL}, 413, "udp"}, {"infoseek", {NULL}, 414, "tcp"}, {"infoseek", {NULL}, 414, "udp"}, {"bnet", {NULL}, 415, "tcp"}, {"bnet", {NULL}, 415, "udp"}, {"silverplatter", {NULL}, 416, "tcp"}, {"silverplatter", {NULL}, 416, "udp"}, {"onmux", {NULL}, 417, "tcp"}, {"onmux", {NULL}, 417, "udp"}, {"hyper-g", {NULL}, 418, "tcp"}, {"hyper-g", {NULL}, 418, "udp"}, {"ariel1", {NULL}, 419, "tcp"}, {"ariel1", {NULL}, 419, "udp"}, {"smpte", {NULL}, 420, "tcp"}, {"smpte", {NULL}, 420, "udp"}, {"ariel2", {NULL}, 421, "tcp"}, {"ariel2", {NULL}, 421, "udp"}, {"ariel3", {NULL}, 422, "tcp"}, {"ariel3", {NULL}, 422, "udp"}, {"opc-job-start", {NULL}, 423, "tcp"}, {"opc-job-start", {NULL}, 423, "udp"}, {"opc-job-track", {NULL}, 424, "tcp"}, {"opc-job-track", {NULL}, 424, "udp"}, {"icad-el", {NULL}, 425, "tcp"}, {"icad-el", {NULL}, 425, "udp"}, {"smartsdp", {NULL}, 426, "tcp"}, {"smartsdp", {NULL}, 426, "udp"}, {"svrloc", {NULL}, 427, "tcp"}, {"svrloc", {NULL}, 427, "udp"}, {"ocs_cmu", {NULL}, 428, "tcp"}, {"ocs_cmu", {NULL}, 428, "udp"}, {"ocs_amu", {NULL}, 429, "tcp"}, {"ocs_amu", {NULL}, 429, "udp"}, {"utmpsd", {NULL}, 430, "tcp"}, {"utmpsd", {NULL}, 430, "udp"}, {"utmpcd", {NULL}, 431, "tcp"}, {"utmpcd", {NULL}, 431, "udp"}, {"iasd", {NULL}, 432, "tcp"}, {"iasd", {NULL}, 432, "udp"}, {"nnsp", {NULL}, 433, "tcp"}, {"nnsp", {NULL}, 433, "udp"}, {"mobileip-agent", {NULL}, 434, "tcp"}, {"mobileip-agent", {NULL}, 434, "udp"}, {"mobilip-mn", {NULL}, 435, "tcp"}, {"mobilip-mn", {NULL}, 435, "udp"}, {"dna-cml", {NULL}, 436, "tcp"}, {"dna-cml", {NULL}, 436, "udp"}, {"comscm", {NULL}, 437, "tcp"}, {"comscm", {NULL}, 437, "udp"}, {"dsfgw", {NULL}, 438, "tcp"}, {"dsfgw", {NULL}, 438, "udp"}, {"dasp", {NULL}, 439, "tcp"}, {"dasp", {NULL}, 439, "udp"}, {"sgcp", {NULL}, 440, "tcp"}, {"sgcp", {NULL}, 440, "udp"}, {"decvms-sysmgt", {NULL}, 441, "tcp"}, {"decvms-sysmgt", {NULL}, 441, "udp"}, {"cvc_hostd", {NULL}, 442, "tcp"}, {"cvc_hostd", {NULL}, 442, "udp"}, {"https", {NULL}, 443, "tcp"}, {"https", {NULL}, 443, "udp"}, {"https", {NULL}, 443, "sctp"}, {"snpp", {NULL}, 444, "tcp"}, {"snpp", {NULL}, 444, "udp"}, {"microsoft-ds", {NULL}, 445, "tcp"}, {"microsoft-ds", {NULL}, 445, "udp"}, {"ddm-rdb", {NULL}, 446, "tcp"}, {"ddm-rdb", {NULL}, 446, "udp"}, {"ddm-dfm", {NULL}, 447, "tcp"}, {"ddm-dfm", {NULL}, 447, "udp"}, {"ddm-ssl", {NULL}, 448, "tcp"}, {"ddm-ssl", {NULL}, 448, "udp"}, {"as-servermap", {NULL}, 449, "tcp"}, {"as-servermap", {NULL}, 449, "udp"}, {"tserver", {NULL}, 450, "tcp"}, {"tserver", {NULL}, 450, "udp"}, {"sfs-smp-net", {NULL}, 451, "tcp"}, {"sfs-smp-net", {NULL}, 451, "udp"}, {"sfs-config", {NULL}, 452, "tcp"}, {"sfs-config", {NULL}, 452, "udp"}, {"creativeserver", {NULL}, 453, "tcp"}, {"creativeserver", {NULL}, 453, "udp"}, {"contentserver", {NULL}, 454, "tcp"}, {"contentserver", {NULL}, 454, "udp"}, {"creativepartnr", {NULL}, 455, "tcp"}, {"creativepartnr", {NULL}, 455, "udp"}, {"macon-tcp", {NULL}, 456, "tcp"}, {"macon-udp", {NULL}, 456, "udp"}, {"scohelp", {NULL}, 457, "tcp"}, {"scohelp", {NULL}, 457, "udp"}, {"appleqtc", {NULL}, 458, "tcp"}, {"appleqtc", {NULL}, 458, "udp"}, {"ampr-rcmd", {NULL}, 459, "tcp"}, {"ampr-rcmd", {NULL}, 459, "udp"}, {"skronk", {NULL}, 460, "tcp"}, {"skronk", {NULL}, 460, "udp"}, {"datasurfsrv", {NULL}, 461, "tcp"}, {"datasurfsrv", {NULL}, 461, "udp"}, {"datasurfsrvsec", {NULL}, 462, "tcp"}, {"datasurfsrvsec", {NULL}, 462, "udp"}, {"alpes", {NULL}, 463, "tcp"}, {"alpes", {NULL}, 463, "udp"}, {"kpasswd", {NULL}, 464, "tcp"}, {"kpasswd", {NULL}, 464, "udp"}, {"urd", {NULL}, 465, "tcp"}, {"igmpv3lite", {NULL}, 465, "udp"}, {"digital-vrc", {NULL}, 466, "tcp"}, {"digital-vrc", {NULL}, 466, "udp"}, {"mylex-mapd", {NULL}, 467, "tcp"}, {"mylex-mapd", {NULL}, 467, "udp"}, {"photuris", {NULL}, 468, "tcp"}, {"photuris", {NULL}, 468, "udp"}, {"rcp", {NULL}, 469, "tcp"}, {"rcp", {NULL}, 469, "udp"}, {"scx-proxy", {NULL}, 470, "tcp"}, {"scx-proxy", {NULL}, 470, "udp"}, {"mondex", {NULL}, 471, "tcp"}, {"mondex", {NULL}, 471, "udp"}, {"ljk-login", {NULL}, 472, "tcp"}, {"ljk-login", {NULL}, 472, "udp"}, {"hybrid-pop", {NULL}, 473, "tcp"}, {"hybrid-pop", {NULL}, 473, "udp"}, {"tn-tl-w1", {NULL}, 474, "tcp"}, {"tn-tl-w2", {NULL}, 474, "udp"}, {"tcpnethaspsrv", {NULL}, 475, "tcp"}, {"tcpnethaspsrv", {NULL}, 475, "udp"}, {"tn-tl-fd1", {NULL}, 476, "tcp"}, {"tn-tl-fd1", {NULL}, 476, "udp"}, {"ss7ns", {NULL}, 477, "tcp"}, {"ss7ns", {NULL}, 477, "udp"}, {"spsc", {NULL}, 478, "tcp"}, {"spsc", {NULL}, 478, "udp"}, {"iafserver", {NULL}, 479, "tcp"}, {"iafserver", {NULL}, 479, "udp"}, {"iafdbase", {NULL}, 480, "tcp"}, {"iafdbase", {NULL}, 480, "udp"}, {"ph", {NULL}, 481, "tcp"}, {"ph", {NULL}, 481, "udp"}, {"bgs-nsi", {NULL}, 482, "tcp"}, {"bgs-nsi", {NULL}, 482, "udp"}, {"ulpnet", {NULL}, 483, "tcp"}, {"ulpnet", {NULL}, 483, "udp"}, {"integra-sme", {NULL}, 484, "tcp"}, {"integra-sme", {NULL}, 484, "udp"}, {"powerburst", {NULL}, 485, "tcp"}, {"powerburst", {NULL}, 485, "udp"}, {"avian", {NULL}, 486, "tcp"}, {"avian", {NULL}, 486, "udp"}, {"saft", {NULL}, 487, "tcp"}, {"saft", {NULL}, 487, "udp"}, {"gss-http", {NULL}, 488, "tcp"}, {"gss-http", {NULL}, 488, "udp"}, {"nest-protocol", {NULL}, 489, "tcp"}, {"nest-protocol", {NULL}, 489, "udp"}, {"micom-pfs", {NULL}, 490, "tcp"}, {"micom-pfs", {NULL}, 490, "udp"}, {"go-login", {NULL}, 491, "tcp"}, {"go-login", {NULL}, 491, "udp"}, {"ticf-1", {NULL}, 492, "tcp"}, {"ticf-1", {NULL}, 492, "udp"}, {"ticf-2", {NULL}, 493, "tcp"}, {"ticf-2", {NULL}, 493, "udp"}, {"pov-ray", {NULL}, 494, "tcp"}, {"pov-ray", {NULL}, 494, "udp"}, {"intecourier", {NULL}, 495, "tcp"}, {"intecourier", {NULL}, 495, "udp"}, {"pim-rp-disc", {NULL}, 496, "tcp"}, {"pim-rp-disc", {NULL}, 496, "udp"}, {"dantz", {NULL}, 497, "tcp"}, {"dantz", {NULL}, 497, "udp"}, {"siam", {NULL}, 498, "tcp"}, {"siam", {NULL}, 498, "udp"}, {"iso-ill", {NULL}, 499, "tcp"}, {"iso-ill", {NULL}, 499, "udp"}, {"isakmp", {NULL}, 500, "tcp"}, {"isakmp", {NULL}, 500, "udp"}, {"stmf", {NULL}, 501, "tcp"}, {"stmf", {NULL}, 501, "udp"}, {"asa-appl-proto", {NULL}, 502, "tcp"}, {"asa-appl-proto", {NULL}, 502, "udp"}, {"intrinsa", {NULL}, 503, "tcp"}, {"intrinsa", {NULL}, 503, "udp"}, {"citadel", {NULL}, 504, "tcp"}, {"citadel", {NULL}, 504, "udp"}, {"mailbox-lm", {NULL}, 505, "tcp"}, {"mailbox-lm", {NULL}, 505, "udp"}, {"ohimsrv", {NULL}, 506, "tcp"}, {"ohimsrv", {NULL}, 506, "udp"}, {"crs", {NULL}, 507, "tcp"}, {"crs", {NULL}, 507, "udp"}, {"xvttp", {NULL}, 508, "tcp"}, {"xvttp", {NULL}, 508, "udp"}, {"snare", {NULL}, 509, "tcp"}, {"snare", {NULL}, 509, "udp"}, {"fcp", {NULL}, 510, "tcp"}, {"fcp", {NULL}, 510, "udp"}, {"passgo", {NULL}, 511, "tcp"}, {"passgo", {NULL}, 511, "udp"}, {"exec", {NULL}, 512, "tcp"}, {"comsat", {NULL}, 512, "udp"}, {"biff", {NULL}, 512, "udp"}, {"login", {NULL}, 513, "tcp"}, {"who", {NULL}, 513, "udp"}, {"shell", {NULL}, 514, "tcp"}, {"syslog", {NULL}, 514, "udp"}, {"printer", {NULL}, 515, "tcp"}, {"printer", {NULL}, 515, "udp"}, {"videotex", {NULL}, 516, "tcp"}, {"videotex", {NULL}, 516, "udp"}, {"talk", {NULL}, 517, "tcp"}, {"talk", {NULL}, 517, "udp"}, {"ntalk", {NULL}, 518, "tcp"}, {"ntalk", {NULL}, 518, "udp"}, {"utime", {NULL}, 519, "tcp"}, {"utime", {NULL}, 519, "udp"}, {"efs", {NULL}, 520, "tcp"}, {"router", {NULL}, 520, "udp"}, {"ripng", {NULL}, 521, "tcp"}, {"ripng", {NULL}, 521, "udp"}, {"ulp", {NULL}, 522, "tcp"}, {"ulp", {NULL}, 522, "udp"}, {"ibm-db2", {NULL}, 523, "tcp"}, {"ibm-db2", {NULL}, 523, "udp"}, {"ncp", {NULL}, 524, "tcp"}, {"ncp", {NULL}, 524, "udp"}, {"timed", {NULL}, 525, "tcp"}, {"timed", {NULL}, 525, "udp"}, {"tempo", {NULL}, 526, "tcp"}, {"tempo", {NULL}, 526, "udp"}, {"stx", {NULL}, 527, "tcp"}, {"stx", {NULL}, 527, "udp"}, {"custix", {NULL}, 528, "tcp"}, {"custix", {NULL}, 528, "udp"}, {"irc-serv", {NULL}, 529, "tcp"}, {"irc-serv", {NULL}, 529, "udp"}, {"courier", {NULL}, 530, "tcp"}, {"courier", {NULL}, 530, "udp"}, {"conference", {NULL}, 531, "tcp"}, {"conference", {NULL}, 531, "udp"}, {"netnews", {NULL}, 532, "tcp"}, {"netnews", {NULL}, 532, "udp"}, {"netwall", {NULL}, 533, "tcp"}, {"netwall", {NULL}, 533, "udp"}, {"windream", {NULL}, 534, "tcp"}, {"windream", {NULL}, 534, "udp"}, {"iiop", {NULL}, 535, "tcp"}, {"iiop", {NULL}, 535, "udp"}, {"opalis-rdv", {NULL}, 536, "tcp"}, {"opalis-rdv", {NULL}, 536, "udp"}, {"nmsp", {NULL}, 537, "tcp"}, {"nmsp", {NULL}, 537, "udp"}, {"gdomap", {NULL}, 538, "tcp"}, {"gdomap", {NULL}, 538, "udp"}, {"apertus-ldp", {NULL}, 539, "tcp"}, {"apertus-ldp", {NULL}, 539, "udp"}, {"uucp", {NULL}, 540, "tcp"}, {"uucp", {NULL}, 540, "udp"}, {"uucp-rlogin", {NULL}, 541, "tcp"}, {"uucp-rlogin", {NULL}, 541, "udp"}, {"commerce", {NULL}, 542, "tcp"}, {"commerce", {NULL}, 542, "udp"}, {"klogin", {NULL}, 543, "tcp"}, {"klogin", {NULL}, 543, "udp"}, {"kshell", {NULL}, 544, "tcp"}, {"kshell", {NULL}, 544, "udp"}, {"appleqtcsrvr", {NULL}, 545, "tcp"}, {"appleqtcsrvr", {NULL}, 545, "udp"}, {"dhcpv6-client", {NULL}, 546, "tcp"}, {"dhcpv6-client", {NULL}, 546, "udp"}, {"dhcpv6-server", {NULL}, 547, "tcp"}, {"dhcpv6-server", {NULL}, 547, "udp"}, {"afpovertcp", {NULL}, 548, "tcp"}, {"afpovertcp", {NULL}, 548, "udp"}, {"idfp", {NULL}, 549, "tcp"}, {"idfp", {NULL}, 549, "udp"}, {"new-rwho", {NULL}, 550, "tcp"}, {"new-rwho", {NULL}, 550, "udp"}, {"cybercash", {NULL}, 551, "tcp"}, {"cybercash", {NULL}, 551, "udp"}, {"devshr-nts", {NULL}, 552, "tcp"}, {"devshr-nts", {NULL}, 552, "udp"}, {"pirp", {NULL}, 553, "tcp"}, {"pirp", {NULL}, 553, "udp"}, {"rtsp", {NULL}, 554, "tcp"}, {"rtsp", {NULL}, 554, "udp"}, {"dsf", {NULL}, 555, "tcp"}, {"dsf", {NULL}, 555, "udp"}, {"remotefs", {NULL}, 556, "tcp"}, {"remotefs", {NULL}, 556, "udp"}, {"openvms-sysipc", {NULL}, 557, "tcp"}, {"openvms-sysipc", {NULL}, 557, "udp"}, {"sdnskmp", {NULL}, 558, "tcp"}, {"sdnskmp", {NULL}, 558, "udp"}, {"teedtap", {NULL}, 559, "tcp"}, {"teedtap", {NULL}, 559, "udp"}, {"rmonitor", {NULL}, 560, "tcp"}, {"rmonitor", {NULL}, 560, "udp"}, {"monitor", {NULL}, 561, "tcp"}, {"monitor", {NULL}, 561, "udp"}, {"chshell", {NULL}, 562, "tcp"}, {"chshell", {NULL}, 562, "udp"}, {"nntps", {NULL}, 563, "tcp"}, {"nntps", {NULL}, 563, "udp"}, {"9pfs", {NULL}, 564, "tcp"}, {"9pfs", {NULL}, 564, "udp"}, {"whoami", {NULL}, 565, "tcp"}, {"whoami", {NULL}, 565, "udp"}, {"streettalk", {NULL}, 566, "tcp"}, {"streettalk", {NULL}, 566, "udp"}, {"banyan-rpc", {NULL}, 567, "tcp"}, {"banyan-rpc", {NULL}, 567, "udp"}, {"ms-shuttle", {NULL}, 568, "tcp"}, {"ms-shuttle", {NULL}, 568, "udp"}, {"ms-rome", {NULL}, 569, "tcp"}, {"ms-rome", {NULL}, 569, "udp"}, {"meter", {NULL}, 570, "tcp"}, {"meter", {NULL}, 570, "udp"}, {"meter", {NULL}, 571, "tcp"}, {"meter", {NULL}, 571, "udp"}, {"sonar", {NULL}, 572, "tcp"}, {"sonar", {NULL}, 572, "udp"}, {"banyan-vip", {NULL}, 573, "tcp"}, {"banyan-vip", {NULL}, 573, "udp"}, {"ftp-agent", {NULL}, 574, "tcp"}, {"ftp-agent", {NULL}, 574, "udp"}, {"vemmi", {NULL}, 575, "tcp"}, {"vemmi", {NULL}, 575, "udp"}, {"ipcd", {NULL}, 576, "tcp"}, {"ipcd", {NULL}, 576, "udp"}, {"vnas", {NULL}, 577, "tcp"}, {"vnas", {NULL}, 577, "udp"}, {"ipdd", {NULL}, 578, "tcp"}, {"ipdd", {NULL}, 578, "udp"}, {"decbsrv", {NULL}, 579, "tcp"}, {"decbsrv", {NULL}, 579, "udp"}, {"sntp-heartbeat", {NULL}, 580, "tcp"}, {"sntp-heartbeat", {NULL}, 580, "udp"}, {"bdp", {NULL}, 581, "tcp"}, {"bdp", {NULL}, 581, "udp"}, {"scc-security", {NULL}, 582, "tcp"}, {"scc-security", {NULL}, 582, "udp"}, {"philips-vc", {NULL}, 583, "tcp"}, {"philips-vc", {NULL}, 583, "udp"}, {"keyserver", {NULL}, 584, "tcp"}, {"keyserver", {NULL}, 584, "udp"}, {"password-chg", {NULL}, 586, "tcp"}, {"password-chg", {NULL}, 586, "udp"}, {"submission", {NULL}, 587, "tcp"}, {"submission", {NULL}, 587, "udp"}, {"cal", {NULL}, 588, "tcp"}, {"cal", {NULL}, 588, "udp"}, {"eyelink", {NULL}, 589, "tcp"}, {"eyelink", {NULL}, 589, "udp"}, {"tns-cml", {NULL}, 590, "tcp"}, {"tns-cml", {NULL}, 590, "udp"}, {"http-alt", {NULL}, 591, "tcp"}, {"http-alt", {NULL}, 591, "udp"}, {"eudora-set", {NULL}, 592, "tcp"}, {"eudora-set", {NULL}, 592, "udp"}, {"http-rpc-epmap", {NULL}, 593, "tcp"}, {"http-rpc-epmap", {NULL}, 593, "udp"}, {"tpip", {NULL}, 594, "tcp"}, {"tpip", {NULL}, 594, "udp"}, {"cab-protocol", {NULL}, 595, "tcp"}, {"cab-protocol", {NULL}, 595, "udp"}, {"smsd", {NULL}, 596, "tcp"}, {"smsd", {NULL}, 596, "udp"}, {"ptcnameservice", {NULL}, 597, "tcp"}, {"ptcnameservice", {NULL}, 597, "udp"}, {"sco-websrvrmg3", {NULL}, 598, "tcp"}, {"sco-websrvrmg3", {NULL}, 598, "udp"}, {"acp", {NULL}, 599, "tcp"}, {"acp", {NULL}, 599, "udp"}, {"ipcserver", {NULL}, 600, "tcp"}, {"ipcserver", {NULL}, 600, "udp"}, {"syslog-conn", {NULL}, 601, "tcp"}, {"syslog-conn", {NULL}, 601, "udp"}, {"xmlrpc-beep", {NULL}, 602, "tcp"}, {"xmlrpc-beep", {NULL}, 602, "udp"}, {"idxp", {NULL}, 603, "tcp"}, {"idxp", {NULL}, 603, "udp"}, {"tunnel", {NULL}, 604, "tcp"}, {"tunnel", {NULL}, 604, "udp"}, {"soap-beep", {NULL}, 605, "tcp"}, {"soap-beep", {NULL}, 605, "udp"}, {"urm", {NULL}, 606, "tcp"}, {"urm", {NULL}, 606, "udp"}, {"nqs", {NULL}, 607, "tcp"}, {"nqs", {NULL}, 607, "udp"}, {"sift-uft", {NULL}, 608, "tcp"}, {"sift-uft", {NULL}, 608, "udp"}, {"npmp-trap", {NULL}, 609, "tcp"}, {"npmp-trap", {NULL}, 609, "udp"}, {"npmp-local", {NULL}, 610, "tcp"}, {"npmp-local", {NULL}, 610, "udp"}, {"npmp-gui", {NULL}, 611, "tcp"}, {"npmp-gui", {NULL}, 611, "udp"}, {"hmmp-ind", {NULL}, 612, "tcp"}, {"hmmp-ind", {NULL}, 612, "udp"}, {"hmmp-op", {NULL}, 613, "tcp"}, {"hmmp-op", {NULL}, 613, "udp"}, {"sshell", {NULL}, 614, "tcp"}, {"sshell", {NULL}, 614, "udp"}, {"sco-inetmgr", {NULL}, 615, "tcp"}, {"sco-inetmgr", {NULL}, 615, "udp"}, {"sco-sysmgr", {NULL}, 616, "tcp"}, {"sco-sysmgr", {NULL}, 616, "udp"}, {"sco-dtmgr", {NULL}, 617, "tcp"}, {"sco-dtmgr", {NULL}, 617, "udp"}, {"dei-icda", {NULL}, 618, "tcp"}, {"dei-icda", {NULL}, 618, "udp"}, {"compaq-evm", {NULL}, 619, "tcp"}, {"compaq-evm", {NULL}, 619, "udp"}, {"sco-websrvrmgr", {NULL}, 620, "tcp"}, {"sco-websrvrmgr", {NULL}, 620, "udp"}, {"escp-ip", {NULL}, 621, "tcp"}, {"escp-ip", {NULL}, 621, "udp"}, {"collaborator", {NULL}, 622, "tcp"}, {"collaborator", {NULL}, 622, "udp"}, {"oob-ws-http", {NULL}, 623, "tcp"}, {"asf-rmcp", {NULL}, 623, "udp"}, {"cryptoadmin", {NULL}, 624, "tcp"}, {"cryptoadmin", {NULL}, 624, "udp"}, {"dec_dlm", {NULL}, 625, "tcp"}, {"dec_dlm", {NULL}, 625, "udp"}, {"asia", {NULL}, 626, "tcp"}, {"asia", {NULL}, 626, "udp"}, {"passgo-tivoli", {NULL}, 627, "tcp"}, {"passgo-tivoli", {NULL}, 627, "udp"}, {"qmqp", {NULL}, 628, "tcp"}, {"qmqp", {NULL}, 628, "udp"}, {"3com-amp3", {NULL}, 629, "tcp"}, {"3com-amp3", {NULL}, 629, "udp"}, {"rda", {NULL}, 630, "tcp"}, {"rda", {NULL}, 630, "udp"}, {"ipp", {NULL}, 631, "tcp"}, {"ipp", {NULL}, 631, "udp"}, {"bmpp", {NULL}, 632, "tcp"}, {"bmpp", {NULL}, 632, "udp"}, {"servstat", {NULL}, 633, "tcp"}, {"servstat", {NULL}, 633, "udp"}, {"ginad", {NULL}, 634, "tcp"}, {"ginad", {NULL}, 634, "udp"}, {"rlzdbase", {NULL}, 635, "tcp"}, {"rlzdbase", {NULL}, 635, "udp"}, {"ldaps", {NULL}, 636, "tcp"}, {"ldaps", {NULL}, 636, "udp"}, {"lanserver", {NULL}, 637, "tcp"}, {"lanserver", {NULL}, 637, "udp"}, {"mcns-sec", {NULL}, 638, "tcp"}, {"mcns-sec", {NULL}, 638, "udp"}, {"msdp", {NULL}, 639, "tcp"}, {"msdp", {NULL}, 639, "udp"}, {"entrust-sps", {NULL}, 640, "tcp"}, {"entrust-sps", {NULL}, 640, "udp"}, {"repcmd", {NULL}, 641, "tcp"}, {"repcmd", {NULL}, 641, "udp"}, {"esro-emsdp", {NULL}, 642, "tcp"}, {"esro-emsdp", {NULL}, 642, "udp"}, {"sanity", {NULL}, 643, "tcp"}, {"sanity", {NULL}, 643, "udp"}, {"dwr", {NULL}, 644, "tcp"}, {"dwr", {NULL}, 644, "udp"}, {"pssc", {NULL}, 645, "tcp"}, {"pssc", {NULL}, 645, "udp"}, {"ldp", {NULL}, 646, "tcp"}, {"ldp", {NULL}, 646, "udp"}, {"dhcp-failover", {NULL}, 647, "tcp"}, {"dhcp-failover", {NULL}, 647, "udp"}, {"rrp", {NULL}, 648, "tcp"}, {"rrp", {NULL}, 648, "udp"}, {"cadview-3d", {NULL}, 649, "tcp"}, {"cadview-3d", {NULL}, 649, "udp"}, {"obex", {NULL}, 650, "tcp"}, {"obex", {NULL}, 650, "udp"}, {"ieee-mms", {NULL}, 651, "tcp"}, {"ieee-mms", {NULL}, 651, "udp"}, {"hello-port", {NULL}, 652, "tcp"}, {"hello-port", {NULL}, 652, "udp"}, {"repscmd", {NULL}, 653, "tcp"}, {"repscmd", {NULL}, 653, "udp"}, {"aodv", {NULL}, 654, "tcp"}, {"aodv", {NULL}, 654, "udp"}, {"tinc", {NULL}, 655, "tcp"}, {"tinc", {NULL}, 655, "udp"}, {"spmp", {NULL}, 656, "tcp"}, {"spmp", {NULL}, 656, "udp"}, {"rmc", {NULL}, 657, "tcp"}, {"rmc", {NULL}, 657, "udp"}, {"tenfold", {NULL}, 658, "tcp"}, {"tenfold", {NULL}, 658, "udp"}, {"mac-srvr-admin", {NULL}, 660, "tcp"}, {"mac-srvr-admin", {NULL}, 660, "udp"}, {"hap", {NULL}, 661, "tcp"}, {"hap", {NULL}, 661, "udp"}, {"pftp", {NULL}, 662, "tcp"}, {"pftp", {NULL}, 662, "udp"}, {"purenoise", {NULL}, 663, "tcp"}, {"purenoise", {NULL}, 663, "udp"}, {"oob-ws-https", {NULL}, 664, "tcp"}, {"asf-secure-rmcp", {NULL}, 664, "udp"}, {"sun-dr", {NULL}, 665, "tcp"}, {"sun-dr", {NULL}, 665, "udp"}, {"mdqs", {NULL}, 666, "tcp"}, {"mdqs", {NULL}, 666, "udp"}, {"doom", {NULL}, 666, "tcp"}, {"doom", {NULL}, 666, "udp"}, {"disclose", {NULL}, 667, "tcp"}, {"disclose", {NULL}, 667, "udp"}, {"mecomm", {NULL}, 668, "tcp"}, {"mecomm", {NULL}, 668, "udp"}, {"meregister", {NULL}, 669, "tcp"}, {"meregister", {NULL}, 669, "udp"}, {"vacdsm-sws", {NULL}, 670, "tcp"}, {"vacdsm-sws", {NULL}, 670, "udp"}, {"vacdsm-app", {NULL}, 671, "tcp"}, {"vacdsm-app", {NULL}, 671, "udp"}, {"vpps-qua", {NULL}, 672, "tcp"}, {"vpps-qua", {NULL}, 672, "udp"}, {"cimplex", {NULL}, 673, "tcp"}, {"cimplex", {NULL}, 673, "udp"}, {"acap", {NULL}, 674, "tcp"}, {"acap", {NULL}, 674, "udp"}, {"dctp", {NULL}, 675, "tcp"}, {"dctp", {NULL}, 675, "udp"}, {"vpps-via", {NULL}, 676, "tcp"}, {"vpps-via", {NULL}, 676, "udp"}, {"vpp", {NULL}, 677, "tcp"}, {"vpp", {NULL}, 677, "udp"}, {"ggf-ncp", {NULL}, 678, "tcp"}, {"ggf-ncp", {NULL}, 678, "udp"}, {"mrm", {NULL}, 679, "tcp"}, {"mrm", {NULL}, 679, "udp"}, {"entrust-aaas", {NULL}, 680, "tcp"}, {"entrust-aaas", {NULL}, 680, "udp"}, {"entrust-aams", {NULL}, 681, "tcp"}, {"entrust-aams", {NULL}, 681, "udp"}, {"xfr", {NULL}, 682, "tcp"}, {"xfr", {NULL}, 682, "udp"}, {"corba-iiop", {NULL}, 683, "tcp"}, {"corba-iiop", {NULL}, 683, "udp"}, {"corba-iiop-ssl", {NULL}, 684, "tcp"}, {"corba-iiop-ssl", {NULL}, 684, "udp"}, {"mdc-portmapper", {NULL}, 685, "tcp"}, {"mdc-portmapper", {NULL}, 685, "udp"}, {"hcp-wismar", {NULL}, 686, "tcp"}, {"hcp-wismar", {NULL}, 686, "udp"}, {"asipregistry", {NULL}, 687, "tcp"}, {"asipregistry", {NULL}, 687, "udp"}, {"realm-rusd", {NULL}, 688, "tcp"}, {"realm-rusd", {NULL}, 688, "udp"}, {"nmap", {NULL}, 689, "tcp"}, {"nmap", {NULL}, 689, "udp"}, {"vatp", {NULL}, 690, "tcp"}, {"vatp", {NULL}, 690, "udp"}, {"msexch-routing", {NULL}, 691, "tcp"}, {"msexch-routing", {NULL}, 691, "udp"}, {"hyperwave-isp", {NULL}, 692, "tcp"}, {"hyperwave-isp", {NULL}, 692, "udp"}, {"connendp", {NULL}, 693, "tcp"}, {"connendp", {NULL}, 693, "udp"}, {"ha-cluster", {NULL}, 694, "tcp"}, {"ha-cluster", {NULL}, 694, "udp"}, {"ieee-mms-ssl", {NULL}, 695, "tcp"}, {"ieee-mms-ssl", {NULL}, 695, "udp"}, {"rushd", {NULL}, 696, "tcp"}, {"rushd", {NULL}, 696, "udp"}, {"uuidgen", {NULL}, 697, "tcp"}, {"uuidgen", {NULL}, 697, "udp"}, {"olsr", {NULL}, 698, "tcp"}, {"olsr", {NULL}, 698, "udp"}, {"accessnetwork", {NULL}, 699, "tcp"}, {"accessnetwork", {NULL}, 699, "udp"}, {"epp", {NULL}, 700, "tcp"}, {"epp", {NULL}, 700, "udp"}, {"lmp", {NULL}, 701, "tcp"}, {"lmp", {NULL}, 701, "udp"}, {"iris-beep", {NULL}, 702, "tcp"}, {"iris-beep", {NULL}, 702, "udp"}, {"elcsd", {NULL}, 704, "tcp"}, {"elcsd", {NULL}, 704, "udp"}, {"agentx", {NULL}, 705, "tcp"}, {"agentx", {NULL}, 705, "udp"}, {"silc", {NULL}, 706, "tcp"}, {"silc", {NULL}, 706, "udp"}, {"borland-dsj", {NULL}, 707, "tcp"}, {"borland-dsj", {NULL}, 707, "udp"}, {"entrust-kmsh", {NULL}, 709, "tcp"}, {"entrust-kmsh", {NULL}, 709, "udp"}, {"entrust-ash", {NULL}, 710, "tcp"}, {"entrust-ash", {NULL}, 710, "udp"}, {"cisco-tdp", {NULL}, 711, "tcp"}, {"cisco-tdp", {NULL}, 711, "udp"}, {"tbrpf", {NULL}, 712, "tcp"}, {"tbrpf", {NULL}, 712, "udp"}, {"iris-xpc", {NULL}, 713, "tcp"}, {"iris-xpc", {NULL}, 713, "udp"}, {"iris-xpcs", {NULL}, 714, "tcp"}, {"iris-xpcs", {NULL}, 714, "udp"}, {"iris-lwz", {NULL}, 715, "tcp"}, {"iris-lwz", {NULL}, 715, "udp"}, {"pana", {NULL}, 716, "udp"}, {"netviewdm1", {NULL}, 729, "tcp"}, {"netviewdm1", {NULL}, 729, "udp"}, {"netviewdm2", {NULL}, 730, "tcp"}, {"netviewdm2", {NULL}, 730, "udp"}, {"netviewdm3", {NULL}, 731, "tcp"}, {"netviewdm3", {NULL}, 731, "udp"}, {"netgw", {NULL}, 741, "tcp"}, {"netgw", {NULL}, 741, "udp"}, {"netrcs", {NULL}, 742, "tcp"}, {"netrcs", {NULL}, 742, "udp"}, {"flexlm", {NULL}, 744, "tcp"}, {"flexlm", {NULL}, 744, "udp"}, {"fujitsu-dev", {NULL}, 747, "tcp"}, {"fujitsu-dev", {NULL}, 747, "udp"}, {"ris-cm", {NULL}, 748, "tcp"}, {"ris-cm", {NULL}, 748, "udp"}, {"kerberos-adm", {NULL}, 749, "tcp"}, {"kerberos-adm", {NULL}, 749, "udp"}, {"rfile", {NULL}, 750, "tcp"}, {"loadav", {NULL}, 750, "udp"}, {"kerberos-iv", {NULL}, 750, "udp"}, {"pump", {NULL}, 751, "tcp"}, {"pump", {NULL}, 751, "udp"}, {"qrh", {NULL}, 752, "tcp"}, {"qrh", {NULL}, 752, "udp"}, {"rrh", {NULL}, 753, "tcp"}, {"rrh", {NULL}, 753, "udp"}, {"tell", {NULL}, 754, "tcp"}, {"tell", {NULL}, 754, "udp"}, {"nlogin", {NULL}, 758, "tcp"}, {"nlogin", {NULL}, 758, "udp"}, {"con", {NULL}, 759, "tcp"}, {"con", {NULL}, 759, "udp"}, {"ns", {NULL}, 760, "tcp"}, {"ns", {NULL}, 760, "udp"}, {"rxe", {NULL}, 761, "tcp"}, {"rxe", {NULL}, 761, "udp"}, {"quotad", {NULL}, 762, "tcp"}, {"quotad", {NULL}, 762, "udp"}, {"cycleserv", {NULL}, 763, "tcp"}, {"cycleserv", {NULL}, 763, "udp"}, {"omserv", {NULL}, 764, "tcp"}, {"omserv", {NULL}, 764, "udp"}, {"webster", {NULL}, 765, "tcp"}, {"webster", {NULL}, 765, "udp"}, {"phonebook", {NULL}, 767, "tcp"}, {"phonebook", {NULL}, 767, "udp"}, {"vid", {NULL}, 769, "tcp"}, {"vid", {NULL}, 769, "udp"}, {"cadlock", {NULL}, 770, "tcp"}, {"cadlock", {NULL}, 770, "udp"}, {"rtip", {NULL}, 771, "tcp"}, {"rtip", {NULL}, 771, "udp"}, {"cycleserv2", {NULL}, 772, "tcp"}, {"cycleserv2", {NULL}, 772, "udp"}, {"submit", {NULL}, 773, "tcp"}, {"notify", {NULL}, 773, "udp"}, {"rpasswd", {NULL}, 774, "tcp"}, {"acmaint_dbd", {NULL}, 774, "udp"}, {"entomb", {NULL}, 775, "tcp"}, {"acmaint_transd", {NULL}, 775, "udp"}, {"wpages", {NULL}, 776, "tcp"}, {"wpages", {NULL}, 776, "udp"}, {"multiling-http", {NULL}, 777, "tcp"}, {"multiling-http", {NULL}, 777, "udp"}, {"wpgs", {NULL}, 780, "tcp"}, {"wpgs", {NULL}, 780, "udp"}, {"mdbs_daemon", {NULL}, 800, "tcp"}, {"mdbs_daemon", {NULL}, 800, "udp"}, {"device", {NULL}, 801, "tcp"}, {"device", {NULL}, 801, "udp"}, {"fcp-udp", {NULL}, 810, "tcp"}, {"fcp-udp", {NULL}, 810, "udp"}, {"itm-mcell-s", {NULL}, 828, "tcp"}, {"itm-mcell-s", {NULL}, 828, "udp"}, {"pkix-3-ca-ra", {NULL}, 829, "tcp"}, {"pkix-3-ca-ra", {NULL}, 829, "udp"}, {"netconf-ssh", {NULL}, 830, "tcp"}, {"netconf-ssh", {NULL}, 830, "udp"}, {"netconf-beep", {NULL}, 831, "tcp"}, {"netconf-beep", {NULL}, 831, "udp"}, {"netconfsoaphttp", {NULL}, 832, "tcp"}, {"netconfsoaphttp", {NULL}, 832, "udp"}, {"netconfsoapbeep", {NULL}, 833, "tcp"}, {"netconfsoapbeep", {NULL}, 833, "udp"}, {"dhcp-failover2", {NULL}, 847, "tcp"}, {"dhcp-failover2", {NULL}, 847, "udp"}, {"gdoi", {NULL}, 848, "tcp"}, {"gdoi", {NULL}, 848, "udp"}, {"iscsi", {NULL}, 860, "tcp"}, {"iscsi", {NULL}, 860, "udp"}, {"owamp-control", {NULL}, 861, "tcp"}, {"owamp-control", {NULL}, 861, "udp"}, {"twamp-control", {NULL}, 862, "tcp"}, {"twamp-control", {NULL}, 862, "udp"}, {"rsync", {NULL}, 873, "tcp"}, {"rsync", {NULL}, 873, "udp"}, {"iclcnet-locate", {NULL}, 886, "tcp"}, {"iclcnet-locate", {NULL}, 886, "udp"}, {"iclcnet_svinfo", {NULL}, 887, "tcp"}, {"iclcnet_svinfo", {NULL}, 887, "udp"}, {"accessbuilder", {NULL}, 888, "tcp"}, {"accessbuilder", {NULL}, 888, "udp"}, {"cddbp", {NULL}, 888, "tcp"}, {"omginitialrefs", {NULL}, 900, "tcp"}, {"omginitialrefs", {NULL}, 900, "udp"}, {"smpnameres", {NULL}, 901, "tcp"}, {"smpnameres", {NULL}, 901, "udp"}, {"ideafarm-door", {NULL}, 902, "tcp"}, {"ideafarm-door", {NULL}, 902, "udp"}, {"ideafarm-panic", {NULL}, 903, "tcp"}, {"ideafarm-panic", {NULL}, 903, "udp"}, {"kink", {NULL}, 910, "tcp"}, {"kink", {NULL}, 910, "udp"}, {"xact-backup", {NULL}, 911, "tcp"}, {"xact-backup", {NULL}, 911, "udp"}, {"apex-mesh", {NULL}, 912, "tcp"}, {"apex-mesh", {NULL}, 912, "udp"}, {"apex-edge", {NULL}, 913, "tcp"}, {"apex-edge", {NULL}, 913, "udp"}, {"ftps-data", {NULL}, 989, "tcp"}, {"ftps-data", {NULL}, 989, "udp"}, {"ftps", {NULL}, 990, "tcp"}, {"ftps", {NULL}, 990, "udp"}, {"nas", {NULL}, 991, "tcp"}, {"nas", {NULL}, 991, "udp"}, {"telnets", {NULL}, 992, "tcp"}, {"telnets", {NULL}, 992, "udp"}, {"imaps", {NULL}, 993, "tcp"}, {"imaps", {NULL}, 993, "udp"}, {"ircs", {NULL}, 994, "tcp"}, {"ircs", {NULL}, 994, "udp"}, {"pop3s", {NULL}, 995, "tcp"}, {"pop3s", {NULL}, 995, "udp"}, {"vsinet", {NULL}, 996, "tcp"}, {"vsinet", {NULL}, 996, "udp"}, {"maitrd", {NULL}, 997, "tcp"}, {"maitrd", {NULL}, 997, "udp"}, {"busboy", {NULL}, 998, "tcp"}, {"puparp", {NULL}, 998, "udp"}, {"garcon", {NULL}, 999, "tcp"}, {"applix", {NULL}, 999, "udp"}, {"puprouter", {NULL}, 999, "tcp"}, {"puprouter", {NULL}, 999, "udp"}, {"cadlock2", {NULL}, 1000, "tcp"}, {"cadlock2", {NULL}, 1000, "udp"}, {"surf", {NULL}, 1010, "tcp"}, {"surf", {NULL}, 1010, "udp"}, {"exp1", {NULL}, 1021, "tcp"}, {"exp1", {NULL}, 1021, "udp"}, {"exp2", {NULL}, 1022, "tcp"}, {"exp2", {NULL}, 1022, "udp"}, #endif /* USE_IANA_WELL_KNOWN_PORTS */ #ifdef USE_IANA_REGISTERED_PORTS {"blackjack", {NULL}, 1025, "tcp"}, {"blackjack", {NULL}, 1025, "udp"}, {"cap", {NULL}, 1026, "tcp"}, {"cap", {NULL}, 1026, "udp"}, {"solid-mux", {NULL}, 1029, "tcp"}, {"solid-mux", {NULL}, 1029, "udp"}, {"iad1", {NULL}, 1030, "tcp"}, {"iad1", {NULL}, 1030, "udp"}, {"iad2", {NULL}, 1031, "tcp"}, {"iad2", {NULL}, 1031, "udp"}, {"iad3", {NULL}, 1032, "tcp"}, {"iad3", {NULL}, 1032, "udp"}, {"netinfo-local", {NULL}, 1033, "tcp"}, {"netinfo-local", {NULL}, 1033, "udp"}, {"activesync", {NULL}, 1034, "tcp"}, {"activesync", {NULL}, 1034, "udp"}, {"mxxrlogin", {NULL}, 1035, "tcp"}, {"mxxrlogin", {NULL}, 1035, "udp"}, {"nsstp", {NULL}, 1036, "tcp"}, {"nsstp", {NULL}, 1036, "udp"}, {"ams", {NULL}, 1037, "tcp"}, {"ams", {NULL}, 1037, "udp"}, {"mtqp", {NULL}, 1038, "tcp"}, {"mtqp", {NULL}, 1038, "udp"}, {"sbl", {NULL}, 1039, "tcp"}, {"sbl", {NULL}, 1039, "udp"}, {"netarx", {NULL}, 1040, "tcp"}, {"netarx", {NULL}, 1040, "udp"}, {"danf-ak2", {NULL}, 1041, "tcp"}, {"danf-ak2", {NULL}, 1041, "udp"}, {"afrog", {NULL}, 1042, "tcp"}, {"afrog", {NULL}, 1042, "udp"}, {"boinc-client", {NULL}, 1043, "tcp"}, {"boinc-client", {NULL}, 1043, "udp"}, {"dcutility", {NULL}, 1044, "tcp"}, {"dcutility", {NULL}, 1044, "udp"}, {"fpitp", {NULL}, 1045, "tcp"}, {"fpitp", {NULL}, 1045, "udp"}, {"wfremotertm", {NULL}, 1046, "tcp"}, {"wfremotertm", {NULL}, 1046, "udp"}, {"neod1", {NULL}, 1047, "tcp"}, {"neod1", {NULL}, 1047, "udp"}, {"neod2", {NULL}, 1048, "tcp"}, {"neod2", {NULL}, 1048, "udp"}, {"td-postman", {NULL}, 1049, "tcp"}, {"td-postman", {NULL}, 1049, "udp"}, {"cma", {NULL}, 1050, "tcp"}, {"cma", {NULL}, 1050, "udp"}, {"optima-vnet", {NULL}, 1051, "tcp"}, {"optima-vnet", {NULL}, 1051, "udp"}, {"ddt", {NULL}, 1052, "tcp"}, {"ddt", {NULL}, 1052, "udp"}, {"remote-as", {NULL}, 1053, "tcp"}, {"remote-as", {NULL}, 1053, "udp"}, {"brvread", {NULL}, 1054, "tcp"}, {"brvread", {NULL}, 1054, "udp"}, {"ansyslmd", {NULL}, 1055, "tcp"}, {"ansyslmd", {NULL}, 1055, "udp"}, {"vfo", {NULL}, 1056, "tcp"}, {"vfo", {NULL}, 1056, "udp"}, {"startron", {NULL}, 1057, "tcp"}, {"startron", {NULL}, 1057, "udp"}, {"nim", {NULL}, 1058, "tcp"}, {"nim", {NULL}, 1058, "udp"}, {"nimreg", {NULL}, 1059, "tcp"}, {"nimreg", {NULL}, 1059, "udp"}, {"polestar", {NULL}, 1060, "tcp"}, {"polestar", {NULL}, 1060, "udp"}, {"kiosk", {NULL}, 1061, "tcp"}, {"kiosk", {NULL}, 1061, "udp"}, {"veracity", {NULL}, 1062, "tcp"}, {"veracity", {NULL}, 1062, "udp"}, {"kyoceranetdev", {NULL}, 1063, "tcp"}, {"kyoceranetdev", {NULL}, 1063, "udp"}, {"jstel", {NULL}, 1064, "tcp"}, {"jstel", {NULL}, 1064, "udp"}, {"syscomlan", {NULL}, 1065, "tcp"}, {"syscomlan", {NULL}, 1065, "udp"}, {"fpo-fns", {NULL}, 1066, "tcp"}, {"fpo-fns", {NULL}, 1066, "udp"}, {"instl_boots", {NULL}, 1067, "tcp"}, {"instl_boots", {NULL}, 1067, "udp"}, {"instl_bootc", {NULL}, 1068, "tcp"}, {"instl_bootc", {NULL}, 1068, "udp"}, {"cognex-insight", {NULL}, 1069, "tcp"}, {"cognex-insight", {NULL}, 1069, "udp"}, {"gmrupdateserv", {NULL}, 1070, "tcp"}, {"gmrupdateserv", {NULL}, 1070, "udp"}, {"bsquare-voip", {NULL}, 1071, "tcp"}, {"bsquare-voip", {NULL}, 1071, "udp"}, {"cardax", {NULL}, 1072, "tcp"}, {"cardax", {NULL}, 1072, "udp"}, {"bridgecontrol", {NULL}, 1073, "tcp"}, {"bridgecontrol", {NULL}, 1073, "udp"}, {"warmspotMgmt", {NULL}, 1074, "tcp"}, {"warmspotMgmt", {NULL}, 1074, "udp"}, {"rdrmshc", {NULL}, 1075, "tcp"}, {"rdrmshc", {NULL}, 1075, "udp"}, {"dab-sti-c", {NULL}, 1076, "tcp"}, {"dab-sti-c", {NULL}, 1076, "udp"}, {"imgames", {NULL}, 1077, "tcp"}, {"imgames", {NULL}, 1077, "udp"}, {"avocent-proxy", {NULL}, 1078, "tcp"}, {"avocent-proxy", {NULL}, 1078, "udp"}, {"asprovatalk", {NULL}, 1079, "tcp"}, {"asprovatalk", {NULL}, 1079, "udp"}, {"socks", {NULL}, 1080, "tcp"}, {"socks", {NULL}, 1080, "udp"}, {"pvuniwien", {NULL}, 1081, "tcp"}, {"pvuniwien", {NULL}, 1081, "udp"}, {"amt-esd-prot", {NULL}, 1082, "tcp"}, {"amt-esd-prot", {NULL}, 1082, "udp"}, {"ansoft-lm-1", {NULL}, 1083, "tcp"}, {"ansoft-lm-1", {NULL}, 1083, "udp"}, {"ansoft-lm-2", {NULL}, 1084, "tcp"}, {"ansoft-lm-2", {NULL}, 1084, "udp"}, {"webobjects", {NULL}, 1085, "tcp"}, {"webobjects", {NULL}, 1085, "udp"}, {"cplscrambler-lg", {NULL}, 1086, "tcp"}, {"cplscrambler-lg", {NULL}, 1086, "udp"}, {"cplscrambler-in", {NULL}, 1087, "tcp"}, {"cplscrambler-in", {NULL}, 1087, "udp"}, {"cplscrambler-al", {NULL}, 1088, "tcp"}, {"cplscrambler-al", {NULL}, 1088, "udp"}, {"ff-annunc", {NULL}, 1089, "tcp"}, {"ff-annunc", {NULL}, 1089, "udp"}, {"ff-fms", {NULL}, 1090, "tcp"}, {"ff-fms", {NULL}, 1090, "udp"}, {"ff-sm", {NULL}, 1091, "tcp"}, {"ff-sm", {NULL}, 1091, "udp"}, {"obrpd", {NULL}, 1092, "tcp"}, {"obrpd", {NULL}, 1092, "udp"}, {"proofd", {NULL}, 1093, "tcp"}, {"proofd", {NULL}, 1093, "udp"}, {"rootd", {NULL}, 1094, "tcp"}, {"rootd", {NULL}, 1094, "udp"}, {"nicelink", {NULL}, 1095, "tcp"}, {"nicelink", {NULL}, 1095, "udp"}, {"cnrprotocol", {NULL}, 1096, "tcp"}, {"cnrprotocol", {NULL}, 1096, "udp"}, {"sunclustermgr", {NULL}, 1097, "tcp"}, {"sunclustermgr", {NULL}, 1097, "udp"}, {"rmiactivation", {NULL}, 1098, "tcp"}, {"rmiactivation", {NULL}, 1098, "udp"}, {"rmiregistry", {NULL}, 1099, "tcp"}, {"rmiregistry", {NULL}, 1099, "udp"}, {"mctp", {NULL}, 1100, "tcp"}, {"mctp", {NULL}, 1100, "udp"}, {"pt2-discover", {NULL}, 1101, "tcp"}, {"pt2-discover", {NULL}, 1101, "udp"}, {"adobeserver-1", {NULL}, 1102, "tcp"}, {"adobeserver-1", {NULL}, 1102, "udp"}, {"adobeserver-2", {NULL}, 1103, "tcp"}, {"adobeserver-2", {NULL}, 1103, "udp"}, {"xrl", {NULL}, 1104, "tcp"}, {"xrl", {NULL}, 1104, "udp"}, {"ftranhc", {NULL}, 1105, "tcp"}, {"ftranhc", {NULL}, 1105, "udp"}, {"isoipsigport-1", {NULL}, 1106, "tcp"}, {"isoipsigport-1", {NULL}, 1106, "udp"}, {"isoipsigport-2", {NULL}, 1107, "tcp"}, {"isoipsigport-2", {NULL}, 1107, "udp"}, {"ratio-adp", {NULL}, 1108, "tcp"}, {"ratio-adp", {NULL}, 1108, "udp"}, {"webadmstart", {NULL}, 1110, "tcp"}, {"nfsd-keepalive", {NULL}, 1110, "udp"}, {"lmsocialserver", {NULL}, 1111, "tcp"}, {"lmsocialserver", {NULL}, 1111, "udp"}, {"icp", {NULL}, 1112, "tcp"}, {"icp", {NULL}, 1112, "udp"}, {"ltp-deepspace", {NULL}, 1113, "tcp"}, {"ltp-deepspace", {NULL}, 1113, "udp"}, {"mini-sql", {NULL}, 1114, "tcp"}, {"mini-sql", {NULL}, 1114, "udp"}, {"ardus-trns", {NULL}, 1115, "tcp"}, {"ardus-trns", {NULL}, 1115, "udp"}, {"ardus-cntl", {NULL}, 1116, "tcp"}, {"ardus-cntl", {NULL}, 1116, "udp"}, {"ardus-mtrns", {NULL}, 1117, "tcp"}, {"ardus-mtrns", {NULL}, 1117, "udp"}, {"sacred", {NULL}, 1118, "tcp"}, {"sacred", {NULL}, 1118, "udp"}, {"bnetgame", {NULL}, 1119, "tcp"}, {"bnetgame", {NULL}, 1119, "udp"}, {"bnetfile", {NULL}, 1120, "tcp"}, {"bnetfile", {NULL}, 1120, "udp"}, {"rmpp", {NULL}, 1121, "tcp"}, {"rmpp", {NULL}, 1121, "udp"}, {"availant-mgr", {NULL}, 1122, "tcp"}, {"availant-mgr", {NULL}, 1122, "udp"}, {"murray", {NULL}, 1123, "tcp"}, {"murray", {NULL}, 1123, "udp"}, {"hpvmmcontrol", {NULL}, 1124, "tcp"}, {"hpvmmcontrol", {NULL}, 1124, "udp"}, {"hpvmmagent", {NULL}, 1125, "tcp"}, {"hpvmmagent", {NULL}, 1125, "udp"}, {"hpvmmdata", {NULL}, 1126, "tcp"}, {"hpvmmdata", {NULL}, 1126, "udp"}, {"kwdb-commn", {NULL}, 1127, "tcp"}, {"kwdb-commn", {NULL}, 1127, "udp"}, {"saphostctrl", {NULL}, 1128, "tcp"}, {"saphostctrl", {NULL}, 1128, "udp"}, {"saphostctrls", {NULL}, 1129, "tcp"}, {"saphostctrls", {NULL}, 1129, "udp"}, {"casp", {NULL}, 1130, "tcp"}, {"casp", {NULL}, 1130, "udp"}, {"caspssl", {NULL}, 1131, "tcp"}, {"caspssl", {NULL}, 1131, "udp"}, {"kvm-via-ip", {NULL}, 1132, "tcp"}, {"kvm-via-ip", {NULL}, 1132, "udp"}, {"dfn", {NULL}, 1133, "tcp"}, {"dfn", {NULL}, 1133, "udp"}, {"aplx", {NULL}, 1134, "tcp"}, {"aplx", {NULL}, 1134, "udp"}, {"omnivision", {NULL}, 1135, "tcp"}, {"omnivision", {NULL}, 1135, "udp"}, {"hhb-gateway", {NULL}, 1136, "tcp"}, {"hhb-gateway", {NULL}, 1136, "udp"}, {"trim", {NULL}, 1137, "tcp"}, {"trim", {NULL}, 1137, "udp"}, {"encrypted_admin", {NULL}, 1138, "tcp"}, {"encrypted_admin", {NULL}, 1138, "udp"}, {"evm", {NULL}, 1139, "tcp"}, {"evm", {NULL}, 1139, "udp"}, {"autonoc", {NULL}, 1140, "tcp"}, {"autonoc", {NULL}, 1140, "udp"}, {"mxomss", {NULL}, 1141, "tcp"}, {"mxomss", {NULL}, 1141, "udp"}, {"edtools", {NULL}, 1142, "tcp"}, {"edtools", {NULL}, 1142, "udp"}, {"imyx", {NULL}, 1143, "tcp"}, {"imyx", {NULL}, 1143, "udp"}, {"fuscript", {NULL}, 1144, "tcp"}, {"fuscript", {NULL}, 1144, "udp"}, {"x9-icue", {NULL}, 1145, "tcp"}, {"x9-icue", {NULL}, 1145, "udp"}, {"audit-transfer", {NULL}, 1146, "tcp"}, {"audit-transfer", {NULL}, 1146, "udp"}, {"capioverlan", {NULL}, 1147, "tcp"}, {"capioverlan", {NULL}, 1147, "udp"}, {"elfiq-repl", {NULL}, 1148, "tcp"}, {"elfiq-repl", {NULL}, 1148, "udp"}, {"bvtsonar", {NULL}, 1149, "tcp"}, {"bvtsonar", {NULL}, 1149, "udp"}, {"blaze", {NULL}, 1150, "tcp"}, {"blaze", {NULL}, 1150, "udp"}, {"unizensus", {NULL}, 1151, "tcp"}, {"unizensus", {NULL}, 1151, "udp"}, {"winpoplanmess", {NULL}, 1152, "tcp"}, {"winpoplanmess", {NULL}, 1152, "udp"}, {"c1222-acse", {NULL}, 1153, "tcp"}, {"c1222-acse", {NULL}, 1153, "udp"}, {"resacommunity", {NULL}, 1154, "tcp"}, {"resacommunity", {NULL}, 1154, "udp"}, {"nfa", {NULL}, 1155, "tcp"}, {"nfa", {NULL}, 1155, "udp"}, {"iascontrol-oms", {NULL}, 1156, "tcp"}, {"iascontrol-oms", {NULL}, 1156, "udp"}, {"iascontrol", {NULL}, 1157, "tcp"}, {"iascontrol", {NULL}, 1157, "udp"}, {"dbcontrol-oms", {NULL}, 1158, "tcp"}, {"dbcontrol-oms", {NULL}, 1158, "udp"}, {"oracle-oms", {NULL}, 1159, "tcp"}, {"oracle-oms", {NULL}, 1159, "udp"}, {"olsv", {NULL}, 1160, "tcp"}, {"olsv", {NULL}, 1160, "udp"}, {"health-polling", {NULL}, 1161, "tcp"}, {"health-polling", {NULL}, 1161, "udp"}, {"health-trap", {NULL}, 1162, "tcp"}, {"health-trap", {NULL}, 1162, "udp"}, {"sddp", {NULL}, 1163, "tcp"}, {"sddp", {NULL}, 1163, "udp"}, {"qsm-proxy", {NULL}, 1164, "tcp"}, {"qsm-proxy", {NULL}, 1164, "udp"}, {"qsm-gui", {NULL}, 1165, "tcp"}, {"qsm-gui", {NULL}, 1165, "udp"}, {"qsm-remote", {NULL}, 1166, "tcp"}, {"qsm-remote", {NULL}, 1166, "udp"}, {"cisco-ipsla", {NULL}, 1167, "tcp"}, {"cisco-ipsla", {NULL}, 1167, "udp"}, {"cisco-ipsla", {NULL}, 1167, "sctp"}, {"vchat", {NULL}, 1168, "tcp"}, {"vchat", {NULL}, 1168, "udp"}, {"tripwire", {NULL}, 1169, "tcp"}, {"tripwire", {NULL}, 1169, "udp"}, {"atc-lm", {NULL}, 1170, "tcp"}, {"atc-lm", {NULL}, 1170, "udp"}, {"atc-appserver", {NULL}, 1171, "tcp"}, {"atc-appserver", {NULL}, 1171, "udp"}, {"dnap", {NULL}, 1172, "tcp"}, {"dnap", {NULL}, 1172, "udp"}, {"d-cinema-rrp", {NULL}, 1173, "tcp"}, {"d-cinema-rrp", {NULL}, 1173, "udp"}, {"fnet-remote-ui", {NULL}, 1174, "tcp"}, {"fnet-remote-ui", {NULL}, 1174, "udp"}, {"dossier", {NULL}, 1175, "tcp"}, {"dossier", {NULL}, 1175, "udp"}, {"indigo-server", {NULL}, 1176, "tcp"}, {"indigo-server", {NULL}, 1176, "udp"}, {"dkmessenger", {NULL}, 1177, "tcp"}, {"dkmessenger", {NULL}, 1177, "udp"}, {"sgi-storman", {NULL}, 1178, "tcp"}, {"sgi-storman", {NULL}, 1178, "udp"}, {"b2n", {NULL}, 1179, "tcp"}, {"b2n", {NULL}, 1179, "udp"}, {"mc-client", {NULL}, 1180, "tcp"}, {"mc-client", {NULL}, 1180, "udp"}, {"3comnetman", {NULL}, 1181, "tcp"}, {"3comnetman", {NULL}, 1181, "udp"}, {"accelenet", {NULL}, 1182, "tcp"}, {"accelenet-data", {NULL}, 1182, "udp"}, {"llsurfup-http", {NULL}, 1183, "tcp"}, {"llsurfup-http", {NULL}, 1183, "udp"}, {"llsurfup-https", {NULL}, 1184, "tcp"}, {"llsurfup-https", {NULL}, 1184, "udp"}, {"catchpole", {NULL}, 1185, "tcp"}, {"catchpole", {NULL}, 1185, "udp"}, {"mysql-cluster", {NULL}, 1186, "tcp"}, {"mysql-cluster", {NULL}, 1186, "udp"}, {"alias", {NULL}, 1187, "tcp"}, {"alias", {NULL}, 1187, "udp"}, {"hp-webadmin", {NULL}, 1188, "tcp"}, {"hp-webadmin", {NULL}, 1188, "udp"}, {"unet", {NULL}, 1189, "tcp"}, {"unet", {NULL}, 1189, "udp"}, {"commlinx-avl", {NULL}, 1190, "tcp"}, {"commlinx-avl", {NULL}, 1190, "udp"}, {"gpfs", {NULL}, 1191, "tcp"}, {"gpfs", {NULL}, 1191, "udp"}, {"caids-sensor", {NULL}, 1192, "tcp"}, {"caids-sensor", {NULL}, 1192, "udp"}, {"fiveacross", {NULL}, 1193, "tcp"}, {"fiveacross", {NULL}, 1193, "udp"}, {"openvpn", {NULL}, 1194, "tcp"}, {"openvpn", {NULL}, 1194, "udp"}, {"rsf-1", {NULL}, 1195, "tcp"}, {"rsf-1", {NULL}, 1195, "udp"}, {"netmagic", {NULL}, 1196, "tcp"}, {"netmagic", {NULL}, 1196, "udp"}, {"carrius-rshell", {NULL}, 1197, "tcp"}, {"carrius-rshell", {NULL}, 1197, "udp"}, {"cajo-discovery", {NULL}, 1198, "tcp"}, {"cajo-discovery", {NULL}, 1198, "udp"}, {"dmidi", {NULL}, 1199, "tcp"}, {"dmidi", {NULL}, 1199, "udp"}, {"scol", {NULL}, 1200, "tcp"}, {"scol", {NULL}, 1200, "udp"}, {"nucleus-sand", {NULL}, 1201, "tcp"}, {"nucleus-sand", {NULL}, 1201, "udp"}, {"caiccipc", {NULL}, 1202, "tcp"}, {"caiccipc", {NULL}, 1202, "udp"}, {"ssslic-mgr", {NULL}, 1203, "tcp"}, {"ssslic-mgr", {NULL}, 1203, "udp"}, {"ssslog-mgr", {NULL}, 1204, "tcp"}, {"ssslog-mgr", {NULL}, 1204, "udp"}, {"accord-mgc", {NULL}, 1205, "tcp"}, {"accord-mgc", {NULL}, 1205, "udp"}, {"anthony-data", {NULL}, 1206, "tcp"}, {"anthony-data", {NULL}, 1206, "udp"}, {"metasage", {NULL}, 1207, "tcp"}, {"metasage", {NULL}, 1207, "udp"}, {"seagull-ais", {NULL}, 1208, "tcp"}, {"seagull-ais", {NULL}, 1208, "udp"}, {"ipcd3", {NULL}, 1209, "tcp"}, {"ipcd3", {NULL}, 1209, "udp"}, {"eoss", {NULL}, 1210, "tcp"}, {"eoss", {NULL}, 1210, "udp"}, {"groove-dpp", {NULL}, 1211, "tcp"}, {"groove-dpp", {NULL}, 1211, "udp"}, {"lupa", {NULL}, 1212, "tcp"}, {"lupa", {NULL}, 1212, "udp"}, {"mpc-lifenet", {NULL}, 1213, "tcp"}, {"mpc-lifenet", {NULL}, 1213, "udp"}, {"kazaa", {NULL}, 1214, "tcp"}, {"kazaa", {NULL}, 1214, "udp"}, {"scanstat-1", {NULL}, 1215, "tcp"}, {"scanstat-1", {NULL}, 1215, "udp"}, {"etebac5", {NULL}, 1216, "tcp"}, {"etebac5", {NULL}, 1216, "udp"}, {"hpss-ndapi", {NULL}, 1217, "tcp"}, {"hpss-ndapi", {NULL}, 1217, "udp"}, {"aeroflight-ads", {NULL}, 1218, "tcp"}, {"aeroflight-ads", {NULL}, 1218, "udp"}, {"aeroflight-ret", {NULL}, 1219, "tcp"}, {"aeroflight-ret", {NULL}, 1219, "udp"}, {"qt-serveradmin", {NULL}, 1220, "tcp"}, {"qt-serveradmin", {NULL}, 1220, "udp"}, {"sweetware-apps", {NULL}, 1221, "tcp"}, {"sweetware-apps", {NULL}, 1221, "udp"}, {"nerv", {NULL}, 1222, "tcp"}, {"nerv", {NULL}, 1222, "udp"}, {"tgp", {NULL}, 1223, "tcp"}, {"tgp", {NULL}, 1223, "udp"}, {"vpnz", {NULL}, 1224, "tcp"}, {"vpnz", {NULL}, 1224, "udp"}, {"slinkysearch", {NULL}, 1225, "tcp"}, {"slinkysearch", {NULL}, 1225, "udp"}, {"stgxfws", {NULL}, 1226, "tcp"}, {"stgxfws", {NULL}, 1226, "udp"}, {"dns2go", {NULL}, 1227, "tcp"}, {"dns2go", {NULL}, 1227, "udp"}, {"florence", {NULL}, 1228, "tcp"}, {"florence", {NULL}, 1228, "udp"}, {"zented", {NULL}, 1229, "tcp"}, {"zented", {NULL}, 1229, "udp"}, {"periscope", {NULL}, 1230, "tcp"}, {"periscope", {NULL}, 1230, "udp"}, {"menandmice-lpm", {NULL}, 1231, "tcp"}, {"menandmice-lpm", {NULL}, 1231, "udp"}, {"univ-appserver", {NULL}, 1233, "tcp"}, {"univ-appserver", {NULL}, 1233, "udp"}, {"search-agent", {NULL}, 1234, "tcp"}, {"search-agent", {NULL}, 1234, "udp"}, {"mosaicsyssvc1", {NULL}, 1235, "tcp"}, {"mosaicsyssvc1", {NULL}, 1235, "udp"}, {"bvcontrol", {NULL}, 1236, "tcp"}, {"bvcontrol", {NULL}, 1236, "udp"}, {"tsdos390", {NULL}, 1237, "tcp"}, {"tsdos390", {NULL}, 1237, "udp"}, {"hacl-qs", {NULL}, 1238, "tcp"}, {"hacl-qs", {NULL}, 1238, "udp"}, {"nmsd", {NULL}, 1239, "tcp"}, {"nmsd", {NULL}, 1239, "udp"}, {"instantia", {NULL}, 1240, "tcp"}, {"instantia", {NULL}, 1240, "udp"}, {"nessus", {NULL}, 1241, "tcp"}, {"nessus", {NULL}, 1241, "udp"}, {"nmasoverip", {NULL}, 1242, "tcp"}, {"nmasoverip", {NULL}, 1242, "udp"}, {"serialgateway", {NULL}, 1243, "tcp"}, {"serialgateway", {NULL}, 1243, "udp"}, {"isbconference1", {NULL}, 1244, "tcp"}, {"isbconference1", {NULL}, 1244, "udp"}, {"isbconference2", {NULL}, 1245, "tcp"}, {"isbconference2", {NULL}, 1245, "udp"}, {"payrouter", {NULL}, 1246, "tcp"}, {"payrouter", {NULL}, 1246, "udp"}, {"visionpyramid", {NULL}, 1247, "tcp"}, {"visionpyramid", {NULL}, 1247, "udp"}, {"hermes", {NULL}, 1248, "tcp"}, {"hermes", {NULL}, 1248, "udp"}, {"mesavistaco", {NULL}, 1249, "tcp"}, {"mesavistaco", {NULL}, 1249, "udp"}, {"swldy-sias", {NULL}, 1250, "tcp"}, {"swldy-sias", {NULL}, 1250, "udp"}, {"servergraph", {NULL}, 1251, "tcp"}, {"servergraph", {NULL}, 1251, "udp"}, {"bspne-pcc", {NULL}, 1252, "tcp"}, {"bspne-pcc", {NULL}, 1252, "udp"}, {"q55-pcc", {NULL}, 1253, "tcp"}, {"q55-pcc", {NULL}, 1253, "udp"}, {"de-noc", {NULL}, 1254, "tcp"}, {"de-noc", {NULL}, 1254, "udp"}, {"de-cache-query", {NULL}, 1255, "tcp"}, {"de-cache-query", {NULL}, 1255, "udp"}, {"de-server", {NULL}, 1256, "tcp"}, {"de-server", {NULL}, 1256, "udp"}, {"shockwave2", {NULL}, 1257, "tcp"}, {"shockwave2", {NULL}, 1257, "udp"}, {"opennl", {NULL}, 1258, "tcp"}, {"opennl", {NULL}, 1258, "udp"}, {"opennl-voice", {NULL}, 1259, "tcp"}, {"opennl-voice", {NULL}, 1259, "udp"}, {"ibm-ssd", {NULL}, 1260, "tcp"}, {"ibm-ssd", {NULL}, 1260, "udp"}, {"mpshrsv", {NULL}, 1261, "tcp"}, {"mpshrsv", {NULL}, 1261, "udp"}, {"qnts-orb", {NULL}, 1262, "tcp"}, {"qnts-orb", {NULL}, 1262, "udp"}, {"dka", {NULL}, 1263, "tcp"}, {"dka", {NULL}, 1263, "udp"}, {"prat", {NULL}, 1264, "tcp"}, {"prat", {NULL}, 1264, "udp"}, {"dssiapi", {NULL}, 1265, "tcp"}, {"dssiapi", {NULL}, 1265, "udp"}, {"dellpwrappks", {NULL}, 1266, "tcp"}, {"dellpwrappks", {NULL}, 1266, "udp"}, {"epc", {NULL}, 1267, "tcp"}, {"epc", {NULL}, 1267, "udp"}, {"propel-msgsys", {NULL}, 1268, "tcp"}, {"propel-msgsys", {NULL}, 1268, "udp"}, {"watilapp", {NULL}, 1269, "tcp"}, {"watilapp", {NULL}, 1269, "udp"}, {"opsmgr", {NULL}, 1270, "tcp"}, {"opsmgr", {NULL}, 1270, "udp"}, {"excw", {NULL}, 1271, "tcp"}, {"excw", {NULL}, 1271, "udp"}, {"cspmlockmgr", {NULL}, 1272, "tcp"}, {"cspmlockmgr", {NULL}, 1272, "udp"}, {"emc-gateway", {NULL}, 1273, "tcp"}, {"emc-gateway", {NULL}, 1273, "udp"}, {"t1distproc", {NULL}, 1274, "tcp"}, {"t1distproc", {NULL}, 1274, "udp"}, {"ivcollector", {NULL}, 1275, "tcp"}, {"ivcollector", {NULL}, 1275, "udp"}, {"ivmanager", {NULL}, 1276, "tcp"}, {"ivmanager", {NULL}, 1276, "udp"}, {"miva-mqs", {NULL}, 1277, "tcp"}, {"miva-mqs", {NULL}, 1277, "udp"}, {"dellwebadmin-1", {NULL}, 1278, "tcp"}, {"dellwebadmin-1", {NULL}, 1278, "udp"}, {"dellwebadmin-2", {NULL}, 1279, "tcp"}, {"dellwebadmin-2", {NULL}, 1279, "udp"}, {"pictrography", {NULL}, 1280, "tcp"}, {"pictrography", {NULL}, 1280, "udp"}, {"healthd", {NULL}, 1281, "tcp"}, {"healthd", {NULL}, 1281, "udp"}, {"emperion", {NULL}, 1282, "tcp"}, {"emperion", {NULL}, 1282, "udp"}, {"productinfo", {NULL}, 1283, "tcp"}, {"productinfo", {NULL}, 1283, "udp"}, {"iee-qfx", {NULL}, 1284, "tcp"}, {"iee-qfx", {NULL}, 1284, "udp"}, {"neoiface", {NULL}, 1285, "tcp"}, {"neoiface", {NULL}, 1285, "udp"}, {"netuitive", {NULL}, 1286, "tcp"}, {"netuitive", {NULL}, 1286, "udp"}, {"routematch", {NULL}, 1287, "tcp"}, {"routematch", {NULL}, 1287, "udp"}, {"navbuddy", {NULL}, 1288, "tcp"}, {"navbuddy", {NULL}, 1288, "udp"}, {"jwalkserver", {NULL}, 1289, "tcp"}, {"jwalkserver", {NULL}, 1289, "udp"}, {"winjaserver", {NULL}, 1290, "tcp"}, {"winjaserver", {NULL}, 1290, "udp"}, {"seagulllms", {NULL}, 1291, "tcp"}, {"seagulllms", {NULL}, 1291, "udp"}, {"dsdn", {NULL}, 1292, "tcp"}, {"dsdn", {NULL}, 1292, "udp"}, {"pkt-krb-ipsec", {NULL}, 1293, "tcp"}, {"pkt-krb-ipsec", {NULL}, 1293, "udp"}, {"cmmdriver", {NULL}, 1294, "tcp"}, {"cmmdriver", {NULL}, 1294, "udp"}, {"ehtp", {NULL}, 1295, "tcp"}, {"ehtp", {NULL}, 1295, "udp"}, {"dproxy", {NULL}, 1296, "tcp"}, {"dproxy", {NULL}, 1296, "udp"}, {"sdproxy", {NULL}, 1297, "tcp"}, {"sdproxy", {NULL}, 1297, "udp"}, {"lpcp", {NULL}, 1298, "tcp"}, {"lpcp", {NULL}, 1298, "udp"}, {"hp-sci", {NULL}, 1299, "tcp"}, {"hp-sci", {NULL}, 1299, "udp"}, {"h323hostcallsc", {NULL}, 1300, "tcp"}, {"h323hostcallsc", {NULL}, 1300, "udp"}, {"ci3-software-1", {NULL}, 1301, "tcp"}, {"ci3-software-1", {NULL}, 1301, "udp"}, {"ci3-software-2", {NULL}, 1302, "tcp"}, {"ci3-software-2", {NULL}, 1302, "udp"}, {"sftsrv", {NULL}, 1303, "tcp"}, {"sftsrv", {NULL}, 1303, "udp"}, {"boomerang", {NULL}, 1304, "tcp"}, {"boomerang", {NULL}, 1304, "udp"}, {"pe-mike", {NULL}, 1305, "tcp"}, {"pe-mike", {NULL}, 1305, "udp"}, {"re-conn-proto", {NULL}, 1306, "tcp"}, {"re-conn-proto", {NULL}, 1306, "udp"}, {"pacmand", {NULL}, 1307, "tcp"}, {"pacmand", {NULL}, 1307, "udp"}, {"odsi", {NULL}, 1308, "tcp"}, {"odsi", {NULL}, 1308, "udp"}, {"jtag-server", {NULL}, 1309, "tcp"}, {"jtag-server", {NULL}, 1309, "udp"}, {"husky", {NULL}, 1310, "tcp"}, {"husky", {NULL}, 1310, "udp"}, {"rxmon", {NULL}, 1311, "tcp"}, {"rxmon", {NULL}, 1311, "udp"}, {"sti-envision", {NULL}, 1312, "tcp"}, {"sti-envision", {NULL}, 1312, "udp"}, {"bmc_patroldb", {NULL}, 1313, "tcp"}, {"bmc_patroldb", {NULL}, 1313, "udp"}, {"pdps", {NULL}, 1314, "tcp"}, {"pdps", {NULL}, 1314, "udp"}, {"els", {NULL}, 1315, "tcp"}, {"els", {NULL}, 1315, "udp"}, {"exbit-escp", {NULL}, 1316, "tcp"}, {"exbit-escp", {NULL}, 1316, "udp"}, {"vrts-ipcserver", {NULL}, 1317, "tcp"}, {"vrts-ipcserver", {NULL}, 1317, "udp"}, {"krb5gatekeeper", {NULL}, 1318, "tcp"}, {"krb5gatekeeper", {NULL}, 1318, "udp"}, {"amx-icsp", {NULL}, 1319, "tcp"}, {"amx-icsp", {NULL}, 1319, "udp"}, {"amx-axbnet", {NULL}, 1320, "tcp"}, {"amx-axbnet", {NULL}, 1320, "udp"}, {"pip", {NULL}, 1321, "tcp"}, {"pip", {NULL}, 1321, "udp"}, {"novation", {NULL}, 1322, "tcp"}, {"novation", {NULL}, 1322, "udp"}, {"brcd", {NULL}, 1323, "tcp"}, {"brcd", {NULL}, 1323, "udp"}, {"delta-mcp", {NULL}, 1324, "tcp"}, {"delta-mcp", {NULL}, 1324, "udp"}, {"dx-instrument", {NULL}, 1325, "tcp"}, {"dx-instrument", {NULL}, 1325, "udp"}, {"wimsic", {NULL}, 1326, "tcp"}, {"wimsic", {NULL}, 1326, "udp"}, {"ultrex", {NULL}, 1327, "tcp"}, {"ultrex", {NULL}, 1327, "udp"}, {"ewall", {NULL}, 1328, "tcp"}, {"ewall", {NULL}, 1328, "udp"}, {"netdb-export", {NULL}, 1329, "tcp"}, {"netdb-export", {NULL}, 1329, "udp"}, {"streetperfect", {NULL}, 1330, "tcp"}, {"streetperfect", {NULL}, 1330, "udp"}, {"intersan", {NULL}, 1331, "tcp"}, {"intersan", {NULL}, 1331, "udp"}, {"pcia-rxp-b", {NULL}, 1332, "tcp"}, {"pcia-rxp-b", {NULL}, 1332, "udp"}, {"passwrd-policy", {NULL}, 1333, "tcp"}, {"passwrd-policy", {NULL}, 1333, "udp"}, {"writesrv", {NULL}, 1334, "tcp"}, {"writesrv", {NULL}, 1334, "udp"}, {"digital-notary", {NULL}, 1335, "tcp"}, {"digital-notary", {NULL}, 1335, "udp"}, {"ischat", {NULL}, 1336, "tcp"}, {"ischat", {NULL}, 1336, "udp"}, {"menandmice-dns", {NULL}, 1337, "tcp"}, {"menandmice-dns", {NULL}, 1337, "udp"}, {"wmc-log-svc", {NULL}, 1338, "tcp"}, {"wmc-log-svc", {NULL}, 1338, "udp"}, {"kjtsiteserver", {NULL}, 1339, "tcp"}, {"kjtsiteserver", {NULL}, 1339, "udp"}, {"naap", {NULL}, 1340, "tcp"}, {"naap", {NULL}, 1340, "udp"}, {"qubes", {NULL}, 1341, "tcp"}, {"qubes", {NULL}, 1341, "udp"}, {"esbroker", {NULL}, 1342, "tcp"}, {"esbroker", {NULL}, 1342, "udp"}, {"re101", {NULL}, 1343, "tcp"}, {"re101", {NULL}, 1343, "udp"}, {"icap", {NULL}, 1344, "tcp"}, {"icap", {NULL}, 1344, "udp"}, {"vpjp", {NULL}, 1345, "tcp"}, {"vpjp", {NULL}, 1345, "udp"}, {"alta-ana-lm", {NULL}, 1346, "tcp"}, {"alta-ana-lm", {NULL}, 1346, "udp"}, {"bbn-mmc", {NULL}, 1347, "tcp"}, {"bbn-mmc", {NULL}, 1347, "udp"}, {"bbn-mmx", {NULL}, 1348, "tcp"}, {"bbn-mmx", {NULL}, 1348, "udp"}, {"sbook", {NULL}, 1349, "tcp"}, {"sbook", {NULL}, 1349, "udp"}, {"editbench", {NULL}, 1350, "tcp"}, {"editbench", {NULL}, 1350, "udp"}, {"equationbuilder", {NULL}, 1351, "tcp"}, {"equationbuilder", {NULL}, 1351, "udp"}, {"lotusnote", {NULL}, 1352, "tcp"}, {"lotusnote", {NULL}, 1352, "udp"}, {"relief", {NULL}, 1353, "tcp"}, {"relief", {NULL}, 1353, "udp"}, {"XSIP-network", {NULL}, 1354, "tcp"}, {"XSIP-network", {NULL}, 1354, "udp"}, {"intuitive-edge", {NULL}, 1355, "tcp"}, {"intuitive-edge", {NULL}, 1355, "udp"}, {"cuillamartin", {NULL}, 1356, "tcp"}, {"cuillamartin", {NULL}, 1356, "udp"}, {"pegboard", {NULL}, 1357, "tcp"}, {"pegboard", {NULL}, 1357, "udp"}, {"connlcli", {NULL}, 1358, "tcp"}, {"connlcli", {NULL}, 1358, "udp"}, {"ftsrv", {NULL}, 1359, "tcp"}, {"ftsrv", {NULL}, 1359, "udp"}, {"mimer", {NULL}, 1360, "tcp"}, {"mimer", {NULL}, 1360, "udp"}, {"linx", {NULL}, 1361, "tcp"}, {"linx", {NULL}, 1361, "udp"}, {"timeflies", {NULL}, 1362, "tcp"}, {"timeflies", {NULL}, 1362, "udp"}, {"ndm-requester", {NULL}, 1363, "tcp"}, {"ndm-requester", {NULL}, 1363, "udp"}, {"ndm-server", {NULL}, 1364, "tcp"}, {"ndm-server", {NULL}, 1364, "udp"}, {"adapt-sna", {NULL}, 1365, "tcp"}, {"adapt-sna", {NULL}, 1365, "udp"}, {"netware-csp", {NULL}, 1366, "tcp"}, {"netware-csp", {NULL}, 1366, "udp"}, {"dcs", {NULL}, 1367, "tcp"}, {"dcs", {NULL}, 1367, "udp"}, {"screencast", {NULL}, 1368, "tcp"}, {"screencast", {NULL}, 1368, "udp"}, {"gv-us", {NULL}, 1369, "tcp"}, {"gv-us", {NULL}, 1369, "udp"}, {"us-gv", {NULL}, 1370, "tcp"}, {"us-gv", {NULL}, 1370, "udp"}, {"fc-cli", {NULL}, 1371, "tcp"}, {"fc-cli", {NULL}, 1371, "udp"}, {"fc-ser", {NULL}, 1372, "tcp"}, {"fc-ser", {NULL}, 1372, "udp"}, {"chromagrafx", {NULL}, 1373, "tcp"}, {"chromagrafx", {NULL}, 1373, "udp"}, {"molly", {NULL}, 1374, "tcp"}, {"molly", {NULL}, 1374, "udp"}, {"bytex", {NULL}, 1375, "tcp"}, {"bytex", {NULL}, 1375, "udp"}, {"ibm-pps", {NULL}, 1376, "tcp"}, {"ibm-pps", {NULL}, 1376, "udp"}, {"cichlid", {NULL}, 1377, "tcp"}, {"cichlid", {NULL}, 1377, "udp"}, {"elan", {NULL}, 1378, "tcp"}, {"elan", {NULL}, 1378, "udp"}, {"dbreporter", {NULL}, 1379, "tcp"}, {"dbreporter", {NULL}, 1379, "udp"}, {"telesis-licman", {NULL}, 1380, "tcp"}, {"telesis-licman", {NULL}, 1380, "udp"}, {"apple-licman", {NULL}, 1381, "tcp"}, {"apple-licman", {NULL}, 1381, "udp"}, {"udt_os", {NULL}, 1382, "tcp"}, {"udt_os", {NULL}, 1382, "udp"}, {"gwha", {NULL}, 1383, "tcp"}, {"gwha", {NULL}, 1383, "udp"}, {"os-licman", {NULL}, 1384, "tcp"}, {"os-licman", {NULL}, 1384, "udp"}, {"atex_elmd", {NULL}, 1385, "tcp"}, {"atex_elmd", {NULL}, 1385, "udp"}, {"checksum", {NULL}, 1386, "tcp"}, {"checksum", {NULL}, 1386, "udp"}, {"cadsi-lm", {NULL}, 1387, "tcp"}, {"cadsi-lm", {NULL}, 1387, "udp"}, {"objective-dbc", {NULL}, 1388, "tcp"}, {"objective-dbc", {NULL}, 1388, "udp"}, {"iclpv-dm", {NULL}, 1389, "tcp"}, {"iclpv-dm", {NULL}, 1389, "udp"}, {"iclpv-sc", {NULL}, 1390, "tcp"}, {"iclpv-sc", {NULL}, 1390, "udp"}, {"iclpv-sas", {NULL}, 1391, "tcp"}, {"iclpv-sas", {NULL}, 1391, "udp"}, {"iclpv-pm", {NULL}, 1392, "tcp"}, {"iclpv-pm", {NULL}, 1392, "udp"}, {"iclpv-nls", {NULL}, 1393, "tcp"}, {"iclpv-nls", {NULL}, 1393, "udp"}, {"iclpv-nlc", {NULL}, 1394, "tcp"}, {"iclpv-nlc", {NULL}, 1394, "udp"}, {"iclpv-wsm", {NULL}, 1395, "tcp"}, {"iclpv-wsm", {NULL}, 1395, "udp"}, {"dvl-activemail", {NULL}, 1396, "tcp"}, {"dvl-activemail", {NULL}, 1396, "udp"}, {"audio-activmail", {NULL}, 1397, "tcp"}, {"audio-activmail", {NULL}, 1397, "udp"}, {"video-activmail", {NULL}, 1398, "tcp"}, {"video-activmail", {NULL}, 1398, "udp"}, {"cadkey-licman", {NULL}, 1399, "tcp"}, {"cadkey-licman", {NULL}, 1399, "udp"}, {"cadkey-tablet", {NULL}, 1400, "tcp"}, {"cadkey-tablet", {NULL}, 1400, "udp"}, {"goldleaf-licman", {NULL}, 1401, "tcp"}, {"goldleaf-licman", {NULL}, 1401, "udp"}, {"prm-sm-np", {NULL}, 1402, "tcp"}, {"prm-sm-np", {NULL}, 1402, "udp"}, {"prm-nm-np", {NULL}, 1403, "tcp"}, {"prm-nm-np", {NULL}, 1403, "udp"}, {"igi-lm", {NULL}, 1404, "tcp"}, {"igi-lm", {NULL}, 1404, "udp"}, {"ibm-res", {NULL}, 1405, "tcp"}, {"ibm-res", {NULL}, 1405, "udp"}, {"netlabs-lm", {NULL}, 1406, "tcp"}, {"netlabs-lm", {NULL}, 1406, "udp"}, {"dbsa-lm", {NULL}, 1407, "tcp"}, {"dbsa-lm", {NULL}, 1407, "udp"}, {"sophia-lm", {NULL}, 1408, "tcp"}, {"sophia-lm", {NULL}, 1408, "udp"}, {"here-lm", {NULL}, 1409, "tcp"}, {"here-lm", {NULL}, 1409, "udp"}, {"hiq", {NULL}, 1410, "tcp"}, {"hiq", {NULL}, 1410, "udp"}, {"af", {NULL}, 1411, "tcp"}, {"af", {NULL}, 1411, "udp"}, {"innosys", {NULL}, 1412, "tcp"}, {"innosys", {NULL}, 1412, "udp"}, {"innosys-acl", {NULL}, 1413, "tcp"}, {"innosys-acl", {NULL}, 1413, "udp"}, {"ibm-mqseries", {NULL}, 1414, "tcp"}, {"ibm-mqseries", {NULL}, 1414, "udp"}, {"dbstar", {NULL}, 1415, "tcp"}, {"dbstar", {NULL}, 1415, "udp"}, {"novell-lu6.2", {NULL}, 1416, "tcp"}, {"novell-lu6.2", {NULL}, 1416, "udp"}, {"timbuktu-srv1", {NULL}, 1417, "tcp"}, {"timbuktu-srv1", {NULL}, 1417, "udp"}, {"timbuktu-srv2", {NULL}, 1418, "tcp"}, {"timbuktu-srv2", {NULL}, 1418, "udp"}, {"timbuktu-srv3", {NULL}, 1419, "tcp"}, {"timbuktu-srv3", {NULL}, 1419, "udp"}, {"timbuktu-srv4", {NULL}, 1420, "tcp"}, {"timbuktu-srv4", {NULL}, 1420, "udp"}, {"gandalf-lm", {NULL}, 1421, "tcp"}, {"gandalf-lm", {NULL}, 1421, "udp"}, {"autodesk-lm", {NULL}, 1422, "tcp"}, {"autodesk-lm", {NULL}, 1422, "udp"}, {"essbase", {NULL}, 1423, "tcp"}, {"essbase", {NULL}, 1423, "udp"}, {"hybrid", {NULL}, 1424, "tcp"}, {"hybrid", {NULL}, 1424, "udp"}, {"zion-lm", {NULL}, 1425, "tcp"}, {"zion-lm", {NULL}, 1425, "udp"}, {"sais", {NULL}, 1426, "tcp"}, {"sais", {NULL}, 1426, "udp"}, {"mloadd", {NULL}, 1427, "tcp"}, {"mloadd", {NULL}, 1427, "udp"}, {"informatik-lm", {NULL}, 1428, "tcp"}, {"informatik-lm", {NULL}, 1428, "udp"}, {"nms", {NULL}, 1429, "tcp"}, {"nms", {NULL}, 1429, "udp"}, {"tpdu", {NULL}, 1430, "tcp"}, {"tpdu", {NULL}, 1430, "udp"}, {"rgtp", {NULL}, 1431, "tcp"}, {"rgtp", {NULL}, 1431, "udp"}, {"blueberry-lm", {NULL}, 1432, "tcp"}, {"blueberry-lm", {NULL}, 1432, "udp"}, {"ms-sql-s", {NULL}, 1433, "tcp"}, {"ms-sql-s", {NULL}, 1433, "udp"}, {"ms-sql-m", {NULL}, 1434, "tcp"}, {"ms-sql-m", {NULL}, 1434, "udp"}, {"ibm-cics", {NULL}, 1435, "tcp"}, {"ibm-cics", {NULL}, 1435, "udp"}, {"saism", {NULL}, 1436, "tcp"}, {"saism", {NULL}, 1436, "udp"}, {"tabula", {NULL}, 1437, "tcp"}, {"tabula", {NULL}, 1437, "udp"}, {"eicon-server", {NULL}, 1438, "tcp"}, {"eicon-server", {NULL}, 1438, "udp"}, {"eicon-x25", {NULL}, 1439, "tcp"}, {"eicon-x25", {NULL}, 1439, "udp"}, {"eicon-slp", {NULL}, 1440, "tcp"}, {"eicon-slp", {NULL}, 1440, "udp"}, {"cadis-1", {NULL}, 1441, "tcp"}, {"cadis-1", {NULL}, 1441, "udp"}, {"cadis-2", {NULL}, 1442, "tcp"}, {"cadis-2", {NULL}, 1442, "udp"}, {"ies-lm", {NULL}, 1443, "tcp"}, {"ies-lm", {NULL}, 1443, "udp"}, {"marcam-lm", {NULL}, 1444, "tcp"}, {"marcam-lm", {NULL}, 1444, "udp"}, {"proxima-lm", {NULL}, 1445, "tcp"}, {"proxima-lm", {NULL}, 1445, "udp"}, {"ora-lm", {NULL}, 1446, "tcp"}, {"ora-lm", {NULL}, 1446, "udp"}, {"apri-lm", {NULL}, 1447, "tcp"}, {"apri-lm", {NULL}, 1447, "udp"}, {"oc-lm", {NULL}, 1448, "tcp"}, {"oc-lm", {NULL}, 1448, "udp"}, {"peport", {NULL}, 1449, "tcp"}, {"peport", {NULL}, 1449, "udp"}, {"dwf", {NULL}, 1450, "tcp"}, {"dwf", {NULL}, 1450, "udp"}, {"infoman", {NULL}, 1451, "tcp"}, {"infoman", {NULL}, 1451, "udp"}, {"gtegsc-lm", {NULL}, 1452, "tcp"}, {"gtegsc-lm", {NULL}, 1452, "udp"}, {"genie-lm", {NULL}, 1453, "tcp"}, {"genie-lm", {NULL}, 1453, "udp"}, {"interhdl_elmd", {NULL}, 1454, "tcp"}, {"interhdl_elmd", {NULL}, 1454, "udp"}, {"esl-lm", {NULL}, 1455, "tcp"}, {"esl-lm", {NULL}, 1455, "udp"}, {"dca", {NULL}, 1456, "tcp"}, {"dca", {NULL}, 1456, "udp"}, {"valisys-lm", {NULL}, 1457, "tcp"}, {"valisys-lm", {NULL}, 1457, "udp"}, {"nrcabq-lm", {NULL}, 1458, "tcp"}, {"nrcabq-lm", {NULL}, 1458, "udp"}, {"proshare1", {NULL}, 1459, "tcp"}, {"proshare1", {NULL}, 1459, "udp"}, {"proshare2", {NULL}, 1460, "tcp"}, {"proshare2", {NULL}, 1460, "udp"}, {"ibm_wrless_lan", {NULL}, 1461, "tcp"}, {"ibm_wrless_lan", {NULL}, 1461, "udp"}, {"world-lm", {NULL}, 1462, "tcp"}, {"world-lm", {NULL}, 1462, "udp"}, {"nucleus", {NULL}, 1463, "tcp"}, {"nucleus", {NULL}, 1463, "udp"}, {"msl_lmd", {NULL}, 1464, "tcp"}, {"msl_lmd", {NULL}, 1464, "udp"}, {"pipes", {NULL}, 1465, "tcp"}, {"pipes", {NULL}, 1465, "udp"}, {"oceansoft-lm", {NULL}, 1466, "tcp"}, {"oceansoft-lm", {NULL}, 1466, "udp"}, {"csdmbase", {NULL}, 1467, "tcp"}, {"csdmbase", {NULL}, 1467, "udp"}, {"csdm", {NULL}, 1468, "tcp"}, {"csdm", {NULL}, 1468, "udp"}, {"aal-lm", {NULL}, 1469, "tcp"}, {"aal-lm", {NULL}, 1469, "udp"}, {"uaiact", {NULL}, 1470, "tcp"}, {"uaiact", {NULL}, 1470, "udp"}, {"csdmbase", {NULL}, 1471, "tcp"}, {"csdmbase", {NULL}, 1471, "udp"}, {"csdm", {NULL}, 1472, "tcp"}, {"csdm", {NULL}, 1472, "udp"}, {"openmath", {NULL}, 1473, "tcp"}, {"openmath", {NULL}, 1473, "udp"}, {"telefinder", {NULL}, 1474, "tcp"}, {"telefinder", {NULL}, 1474, "udp"}, {"taligent-lm", {NULL}, 1475, "tcp"}, {"taligent-lm", {NULL}, 1475, "udp"}, {"clvm-cfg", {NULL}, 1476, "tcp"}, {"clvm-cfg", {NULL}, 1476, "udp"}, {"ms-sna-server", {NULL}, 1477, "tcp"}, {"ms-sna-server", {NULL}, 1477, "udp"}, {"ms-sna-base", {NULL}, 1478, "tcp"}, {"ms-sna-base", {NULL}, 1478, "udp"}, {"dberegister", {NULL}, 1479, "tcp"}, {"dberegister", {NULL}, 1479, "udp"}, {"pacerforum", {NULL}, 1480, "tcp"}, {"pacerforum", {NULL}, 1480, "udp"}, {"airs", {NULL}, 1481, "tcp"}, {"airs", {NULL}, 1481, "udp"}, {"miteksys-lm", {NULL}, 1482, "tcp"}, {"miteksys-lm", {NULL}, 1482, "udp"}, {"afs", {NULL}, 1483, "tcp"}, {"afs", {NULL}, 1483, "udp"}, {"confluent", {NULL}, 1484, "tcp"}, {"confluent", {NULL}, 1484, "udp"}, {"lansource", {NULL}, 1485, "tcp"}, {"lansource", {NULL}, 1485, "udp"}, {"nms_topo_serv", {NULL}, 1486, "tcp"}, {"nms_topo_serv", {NULL}, 1486, "udp"}, {"localinfosrvr", {NULL}, 1487, "tcp"}, {"localinfosrvr", {NULL}, 1487, "udp"}, {"docstor", {NULL}, 1488, "tcp"}, {"docstor", {NULL}, 1488, "udp"}, {"dmdocbroker", {NULL}, 1489, "tcp"}, {"dmdocbroker", {NULL}, 1489, "udp"}, {"insitu-conf", {NULL}, 1490, "tcp"}, {"insitu-conf", {NULL}, 1490, "udp"}, {"stone-design-1", {NULL}, 1492, "tcp"}, {"stone-design-1", {NULL}, 1492, "udp"}, {"netmap_lm", {NULL}, 1493, "tcp"}, {"netmap_lm", {NULL}, 1493, "udp"}, {"ica", {NULL}, 1494, "tcp"}, {"ica", {NULL}, 1494, "udp"}, {"cvc", {NULL}, 1495, "tcp"}, {"cvc", {NULL}, 1495, "udp"}, {"liberty-lm", {NULL}, 1496, "tcp"}, {"liberty-lm", {NULL}, 1496, "udp"}, {"rfx-lm", {NULL}, 1497, "tcp"}, {"rfx-lm", {NULL}, 1497, "udp"}, {"sybase-sqlany", {NULL}, 1498, "tcp"}, {"sybase-sqlany", {NULL}, 1498, "udp"}, {"fhc", {NULL}, 1499, "tcp"}, {"fhc", {NULL}, 1499, "udp"}, {"vlsi-lm", {NULL}, 1500, "tcp"}, {"vlsi-lm", {NULL}, 1500, "udp"}, {"saiscm", {NULL}, 1501, "tcp"}, {"saiscm", {NULL}, 1501, "udp"}, {"shivadiscovery", {NULL}, 1502, "tcp"}, {"shivadiscovery", {NULL}, 1502, "udp"}, {"imtc-mcs", {NULL}, 1503, "tcp"}, {"imtc-mcs", {NULL}, 1503, "udp"}, {"evb-elm", {NULL}, 1504, "tcp"}, {"evb-elm", {NULL}, 1504, "udp"}, {"funkproxy", {NULL}, 1505, "tcp"}, {"funkproxy", {NULL}, 1505, "udp"}, {"utcd", {NULL}, 1506, "tcp"}, {"utcd", {NULL}, 1506, "udp"}, {"symplex", {NULL}, 1507, "tcp"}, {"symplex", {NULL}, 1507, "udp"}, {"diagmond", {NULL}, 1508, "tcp"}, {"diagmond", {NULL}, 1508, "udp"}, {"robcad-lm", {NULL}, 1509, "tcp"}, {"robcad-lm", {NULL}, 1509, "udp"}, {"mvx-lm", {NULL}, 1510, "tcp"}, {"mvx-lm", {NULL}, 1510, "udp"}, {"3l-l1", {NULL}, 1511, "tcp"}, {"3l-l1", {NULL}, 1511, "udp"}, {"wins", {NULL}, 1512, "tcp"}, {"wins", {NULL}, 1512, "udp"}, {"fujitsu-dtc", {NULL}, 1513, "tcp"}, {"fujitsu-dtc", {NULL}, 1513, "udp"}, {"fujitsu-dtcns", {NULL}, 1514, "tcp"}, {"fujitsu-dtcns", {NULL}, 1514, "udp"}, {"ifor-protocol", {NULL}, 1515, "tcp"}, {"ifor-protocol", {NULL}, 1515, "udp"}, {"vpad", {NULL}, 1516, "tcp"}, {"vpad", {NULL}, 1516, "udp"}, {"vpac", {NULL}, 1517, "tcp"}, {"vpac", {NULL}, 1517, "udp"}, {"vpvd", {NULL}, 1518, "tcp"}, {"vpvd", {NULL}, 1518, "udp"}, {"vpvc", {NULL}, 1519, "tcp"}, {"vpvc", {NULL}, 1519, "udp"}, {"atm-zip-office", {NULL}, 1520, "tcp"}, {"atm-zip-office", {NULL}, 1520, "udp"}, {"ncube-lm", {NULL}, 1521, "tcp"}, {"ncube-lm", {NULL}, 1521, "udp"}, {"ricardo-lm", {NULL}, 1522, "tcp"}, {"ricardo-lm", {NULL}, 1522, "udp"}, {"cichild-lm", {NULL}, 1523, "tcp"}, {"cichild-lm", {NULL}, 1523, "udp"}, {"ingreslock", {NULL}, 1524, "tcp"}, {"ingreslock", {NULL}, 1524, "udp"}, {"orasrv", {NULL}, 1525, "tcp"}, {"orasrv", {NULL}, 1525, "udp"}, {"prospero-np", {NULL}, 1525, "tcp"}, {"prospero-np", {NULL}, 1525, "udp"}, {"pdap-np", {NULL}, 1526, "tcp"}, {"pdap-np", {NULL}, 1526, "udp"}, {"tlisrv", {NULL}, 1527, "tcp"}, {"tlisrv", {NULL}, 1527, "udp"}, {"coauthor", {NULL}, 1529, "tcp"}, {"coauthor", {NULL}, 1529, "udp"}, {"rap-service", {NULL}, 1530, "tcp"}, {"rap-service", {NULL}, 1530, "udp"}, {"rap-listen", {NULL}, 1531, "tcp"}, {"rap-listen", {NULL}, 1531, "udp"}, {"miroconnect", {NULL}, 1532, "tcp"}, {"miroconnect", {NULL}, 1532, "udp"}, {"virtual-places", {NULL}, 1533, "tcp"}, {"virtual-places", {NULL}, 1533, "udp"}, {"micromuse-lm", {NULL}, 1534, "tcp"}, {"micromuse-lm", {NULL}, 1534, "udp"}, {"ampr-info", {NULL}, 1535, "tcp"}, {"ampr-info", {NULL}, 1535, "udp"}, {"ampr-inter", {NULL}, 1536, "tcp"}, {"ampr-inter", {NULL}, 1536, "udp"}, {"sdsc-lm", {NULL}, 1537, "tcp"}, {"sdsc-lm", {NULL}, 1537, "udp"}, {"3ds-lm", {NULL}, 1538, "tcp"}, {"3ds-lm", {NULL}, 1538, "udp"}, {"intellistor-lm", {NULL}, 1539, "tcp"}, {"intellistor-lm", {NULL}, 1539, "udp"}, {"rds", {NULL}, 1540, "tcp"}, {"rds", {NULL}, 1540, "udp"}, {"rds2", {NULL}, 1541, "tcp"}, {"rds2", {NULL}, 1541, "udp"}, {"gridgen-elmd", {NULL}, 1542, "tcp"}, {"gridgen-elmd", {NULL}, 1542, "udp"}, {"simba-cs", {NULL}, 1543, "tcp"}, {"simba-cs", {NULL}, 1543, "udp"}, {"aspeclmd", {NULL}, 1544, "tcp"}, {"aspeclmd", {NULL}, 1544, "udp"}, {"vistium-share", {NULL}, 1545, "tcp"}, {"vistium-share", {NULL}, 1545, "udp"}, {"abbaccuray", {NULL}, 1546, "tcp"}, {"abbaccuray", {NULL}, 1546, "udp"}, {"laplink", {NULL}, 1547, "tcp"}, {"laplink", {NULL}, 1547, "udp"}, {"axon-lm", {NULL}, 1548, "tcp"}, {"axon-lm", {NULL}, 1548, "udp"}, {"shivahose", {NULL}, 1549, "tcp"}, {"shivasound", {NULL}, 1549, "udp"}, {"3m-image-lm", {NULL}, 1550, "tcp"}, {"3m-image-lm", {NULL}, 1550, "udp"}, {"hecmtl-db", {NULL}, 1551, "tcp"}, {"hecmtl-db", {NULL}, 1551, "udp"}, {"pciarray", {NULL}, 1552, "tcp"}, {"pciarray", {NULL}, 1552, "udp"}, {"sna-cs", {NULL}, 1553, "tcp"}, {"sna-cs", {NULL}, 1553, "udp"}, {"caci-lm", {NULL}, 1554, "tcp"}, {"caci-lm", {NULL}, 1554, "udp"}, {"livelan", {NULL}, 1555, "tcp"}, {"livelan", {NULL}, 1555, "udp"}, {"veritas_pbx", {NULL}, 1556, "tcp"}, {"veritas_pbx", {NULL}, 1556, "udp"}, {"arbortext-lm", {NULL}, 1557, "tcp"}, {"arbortext-lm", {NULL}, 1557, "udp"}, {"xingmpeg", {NULL}, 1558, "tcp"}, {"xingmpeg", {NULL}, 1558, "udp"}, {"web2host", {NULL}, 1559, "tcp"}, {"web2host", {NULL}, 1559, "udp"}, {"asci-val", {NULL}, 1560, "tcp"}, {"asci-val", {NULL}, 1560, "udp"}, {"facilityview", {NULL}, 1561, "tcp"}, {"facilityview", {NULL}, 1561, "udp"}, {"pconnectmgr", {NULL}, 1562, "tcp"}, {"pconnectmgr", {NULL}, 1562, "udp"}, {"cadabra-lm", {NULL}, 1563, "tcp"}, {"cadabra-lm", {NULL}, 1563, "udp"}, {"pay-per-view", {NULL}, 1564, "tcp"}, {"pay-per-view", {NULL}, 1564, "udp"}, {"winddlb", {NULL}, 1565, "tcp"}, {"winddlb", {NULL}, 1565, "udp"}, {"corelvideo", {NULL}, 1566, "tcp"}, {"corelvideo", {NULL}, 1566, "udp"}, {"jlicelmd", {NULL}, 1567, "tcp"}, {"jlicelmd", {NULL}, 1567, "udp"}, {"tsspmap", {NULL}, 1568, "tcp"}, {"tsspmap", {NULL}, 1568, "udp"}, {"ets", {NULL}, 1569, "tcp"}, {"ets", {NULL}, 1569, "udp"}, {"orbixd", {NULL}, 1570, "tcp"}, {"orbixd", {NULL}, 1570, "udp"}, {"rdb-dbs-disp", {NULL}, 1571, "tcp"}, {"rdb-dbs-disp", {NULL}, 1571, "udp"}, {"chip-lm", {NULL}, 1572, "tcp"}, {"chip-lm", {NULL}, 1572, "udp"}, {"itscomm-ns", {NULL}, 1573, "tcp"}, {"itscomm-ns", {NULL}, 1573, "udp"}, {"mvel-lm", {NULL}, 1574, "tcp"}, {"mvel-lm", {NULL}, 1574, "udp"}, {"oraclenames", {NULL}, 1575, "tcp"}, {"oraclenames", {NULL}, 1575, "udp"}, {"moldflow-lm", {NULL}, 1576, "tcp"}, {"moldflow-lm", {NULL}, 1576, "udp"}, {"hypercube-lm", {NULL}, 1577, "tcp"}, {"hypercube-lm", {NULL}, 1577, "udp"}, {"jacobus-lm", {NULL}, 1578, "tcp"}, {"jacobus-lm", {NULL}, 1578, "udp"}, {"ioc-sea-lm", {NULL}, 1579, "tcp"}, {"ioc-sea-lm", {NULL}, 1579, "udp"}, {"tn-tl-r1", {NULL}, 1580, "tcp"}, {"tn-tl-r2", {NULL}, 1580, "udp"}, {"mil-2045-47001", {NULL}, 1581, "tcp"}, {"mil-2045-47001", {NULL}, 1581, "udp"}, {"msims", {NULL}, 1582, "tcp"}, {"msims", {NULL}, 1582, "udp"}, {"simbaexpress", {NULL}, 1583, "tcp"}, {"simbaexpress", {NULL}, 1583, "udp"}, {"tn-tl-fd2", {NULL}, 1584, "tcp"}, {"tn-tl-fd2", {NULL}, 1584, "udp"}, {"intv", {NULL}, 1585, "tcp"}, {"intv", {NULL}, 1585, "udp"}, {"ibm-abtact", {NULL}, 1586, "tcp"}, {"ibm-abtact", {NULL}, 1586, "udp"}, {"pra_elmd", {NULL}, 1587, "tcp"}, {"pra_elmd", {NULL}, 1587, "udp"}, {"triquest-lm", {NULL}, 1588, "tcp"}, {"triquest-lm", {NULL}, 1588, "udp"}, {"vqp", {NULL}, 1589, "tcp"}, {"vqp", {NULL}, 1589, "udp"}, {"gemini-lm", {NULL}, 1590, "tcp"}, {"gemini-lm", {NULL}, 1590, "udp"}, {"ncpm-pm", {NULL}, 1591, "tcp"}, {"ncpm-pm", {NULL}, 1591, "udp"}, {"commonspace", {NULL}, 1592, "tcp"}, {"commonspace", {NULL}, 1592, "udp"}, {"mainsoft-lm", {NULL}, 1593, "tcp"}, {"mainsoft-lm", {NULL}, 1593, "udp"}, {"sixtrak", {NULL}, 1594, "tcp"}, {"sixtrak", {NULL}, 1594, "udp"}, {"radio", {NULL}, 1595, "tcp"}, {"radio", {NULL}, 1595, "udp"}, {"radio-sm", {NULL}, 1596, "tcp"}, {"radio-bc", {NULL}, 1596, "udp"}, {"orbplus-iiop", {NULL}, 1597, "tcp"}, {"orbplus-iiop", {NULL}, 1597, "udp"}, {"picknfs", {NULL}, 1598, "tcp"}, {"picknfs", {NULL}, 1598, "udp"}, {"simbaservices", {NULL}, 1599, "tcp"}, {"simbaservices", {NULL}, 1599, "udp"}, {"issd", {NULL}, 1600, "tcp"}, {"issd", {NULL}, 1600, "udp"}, {"aas", {NULL}, 1601, "tcp"}, {"aas", {NULL}, 1601, "udp"}, {"inspect", {NULL}, 1602, "tcp"}, {"inspect", {NULL}, 1602, "udp"}, {"picodbc", {NULL}, 1603, "tcp"}, {"picodbc", {NULL}, 1603, "udp"}, {"icabrowser", {NULL}, 1604, "tcp"}, {"icabrowser", {NULL}, 1604, "udp"}, {"slp", {NULL}, 1605, "tcp"}, {"slp", {NULL}, 1605, "udp"}, {"slm-api", {NULL}, 1606, "tcp"}, {"slm-api", {NULL}, 1606, "udp"}, {"stt", {NULL}, 1607, "tcp"}, {"stt", {NULL}, 1607, "udp"}, {"smart-lm", {NULL}, 1608, "tcp"}, {"smart-lm", {NULL}, 1608, "udp"}, {"isysg-lm", {NULL}, 1609, "tcp"}, {"isysg-lm", {NULL}, 1609, "udp"}, {"taurus-wh", {NULL}, 1610, "tcp"}, {"taurus-wh", {NULL}, 1610, "udp"}, {"ill", {NULL}, 1611, "tcp"}, {"ill", {NULL}, 1611, "udp"}, {"netbill-trans", {NULL}, 1612, "tcp"}, {"netbill-trans", {NULL}, 1612, "udp"}, {"netbill-keyrep", {NULL}, 1613, "tcp"}, {"netbill-keyrep", {NULL}, 1613, "udp"}, {"netbill-cred", {NULL}, 1614, "tcp"}, {"netbill-cred", {NULL}, 1614, "udp"}, {"netbill-auth", {NULL}, 1615, "tcp"}, {"netbill-auth", {NULL}, 1615, "udp"}, {"netbill-prod", {NULL}, 1616, "tcp"}, {"netbill-prod", {NULL}, 1616, "udp"}, {"nimrod-agent", {NULL}, 1617, "tcp"}, {"nimrod-agent", {NULL}, 1617, "udp"}, {"skytelnet", {NULL}, 1618, "tcp"}, {"skytelnet", {NULL}, 1618, "udp"}, {"xs-openstorage", {NULL}, 1619, "tcp"}, {"xs-openstorage", {NULL}, 1619, "udp"}, {"faxportwinport", {NULL}, 1620, "tcp"}, {"faxportwinport", {NULL}, 1620, "udp"}, {"softdataphone", {NULL}, 1621, "tcp"}, {"softdataphone", {NULL}, 1621, "udp"}, {"ontime", {NULL}, 1622, "tcp"}, {"ontime", {NULL}, 1622, "udp"}, {"jaleosnd", {NULL}, 1623, "tcp"}, {"jaleosnd", {NULL}, 1623, "udp"}, {"udp-sr-port", {NULL}, 1624, "tcp"}, {"udp-sr-port", {NULL}, 1624, "udp"}, {"svs-omagent", {NULL}, 1625, "tcp"}, {"svs-omagent", {NULL}, 1625, "udp"}, {"shockwave", {NULL}, 1626, "tcp"}, {"shockwave", {NULL}, 1626, "udp"}, {"t128-gateway", {NULL}, 1627, "tcp"}, {"t128-gateway", {NULL}, 1627, "udp"}, {"lontalk-norm", {NULL}, 1628, "tcp"}, {"lontalk-norm", {NULL}, 1628, "udp"}, {"lontalk-urgnt", {NULL}, 1629, "tcp"}, {"lontalk-urgnt", {NULL}, 1629, "udp"}, {"oraclenet8cman", {NULL}, 1630, "tcp"}, {"oraclenet8cman", {NULL}, 1630, "udp"}, {"visitview", {NULL}, 1631, "tcp"}, {"visitview", {NULL}, 1631, "udp"}, {"pammratc", {NULL}, 1632, "tcp"}, {"pammratc", {NULL}, 1632, "udp"}, {"pammrpc", {NULL}, 1633, "tcp"}, {"pammrpc", {NULL}, 1633, "udp"}, {"loaprobe", {NULL}, 1634, "tcp"}, {"loaprobe", {NULL}, 1634, "udp"}, {"edb-server1", {NULL}, 1635, "tcp"}, {"edb-server1", {NULL}, 1635, "udp"}, {"isdc", {NULL}, 1636, "tcp"}, {"isdc", {NULL}, 1636, "udp"}, {"islc", {NULL}, 1637, "tcp"}, {"islc", {NULL}, 1637, "udp"}, {"ismc", {NULL}, 1638, "tcp"}, {"ismc", {NULL}, 1638, "udp"}, {"cert-initiator", {NULL}, 1639, "tcp"}, {"cert-initiator", {NULL}, 1639, "udp"}, {"cert-responder", {NULL}, 1640, "tcp"}, {"cert-responder", {NULL}, 1640, "udp"}, {"invision", {NULL}, 1641, "tcp"}, {"invision", {NULL}, 1641, "udp"}, {"isis-am", {NULL}, 1642, "tcp"}, {"isis-am", {NULL}, 1642, "udp"}, {"isis-ambc", {NULL}, 1643, "tcp"}, {"isis-ambc", {NULL}, 1643, "udp"}, {"saiseh", {NULL}, 1644, "tcp"}, {"sightline", {NULL}, 1645, "tcp"}, {"sightline", {NULL}, 1645, "udp"}, {"sa-msg-port", {NULL}, 1646, "tcp"}, {"sa-msg-port", {NULL}, 1646, "udp"}, {"rsap", {NULL}, 1647, "tcp"}, {"rsap", {NULL}, 1647, "udp"}, {"concurrent-lm", {NULL}, 1648, "tcp"}, {"concurrent-lm", {NULL}, 1648, "udp"}, {"kermit", {NULL}, 1649, "tcp"}, {"kermit", {NULL}, 1649, "udp"}, {"nkd", {NULL}, 1650, "tcp"}, {"nkd", {NULL}, 1650, "udp"}, {"shiva_confsrvr", {NULL}, 1651, "tcp"}, {"shiva_confsrvr", {NULL}, 1651, "udp"}, {"xnmp", {NULL}, 1652, "tcp"}, {"xnmp", {NULL}, 1652, "udp"}, {"alphatech-lm", {NULL}, 1653, "tcp"}, {"alphatech-lm", {NULL}, 1653, "udp"}, {"stargatealerts", {NULL}, 1654, "tcp"}, {"stargatealerts", {NULL}, 1654, "udp"}, {"dec-mbadmin", {NULL}, 1655, "tcp"}, {"dec-mbadmin", {NULL}, 1655, "udp"}, {"dec-mbadmin-h", {NULL}, 1656, "tcp"}, {"dec-mbadmin-h", {NULL}, 1656, "udp"}, {"fujitsu-mmpdc", {NULL}, 1657, "tcp"}, {"fujitsu-mmpdc", {NULL}, 1657, "udp"}, {"sixnetudr", {NULL}, 1658, "tcp"}, {"sixnetudr", {NULL}, 1658, "udp"}, {"sg-lm", {NULL}, 1659, "tcp"}, {"sg-lm", {NULL}, 1659, "udp"}, {"skip-mc-gikreq", {NULL}, 1660, "tcp"}, {"skip-mc-gikreq", {NULL}, 1660, "udp"}, {"netview-aix-1", {NULL}, 1661, "tcp"}, {"netview-aix-1", {NULL}, 1661, "udp"}, {"netview-aix-2", {NULL}, 1662, "tcp"}, {"netview-aix-2", {NULL}, 1662, "udp"}, {"netview-aix-3", {NULL}, 1663, "tcp"}, {"netview-aix-3", {NULL}, 1663, "udp"}, {"netview-aix-4", {NULL}, 1664, "tcp"}, {"netview-aix-4", {NULL}, 1664, "udp"}, {"netview-aix-5", {NULL}, 1665, "tcp"}, {"netview-aix-5", {NULL}, 1665, "udp"}, {"netview-aix-6", {NULL}, 1666, "tcp"}, {"netview-aix-6", {NULL}, 1666, "udp"}, {"netview-aix-7", {NULL}, 1667, "tcp"}, {"netview-aix-7", {NULL}, 1667, "udp"}, {"netview-aix-8", {NULL}, 1668, "tcp"}, {"netview-aix-8", {NULL}, 1668, "udp"}, {"netview-aix-9", {NULL}, 1669, "tcp"}, {"netview-aix-9", {NULL}, 1669, "udp"}, {"netview-aix-10", {NULL}, 1670, "tcp"}, {"netview-aix-10", {NULL}, 1670, "udp"}, {"netview-aix-11", {NULL}, 1671, "tcp"}, {"netview-aix-11", {NULL}, 1671, "udp"}, {"netview-aix-12", {NULL}, 1672, "tcp"}, {"netview-aix-12", {NULL}, 1672, "udp"}, {"proshare-mc-1", {NULL}, 1673, "tcp"}, {"proshare-mc-1", {NULL}, 1673, "udp"}, {"proshare-mc-2", {NULL}, 1674, "tcp"}, {"proshare-mc-2", {NULL}, 1674, "udp"}, {"pdp", {NULL}, 1675, "tcp"}, {"pdp", {NULL}, 1675, "udp"}, {"netcomm1", {NULL}, 1676, "tcp"}, {"netcomm2", {NULL}, 1676, "udp"}, {"groupwise", {NULL}, 1677, "tcp"}, {"groupwise", {NULL}, 1677, "udp"}, {"prolink", {NULL}, 1678, "tcp"}, {"prolink", {NULL}, 1678, "udp"}, {"darcorp-lm", {NULL}, 1679, "tcp"}, {"darcorp-lm", {NULL}, 1679, "udp"}, {"microcom-sbp", {NULL}, 1680, "tcp"}, {"microcom-sbp", {NULL}, 1680, "udp"}, {"sd-elmd", {NULL}, 1681, "tcp"}, {"sd-elmd", {NULL}, 1681, "udp"}, {"lanyon-lantern", {NULL}, 1682, "tcp"}, {"lanyon-lantern", {NULL}, 1682, "udp"}, {"ncpm-hip", {NULL}, 1683, "tcp"}, {"ncpm-hip", {NULL}, 1683, "udp"}, {"snaresecure", {NULL}, 1684, "tcp"}, {"snaresecure", {NULL}, 1684, "udp"}, {"n2nremote", {NULL}, 1685, "tcp"}, {"n2nremote", {NULL}, 1685, "udp"}, {"cvmon", {NULL}, 1686, "tcp"}, {"cvmon", {NULL}, 1686, "udp"}, {"nsjtp-ctrl", {NULL}, 1687, "tcp"}, {"nsjtp-ctrl", {NULL}, 1687, "udp"}, {"nsjtp-data", {NULL}, 1688, "tcp"}, {"nsjtp-data", {NULL}, 1688, "udp"}, {"firefox", {NULL}, 1689, "tcp"}, {"firefox", {NULL}, 1689, "udp"}, {"ng-umds", {NULL}, 1690, "tcp"}, {"ng-umds", {NULL}, 1690, "udp"}, {"empire-empuma", {NULL}, 1691, "tcp"}, {"empire-empuma", {NULL}, 1691, "udp"}, {"sstsys-lm", {NULL}, 1692, "tcp"}, {"sstsys-lm", {NULL}, 1692, "udp"}, {"rrirtr", {NULL}, 1693, "tcp"}, {"rrirtr", {NULL}, 1693, "udp"}, {"rrimwm", {NULL}, 1694, "tcp"}, {"rrimwm", {NULL}, 1694, "udp"}, {"rrilwm", {NULL}, 1695, "tcp"}, {"rrilwm", {NULL}, 1695, "udp"}, {"rrifmm", {NULL}, 1696, "tcp"}, {"rrifmm", {NULL}, 1696, "udp"}, {"rrisat", {NULL}, 1697, "tcp"}, {"rrisat", {NULL}, 1697, "udp"}, {"rsvp-encap-1", {NULL}, 1698, "tcp"}, {"rsvp-encap-1", {NULL}, 1698, "udp"}, {"rsvp-encap-2", {NULL}, 1699, "tcp"}, {"rsvp-encap-2", {NULL}, 1699, "udp"}, {"mps-raft", {NULL}, 1700, "tcp"}, {"mps-raft", {NULL}, 1700, "udp"}, {"l2f", {NULL}, 1701, "tcp"}, {"l2f", {NULL}, 1701, "udp"}, {"l2tp", {NULL}, 1701, "tcp"}, {"l2tp", {NULL}, 1701, "udp"}, {"deskshare", {NULL}, 1702, "tcp"}, {"deskshare", {NULL}, 1702, "udp"}, {"hb-engine", {NULL}, 1703, "tcp"}, {"hb-engine", {NULL}, 1703, "udp"}, {"bcs-broker", {NULL}, 1704, "tcp"}, {"bcs-broker", {NULL}, 1704, "udp"}, {"slingshot", {NULL}, 1705, "tcp"}, {"slingshot", {NULL}, 1705, "udp"}, {"jetform", {NULL}, 1706, "tcp"}, {"jetform", {NULL}, 1706, "udp"}, {"vdmplay", {NULL}, 1707, "tcp"}, {"vdmplay", {NULL}, 1707, "udp"}, {"gat-lmd", {NULL}, 1708, "tcp"}, {"gat-lmd", {NULL}, 1708, "udp"}, {"centra", {NULL}, 1709, "tcp"}, {"centra", {NULL}, 1709, "udp"}, {"impera", {NULL}, 1710, "tcp"}, {"impera", {NULL}, 1710, "udp"}, {"pptconference", {NULL}, 1711, "tcp"}, {"pptconference", {NULL}, 1711, "udp"}, {"registrar", {NULL}, 1712, "tcp"}, {"registrar", {NULL}, 1712, "udp"}, {"conferencetalk", {NULL}, 1713, "tcp"}, {"conferencetalk", {NULL}, 1713, "udp"}, {"sesi-lm", {NULL}, 1714, "tcp"}, {"sesi-lm", {NULL}, 1714, "udp"}, {"houdini-lm", {NULL}, 1715, "tcp"}, {"houdini-lm", {NULL}, 1715, "udp"}, {"xmsg", {NULL}, 1716, "tcp"}, {"xmsg", {NULL}, 1716, "udp"}, {"fj-hdnet", {NULL}, 1717, "tcp"}, {"fj-hdnet", {NULL}, 1717, "udp"}, {"h323gatedisc", {NULL}, 1718, "tcp"}, {"h323gatedisc", {NULL}, 1718, "udp"}, {"h323gatestat", {NULL}, 1719, "tcp"}, {"h323gatestat", {NULL}, 1719, "udp"}, {"h323hostcall", {NULL}, 1720, "tcp"}, {"h323hostcall", {NULL}, 1720, "udp"}, {"caicci", {NULL}, 1721, "tcp"}, {"caicci", {NULL}, 1721, "udp"}, {"hks-lm", {NULL}, 1722, "tcp"}, {"hks-lm", {NULL}, 1722, "udp"}, {"pptp", {NULL}, 1723, "tcp"}, {"pptp", {NULL}, 1723, "udp"}, {"csbphonemaster", {NULL}, 1724, "tcp"}, {"csbphonemaster", {NULL}, 1724, "udp"}, {"iden-ralp", {NULL}, 1725, "tcp"}, {"iden-ralp", {NULL}, 1725, "udp"}, {"iberiagames", {NULL}, 1726, "tcp"}, {"iberiagames", {NULL}, 1726, "udp"}, {"winddx", {NULL}, 1727, "tcp"}, {"winddx", {NULL}, 1727, "udp"}, {"telindus", {NULL}, 1728, "tcp"}, {"telindus", {NULL}, 1728, "udp"}, {"citynl", {NULL}, 1729, "tcp"}, {"citynl", {NULL}, 1729, "udp"}, {"roketz", {NULL}, 1730, "tcp"}, {"roketz", {NULL}, 1730, "udp"}, {"msiccp", {NULL}, 1731, "tcp"}, {"msiccp", {NULL}, 1731, "udp"}, {"proxim", {NULL}, 1732, "tcp"}, {"proxim", {NULL}, 1732, "udp"}, {"siipat", {NULL}, 1733, "tcp"}, {"siipat", {NULL}, 1733, "udp"}, {"cambertx-lm", {NULL}, 1734, "tcp"}, {"cambertx-lm", {NULL}, 1734, "udp"}, {"privatechat", {NULL}, 1735, "tcp"}, {"privatechat", {NULL}, 1735, "udp"}, {"street-stream", {NULL}, 1736, "tcp"}, {"street-stream", {NULL}, 1736, "udp"}, {"ultimad", {NULL}, 1737, "tcp"}, {"ultimad", {NULL}, 1737, "udp"}, {"gamegen1", {NULL}, 1738, "tcp"}, {"gamegen1", {NULL}, 1738, "udp"}, {"webaccess", {NULL}, 1739, "tcp"}, {"webaccess", {NULL}, 1739, "udp"}, {"encore", {NULL}, 1740, "tcp"}, {"encore", {NULL}, 1740, "udp"}, {"cisco-net-mgmt", {NULL}, 1741, "tcp"}, {"cisco-net-mgmt", {NULL}, 1741, "udp"}, {"3Com-nsd", {NULL}, 1742, "tcp"}, {"3Com-nsd", {NULL}, 1742, "udp"}, {"cinegrfx-lm", {NULL}, 1743, "tcp"}, {"cinegrfx-lm", {NULL}, 1743, "udp"}, {"ncpm-ft", {NULL}, 1744, "tcp"}, {"ncpm-ft", {NULL}, 1744, "udp"}, {"remote-winsock", {NULL}, 1745, "tcp"}, {"remote-winsock", {NULL}, 1745, "udp"}, {"ftrapid-1", {NULL}, 1746, "tcp"}, {"ftrapid-1", {NULL}, 1746, "udp"}, {"ftrapid-2", {NULL}, 1747, "tcp"}, {"ftrapid-2", {NULL}, 1747, "udp"}, {"oracle-em1", {NULL}, 1748, "tcp"}, {"oracle-em1", {NULL}, 1748, "udp"}, {"aspen-services", {NULL}, 1749, "tcp"}, {"aspen-services", {NULL}, 1749, "udp"}, {"sslp", {NULL}, 1750, "tcp"}, {"sslp", {NULL}, 1750, "udp"}, {"swiftnet", {NULL}, 1751, "tcp"}, {"swiftnet", {NULL}, 1751, "udp"}, {"lofr-lm", {NULL}, 1752, "tcp"}, {"lofr-lm", {NULL}, 1752, "udp"}, {"oracle-em2", {NULL}, 1754, "tcp"}, {"oracle-em2", {NULL}, 1754, "udp"}, {"ms-streaming", {NULL}, 1755, "tcp"}, {"ms-streaming", {NULL}, 1755, "udp"}, {"capfast-lmd", {NULL}, 1756, "tcp"}, {"capfast-lmd", {NULL}, 1756, "udp"}, {"cnhrp", {NULL}, 1757, "tcp"}, {"cnhrp", {NULL}, 1757, "udp"}, {"tftp-mcast", {NULL}, 1758, "tcp"}, {"tftp-mcast", {NULL}, 1758, "udp"}, {"spss-lm", {NULL}, 1759, "tcp"}, {"spss-lm", {NULL}, 1759, "udp"}, {"www-ldap-gw", {NULL}, 1760, "tcp"}, {"www-ldap-gw", {NULL}, 1760, "udp"}, {"cft-0", {NULL}, 1761, "tcp"}, {"cft-0", {NULL}, 1761, "udp"}, {"cft-1", {NULL}, 1762, "tcp"}, {"cft-1", {NULL}, 1762, "udp"}, {"cft-2", {NULL}, 1763, "tcp"}, {"cft-2", {NULL}, 1763, "udp"}, {"cft-3", {NULL}, 1764, "tcp"}, {"cft-3", {NULL}, 1764, "udp"}, {"cft-4", {NULL}, 1765, "tcp"}, {"cft-4", {NULL}, 1765, "udp"}, {"cft-5", {NULL}, 1766, "tcp"}, {"cft-5", {NULL}, 1766, "udp"}, {"cft-6", {NULL}, 1767, "tcp"}, {"cft-6", {NULL}, 1767, "udp"}, {"cft-7", {NULL}, 1768, "tcp"}, {"cft-7", {NULL}, 1768, "udp"}, {"bmc-net-adm", {NULL}, 1769, "tcp"}, {"bmc-net-adm", {NULL}, 1769, "udp"}, {"bmc-net-svc", {NULL}, 1770, "tcp"}, {"bmc-net-svc", {NULL}, 1770, "udp"}, {"vaultbase", {NULL}, 1771, "tcp"}, {"vaultbase", {NULL}, 1771, "udp"}, {"essweb-gw", {NULL}, 1772, "tcp"}, {"essweb-gw", {NULL}, 1772, "udp"}, {"kmscontrol", {NULL}, 1773, "tcp"}, {"kmscontrol", {NULL}, 1773, "udp"}, {"global-dtserv", {NULL}, 1774, "tcp"}, {"global-dtserv", {NULL}, 1774, "udp"}, {"femis", {NULL}, 1776, "tcp"}, {"femis", {NULL}, 1776, "udp"}, {"powerguardian", {NULL}, 1777, "tcp"}, {"powerguardian", {NULL}, 1777, "udp"}, {"prodigy-intrnet", {NULL}, 1778, "tcp"}, {"prodigy-intrnet", {NULL}, 1778, "udp"}, {"pharmasoft", {NULL}, 1779, "tcp"}, {"pharmasoft", {NULL}, 1779, "udp"}, {"dpkeyserv", {NULL}, 1780, "tcp"}, {"dpkeyserv", {NULL}, 1780, "udp"}, {"answersoft-lm", {NULL}, 1781, "tcp"}, {"answersoft-lm", {NULL}, 1781, "udp"}, {"hp-hcip", {NULL}, 1782, "tcp"}, {"hp-hcip", {NULL}, 1782, "udp"}, {"finle-lm", {NULL}, 1784, "tcp"}, {"finle-lm", {NULL}, 1784, "udp"}, {"windlm", {NULL}, 1785, "tcp"}, {"windlm", {NULL}, 1785, "udp"}, {"funk-logger", {NULL}, 1786, "tcp"}, {"funk-logger", {NULL}, 1786, "udp"}, {"funk-license", {NULL}, 1787, "tcp"}, {"funk-license", {NULL}, 1787, "udp"}, {"psmond", {NULL}, 1788, "tcp"}, {"psmond", {NULL}, 1788, "udp"}, {"hello", {NULL}, 1789, "tcp"}, {"hello", {NULL}, 1789, "udp"}, {"nmsp", {NULL}, 1790, "tcp"}, {"nmsp", {NULL}, 1790, "udp"}, {"ea1", {NULL}, 1791, "tcp"}, {"ea1", {NULL}, 1791, "udp"}, {"ibm-dt-2", {NULL}, 1792, "tcp"}, {"ibm-dt-2", {NULL}, 1792, "udp"}, {"rsc-robot", {NULL}, 1793, "tcp"}, {"rsc-robot", {NULL}, 1793, "udp"}, {"cera-bcm", {NULL}, 1794, "tcp"}, {"cera-bcm", {NULL}, 1794, "udp"}, {"dpi-proxy", {NULL}, 1795, "tcp"}, {"dpi-proxy", {NULL}, 1795, "udp"}, {"vocaltec-admin", {NULL}, 1796, "tcp"}, {"vocaltec-admin", {NULL}, 1796, "udp"}, {"uma", {NULL}, 1797, "tcp"}, {"uma", {NULL}, 1797, "udp"}, {"etp", {NULL}, 1798, "tcp"}, {"etp", {NULL}, 1798, "udp"}, {"netrisk", {NULL}, 1799, "tcp"}, {"netrisk", {NULL}, 1799, "udp"}, {"ansys-lm", {NULL}, 1800, "tcp"}, {"ansys-lm", {NULL}, 1800, "udp"}, {"msmq", {NULL}, 1801, "tcp"}, {"msmq", {NULL}, 1801, "udp"}, {"concomp1", {NULL}, 1802, "tcp"}, {"concomp1", {NULL}, 1802, "udp"}, {"hp-hcip-gwy", {NULL}, 1803, "tcp"}, {"hp-hcip-gwy", {NULL}, 1803, "udp"}, {"enl", {NULL}, 1804, "tcp"}, {"enl", {NULL}, 1804, "udp"}, {"enl-name", {NULL}, 1805, "tcp"}, {"enl-name", {NULL}, 1805, "udp"}, {"musiconline", {NULL}, 1806, "tcp"}, {"musiconline", {NULL}, 1806, "udp"}, {"fhsp", {NULL}, 1807, "tcp"}, {"fhsp", {NULL}, 1807, "udp"}, {"oracle-vp2", {NULL}, 1808, "tcp"}, {"oracle-vp2", {NULL}, 1808, "udp"}, {"oracle-vp1", {NULL}, 1809, "tcp"}, {"oracle-vp1", {NULL}, 1809, "udp"}, {"jerand-lm", {NULL}, 1810, "tcp"}, {"jerand-lm", {NULL}, 1810, "udp"}, {"scientia-sdb", {NULL}, 1811, "tcp"}, {"scientia-sdb", {NULL}, 1811, "udp"}, {"radius", {NULL}, 1812, "tcp"}, {"radius", {NULL}, 1812, "udp"}, {"radius-acct", {NULL}, 1813, "tcp"}, {"radius-acct", {NULL}, 1813, "udp"}, {"tdp-suite", {NULL}, 1814, "tcp"}, {"tdp-suite", {NULL}, 1814, "udp"}, {"mmpft", {NULL}, 1815, "tcp"}, {"mmpft", {NULL}, 1815, "udp"}, {"harp", {NULL}, 1816, "tcp"}, {"harp", {NULL}, 1816, "udp"}, {"rkb-oscs", {NULL}, 1817, "tcp"}, {"rkb-oscs", {NULL}, 1817, "udp"}, {"etftp", {NULL}, 1818, "tcp"}, {"etftp", {NULL}, 1818, "udp"}, {"plato-lm", {NULL}, 1819, "tcp"}, {"plato-lm", {NULL}, 1819, "udp"}, {"mcagent", {NULL}, 1820, "tcp"}, {"mcagent", {NULL}, 1820, "udp"}, {"donnyworld", {NULL}, 1821, "tcp"}, {"donnyworld", {NULL}, 1821, "udp"}, {"es-elmd", {NULL}, 1822, "tcp"}, {"es-elmd", {NULL}, 1822, "udp"}, {"unisys-lm", {NULL}, 1823, "tcp"}, {"unisys-lm", {NULL}, 1823, "udp"}, {"metrics-pas", {NULL}, 1824, "tcp"}, {"metrics-pas", {NULL}, 1824, "udp"}, {"direcpc-video", {NULL}, 1825, "tcp"}, {"direcpc-video", {NULL}, 1825, "udp"}, {"ardt", {NULL}, 1826, "tcp"}, {"ardt", {NULL}, 1826, "udp"}, {"asi", {NULL}, 1827, "tcp"}, {"asi", {NULL}, 1827, "udp"}, {"itm-mcell-u", {NULL}, 1828, "tcp"}, {"itm-mcell-u", {NULL}, 1828, "udp"}, {"optika-emedia", {NULL}, 1829, "tcp"}, {"optika-emedia", {NULL}, 1829, "udp"}, {"net8-cman", {NULL}, 1830, "tcp"}, {"net8-cman", {NULL}, 1830, "udp"}, {"myrtle", {NULL}, 1831, "tcp"}, {"myrtle", {NULL}, 1831, "udp"}, {"tht-treasure", {NULL}, 1832, "tcp"}, {"tht-treasure", {NULL}, 1832, "udp"}, {"udpradio", {NULL}, 1833, "tcp"}, {"udpradio", {NULL}, 1833, "udp"}, {"ardusuni", {NULL}, 1834, "tcp"}, {"ardusuni", {NULL}, 1834, "udp"}, {"ardusmul", {NULL}, 1835, "tcp"}, {"ardusmul", {NULL}, 1835, "udp"}, {"ste-smsc", {NULL}, 1836, "tcp"}, {"ste-smsc", {NULL}, 1836, "udp"}, {"csoft1", {NULL}, 1837, "tcp"}, {"csoft1", {NULL}, 1837, "udp"}, {"talnet", {NULL}, 1838, "tcp"}, {"talnet", {NULL}, 1838, "udp"}, {"netopia-vo1", {NULL}, 1839, "tcp"}, {"netopia-vo1", {NULL}, 1839, "udp"}, {"netopia-vo2", {NULL}, 1840, "tcp"}, {"netopia-vo2", {NULL}, 1840, "udp"}, {"netopia-vo3", {NULL}, 1841, "tcp"}, {"netopia-vo3", {NULL}, 1841, "udp"}, {"netopia-vo4", {NULL}, 1842, "tcp"}, {"netopia-vo4", {NULL}, 1842, "udp"}, {"netopia-vo5", {NULL}, 1843, "tcp"}, {"netopia-vo5", {NULL}, 1843, "udp"}, {"direcpc-dll", {NULL}, 1844, "tcp"}, {"direcpc-dll", {NULL}, 1844, "udp"}, {"altalink", {NULL}, 1845, "tcp"}, {"altalink", {NULL}, 1845, "udp"}, {"tunstall-pnc", {NULL}, 1846, "tcp"}, {"tunstall-pnc", {NULL}, 1846, "udp"}, {"slp-notify", {NULL}, 1847, "tcp"}, {"slp-notify", {NULL}, 1847, "udp"}, {"fjdocdist", {NULL}, 1848, "tcp"}, {"fjdocdist", {NULL}, 1848, "udp"}, {"alpha-sms", {NULL}, 1849, "tcp"}, {"alpha-sms", {NULL}, 1849, "udp"}, {"gsi", {NULL}, 1850, "tcp"}, {"gsi", {NULL}, 1850, "udp"}, {"ctcd", {NULL}, 1851, "tcp"}, {"ctcd", {NULL}, 1851, "udp"}, {"virtual-time", {NULL}, 1852, "tcp"}, {"virtual-time", {NULL}, 1852, "udp"}, {"vids-avtp", {NULL}, 1853, "tcp"}, {"vids-avtp", {NULL}, 1853, "udp"}, {"buddy-draw", {NULL}, 1854, "tcp"}, {"buddy-draw", {NULL}, 1854, "udp"}, {"fiorano-rtrsvc", {NULL}, 1855, "tcp"}, {"fiorano-rtrsvc", {NULL}, 1855, "udp"}, {"fiorano-msgsvc", {NULL}, 1856, "tcp"}, {"fiorano-msgsvc", {NULL}, 1856, "udp"}, {"datacaptor", {NULL}, 1857, "tcp"}, {"datacaptor", {NULL}, 1857, "udp"}, {"privateark", {NULL}, 1858, "tcp"}, {"privateark", {NULL}, 1858, "udp"}, {"gammafetchsvr", {NULL}, 1859, "tcp"}, {"gammafetchsvr", {NULL}, 1859, "udp"}, {"sunscalar-svc", {NULL}, 1860, "tcp"}, {"sunscalar-svc", {NULL}, 1860, "udp"}, {"lecroy-vicp", {NULL}, 1861, "tcp"}, {"lecroy-vicp", {NULL}, 1861, "udp"}, {"mysql-cm-agent", {NULL}, 1862, "tcp"}, {"mysql-cm-agent", {NULL}, 1862, "udp"}, {"msnp", {NULL}, 1863, "tcp"}, {"msnp", {NULL}, 1863, "udp"}, {"paradym-31port", {NULL}, 1864, "tcp"}, {"paradym-31port", {NULL}, 1864, "udp"}, {"entp", {NULL}, 1865, "tcp"}, {"entp", {NULL}, 1865, "udp"}, {"swrmi", {NULL}, 1866, "tcp"}, {"swrmi", {NULL}, 1866, "udp"}, {"udrive", {NULL}, 1867, "tcp"}, {"udrive", {NULL}, 1867, "udp"}, {"viziblebrowser", {NULL}, 1868, "tcp"}, {"viziblebrowser", {NULL}, 1868, "udp"}, {"transact", {NULL}, 1869, "tcp"}, {"transact", {NULL}, 1869, "udp"}, {"sunscalar-dns", {NULL}, 1870, "tcp"}, {"sunscalar-dns", {NULL}, 1870, "udp"}, {"canocentral0", {NULL}, 1871, "tcp"}, {"canocentral0", {NULL}, 1871, "udp"}, {"canocentral1", {NULL}, 1872, "tcp"}, {"canocentral1", {NULL}, 1872, "udp"}, {"fjmpjps", {NULL}, 1873, "tcp"}, {"fjmpjps", {NULL}, 1873, "udp"}, {"fjswapsnp", {NULL}, 1874, "tcp"}, {"fjswapsnp", {NULL}, 1874, "udp"}, {"westell-stats", {NULL}, 1875, "tcp"}, {"westell-stats", {NULL}, 1875, "udp"}, {"ewcappsrv", {NULL}, 1876, "tcp"}, {"ewcappsrv", {NULL}, 1876, "udp"}, {"hp-webqosdb", {NULL}, 1877, "tcp"}, {"hp-webqosdb", {NULL}, 1877, "udp"}, {"drmsmc", {NULL}, 1878, "tcp"}, {"drmsmc", {NULL}, 1878, "udp"}, {"nettgain-nms", {NULL}, 1879, "tcp"}, {"nettgain-nms", {NULL}, 1879, "udp"}, {"vsat-control", {NULL}, 1880, "tcp"}, {"vsat-control", {NULL}, 1880, "udp"}, {"ibm-mqseries2", {NULL}, 1881, "tcp"}, {"ibm-mqseries2", {NULL}, 1881, "udp"}, {"ecsqdmn", {NULL}, 1882, "tcp"}, {"ecsqdmn", {NULL}, 1882, "udp"}, {"ibm-mqisdp", {NULL}, 1883, "tcp"}, {"ibm-mqisdp", {NULL}, 1883, "udp"}, {"idmaps", {NULL}, 1884, "tcp"}, {"idmaps", {NULL}, 1884, "udp"}, {"vrtstrapserver", {NULL}, 1885, "tcp"}, {"vrtstrapserver", {NULL}, 1885, "udp"}, {"leoip", {NULL}, 1886, "tcp"}, {"leoip", {NULL}, 1886, "udp"}, {"filex-lport", {NULL}, 1887, "tcp"}, {"filex-lport", {NULL}, 1887, "udp"}, {"ncconfig", {NULL}, 1888, "tcp"}, {"ncconfig", {NULL}, 1888, "udp"}, {"unify-adapter", {NULL}, 1889, "tcp"}, {"unify-adapter", {NULL}, 1889, "udp"}, {"wilkenlistener", {NULL}, 1890, "tcp"}, {"wilkenlistener", {NULL}, 1890, "udp"}, {"childkey-notif", {NULL}, 1891, "tcp"}, {"childkey-notif", {NULL}, 1891, "udp"}, {"childkey-ctrl", {NULL}, 1892, "tcp"}, {"childkey-ctrl", {NULL}, 1892, "udp"}, {"elad", {NULL}, 1893, "tcp"}, {"elad", {NULL}, 1893, "udp"}, {"o2server-port", {NULL}, 1894, "tcp"}, {"o2server-port", {NULL}, 1894, "udp"}, {"b-novative-ls", {NULL}, 1896, "tcp"}, {"b-novative-ls", {NULL}, 1896, "udp"}, {"metaagent", {NULL}, 1897, "tcp"}, {"metaagent", {NULL}, 1897, "udp"}, {"cymtec-port", {NULL}, 1898, "tcp"}, {"cymtec-port", {NULL}, 1898, "udp"}, {"mc2studios", {NULL}, 1899, "tcp"}, {"mc2studios", {NULL}, 1899, "udp"}, {"ssdp", {NULL}, 1900, "tcp"}, {"ssdp", {NULL}, 1900, "udp"}, {"fjicl-tep-a", {NULL}, 1901, "tcp"}, {"fjicl-tep-a", {NULL}, 1901, "udp"}, {"fjicl-tep-b", {NULL}, 1902, "tcp"}, {"fjicl-tep-b", {NULL}, 1902, "udp"}, {"linkname", {NULL}, 1903, "tcp"}, {"linkname", {NULL}, 1903, "udp"}, {"fjicl-tep-c", {NULL}, 1904, "tcp"}, {"fjicl-tep-c", {NULL}, 1904, "udp"}, {"sugp", {NULL}, 1905, "tcp"}, {"sugp", {NULL}, 1905, "udp"}, {"tpmd", {NULL}, 1906, "tcp"}, {"tpmd", {NULL}, 1906, "udp"}, {"intrastar", {NULL}, 1907, "tcp"}, {"intrastar", {NULL}, 1907, "udp"}, {"dawn", {NULL}, 1908, "tcp"}, {"dawn", {NULL}, 1908, "udp"}, {"global-wlink", {NULL}, 1909, "tcp"}, {"global-wlink", {NULL}, 1909, "udp"}, {"ultrabac", {NULL}, 1910, "tcp"}, {"ultrabac", {NULL}, 1910, "udp"}, {"mtp", {NULL}, 1911, "tcp"}, {"mtp", {NULL}, 1911, "udp"}, {"rhp-iibp", {NULL}, 1912, "tcp"}, {"rhp-iibp", {NULL}, 1912, "udp"}, {"armadp", {NULL}, 1913, "tcp"}, {"armadp", {NULL}, 1913, "udp"}, {"elm-momentum", {NULL}, 1914, "tcp"}, {"elm-momentum", {NULL}, 1914, "udp"}, {"facelink", {NULL}, 1915, "tcp"}, {"facelink", {NULL}, 1915, "udp"}, {"persona", {NULL}, 1916, "tcp"}, {"persona", {NULL}, 1916, "udp"}, {"noagent", {NULL}, 1917, "tcp"}, {"noagent", {NULL}, 1917, "udp"}, {"can-nds", {NULL}, 1918, "tcp"}, {"can-nds", {NULL}, 1918, "udp"}, {"can-dch", {NULL}, 1919, "tcp"}, {"can-dch", {NULL}, 1919, "udp"}, {"can-ferret", {NULL}, 1920, "tcp"}, {"can-ferret", {NULL}, 1920, "udp"}, {"noadmin", {NULL}, 1921, "tcp"}, {"noadmin", {NULL}, 1921, "udp"}, {"tapestry", {NULL}, 1922, "tcp"}, {"tapestry", {NULL}, 1922, "udp"}, {"spice", {NULL}, 1923, "tcp"}, {"spice", {NULL}, 1923, "udp"}, {"xiip", {NULL}, 1924, "tcp"}, {"xiip", {NULL}, 1924, "udp"}, {"discovery-port", {NULL}, 1925, "tcp"}, {"discovery-port", {NULL}, 1925, "udp"}, {"egs", {NULL}, 1926, "tcp"}, {"egs", {NULL}, 1926, "udp"}, {"videte-cipc", {NULL}, 1927, "tcp"}, {"videte-cipc", {NULL}, 1927, "udp"}, {"emsd-port", {NULL}, 1928, "tcp"}, {"emsd-port", {NULL}, 1928, "udp"}, {"bandwiz-system", {NULL}, 1929, "tcp"}, {"bandwiz-system", {NULL}, 1929, "udp"}, {"driveappserver", {NULL}, 1930, "tcp"}, {"driveappserver", {NULL}, 1930, "udp"}, {"amdsched", {NULL}, 1931, "tcp"}, {"amdsched", {NULL}, 1931, "udp"}, {"ctt-broker", {NULL}, 1932, "tcp"}, {"ctt-broker", {NULL}, 1932, "udp"}, {"xmapi", {NULL}, 1933, "tcp"}, {"xmapi", {NULL}, 1933, "udp"}, {"xaapi", {NULL}, 1934, "tcp"}, {"xaapi", {NULL}, 1934, "udp"}, {"macromedia-fcs", {NULL}, 1935, "tcp"}, {"macromedia-fcs", {NULL}, 1935, "udp"}, {"jetcmeserver", {NULL}, 1936, "tcp"}, {"jetcmeserver", {NULL}, 1936, "udp"}, {"jwserver", {NULL}, 1937, "tcp"}, {"jwserver", {NULL}, 1937, "udp"}, {"jwclient", {NULL}, 1938, "tcp"}, {"jwclient", {NULL}, 1938, "udp"}, {"jvserver", {NULL}, 1939, "tcp"}, {"jvserver", {NULL}, 1939, "udp"}, {"jvclient", {NULL}, 1940, "tcp"}, {"jvclient", {NULL}, 1940, "udp"}, {"dic-aida", {NULL}, 1941, "tcp"}, {"dic-aida", {NULL}, 1941, "udp"}, {"res", {NULL}, 1942, "tcp"}, {"res", {NULL}, 1942, "udp"}, {"beeyond-media", {NULL}, 1943, "tcp"}, {"beeyond-media", {NULL}, 1943, "udp"}, {"close-combat", {NULL}, 1944, "tcp"}, {"close-combat", {NULL}, 1944, "udp"}, {"dialogic-elmd", {NULL}, 1945, "tcp"}, {"dialogic-elmd", {NULL}, 1945, "udp"}, {"tekpls", {NULL}, 1946, "tcp"}, {"tekpls", {NULL}, 1946, "udp"}, {"sentinelsrm", {NULL}, 1947, "tcp"}, {"sentinelsrm", {NULL}, 1947, "udp"}, {"eye2eye", {NULL}, 1948, "tcp"}, {"eye2eye", {NULL}, 1948, "udp"}, {"ismaeasdaqlive", {NULL}, 1949, "tcp"}, {"ismaeasdaqlive", {NULL}, 1949, "udp"}, {"ismaeasdaqtest", {NULL}, 1950, "tcp"}, {"ismaeasdaqtest", {NULL}, 1950, "udp"}, {"bcs-lmserver", {NULL}, 1951, "tcp"}, {"bcs-lmserver", {NULL}, 1951, "udp"}, {"mpnjsc", {NULL}, 1952, "tcp"}, {"mpnjsc", {NULL}, 1952, "udp"}, {"rapidbase", {NULL}, 1953, "tcp"}, {"rapidbase", {NULL}, 1953, "udp"}, {"abr-api", {NULL}, 1954, "tcp"}, {"abr-api", {NULL}, 1954, "udp"}, {"abr-secure", {NULL}, 1955, "tcp"}, {"abr-secure", {NULL}, 1955, "udp"}, {"vrtl-vmf-ds", {NULL}, 1956, "tcp"}, {"vrtl-vmf-ds", {NULL}, 1956, "udp"}, {"unix-status", {NULL}, 1957, "tcp"}, {"unix-status", {NULL}, 1957, "udp"}, {"dxadmind", {NULL}, 1958, "tcp"}, {"dxadmind", {NULL}, 1958, "udp"}, {"simp-all", {NULL}, 1959, "tcp"}, {"simp-all", {NULL}, 1959, "udp"}, {"nasmanager", {NULL}, 1960, "tcp"}, {"nasmanager", {NULL}, 1960, "udp"}, {"bts-appserver", {NULL}, 1961, "tcp"}, {"bts-appserver", {NULL}, 1961, "udp"}, {"biap-mp", {NULL}, 1962, "tcp"}, {"biap-mp", {NULL}, 1962, "udp"}, {"webmachine", {NULL}, 1963, "tcp"}, {"webmachine", {NULL}, 1963, "udp"}, {"solid-e-engine", {NULL}, 1964, "tcp"}, {"solid-e-engine", {NULL}, 1964, "udp"}, {"tivoli-npm", {NULL}, 1965, "tcp"}, {"tivoli-npm", {NULL}, 1965, "udp"}, {"slush", {NULL}, 1966, "tcp"}, {"slush", {NULL}, 1966, "udp"}, {"sns-quote", {NULL}, 1967, "tcp"}, {"sns-quote", {NULL}, 1967, "udp"}, {"lipsinc", {NULL}, 1968, "tcp"}, {"lipsinc", {NULL}, 1968, "udp"}, {"lipsinc1", {NULL}, 1969, "tcp"}, {"lipsinc1", {NULL}, 1969, "udp"}, {"netop-rc", {NULL}, 1970, "tcp"}, {"netop-rc", {NULL}, 1970, "udp"}, {"netop-school", {NULL}, 1971, "tcp"}, {"netop-school", {NULL}, 1971, "udp"}, {"intersys-cache", {NULL}, 1972, "tcp"}, {"intersys-cache", {NULL}, 1972, "udp"}, {"dlsrap", {NULL}, 1973, "tcp"}, {"dlsrap", {NULL}, 1973, "udp"}, {"drp", {NULL}, 1974, "tcp"}, {"drp", {NULL}, 1974, "udp"}, {"tcoflashagent", {NULL}, 1975, "tcp"}, {"tcoflashagent", {NULL}, 1975, "udp"}, {"tcoregagent", {NULL}, 1976, "tcp"}, {"tcoregagent", {NULL}, 1976, "udp"}, {"tcoaddressbook", {NULL}, 1977, "tcp"}, {"tcoaddressbook", {NULL}, 1977, "udp"}, {"unisql", {NULL}, 1978, "tcp"}, {"unisql", {NULL}, 1978, "udp"}, {"unisql-java", {NULL}, 1979, "tcp"}, {"unisql-java", {NULL}, 1979, "udp"}, {"pearldoc-xact", {NULL}, 1980, "tcp"}, {"pearldoc-xact", {NULL}, 1980, "udp"}, {"p2pq", {NULL}, 1981, "tcp"}, {"p2pq", {NULL}, 1981, "udp"}, {"estamp", {NULL}, 1982, "tcp"}, {"estamp", {NULL}, 1982, "udp"}, {"lhtp", {NULL}, 1983, "tcp"}, {"lhtp", {NULL}, 1983, "udp"}, {"bb", {NULL}, 1984, "tcp"}, {"bb", {NULL}, 1984, "udp"}, {"hsrp", {NULL}, 1985, "tcp"}, {"hsrp", {NULL}, 1985, "udp"}, {"licensedaemon", {NULL}, 1986, "tcp"}, {"licensedaemon", {NULL}, 1986, "udp"}, {"tr-rsrb-p1", {NULL}, 1987, "tcp"}, {"tr-rsrb-p1", {NULL}, 1987, "udp"}, {"tr-rsrb-p2", {NULL}, 1988, "tcp"}, {"tr-rsrb-p2", {NULL}, 1988, "udp"}, {"tr-rsrb-p3", {NULL}, 1989, "tcp"}, {"tr-rsrb-p3", {NULL}, 1989, "udp"}, {"mshnet", {NULL}, 1989, "tcp"}, {"mshnet", {NULL}, 1989, "udp"}, {"stun-p1", {NULL}, 1990, "tcp"}, {"stun-p1", {NULL}, 1990, "udp"}, {"stun-p2", {NULL}, 1991, "tcp"}, {"stun-p2", {NULL}, 1991, "udp"}, {"stun-p3", {NULL}, 1992, "tcp"}, {"stun-p3", {NULL}, 1992, "udp"}, {"ipsendmsg", {NULL}, 1992, "tcp"}, {"ipsendmsg", {NULL}, 1992, "udp"}, {"snmp-tcp-port", {NULL}, 1993, "tcp"}, {"snmp-tcp-port", {NULL}, 1993, "udp"}, {"stun-port", {NULL}, 1994, "tcp"}, {"stun-port", {NULL}, 1994, "udp"}, {"perf-port", {NULL}, 1995, "tcp"}, {"perf-port", {NULL}, 1995, "udp"}, {"tr-rsrb-port", {NULL}, 1996, "tcp"}, {"tr-rsrb-port", {NULL}, 1996, "udp"}, {"gdp-port", {NULL}, 1997, "tcp"}, {"gdp-port", {NULL}, 1997, "udp"}, {"x25-svc-port", {NULL}, 1998, "tcp"}, {"x25-svc-port", {NULL}, 1998, "udp"}, {"tcp-id-port", {NULL}, 1999, "tcp"}, {"tcp-id-port", {NULL}, 1999, "udp"}, {"cisco-sccp", {NULL}, 2000, "tcp"}, {"cisco-sccp", {NULL}, 2000, "udp"}, {"dc", {NULL}, 2001, "tcp"}, {"wizard", {NULL}, 2001, "udp"}, {"globe", {NULL}, 2002, "tcp"}, {"globe", {NULL}, 2002, "udp"}, {"brutus", {NULL}, 2003, "tcp"}, {"brutus", {NULL}, 2003, "udp"}, {"mailbox", {NULL}, 2004, "tcp"}, {"emce", {NULL}, 2004, "udp"}, {"berknet", {NULL}, 2005, "tcp"}, {"oracle", {NULL}, 2005, "udp"}, {"invokator", {NULL}, 2006, "tcp"}, {"raid-cd", {NULL}, 2006, "udp"}, {"dectalk", {NULL}, 2007, "tcp"}, {"raid-am", {NULL}, 2007, "udp"}, {"conf", {NULL}, 2008, "tcp"}, {"terminaldb", {NULL}, 2008, "udp"}, {"news", {NULL}, 2009, "tcp"}, {"whosockami", {NULL}, 2009, "udp"}, {"search", {NULL}, 2010, "tcp"}, {"pipe_server", {NULL}, 2010, "udp"}, {"raid-cc", {NULL}, 2011, "tcp"}, {"servserv", {NULL}, 2011, "udp"}, {"ttyinfo", {NULL}, 2012, "tcp"}, {"raid-ac", {NULL}, 2012, "udp"}, {"raid-am", {NULL}, 2013, "tcp"}, {"raid-cd", {NULL}, 2013, "udp"}, {"troff", {NULL}, 2014, "tcp"}, {"raid-sf", {NULL}, 2014, "udp"}, {"cypress", {NULL}, 2015, "tcp"}, {"raid-cs", {NULL}, 2015, "udp"}, {"bootserver", {NULL}, 2016, "tcp"}, {"bootserver", {NULL}, 2016, "udp"}, {"cypress-stat", {NULL}, 2017, "tcp"}, {"bootclient", {NULL}, 2017, "udp"}, {"terminaldb", {NULL}, 2018, "tcp"}, {"rellpack", {NULL}, 2018, "udp"}, {"whosockami", {NULL}, 2019, "tcp"}, {"about", {NULL}, 2019, "udp"}, {"xinupageserver", {NULL}, 2020, "tcp"}, {"xinupageserver", {NULL}, 2020, "udp"}, {"servexec", {NULL}, 2021, "tcp"}, {"xinuexpansion1", {NULL}, 2021, "udp"}, {"down", {NULL}, 2022, "tcp"}, {"xinuexpansion2", {NULL}, 2022, "udp"}, {"xinuexpansion3", {NULL}, 2023, "tcp"}, {"xinuexpansion3", {NULL}, 2023, "udp"}, {"xinuexpansion4", {NULL}, 2024, "tcp"}, {"xinuexpansion4", {NULL}, 2024, "udp"}, {"ellpack", {NULL}, 2025, "tcp"}, {"xribs", {NULL}, 2025, "udp"}, {"scrabble", {NULL}, 2026, "tcp"}, {"scrabble", {NULL}, 2026, "udp"}, {"shadowserver", {NULL}, 2027, "tcp"}, {"shadowserver", {NULL}, 2027, "udp"}, {"submitserver", {NULL}, 2028, "tcp"}, {"submitserver", {NULL}, 2028, "udp"}, {"hsrpv6", {NULL}, 2029, "tcp"}, {"hsrpv6", {NULL}, 2029, "udp"}, {"device2", {NULL}, 2030, "tcp"}, {"device2", {NULL}, 2030, "udp"}, {"mobrien-chat", {NULL}, 2031, "tcp"}, {"mobrien-chat", {NULL}, 2031, "udp"}, {"blackboard", {NULL}, 2032, "tcp"}, {"blackboard", {NULL}, 2032, "udp"}, {"glogger", {NULL}, 2033, "tcp"}, {"glogger", {NULL}, 2033, "udp"}, {"scoremgr", {NULL}, 2034, "tcp"}, {"scoremgr", {NULL}, 2034, "udp"}, {"imsldoc", {NULL}, 2035, "tcp"}, {"imsldoc", {NULL}, 2035, "udp"}, {"e-dpnet", {NULL}, 2036, "tcp"}, {"e-dpnet", {NULL}, 2036, "udp"}, {"applus", {NULL}, 2037, "tcp"}, {"applus", {NULL}, 2037, "udp"}, {"objectmanager", {NULL}, 2038, "tcp"}, {"objectmanager", {NULL}, 2038, "udp"}, {"prizma", {NULL}, 2039, "tcp"}, {"prizma", {NULL}, 2039, "udp"}, {"lam", {NULL}, 2040, "tcp"}, {"lam", {NULL}, 2040, "udp"}, {"interbase", {NULL}, 2041, "tcp"}, {"interbase", {NULL}, 2041, "udp"}, {"isis", {NULL}, 2042, "tcp"}, {"isis", {NULL}, 2042, "udp"}, {"isis-bcast", {NULL}, 2043, "tcp"}, {"isis-bcast", {NULL}, 2043, "udp"}, {"rimsl", {NULL}, 2044, "tcp"}, {"rimsl", {NULL}, 2044, "udp"}, {"cdfunc", {NULL}, 2045, "tcp"}, {"cdfunc", {NULL}, 2045, "udp"}, {"sdfunc", {NULL}, 2046, "tcp"}, {"sdfunc", {NULL}, 2046, "udp"}, {"dls", {NULL}, 2047, "tcp"}, {"dls", {NULL}, 2047, "udp"}, {"dls-monitor", {NULL}, 2048, "tcp"}, {"dls-monitor", {NULL}, 2048, "udp"}, {"shilp", {NULL}, 2049, "tcp"}, {"shilp", {NULL}, 2049, "udp"}, {"nfs", {NULL}, 2049, "tcp"}, {"nfs", {NULL}, 2049, "udp"}, {"nfs", {NULL}, 2049, "sctp"}, {"av-emb-config", {NULL}, 2050, "tcp"}, {"av-emb-config", {NULL}, 2050, "udp"}, {"epnsdp", {NULL}, 2051, "tcp"}, {"epnsdp", {NULL}, 2051, "udp"}, {"clearvisn", {NULL}, 2052, "tcp"}, {"clearvisn", {NULL}, 2052, "udp"}, {"lot105-ds-upd", {NULL}, 2053, "tcp"}, {"lot105-ds-upd", {NULL}, 2053, "udp"}, {"weblogin", {NULL}, 2054, "tcp"}, {"weblogin", {NULL}, 2054, "udp"}, {"iop", {NULL}, 2055, "tcp"}, {"iop", {NULL}, 2055, "udp"}, {"omnisky", {NULL}, 2056, "tcp"}, {"omnisky", {NULL}, 2056, "udp"}, {"rich-cp", {NULL}, 2057, "tcp"}, {"rich-cp", {NULL}, 2057, "udp"}, {"newwavesearch", {NULL}, 2058, "tcp"}, {"newwavesearch", {NULL}, 2058, "udp"}, {"bmc-messaging", {NULL}, 2059, "tcp"}, {"bmc-messaging", {NULL}, 2059, "udp"}, {"teleniumdaemon", {NULL}, 2060, "tcp"}, {"teleniumdaemon", {NULL}, 2060, "udp"}, {"netmount", {NULL}, 2061, "tcp"}, {"netmount", {NULL}, 2061, "udp"}, {"icg-swp", {NULL}, 2062, "tcp"}, {"icg-swp", {NULL}, 2062, "udp"}, {"icg-bridge", {NULL}, 2063, "tcp"}, {"icg-bridge", {NULL}, 2063, "udp"}, {"icg-iprelay", {NULL}, 2064, "tcp"}, {"icg-iprelay", {NULL}, 2064, "udp"}, {"dlsrpn", {NULL}, 2065, "tcp"}, {"dlsrpn", {NULL}, 2065, "udp"}, {"aura", {NULL}, 2066, "tcp"}, {"aura", {NULL}, 2066, "udp"}, {"dlswpn", {NULL}, 2067, "tcp"}, {"dlswpn", {NULL}, 2067, "udp"}, {"avauthsrvprtcl", {NULL}, 2068, "tcp"}, {"avauthsrvprtcl", {NULL}, 2068, "udp"}, {"event-port", {NULL}, 2069, "tcp"}, {"event-port", {NULL}, 2069, "udp"}, {"ah-esp-encap", {NULL}, 2070, "tcp"}, {"ah-esp-encap", {NULL}, 2070, "udp"}, {"acp-port", {NULL}, 2071, "tcp"}, {"acp-port", {NULL}, 2071, "udp"}, {"msync", {NULL}, 2072, "tcp"}, {"msync", {NULL}, 2072, "udp"}, {"gxs-data-port", {NULL}, 2073, "tcp"}, {"gxs-data-port", {NULL}, 2073, "udp"}, {"vrtl-vmf-sa", {NULL}, 2074, "tcp"}, {"vrtl-vmf-sa", {NULL}, 2074, "udp"}, {"newlixengine", {NULL}, 2075, "tcp"}, {"newlixengine", {NULL}, 2075, "udp"}, {"newlixconfig", {NULL}, 2076, "tcp"}, {"newlixconfig", {NULL}, 2076, "udp"}, {"tsrmagt", {NULL}, 2077, "tcp"}, {"tsrmagt", {NULL}, 2077, "udp"}, {"tpcsrvr", {NULL}, 2078, "tcp"}, {"tpcsrvr", {NULL}, 2078, "udp"}, {"idware-router", {NULL}, 2079, "tcp"}, {"idware-router", {NULL}, 2079, "udp"}, {"autodesk-nlm", {NULL}, 2080, "tcp"}, {"autodesk-nlm", {NULL}, 2080, "udp"}, {"kme-trap-port", {NULL}, 2081, "tcp"}, {"kme-trap-port", {NULL}, 2081, "udp"}, {"infowave", {NULL}, 2082, "tcp"}, {"infowave", {NULL}, 2082, "udp"}, {"radsec", {NULL}, 2083, "tcp"}, {"radsec", {NULL}, 2083, "udp"}, {"sunclustergeo", {NULL}, 2084, "tcp"}, {"sunclustergeo", {NULL}, 2084, "udp"}, {"ada-cip", {NULL}, 2085, "tcp"}, {"ada-cip", {NULL}, 2085, "udp"}, {"gnunet", {NULL}, 2086, "tcp"}, {"gnunet", {NULL}, 2086, "udp"}, {"eli", {NULL}, 2087, "tcp"}, {"eli", {NULL}, 2087, "udp"}, {"ip-blf", {NULL}, 2088, "tcp"}, {"ip-blf", {NULL}, 2088, "udp"}, {"sep", {NULL}, 2089, "tcp"}, {"sep", {NULL}, 2089, "udp"}, {"lrp", {NULL}, 2090, "tcp"}, {"lrp", {NULL}, 2090, "udp"}, {"prp", {NULL}, 2091, "tcp"}, {"prp", {NULL}, 2091, "udp"}, {"descent3", {NULL}, 2092, "tcp"}, {"descent3", {NULL}, 2092, "udp"}, {"nbx-cc", {NULL}, 2093, "tcp"}, {"nbx-cc", {NULL}, 2093, "udp"}, {"nbx-au", {NULL}, 2094, "tcp"}, {"nbx-au", {NULL}, 2094, "udp"}, {"nbx-ser", {NULL}, 2095, "tcp"}, {"nbx-ser", {NULL}, 2095, "udp"}, {"nbx-dir", {NULL}, 2096, "tcp"}, {"nbx-dir", {NULL}, 2096, "udp"}, {"jetformpreview", {NULL}, 2097, "tcp"}, {"jetformpreview", {NULL}, 2097, "udp"}, {"dialog-port", {NULL}, 2098, "tcp"}, {"dialog-port", {NULL}, 2098, "udp"}, {"h2250-annex-g", {NULL}, 2099, "tcp"}, {"h2250-annex-g", {NULL}, 2099, "udp"}, {"amiganetfs", {NULL}, 2100, "tcp"}, {"amiganetfs", {NULL}, 2100, "udp"}, {"rtcm-sc104", {NULL}, 2101, "tcp"}, {"rtcm-sc104", {NULL}, 2101, "udp"}, {"zephyr-srv", {NULL}, 2102, "tcp"}, {"zephyr-srv", {NULL}, 2102, "udp"}, {"zephyr-clt", {NULL}, 2103, "tcp"}, {"zephyr-clt", {NULL}, 2103, "udp"}, {"zephyr-hm", {NULL}, 2104, "tcp"}, {"zephyr-hm", {NULL}, 2104, "udp"}, {"minipay", {NULL}, 2105, "tcp"}, {"minipay", {NULL}, 2105, "udp"}, {"mzap", {NULL}, 2106, "tcp"}, {"mzap", {NULL}, 2106, "udp"}, {"bintec-admin", {NULL}, 2107, "tcp"}, {"bintec-admin", {NULL}, 2107, "udp"}, {"comcam", {NULL}, 2108, "tcp"}, {"comcam", {NULL}, 2108, "udp"}, {"ergolight", {NULL}, 2109, "tcp"}, {"ergolight", {NULL}, 2109, "udp"}, {"umsp", {NULL}, 2110, "tcp"}, {"umsp", {NULL}, 2110, "udp"}, {"dsatp", {NULL}, 2111, "tcp"}, {"dsatp", {NULL}, 2111, "udp"}, {"idonix-metanet", {NULL}, 2112, "tcp"}, {"idonix-metanet", {NULL}, 2112, "udp"}, {"hsl-storm", {NULL}, 2113, "tcp"}, {"hsl-storm", {NULL}, 2113, "udp"}, {"newheights", {NULL}, 2114, "tcp"}, {"newheights", {NULL}, 2114, "udp"}, {"kdm", {NULL}, 2115, "tcp"}, {"kdm", {NULL}, 2115, "udp"}, {"ccowcmr", {NULL}, 2116, "tcp"}, {"ccowcmr", {NULL}, 2116, "udp"}, {"mentaclient", {NULL}, 2117, "tcp"}, {"mentaclient", {NULL}, 2117, "udp"}, {"mentaserver", {NULL}, 2118, "tcp"}, {"mentaserver", {NULL}, 2118, "udp"}, {"gsigatekeeper", {NULL}, 2119, "tcp"}, {"gsigatekeeper", {NULL}, 2119, "udp"}, {"qencp", {NULL}, 2120, "tcp"}, {"qencp", {NULL}, 2120, "udp"}, {"scientia-ssdb", {NULL}, 2121, "tcp"}, {"scientia-ssdb", {NULL}, 2121, "udp"}, {"caupc-remote", {NULL}, 2122, "tcp"}, {"caupc-remote", {NULL}, 2122, "udp"}, {"gtp-control", {NULL}, 2123, "tcp"}, {"gtp-control", {NULL}, 2123, "udp"}, {"elatelink", {NULL}, 2124, "tcp"}, {"elatelink", {NULL}, 2124, "udp"}, {"lockstep", {NULL}, 2125, "tcp"}, {"lockstep", {NULL}, 2125, "udp"}, {"pktcable-cops", {NULL}, 2126, "tcp"}, {"pktcable-cops", {NULL}, 2126, "udp"}, {"index-pc-wb", {NULL}, 2127, "tcp"}, {"index-pc-wb", {NULL}, 2127, "udp"}, {"net-steward", {NULL}, 2128, "tcp"}, {"net-steward", {NULL}, 2128, "udp"}, {"cs-live", {NULL}, 2129, "tcp"}, {"cs-live", {NULL}, 2129, "udp"}, {"xds", {NULL}, 2130, "tcp"}, {"xds", {NULL}, 2130, "udp"}, {"avantageb2b", {NULL}, 2131, "tcp"}, {"avantageb2b", {NULL}, 2131, "udp"}, {"solera-epmap", {NULL}, 2132, "tcp"}, {"solera-epmap", {NULL}, 2132, "udp"}, {"zymed-zpp", {NULL}, 2133, "tcp"}, {"zymed-zpp", {NULL}, 2133, "udp"}, {"avenue", {NULL}, 2134, "tcp"}, {"avenue", {NULL}, 2134, "udp"}, {"gris", {NULL}, 2135, "tcp"}, {"gris", {NULL}, 2135, "udp"}, {"appworxsrv", {NULL}, 2136, "tcp"}, {"appworxsrv", {NULL}, 2136, "udp"}, {"connect", {NULL}, 2137, "tcp"}, {"connect", {NULL}, 2137, "udp"}, {"unbind-cluster", {NULL}, 2138, "tcp"}, {"unbind-cluster", {NULL}, 2138, "udp"}, {"ias-auth", {NULL}, 2139, "tcp"}, {"ias-auth", {NULL}, 2139, "udp"}, {"ias-reg", {NULL}, 2140, "tcp"}, {"ias-reg", {NULL}, 2140, "udp"}, {"ias-admind", {NULL}, 2141, "tcp"}, {"ias-admind", {NULL}, 2141, "udp"}, {"tdmoip", {NULL}, 2142, "tcp"}, {"tdmoip", {NULL}, 2142, "udp"}, {"lv-jc", {NULL}, 2143, "tcp"}, {"lv-jc", {NULL}, 2143, "udp"}, {"lv-ffx", {NULL}, 2144, "tcp"}, {"lv-ffx", {NULL}, 2144, "udp"}, {"lv-pici", {NULL}, 2145, "tcp"}, {"lv-pici", {NULL}, 2145, "udp"}, {"lv-not", {NULL}, 2146, "tcp"}, {"lv-not", {NULL}, 2146, "udp"}, {"lv-auth", {NULL}, 2147, "tcp"}, {"lv-auth", {NULL}, 2147, "udp"}, {"veritas-ucl", {NULL}, 2148, "tcp"}, {"veritas-ucl", {NULL}, 2148, "udp"}, {"acptsys", {NULL}, 2149, "tcp"}, {"acptsys", {NULL}, 2149, "udp"}, {"dynamic3d", {NULL}, 2150, "tcp"}, {"dynamic3d", {NULL}, 2150, "udp"}, {"docent", {NULL}, 2151, "tcp"}, {"docent", {NULL}, 2151, "udp"}, {"gtp-user", {NULL}, 2152, "tcp"}, {"gtp-user", {NULL}, 2152, "udp"}, {"ctlptc", {NULL}, 2153, "tcp"}, {"ctlptc", {NULL}, 2153, "udp"}, {"stdptc", {NULL}, 2154, "tcp"}, {"stdptc", {NULL}, 2154, "udp"}, {"brdptc", {NULL}, 2155, "tcp"}, {"brdptc", {NULL}, 2155, "udp"}, {"trp", {NULL}, 2156, "tcp"}, {"trp", {NULL}, 2156, "udp"}, {"xnds", {NULL}, 2157, "tcp"}, {"xnds", {NULL}, 2157, "udp"}, {"touchnetplus", {NULL}, 2158, "tcp"}, {"touchnetplus", {NULL}, 2158, "udp"}, {"gdbremote", {NULL}, 2159, "tcp"}, {"gdbremote", {NULL}, 2159, "udp"}, {"apc-2160", {NULL}, 2160, "tcp"}, {"apc-2160", {NULL}, 2160, "udp"}, {"apc-2161", {NULL}, 2161, "tcp"}, {"apc-2161", {NULL}, 2161, "udp"}, {"navisphere", {NULL}, 2162, "tcp"}, {"navisphere", {NULL}, 2162, "udp"}, {"navisphere-sec", {NULL}, 2163, "tcp"}, {"navisphere-sec", {NULL}, 2163, "udp"}, {"ddns-v3", {NULL}, 2164, "tcp"}, {"ddns-v3", {NULL}, 2164, "udp"}, {"x-bone-api", {NULL}, 2165, "tcp"}, {"x-bone-api", {NULL}, 2165, "udp"}, {"iwserver", {NULL}, 2166, "tcp"}, {"iwserver", {NULL}, 2166, "udp"}, {"raw-serial", {NULL}, 2167, "tcp"}, {"raw-serial", {NULL}, 2167, "udp"}, {"easy-soft-mux", {NULL}, 2168, "tcp"}, {"easy-soft-mux", {NULL}, 2168, "udp"}, {"brain", {NULL}, 2169, "tcp"}, {"brain", {NULL}, 2169, "udp"}, {"eyetv", {NULL}, 2170, "tcp"}, {"eyetv", {NULL}, 2170, "udp"}, {"msfw-storage", {NULL}, 2171, "tcp"}, {"msfw-storage", {NULL}, 2171, "udp"}, {"msfw-s-storage", {NULL}, 2172, "tcp"}, {"msfw-s-storage", {NULL}, 2172, "udp"}, {"msfw-replica", {NULL}, 2173, "tcp"}, {"msfw-replica", {NULL}, 2173, "udp"}, {"msfw-array", {NULL}, 2174, "tcp"}, {"msfw-array", {NULL}, 2174, "udp"}, {"airsync", {NULL}, 2175, "tcp"}, {"airsync", {NULL}, 2175, "udp"}, {"rapi", {NULL}, 2176, "tcp"}, {"rapi", {NULL}, 2176, "udp"}, {"qwave", {NULL}, 2177, "tcp"}, {"qwave", {NULL}, 2177, "udp"}, {"bitspeer", {NULL}, 2178, "tcp"}, {"bitspeer", {NULL}, 2178, "udp"}, {"vmrdp", {NULL}, 2179, "tcp"}, {"vmrdp", {NULL}, 2179, "udp"}, {"mc-gt-srv", {NULL}, 2180, "tcp"}, {"mc-gt-srv", {NULL}, 2180, "udp"}, {"eforward", {NULL}, 2181, "tcp"}, {"eforward", {NULL}, 2181, "udp"}, {"cgn-stat", {NULL}, 2182, "tcp"}, {"cgn-stat", {NULL}, 2182, "udp"}, {"cgn-config", {NULL}, 2183, "tcp"}, {"cgn-config", {NULL}, 2183, "udp"}, {"nvd", {NULL}, 2184, "tcp"}, {"nvd", {NULL}, 2184, "udp"}, {"onbase-dds", {NULL}, 2185, "tcp"}, {"onbase-dds", {NULL}, 2185, "udp"}, {"gtaua", {NULL}, 2186, "tcp"}, {"gtaua", {NULL}, 2186, "udp"}, {"ssmc", {NULL}, 2187, "tcp"}, {"ssmd", {NULL}, 2187, "udp"}, {"tivoconnect", {NULL}, 2190, "tcp"}, {"tivoconnect", {NULL}, 2190, "udp"}, {"tvbus", {NULL}, 2191, "tcp"}, {"tvbus", {NULL}, 2191, "udp"}, {"asdis", {NULL}, 2192, "tcp"}, {"asdis", {NULL}, 2192, "udp"}, {"drwcs", {NULL}, 2193, "tcp"}, {"drwcs", {NULL}, 2193, "udp"}, {"mnp-exchange", {NULL}, 2197, "tcp"}, {"mnp-exchange", {NULL}, 2197, "udp"}, {"onehome-remote", {NULL}, 2198, "tcp"}, {"onehome-remote", {NULL}, 2198, "udp"}, {"onehome-help", {NULL}, 2199, "tcp"}, {"onehome-help", {NULL}, 2199, "udp"}, {"ici", {NULL}, 2200, "tcp"}, {"ici", {NULL}, 2200, "udp"}, {"ats", {NULL}, 2201, "tcp"}, {"ats", {NULL}, 2201, "udp"}, {"imtc-map", {NULL}, 2202, "tcp"}, {"imtc-map", {NULL}, 2202, "udp"}, {"b2-runtime", {NULL}, 2203, "tcp"}, {"b2-runtime", {NULL}, 2203, "udp"}, {"b2-license", {NULL}, 2204, "tcp"}, {"b2-license", {NULL}, 2204, "udp"}, {"jps", {NULL}, 2205, "tcp"}, {"jps", {NULL}, 2205, "udp"}, {"hpocbus", {NULL}, 2206, "tcp"}, {"hpocbus", {NULL}, 2206, "udp"}, {"hpssd", {NULL}, 2207, "tcp"}, {"hpssd", {NULL}, 2207, "udp"}, {"hpiod", {NULL}, 2208, "tcp"}, {"hpiod", {NULL}, 2208, "udp"}, {"rimf-ps", {NULL}, 2209, "tcp"}, {"rimf-ps", {NULL}, 2209, "udp"}, {"noaaport", {NULL}, 2210, "tcp"}, {"noaaport", {NULL}, 2210, "udp"}, {"emwin", {NULL}, 2211, "tcp"}, {"emwin", {NULL}, 2211, "udp"}, {"leecoposserver", {NULL}, 2212, "tcp"}, {"leecoposserver", {NULL}, 2212, "udp"}, {"kali", {NULL}, 2213, "tcp"}, {"kali", {NULL}, 2213, "udp"}, {"rpi", {NULL}, 2214, "tcp"}, {"rpi", {NULL}, 2214, "udp"}, {"ipcore", {NULL}, 2215, "tcp"}, {"ipcore", {NULL}, 2215, "udp"}, {"vtu-comms", {NULL}, 2216, "tcp"}, {"vtu-comms", {NULL}, 2216, "udp"}, {"gotodevice", {NULL}, 2217, "tcp"}, {"gotodevice", {NULL}, 2217, "udp"}, {"bounzza", {NULL}, 2218, "tcp"}, {"bounzza", {NULL}, 2218, "udp"}, {"netiq-ncap", {NULL}, 2219, "tcp"}, {"netiq-ncap", {NULL}, 2219, "udp"}, {"netiq", {NULL}, 2220, "tcp"}, {"netiq", {NULL}, 2220, "udp"}, {"rockwell-csp1", {NULL}, 2221, "tcp"}, {"rockwell-csp1", {NULL}, 2221, "udp"}, {"EtherNet/IP-1", {NULL}, 2222, "tcp"}, {"EtherNet/IP-1", {NULL}, 2222, "udp"}, {"rockwell-csp2", {NULL}, 2223, "tcp"}, {"rockwell-csp2", {NULL}, 2223, "udp"}, {"efi-mg", {NULL}, 2224, "tcp"}, {"efi-mg", {NULL}, 2224, "udp"}, {"rcip-itu", {NULL}, 2225, "tcp"}, {"rcip-itu", {NULL}, 2225, "sctp"}, {"di-drm", {NULL}, 2226, "tcp"}, {"di-drm", {NULL}, 2226, "udp"}, {"di-msg", {NULL}, 2227, "tcp"}, {"di-msg", {NULL}, 2227, "udp"}, {"ehome-ms", {NULL}, 2228, "tcp"}, {"ehome-ms", {NULL}, 2228, "udp"}, {"datalens", {NULL}, 2229, "tcp"}, {"datalens", {NULL}, 2229, "udp"}, {"queueadm", {NULL}, 2230, "tcp"}, {"queueadm", {NULL}, 2230, "udp"}, {"wimaxasncp", {NULL}, 2231, "tcp"}, {"wimaxasncp", {NULL}, 2231, "udp"}, {"ivs-video", {NULL}, 2232, "tcp"}, {"ivs-video", {NULL}, 2232, "udp"}, {"infocrypt", {NULL}, 2233, "tcp"}, {"infocrypt", {NULL}, 2233, "udp"}, {"directplay", {NULL}, 2234, "tcp"}, {"directplay", {NULL}, 2234, "udp"}, {"sercomm-wlink", {NULL}, 2235, "tcp"}, {"sercomm-wlink", {NULL}, 2235, "udp"}, {"nani", {NULL}, 2236, "tcp"}, {"nani", {NULL}, 2236, "udp"}, {"optech-port1-lm", {NULL}, 2237, "tcp"}, {"optech-port1-lm", {NULL}, 2237, "udp"}, {"aviva-sna", {NULL}, 2238, "tcp"}, {"aviva-sna", {NULL}, 2238, "udp"}, {"imagequery", {NULL}, 2239, "tcp"}, {"imagequery", {NULL}, 2239, "udp"}, {"recipe", {NULL}, 2240, "tcp"}, {"recipe", {NULL}, 2240, "udp"}, {"ivsd", {NULL}, 2241, "tcp"}, {"ivsd", {NULL}, 2241, "udp"}, {"foliocorp", {NULL}, 2242, "tcp"}, {"foliocorp", {NULL}, 2242, "udp"}, {"magicom", {NULL}, 2243, "tcp"}, {"magicom", {NULL}, 2243, "udp"}, {"nmsserver", {NULL}, 2244, "tcp"}, {"nmsserver", {NULL}, 2244, "udp"}, {"hao", {NULL}, 2245, "tcp"}, {"hao", {NULL}, 2245, "udp"}, {"pc-mta-addrmap", {NULL}, 2246, "tcp"}, {"pc-mta-addrmap", {NULL}, 2246, "udp"}, {"antidotemgrsvr", {NULL}, 2247, "tcp"}, {"antidotemgrsvr", {NULL}, 2247, "udp"}, {"ums", {NULL}, 2248, "tcp"}, {"ums", {NULL}, 2248, "udp"}, {"rfmp", {NULL}, 2249, "tcp"}, {"rfmp", {NULL}, 2249, "udp"}, {"remote-collab", {NULL}, 2250, "tcp"}, {"remote-collab", {NULL}, 2250, "udp"}, {"dif-port", {NULL}, 2251, "tcp"}, {"dif-port", {NULL}, 2251, "udp"}, {"njenet-ssl", {NULL}, 2252, "tcp"}, {"njenet-ssl", {NULL}, 2252, "udp"}, {"dtv-chan-req", {NULL}, 2253, "tcp"}, {"dtv-chan-req", {NULL}, 2253, "udp"}, {"seispoc", {NULL}, 2254, "tcp"}, {"seispoc", {NULL}, 2254, "udp"}, {"vrtp", {NULL}, 2255, "tcp"}, {"vrtp", {NULL}, 2255, "udp"}, {"pcc-mfp", {NULL}, 2256, "tcp"}, {"pcc-mfp", {NULL}, 2256, "udp"}, {"simple-tx-rx", {NULL}, 2257, "tcp"}, {"simple-tx-rx", {NULL}, 2257, "udp"}, {"rcts", {NULL}, 2258, "tcp"}, {"rcts", {NULL}, 2258, "udp"}, {"acd-pm", {NULL}, 2259, "tcp"}, {"acd-pm", {NULL}, 2259, "udp"}, {"apc-2260", {NULL}, 2260, "tcp"}, {"apc-2260", {NULL}, 2260, "udp"}, {"comotionmaster", {NULL}, 2261, "tcp"}, {"comotionmaster", {NULL}, 2261, "udp"}, {"comotionback", {NULL}, 2262, "tcp"}, {"comotionback", {NULL}, 2262, "udp"}, {"ecwcfg", {NULL}, 2263, "tcp"}, {"ecwcfg", {NULL}, 2263, "udp"}, {"apx500api-1", {NULL}, 2264, "tcp"}, {"apx500api-1", {NULL}, 2264, "udp"}, {"apx500api-2", {NULL}, 2265, "tcp"}, {"apx500api-2", {NULL}, 2265, "udp"}, {"mfserver", {NULL}, 2266, "tcp"}, {"mfserver", {NULL}, 2266, "udp"}, {"ontobroker", {NULL}, 2267, "tcp"}, {"ontobroker", {NULL}, 2267, "udp"}, {"amt", {NULL}, 2268, "tcp"}, {"amt", {NULL}, 2268, "udp"}, {"mikey", {NULL}, 2269, "tcp"}, {"mikey", {NULL}, 2269, "udp"}, {"starschool", {NULL}, 2270, "tcp"}, {"starschool", {NULL}, 2270, "udp"}, {"mmcals", {NULL}, 2271, "tcp"}, {"mmcals", {NULL}, 2271, "udp"}, {"mmcal", {NULL}, 2272, "tcp"}, {"mmcal", {NULL}, 2272, "udp"}, {"mysql-im", {NULL}, 2273, "tcp"}, {"mysql-im", {NULL}, 2273, "udp"}, {"pcttunnell", {NULL}, 2274, "tcp"}, {"pcttunnell", {NULL}, 2274, "udp"}, {"ibridge-data", {NULL}, 2275, "tcp"}, {"ibridge-data", {NULL}, 2275, "udp"}, {"ibridge-mgmt", {NULL}, 2276, "tcp"}, {"ibridge-mgmt", {NULL}, 2276, "udp"}, {"bluectrlproxy", {NULL}, 2277, "tcp"}, {"bluectrlproxy", {NULL}, 2277, "udp"}, {"s3db", {NULL}, 2278, "tcp"}, {"s3db", {NULL}, 2278, "udp"}, {"xmquery", {NULL}, 2279, "tcp"}, {"xmquery", {NULL}, 2279, "udp"}, {"lnvpoller", {NULL}, 2280, "tcp"}, {"lnvpoller", {NULL}, 2280, "udp"}, {"lnvconsole", {NULL}, 2281, "tcp"}, {"lnvconsole", {NULL}, 2281, "udp"}, {"lnvalarm", {NULL}, 2282, "tcp"}, {"lnvalarm", {NULL}, 2282, "udp"}, {"lnvstatus", {NULL}, 2283, "tcp"}, {"lnvstatus", {NULL}, 2283, "udp"}, {"lnvmaps", {NULL}, 2284, "tcp"}, {"lnvmaps", {NULL}, 2284, "udp"}, {"lnvmailmon", {NULL}, 2285, "tcp"}, {"lnvmailmon", {NULL}, 2285, "udp"}, {"nas-metering", {NULL}, 2286, "tcp"}, {"nas-metering", {NULL}, 2286, "udp"}, {"dna", {NULL}, 2287, "tcp"}, {"dna", {NULL}, 2287, "udp"}, {"netml", {NULL}, 2288, "tcp"}, {"netml", {NULL}, 2288, "udp"}, {"dict-lookup", {NULL}, 2289, "tcp"}, {"dict-lookup", {NULL}, 2289, "udp"}, {"sonus-logging", {NULL}, 2290, "tcp"}, {"sonus-logging", {NULL}, 2290, "udp"}, {"eapsp", {NULL}, 2291, "tcp"}, {"eapsp", {NULL}, 2291, "udp"}, {"mib-streaming", {NULL}, 2292, "tcp"}, {"mib-streaming", {NULL}, 2292, "udp"}, {"npdbgmngr", {NULL}, 2293, "tcp"}, {"npdbgmngr", {NULL}, 2293, "udp"}, {"konshus-lm", {NULL}, 2294, "tcp"}, {"konshus-lm", {NULL}, 2294, "udp"}, {"advant-lm", {NULL}, 2295, "tcp"}, {"advant-lm", {NULL}, 2295, "udp"}, {"theta-lm", {NULL}, 2296, "tcp"}, {"theta-lm", {NULL}, 2296, "udp"}, {"d2k-datamover1", {NULL}, 2297, "tcp"}, {"d2k-datamover1", {NULL}, 2297, "udp"}, {"d2k-datamover2", {NULL}, 2298, "tcp"}, {"d2k-datamover2", {NULL}, 2298, "udp"}, {"pc-telecommute", {NULL}, 2299, "tcp"}, {"pc-telecommute", {NULL}, 2299, "udp"}, {"cvmmon", {NULL}, 2300, "tcp"}, {"cvmmon", {NULL}, 2300, "udp"}, {"cpq-wbem", {NULL}, 2301, "tcp"}, {"cpq-wbem", {NULL}, 2301, "udp"}, {"binderysupport", {NULL}, 2302, "tcp"}, {"binderysupport", {NULL}, 2302, "udp"}, {"proxy-gateway", {NULL}, 2303, "tcp"}, {"proxy-gateway", {NULL}, 2303, "udp"}, {"attachmate-uts", {NULL}, 2304, "tcp"}, {"attachmate-uts", {NULL}, 2304, "udp"}, {"mt-scaleserver", {NULL}, 2305, "tcp"}, {"mt-scaleserver", {NULL}, 2305, "udp"}, {"tappi-boxnet", {NULL}, 2306, "tcp"}, {"tappi-boxnet", {NULL}, 2306, "udp"}, {"pehelp", {NULL}, 2307, "tcp"}, {"pehelp", {NULL}, 2307, "udp"}, {"sdhelp", {NULL}, 2308, "tcp"}, {"sdhelp", {NULL}, 2308, "udp"}, {"sdserver", {NULL}, 2309, "tcp"}, {"sdserver", {NULL}, 2309, "udp"}, {"sdclient", {NULL}, 2310, "tcp"}, {"sdclient", {NULL}, 2310, "udp"}, {"messageservice", {NULL}, 2311, "tcp"}, {"messageservice", {NULL}, 2311, "udp"}, {"wanscaler", {NULL}, 2312, "tcp"}, {"wanscaler", {NULL}, 2312, "udp"}, {"iapp", {NULL}, 2313, "tcp"}, {"iapp", {NULL}, 2313, "udp"}, {"cr-websystems", {NULL}, 2314, "tcp"}, {"cr-websystems", {NULL}, 2314, "udp"}, {"precise-sft", {NULL}, 2315, "tcp"}, {"precise-sft", {NULL}, 2315, "udp"}, {"sent-lm", {NULL}, 2316, "tcp"}, {"sent-lm", {NULL}, 2316, "udp"}, {"attachmate-g32", {NULL}, 2317, "tcp"}, {"attachmate-g32", {NULL}, 2317, "udp"}, {"cadencecontrol", {NULL}, 2318, "tcp"}, {"cadencecontrol", {NULL}, 2318, "udp"}, {"infolibria", {NULL}, 2319, "tcp"}, {"infolibria", {NULL}, 2319, "udp"}, {"siebel-ns", {NULL}, 2320, "tcp"}, {"siebel-ns", {NULL}, 2320, "udp"}, {"rdlap", {NULL}, 2321, "tcp"}, {"rdlap", {NULL}, 2321, "udp"}, {"ofsd", {NULL}, 2322, "tcp"}, {"ofsd", {NULL}, 2322, "udp"}, {"3d-nfsd", {NULL}, 2323, "tcp"}, {"3d-nfsd", {NULL}, 2323, "udp"}, {"cosmocall", {NULL}, 2324, "tcp"}, {"cosmocall", {NULL}, 2324, "udp"}, {"ansysli", {NULL}, 2325, "tcp"}, {"ansysli", {NULL}, 2325, "udp"}, {"idcp", {NULL}, 2326, "tcp"}, {"idcp", {NULL}, 2326, "udp"}, {"xingcsm", {NULL}, 2327, "tcp"}, {"xingcsm", {NULL}, 2327, "udp"}, {"netrix-sftm", {NULL}, 2328, "tcp"}, {"netrix-sftm", {NULL}, 2328, "udp"}, {"nvd", {NULL}, 2329, "tcp"}, {"nvd", {NULL}, 2329, "udp"}, {"tscchat", {NULL}, 2330, "tcp"}, {"tscchat", {NULL}, 2330, "udp"}, {"agentview", {NULL}, 2331, "tcp"}, {"agentview", {NULL}, 2331, "udp"}, {"rcc-host", {NULL}, 2332, "tcp"}, {"rcc-host", {NULL}, 2332, "udp"}, {"snapp", {NULL}, 2333, "tcp"}, {"snapp", {NULL}, 2333, "udp"}, {"ace-client", {NULL}, 2334, "tcp"}, {"ace-client", {NULL}, 2334, "udp"}, {"ace-proxy", {NULL}, 2335, "tcp"}, {"ace-proxy", {NULL}, 2335, "udp"}, {"appleugcontrol", {NULL}, 2336, "tcp"}, {"appleugcontrol", {NULL}, 2336, "udp"}, {"ideesrv", {NULL}, 2337, "tcp"}, {"ideesrv", {NULL}, 2337, "udp"}, {"norton-lambert", {NULL}, 2338, "tcp"}, {"norton-lambert", {NULL}, 2338, "udp"}, {"3com-webview", {NULL}, 2339, "tcp"}, {"3com-webview", {NULL}, 2339, "udp"}, {"wrs_registry", {NULL}, 2340, "tcp"}, {"wrs_registry", {NULL}, 2340, "udp"}, {"xiostatus", {NULL}, 2341, "tcp"}, {"xiostatus", {NULL}, 2341, "udp"}, {"manage-exec", {NULL}, 2342, "tcp"}, {"manage-exec", {NULL}, 2342, "udp"}, {"nati-logos", {NULL}, 2343, "tcp"}, {"nati-logos", {NULL}, 2343, "udp"}, {"fcmsys", {NULL}, 2344, "tcp"}, {"fcmsys", {NULL}, 2344, "udp"}, {"dbm", {NULL}, 2345, "tcp"}, {"dbm", {NULL}, 2345, "udp"}, {"redstorm_join", {NULL}, 2346, "tcp"}, {"redstorm_join", {NULL}, 2346, "udp"}, {"redstorm_find", {NULL}, 2347, "tcp"}, {"redstorm_find", {NULL}, 2347, "udp"}, {"redstorm_info", {NULL}, 2348, "tcp"}, {"redstorm_info", {NULL}, 2348, "udp"}, {"redstorm_diag", {NULL}, 2349, "tcp"}, {"redstorm_diag", {NULL}, 2349, "udp"}, {"psbserver", {NULL}, 2350, "tcp"}, {"psbserver", {NULL}, 2350, "udp"}, {"psrserver", {NULL}, 2351, "tcp"}, {"psrserver", {NULL}, 2351, "udp"}, {"pslserver", {NULL}, 2352, "tcp"}, {"pslserver", {NULL}, 2352, "udp"}, {"pspserver", {NULL}, 2353, "tcp"}, {"pspserver", {NULL}, 2353, "udp"}, {"psprserver", {NULL}, 2354, "tcp"}, {"psprserver", {NULL}, 2354, "udp"}, {"psdbserver", {NULL}, 2355, "tcp"}, {"psdbserver", {NULL}, 2355, "udp"}, {"gxtelmd", {NULL}, 2356, "tcp"}, {"gxtelmd", {NULL}, 2356, "udp"}, {"unihub-server", {NULL}, 2357, "tcp"}, {"unihub-server", {NULL}, 2357, "udp"}, {"futrix", {NULL}, 2358, "tcp"}, {"futrix", {NULL}, 2358, "udp"}, {"flukeserver", {NULL}, 2359, "tcp"}, {"flukeserver", {NULL}, 2359, "udp"}, {"nexstorindltd", {NULL}, 2360, "tcp"}, {"nexstorindltd", {NULL}, 2360, "udp"}, {"tl1", {NULL}, 2361, "tcp"}, {"tl1", {NULL}, 2361, "udp"}, {"digiman", {NULL}, 2362, "tcp"}, {"digiman", {NULL}, 2362, "udp"}, {"mediacntrlnfsd", {NULL}, 2363, "tcp"}, {"mediacntrlnfsd", {NULL}, 2363, "udp"}, {"oi-2000", {NULL}, 2364, "tcp"}, {"oi-2000", {NULL}, 2364, "udp"}, {"dbref", {NULL}, 2365, "tcp"}, {"dbref", {NULL}, 2365, "udp"}, {"qip-login", {NULL}, 2366, "tcp"}, {"qip-login", {NULL}, 2366, "udp"}, {"service-ctrl", {NULL}, 2367, "tcp"}, {"service-ctrl", {NULL}, 2367, "udp"}, {"opentable", {NULL}, 2368, "tcp"}, {"opentable", {NULL}, 2368, "udp"}, {"l3-hbmon", {NULL}, 2370, "tcp"}, {"l3-hbmon", {NULL}, 2370, "udp"}, {"worldwire", {NULL}, 2371, "tcp"}, {"worldwire", {NULL}, 2371, "udp"}, {"lanmessenger", {NULL}, 2372, "tcp"}, {"lanmessenger", {NULL}, 2372, "udp"}, {"remographlm", {NULL}, 2373, "tcp"}, {"hydra", {NULL}, 2374, "tcp"}, {"compaq-https", {NULL}, 2381, "tcp"}, {"compaq-https", {NULL}, 2381, "udp"}, {"ms-olap3", {NULL}, 2382, "tcp"}, {"ms-olap3", {NULL}, 2382, "udp"}, {"ms-olap4", {NULL}, 2383, "tcp"}, {"ms-olap4", {NULL}, 2383, "udp"}, {"sd-request", {NULL}, 2384, "tcp"}, {"sd-capacity", {NULL}, 2384, "udp"}, {"sd-data", {NULL}, 2385, "tcp"}, {"sd-data", {NULL}, 2385, "udp"}, {"virtualtape", {NULL}, 2386, "tcp"}, {"virtualtape", {NULL}, 2386, "udp"}, {"vsamredirector", {NULL}, 2387, "tcp"}, {"vsamredirector", {NULL}, 2387, "udp"}, {"mynahautostart", {NULL}, 2388, "tcp"}, {"mynahautostart", {NULL}, 2388, "udp"}, {"ovsessionmgr", {NULL}, 2389, "tcp"}, {"ovsessionmgr", {NULL}, 2389, "udp"}, {"rsmtp", {NULL}, 2390, "tcp"}, {"rsmtp", {NULL}, 2390, "udp"}, {"3com-net-mgmt", {NULL}, 2391, "tcp"}, {"3com-net-mgmt", {NULL}, 2391, "udp"}, {"tacticalauth", {NULL}, 2392, "tcp"}, {"tacticalauth", {NULL}, 2392, "udp"}, {"ms-olap1", {NULL}, 2393, "tcp"}, {"ms-olap1", {NULL}, 2393, "udp"}, {"ms-olap2", {NULL}, 2394, "tcp"}, {"ms-olap2", {NULL}, 2394, "udp"}, {"lan900_remote", {NULL}, 2395, "tcp"}, {"lan900_remote", {NULL}, 2395, "udp"}, {"wusage", {NULL}, 2396, "tcp"}, {"wusage", {NULL}, 2396, "udp"}, {"ncl", {NULL}, 2397, "tcp"}, {"ncl", {NULL}, 2397, "udp"}, {"orbiter", {NULL}, 2398, "tcp"}, {"orbiter", {NULL}, 2398, "udp"}, {"fmpro-fdal", {NULL}, 2399, "tcp"}, {"fmpro-fdal", {NULL}, 2399, "udp"}, {"opequus-server", {NULL}, 2400, "tcp"}, {"opequus-server", {NULL}, 2400, "udp"}, {"cvspserver", {NULL}, 2401, "tcp"}, {"cvspserver", {NULL}, 2401, "udp"}, {"taskmaster2000", {NULL}, 2402, "tcp"}, {"taskmaster2000", {NULL}, 2402, "udp"}, {"taskmaster2000", {NULL}, 2403, "tcp"}, {"taskmaster2000", {NULL}, 2403, "udp"}, {"iec-104", {NULL}, 2404, "tcp"}, {"iec-104", {NULL}, 2404, "udp"}, {"trc-netpoll", {NULL}, 2405, "tcp"}, {"trc-netpoll", {NULL}, 2405, "udp"}, {"jediserver", {NULL}, 2406, "tcp"}, {"jediserver", {NULL}, 2406, "udp"}, {"orion", {NULL}, 2407, "tcp"}, {"orion", {NULL}, 2407, "udp"}, {"optimanet", {NULL}, 2408, "tcp"}, {"optimanet", {NULL}, 2408, "udp"}, {"sns-protocol", {NULL}, 2409, "tcp"}, {"sns-protocol", {NULL}, 2409, "udp"}, {"vrts-registry", {NULL}, 2410, "tcp"}, {"vrts-registry", {NULL}, 2410, "udp"}, {"netwave-ap-mgmt", {NULL}, 2411, "tcp"}, {"netwave-ap-mgmt", {NULL}, 2411, "udp"}, {"cdn", {NULL}, 2412, "tcp"}, {"cdn", {NULL}, 2412, "udp"}, {"orion-rmi-reg", {NULL}, 2413, "tcp"}, {"orion-rmi-reg", {NULL}, 2413, "udp"}, {"beeyond", {NULL}, 2414, "tcp"}, {"beeyond", {NULL}, 2414, "udp"}, {"codima-rtp", {NULL}, 2415, "tcp"}, {"codima-rtp", {NULL}, 2415, "udp"}, {"rmtserver", {NULL}, 2416, "tcp"}, {"rmtserver", {NULL}, 2416, "udp"}, {"composit-server", {NULL}, 2417, "tcp"}, {"composit-server", {NULL}, 2417, "udp"}, {"cas", {NULL}, 2418, "tcp"}, {"cas", {NULL}, 2418, "udp"}, {"attachmate-s2s", {NULL}, 2419, "tcp"}, {"attachmate-s2s", {NULL}, 2419, "udp"}, {"dslremote-mgmt", {NULL}, 2420, "tcp"}, {"dslremote-mgmt", {NULL}, 2420, "udp"}, {"g-talk", {NULL}, 2421, "tcp"}, {"g-talk", {NULL}, 2421, "udp"}, {"crmsbits", {NULL}, 2422, "tcp"}, {"crmsbits", {NULL}, 2422, "udp"}, {"rnrp", {NULL}, 2423, "tcp"}, {"rnrp", {NULL}, 2423, "udp"}, {"kofax-svr", {NULL}, 2424, "tcp"}, {"kofax-svr", {NULL}, 2424, "udp"}, {"fjitsuappmgr", {NULL}, 2425, "tcp"}, {"fjitsuappmgr", {NULL}, 2425, "udp"}, {"mgcp-gateway", {NULL}, 2427, "tcp"}, {"mgcp-gateway", {NULL}, 2427, "udp"}, {"ott", {NULL}, 2428, "tcp"}, {"ott", {NULL}, 2428, "udp"}, {"ft-role", {NULL}, 2429, "tcp"}, {"ft-role", {NULL}, 2429, "udp"}, {"venus", {NULL}, 2430, "tcp"}, {"venus", {NULL}, 2430, "udp"}, {"venus-se", {NULL}, 2431, "tcp"}, {"venus-se", {NULL}, 2431, "udp"}, {"codasrv", {NULL}, 2432, "tcp"}, {"codasrv", {NULL}, 2432, "udp"}, {"codasrv-se", {NULL}, 2433, "tcp"}, {"codasrv-se", {NULL}, 2433, "udp"}, {"pxc-epmap", {NULL}, 2434, "tcp"}, {"pxc-epmap", {NULL}, 2434, "udp"}, {"optilogic", {NULL}, 2435, "tcp"}, {"optilogic", {NULL}, 2435, "udp"}, {"topx", {NULL}, 2436, "tcp"}, {"topx", {NULL}, 2436, "udp"}, {"unicontrol", {NULL}, 2437, "tcp"}, {"unicontrol", {NULL}, 2437, "udp"}, {"msp", {NULL}, 2438, "tcp"}, {"msp", {NULL}, 2438, "udp"}, {"sybasedbsynch", {NULL}, 2439, "tcp"}, {"sybasedbsynch", {NULL}, 2439, "udp"}, {"spearway", {NULL}, 2440, "tcp"}, {"spearway", {NULL}, 2440, "udp"}, {"pvsw-inet", {NULL}, 2441, "tcp"}, {"pvsw-inet", {NULL}, 2441, "udp"}, {"netangel", {NULL}, 2442, "tcp"}, {"netangel", {NULL}, 2442, "udp"}, {"powerclientcsf", {NULL}, 2443, "tcp"}, {"powerclientcsf", {NULL}, 2443, "udp"}, {"btpp2sectrans", {NULL}, 2444, "tcp"}, {"btpp2sectrans", {NULL}, 2444, "udp"}, {"dtn1", {NULL}, 2445, "tcp"}, {"dtn1", {NULL}, 2445, "udp"}, {"bues_service", {NULL}, 2446, "tcp"}, {"bues_service", {NULL}, 2446, "udp"}, {"ovwdb", {NULL}, 2447, "tcp"}, {"ovwdb", {NULL}, 2447, "udp"}, {"hpppssvr", {NULL}, 2448, "tcp"}, {"hpppssvr", {NULL}, 2448, "udp"}, {"ratl", {NULL}, 2449, "tcp"}, {"ratl", {NULL}, 2449, "udp"}, {"netadmin", {NULL}, 2450, "tcp"}, {"netadmin", {NULL}, 2450, "udp"}, {"netchat", {NULL}, 2451, "tcp"}, {"netchat", {NULL}, 2451, "udp"}, {"snifferclient", {NULL}, 2452, "tcp"}, {"snifferclient", {NULL}, 2452, "udp"}, {"madge-ltd", {NULL}, 2453, "tcp"}, {"madge-ltd", {NULL}, 2453, "udp"}, {"indx-dds", {NULL}, 2454, "tcp"}, {"indx-dds", {NULL}, 2454, "udp"}, {"wago-io-system", {NULL}, 2455, "tcp"}, {"wago-io-system", {NULL}, 2455, "udp"}, {"altav-remmgt", {NULL}, 2456, "tcp"}, {"altav-remmgt", {NULL}, 2456, "udp"}, {"rapido-ip", {NULL}, 2457, "tcp"}, {"rapido-ip", {NULL}, 2457, "udp"}, {"griffin", {NULL}, 2458, "tcp"}, {"griffin", {NULL}, 2458, "udp"}, {"community", {NULL}, 2459, "tcp"}, {"community", {NULL}, 2459, "udp"}, {"ms-theater", {NULL}, 2460, "tcp"}, {"ms-theater", {NULL}, 2460, "udp"}, {"qadmifoper", {NULL}, 2461, "tcp"}, {"qadmifoper", {NULL}, 2461, "udp"}, {"qadmifevent", {NULL}, 2462, "tcp"}, {"qadmifevent", {NULL}, 2462, "udp"}, {"lsi-raid-mgmt", {NULL}, 2463, "tcp"}, {"lsi-raid-mgmt", {NULL}, 2463, "udp"}, {"direcpc-si", {NULL}, 2464, "tcp"}, {"direcpc-si", {NULL}, 2464, "udp"}, {"lbm", {NULL}, 2465, "tcp"}, {"lbm", {NULL}, 2465, "udp"}, {"lbf", {NULL}, 2466, "tcp"}, {"lbf", {NULL}, 2466, "udp"}, {"high-criteria", {NULL}, 2467, "tcp"}, {"high-criteria", {NULL}, 2467, "udp"}, {"qip-msgd", {NULL}, 2468, "tcp"}, {"qip-msgd", {NULL}, 2468, "udp"}, {"mti-tcs-comm", {NULL}, 2469, "tcp"}, {"mti-tcs-comm", {NULL}, 2469, "udp"}, {"taskman-port", {NULL}, 2470, "tcp"}, {"taskman-port", {NULL}, 2470, "udp"}, {"seaodbc", {NULL}, 2471, "tcp"}, {"seaodbc", {NULL}, 2471, "udp"}, {"c3", {NULL}, 2472, "tcp"}, {"c3", {NULL}, 2472, "udp"}, {"aker-cdp", {NULL}, 2473, "tcp"}, {"aker-cdp", {NULL}, 2473, "udp"}, {"vitalanalysis", {NULL}, 2474, "tcp"}, {"vitalanalysis", {NULL}, 2474, "udp"}, {"ace-server", {NULL}, 2475, "tcp"}, {"ace-server", {NULL}, 2475, "udp"}, {"ace-svr-prop", {NULL}, 2476, "tcp"}, {"ace-svr-prop", {NULL}, 2476, "udp"}, {"ssm-cvs", {NULL}, 2477, "tcp"}, {"ssm-cvs", {NULL}, 2477, "udp"}, {"ssm-cssps", {NULL}, 2478, "tcp"}, {"ssm-cssps", {NULL}, 2478, "udp"}, {"ssm-els", {NULL}, 2479, "tcp"}, {"ssm-els", {NULL}, 2479, "udp"}, {"powerexchange", {NULL}, 2480, "tcp"}, {"powerexchange", {NULL}, 2480, "udp"}, {"giop", {NULL}, 2481, "tcp"}, {"giop", {NULL}, 2481, "udp"}, {"giop-ssl", {NULL}, 2482, "tcp"}, {"giop-ssl", {NULL}, 2482, "udp"}, {"ttc", {NULL}, 2483, "tcp"}, {"ttc", {NULL}, 2483, "udp"}, {"ttc-ssl", {NULL}, 2484, "tcp"}, {"ttc-ssl", {NULL}, 2484, "udp"}, {"netobjects1", {NULL}, 2485, "tcp"}, {"netobjects1", {NULL}, 2485, "udp"}, {"netobjects2", {NULL}, 2486, "tcp"}, {"netobjects2", {NULL}, 2486, "udp"}, {"pns", {NULL}, 2487, "tcp"}, {"pns", {NULL}, 2487, "udp"}, {"moy-corp", {NULL}, 2488, "tcp"}, {"moy-corp", {NULL}, 2488, "udp"}, {"tsilb", {NULL}, 2489, "tcp"}, {"tsilb", {NULL}, 2489, "udp"}, {"qip-qdhcp", {NULL}, 2490, "tcp"}, {"qip-qdhcp", {NULL}, 2490, "udp"}, {"conclave-cpp", {NULL}, 2491, "tcp"}, {"conclave-cpp", {NULL}, 2491, "udp"}, {"groove", {NULL}, 2492, "tcp"}, {"groove", {NULL}, 2492, "udp"}, {"talarian-mqs", {NULL}, 2493, "tcp"}, {"talarian-mqs", {NULL}, 2493, "udp"}, {"bmc-ar", {NULL}, 2494, "tcp"}, {"bmc-ar", {NULL}, 2494, "udp"}, {"fast-rem-serv", {NULL}, 2495, "tcp"}, {"fast-rem-serv", {NULL}, 2495, "udp"}, {"dirgis", {NULL}, 2496, "tcp"}, {"dirgis", {NULL}, 2496, "udp"}, {"quaddb", {NULL}, 2497, "tcp"}, {"quaddb", {NULL}, 2497, "udp"}, {"odn-castraq", {NULL}, 2498, "tcp"}, {"odn-castraq", {NULL}, 2498, "udp"}, {"unicontrol", {NULL}, 2499, "tcp"}, {"unicontrol", {NULL}, 2499, "udp"}, {"rtsserv", {NULL}, 2500, "tcp"}, {"rtsserv", {NULL}, 2500, "udp"}, {"rtsclient", {NULL}, 2501, "tcp"}, {"rtsclient", {NULL}, 2501, "udp"}, {"kentrox-prot", {NULL}, 2502, "tcp"}, {"kentrox-prot", {NULL}, 2502, "udp"}, {"nms-dpnss", {NULL}, 2503, "tcp"}, {"nms-dpnss", {NULL}, 2503, "udp"}, {"wlbs", {NULL}, 2504, "tcp"}, {"wlbs", {NULL}, 2504, "udp"}, {"ppcontrol", {NULL}, 2505, "tcp"}, {"ppcontrol", {NULL}, 2505, "udp"}, {"jbroker", {NULL}, 2506, "tcp"}, {"jbroker", {NULL}, 2506, "udp"}, {"spock", {NULL}, 2507, "tcp"}, {"spock", {NULL}, 2507, "udp"}, {"jdatastore", {NULL}, 2508, "tcp"}, {"jdatastore", {NULL}, 2508, "udp"}, {"fjmpss", {NULL}, 2509, "tcp"}, {"fjmpss", {NULL}, 2509, "udp"}, {"fjappmgrbulk", {NULL}, 2510, "tcp"}, {"fjappmgrbulk", {NULL}, 2510, "udp"}, {"metastorm", {NULL}, 2511, "tcp"}, {"metastorm", {NULL}, 2511, "udp"}, {"citrixima", {NULL}, 2512, "tcp"}, {"citrixima", {NULL}, 2512, "udp"}, {"citrixadmin", {NULL}, 2513, "tcp"}, {"citrixadmin", {NULL}, 2513, "udp"}, {"facsys-ntp", {NULL}, 2514, "tcp"}, {"facsys-ntp", {NULL}, 2514, "udp"}, {"facsys-router", {NULL}, 2515, "tcp"}, {"facsys-router", {NULL}, 2515, "udp"}, {"maincontrol", {NULL}, 2516, "tcp"}, {"maincontrol", {NULL}, 2516, "udp"}, {"call-sig-trans", {NULL}, 2517, "tcp"}, {"call-sig-trans", {NULL}, 2517, "udp"}, {"willy", {NULL}, 2518, "tcp"}, {"willy", {NULL}, 2518, "udp"}, {"globmsgsvc", {NULL}, 2519, "tcp"}, {"globmsgsvc", {NULL}, 2519, "udp"}, {"pvsw", {NULL}, 2520, "tcp"}, {"pvsw", {NULL}, 2520, "udp"}, {"adaptecmgr", {NULL}, 2521, "tcp"}, {"adaptecmgr", {NULL}, 2521, "udp"}, {"windb", {NULL}, 2522, "tcp"}, {"windb", {NULL}, 2522, "udp"}, {"qke-llc-v3", {NULL}, 2523, "tcp"}, {"qke-llc-v3", {NULL}, 2523, "udp"}, {"optiwave-lm", {NULL}, 2524, "tcp"}, {"optiwave-lm", {NULL}, 2524, "udp"}, {"ms-v-worlds", {NULL}, 2525, "tcp"}, {"ms-v-worlds", {NULL}, 2525, "udp"}, {"ema-sent-lm", {NULL}, 2526, "tcp"}, {"ema-sent-lm", {NULL}, 2526, "udp"}, {"iqserver", {NULL}, 2527, "tcp"}, {"iqserver", {NULL}, 2527, "udp"}, {"ncr_ccl", {NULL}, 2528, "tcp"}, {"ncr_ccl", {NULL}, 2528, "udp"}, {"utsftp", {NULL}, 2529, "tcp"}, {"utsftp", {NULL}, 2529, "udp"}, {"vrcommerce", {NULL}, 2530, "tcp"}, {"vrcommerce", {NULL}, 2530, "udp"}, {"ito-e-gui", {NULL}, 2531, "tcp"}, {"ito-e-gui", {NULL}, 2531, "udp"}, {"ovtopmd", {NULL}, 2532, "tcp"}, {"ovtopmd", {NULL}, 2532, "udp"}, {"snifferserver", {NULL}, 2533, "tcp"}, {"snifferserver", {NULL}, 2533, "udp"}, {"combox-web-acc", {NULL}, 2534, "tcp"}, {"combox-web-acc", {NULL}, 2534, "udp"}, {"madcap", {NULL}, 2535, "tcp"}, {"madcap", {NULL}, 2535, "udp"}, {"btpp2audctr1", {NULL}, 2536, "tcp"}, {"btpp2audctr1", {NULL}, 2536, "udp"}, {"upgrade", {NULL}, 2537, "tcp"}, {"upgrade", {NULL}, 2537, "udp"}, {"vnwk-prapi", {NULL}, 2538, "tcp"}, {"vnwk-prapi", {NULL}, 2538, "udp"}, {"vsiadmin", {NULL}, 2539, "tcp"}, {"vsiadmin", {NULL}, 2539, "udp"}, {"lonworks", {NULL}, 2540, "tcp"}, {"lonworks", {NULL}, 2540, "udp"}, {"lonworks2", {NULL}, 2541, "tcp"}, {"lonworks2", {NULL}, 2541, "udp"}, {"udrawgraph", {NULL}, 2542, "tcp"}, {"udrawgraph", {NULL}, 2542, "udp"}, {"reftek", {NULL}, 2543, "tcp"}, {"reftek", {NULL}, 2543, "udp"}, {"novell-zen", {NULL}, 2544, "tcp"}, {"novell-zen", {NULL}, 2544, "udp"}, {"sis-emt", {NULL}, 2545, "tcp"}, {"sis-emt", {NULL}, 2545, "udp"}, {"vytalvaultbrtp", {NULL}, 2546, "tcp"}, {"vytalvaultbrtp", {NULL}, 2546, "udp"}, {"vytalvaultvsmp", {NULL}, 2547, "tcp"}, {"vytalvaultvsmp", {NULL}, 2547, "udp"}, {"vytalvaultpipe", {NULL}, 2548, "tcp"}, {"vytalvaultpipe", {NULL}, 2548, "udp"}, {"ipass", {NULL}, 2549, "tcp"}, {"ipass", {NULL}, 2549, "udp"}, {"ads", {NULL}, 2550, "tcp"}, {"ads", {NULL}, 2550, "udp"}, {"isg-uda-server", {NULL}, 2551, "tcp"}, {"isg-uda-server", {NULL}, 2551, "udp"}, {"call-logging", {NULL}, 2552, "tcp"}, {"call-logging", {NULL}, 2552, "udp"}, {"efidiningport", {NULL}, 2553, "tcp"}, {"efidiningport", {NULL}, 2553, "udp"}, {"vcnet-link-v10", {NULL}, 2554, "tcp"}, {"vcnet-link-v10", {NULL}, 2554, "udp"}, {"compaq-wcp", {NULL}, 2555, "tcp"}, {"compaq-wcp", {NULL}, 2555, "udp"}, {"nicetec-nmsvc", {NULL}, 2556, "tcp"}, {"nicetec-nmsvc", {NULL}, 2556, "udp"}, {"nicetec-mgmt", {NULL}, 2557, "tcp"}, {"nicetec-mgmt", {NULL}, 2557, "udp"}, {"pclemultimedia", {NULL}, 2558, "tcp"}, {"pclemultimedia", {NULL}, 2558, "udp"}, {"lstp", {NULL}, 2559, "tcp"}, {"lstp", {NULL}, 2559, "udp"}, {"labrat", {NULL}, 2560, "tcp"}, {"labrat", {NULL}, 2560, "udp"}, {"mosaixcc", {NULL}, 2561, "tcp"}, {"mosaixcc", {NULL}, 2561, "udp"}, {"delibo", {NULL}, 2562, "tcp"}, {"delibo", {NULL}, 2562, "udp"}, {"cti-redwood", {NULL}, 2563, "tcp"}, {"cti-redwood", {NULL}, 2563, "udp"}, {"hp-3000-telnet", {NULL}, 2564, "tcp"}, {"coord-svr", {NULL}, 2565, "tcp"}, {"coord-svr", {NULL}, 2565, "udp"}, {"pcs-pcw", {NULL}, 2566, "tcp"}, {"pcs-pcw", {NULL}, 2566, "udp"}, {"clp", {NULL}, 2567, "tcp"}, {"clp", {NULL}, 2567, "udp"}, {"spamtrap", {NULL}, 2568, "tcp"}, {"spamtrap", {NULL}, 2568, "udp"}, {"sonuscallsig", {NULL}, 2569, "tcp"}, {"sonuscallsig", {NULL}, 2569, "udp"}, {"hs-port", {NULL}, 2570, "tcp"}, {"hs-port", {NULL}, 2570, "udp"}, {"cecsvc", {NULL}, 2571, "tcp"}, {"cecsvc", {NULL}, 2571, "udp"}, {"ibp", {NULL}, 2572, "tcp"}, {"ibp", {NULL}, 2572, "udp"}, {"trustestablish", {NULL}, 2573, "tcp"}, {"trustestablish", {NULL}, 2573, "udp"}, {"blockade-bpsp", {NULL}, 2574, "tcp"}, {"blockade-bpsp", {NULL}, 2574, "udp"}, {"hl7", {NULL}, 2575, "tcp"}, {"hl7", {NULL}, 2575, "udp"}, {"tclprodebugger", {NULL}, 2576, "tcp"}, {"tclprodebugger", {NULL}, 2576, "udp"}, {"scipticslsrvr", {NULL}, 2577, "tcp"}, {"scipticslsrvr", {NULL}, 2577, "udp"}, {"rvs-isdn-dcp", {NULL}, 2578, "tcp"}, {"rvs-isdn-dcp", {NULL}, 2578, "udp"}, {"mpfoncl", {NULL}, 2579, "tcp"}, {"mpfoncl", {NULL}, 2579, "udp"}, {"tributary", {NULL}, 2580, "tcp"}, {"tributary", {NULL}, 2580, "udp"}, {"argis-te", {NULL}, 2581, "tcp"}, {"argis-te", {NULL}, 2581, "udp"}, {"argis-ds", {NULL}, 2582, "tcp"}, {"argis-ds", {NULL}, 2582, "udp"}, {"mon", {NULL}, 2583, "tcp"}, {"mon", {NULL}, 2583, "udp"}, {"cyaserv", {NULL}, 2584, "tcp"}, {"cyaserv", {NULL}, 2584, "udp"}, {"netx-server", {NULL}, 2585, "tcp"}, {"netx-server", {NULL}, 2585, "udp"}, {"netx-agent", {NULL}, 2586, "tcp"}, {"netx-agent", {NULL}, 2586, "udp"}, {"masc", {NULL}, 2587, "tcp"}, {"masc", {NULL}, 2587, "udp"}, {"privilege", {NULL}, 2588, "tcp"}, {"privilege", {NULL}, 2588, "udp"}, {"quartus-tcl", {NULL}, 2589, "tcp"}, {"quartus-tcl", {NULL}, 2589, "udp"}, {"idotdist", {NULL}, 2590, "tcp"}, {"idotdist", {NULL}, 2590, "udp"}, {"maytagshuffle", {NULL}, 2591, "tcp"}, {"maytagshuffle", {NULL}, 2591, "udp"}, {"netrek", {NULL}, 2592, "tcp"}, {"netrek", {NULL}, 2592, "udp"}, {"mns-mail", {NULL}, 2593, "tcp"}, {"mns-mail", {NULL}, 2593, "udp"}, {"dts", {NULL}, 2594, "tcp"}, {"dts", {NULL}, 2594, "udp"}, {"worldfusion1", {NULL}, 2595, "tcp"}, {"worldfusion1", {NULL}, 2595, "udp"}, {"worldfusion2", {NULL}, 2596, "tcp"}, {"worldfusion2", {NULL}, 2596, "udp"}, {"homesteadglory", {NULL}, 2597, "tcp"}, {"homesteadglory", {NULL}, 2597, "udp"}, {"citriximaclient", {NULL}, 2598, "tcp"}, {"citriximaclient", {NULL}, 2598, "udp"}, {"snapd", {NULL}, 2599, "tcp"}, {"snapd", {NULL}, 2599, "udp"}, {"hpstgmgr", {NULL}, 2600, "tcp"}, {"hpstgmgr", {NULL}, 2600, "udp"}, {"discp-client", {NULL}, 2601, "tcp"}, {"discp-client", {NULL}, 2601, "udp"}, {"discp-server", {NULL}, 2602, "tcp"}, {"discp-server", {NULL}, 2602, "udp"}, {"servicemeter", {NULL}, 2603, "tcp"}, {"servicemeter", {NULL}, 2603, "udp"}, {"nsc-ccs", {NULL}, 2604, "tcp"}, {"nsc-ccs", {NULL}, 2604, "udp"}, {"nsc-posa", {NULL}, 2605, "tcp"}, {"nsc-posa", {NULL}, 2605, "udp"}, {"netmon", {NULL}, 2606, "tcp"}, {"netmon", {NULL}, 2606, "udp"}, {"connection", {NULL}, 2607, "tcp"}, {"connection", {NULL}, 2607, "udp"}, {"wag-service", {NULL}, 2608, "tcp"}, {"wag-service", {NULL}, 2608, "udp"}, {"system-monitor", {NULL}, 2609, "tcp"}, {"system-monitor", {NULL}, 2609, "udp"}, {"versa-tek", {NULL}, 2610, "tcp"}, {"versa-tek", {NULL}, 2610, "udp"}, {"lionhead", {NULL}, 2611, "tcp"}, {"lionhead", {NULL}, 2611, "udp"}, {"qpasa-agent", {NULL}, 2612, "tcp"}, {"qpasa-agent", {NULL}, 2612, "udp"}, {"smntubootstrap", {NULL}, 2613, "tcp"}, {"smntubootstrap", {NULL}, 2613, "udp"}, {"neveroffline", {NULL}, 2614, "tcp"}, {"neveroffline", {NULL}, 2614, "udp"}, {"firepower", {NULL}, 2615, "tcp"}, {"firepower", {NULL}, 2615, "udp"}, {"appswitch-emp", {NULL}, 2616, "tcp"}, {"appswitch-emp", {NULL}, 2616, "udp"}, {"cmadmin", {NULL}, 2617, "tcp"}, {"cmadmin", {NULL}, 2617, "udp"}, {"priority-e-com", {NULL}, 2618, "tcp"}, {"priority-e-com", {NULL}, 2618, "udp"}, {"bruce", {NULL}, 2619, "tcp"}, {"bruce", {NULL}, 2619, "udp"}, {"lpsrecommender", {NULL}, 2620, "tcp"}, {"lpsrecommender", {NULL}, 2620, "udp"}, {"miles-apart", {NULL}, 2621, "tcp"}, {"miles-apart", {NULL}, 2621, "udp"}, {"metricadbc", {NULL}, 2622, "tcp"}, {"metricadbc", {NULL}, 2622, "udp"}, {"lmdp", {NULL}, 2623, "tcp"}, {"lmdp", {NULL}, 2623, "udp"}, {"aria", {NULL}, 2624, "tcp"}, {"aria", {NULL}, 2624, "udp"}, {"blwnkl-port", {NULL}, 2625, "tcp"}, {"blwnkl-port", {NULL}, 2625, "udp"}, {"gbjd816", {NULL}, 2626, "tcp"}, {"gbjd816", {NULL}, 2626, "udp"}, {"moshebeeri", {NULL}, 2627, "tcp"}, {"moshebeeri", {NULL}, 2627, "udp"}, {"dict", {NULL}, 2628, "tcp"}, {"dict", {NULL}, 2628, "udp"}, {"sitaraserver", {NULL}, 2629, "tcp"}, {"sitaraserver", {NULL}, 2629, "udp"}, {"sitaramgmt", {NULL}, 2630, "tcp"}, {"sitaramgmt", {NULL}, 2630, "udp"}, {"sitaradir", {NULL}, 2631, "tcp"}, {"sitaradir", {NULL}, 2631, "udp"}, {"irdg-post", {NULL}, 2632, "tcp"}, {"irdg-post", {NULL}, 2632, "udp"}, {"interintelli", {NULL}, 2633, "tcp"}, {"interintelli", {NULL}, 2633, "udp"}, {"pk-electronics", {NULL}, 2634, "tcp"}, {"pk-electronics", {NULL}, 2634, "udp"}, {"backburner", {NULL}, 2635, "tcp"}, {"backburner", {NULL}, 2635, "udp"}, {"solve", {NULL}, 2636, "tcp"}, {"solve", {NULL}, 2636, "udp"}, {"imdocsvc", {NULL}, 2637, "tcp"}, {"imdocsvc", {NULL}, 2637, "udp"}, {"sybaseanywhere", {NULL}, 2638, "tcp"}, {"sybaseanywhere", {NULL}, 2638, "udp"}, {"aminet", {NULL}, 2639, "tcp"}, {"aminet", {NULL}, 2639, "udp"}, {"sai_sentlm", {NULL}, 2640, "tcp"}, {"sai_sentlm", {NULL}, 2640, "udp"}, {"hdl-srv", {NULL}, 2641, "tcp"}, {"hdl-srv", {NULL}, 2641, "udp"}, {"tragic", {NULL}, 2642, "tcp"}, {"tragic", {NULL}, 2642, "udp"}, {"gte-samp", {NULL}, 2643, "tcp"}, {"gte-samp", {NULL}, 2643, "udp"}, {"travsoft-ipx-t", {NULL}, 2644, "tcp"}, {"travsoft-ipx-t", {NULL}, 2644, "udp"}, {"novell-ipx-cmd", {NULL}, 2645, "tcp"}, {"novell-ipx-cmd", {NULL}, 2645, "udp"}, {"and-lm", {NULL}, 2646, "tcp"}, {"and-lm", {NULL}, 2646, "udp"}, {"syncserver", {NULL}, 2647, "tcp"}, {"syncserver", {NULL}, 2647, "udp"}, {"upsnotifyprot", {NULL}, 2648, "tcp"}, {"upsnotifyprot", {NULL}, 2648, "udp"}, {"vpsipport", {NULL}, 2649, "tcp"}, {"vpsipport", {NULL}, 2649, "udp"}, {"eristwoguns", {NULL}, 2650, "tcp"}, {"eristwoguns", {NULL}, 2650, "udp"}, {"ebinsite", {NULL}, 2651, "tcp"}, {"ebinsite", {NULL}, 2651, "udp"}, {"interpathpanel", {NULL}, 2652, "tcp"}, {"interpathpanel", {NULL}, 2652, "udp"}, {"sonus", {NULL}, 2653, "tcp"}, {"sonus", {NULL}, 2653, "udp"}, {"corel_vncadmin", {NULL}, 2654, "tcp"}, {"corel_vncadmin", {NULL}, 2654, "udp"}, {"unglue", {NULL}, 2655, "tcp"}, {"unglue", {NULL}, 2655, "udp"}, {"kana", {NULL}, 2656, "tcp"}, {"kana", {NULL}, 2656, "udp"}, {"sns-dispatcher", {NULL}, 2657, "tcp"}, {"sns-dispatcher", {NULL}, 2657, "udp"}, {"sns-admin", {NULL}, 2658, "tcp"}, {"sns-admin", {NULL}, 2658, "udp"}, {"sns-query", {NULL}, 2659, "tcp"}, {"sns-query", {NULL}, 2659, "udp"}, {"gcmonitor", {NULL}, 2660, "tcp"}, {"gcmonitor", {NULL}, 2660, "udp"}, {"olhost", {NULL}, 2661, "tcp"}, {"olhost", {NULL}, 2661, "udp"}, {"bintec-capi", {NULL}, 2662, "tcp"}, {"bintec-capi", {NULL}, 2662, "udp"}, {"bintec-tapi", {NULL}, 2663, "tcp"}, {"bintec-tapi", {NULL}, 2663, "udp"}, {"patrol-mq-gm", {NULL}, 2664, "tcp"}, {"patrol-mq-gm", {NULL}, 2664, "udp"}, {"patrol-mq-nm", {NULL}, 2665, "tcp"}, {"patrol-mq-nm", {NULL}, 2665, "udp"}, {"extensis", {NULL}, 2666, "tcp"}, {"extensis", {NULL}, 2666, "udp"}, {"alarm-clock-s", {NULL}, 2667, "tcp"}, {"alarm-clock-s", {NULL}, 2667, "udp"}, {"alarm-clock-c", {NULL}, 2668, "tcp"}, {"alarm-clock-c", {NULL}, 2668, "udp"}, {"toad", {NULL}, 2669, "tcp"}, {"toad", {NULL}, 2669, "udp"}, {"tve-announce", {NULL}, 2670, "tcp"}, {"tve-announce", {NULL}, 2670, "udp"}, {"newlixreg", {NULL}, 2671, "tcp"}, {"newlixreg", {NULL}, 2671, "udp"}, {"nhserver", {NULL}, 2672, "tcp"}, {"nhserver", {NULL}, 2672, "udp"}, {"firstcall42", {NULL}, 2673, "tcp"}, {"firstcall42", {NULL}, 2673, "udp"}, {"ewnn", {NULL}, 2674, "tcp"}, {"ewnn", {NULL}, 2674, "udp"}, {"ttc-etap", {NULL}, 2675, "tcp"}, {"ttc-etap", {NULL}, 2675, "udp"}, {"simslink", {NULL}, 2676, "tcp"}, {"simslink", {NULL}, 2676, "udp"}, {"gadgetgate1way", {NULL}, 2677, "tcp"}, {"gadgetgate1way", {NULL}, 2677, "udp"}, {"gadgetgate2way", {NULL}, 2678, "tcp"}, {"gadgetgate2way", {NULL}, 2678, "udp"}, {"syncserverssl", {NULL}, 2679, "tcp"}, {"syncserverssl", {NULL}, 2679, "udp"}, {"pxc-sapxom", {NULL}, 2680, "tcp"}, {"pxc-sapxom", {NULL}, 2680, "udp"}, {"mpnjsomb", {NULL}, 2681, "tcp"}, {"mpnjsomb", {NULL}, 2681, "udp"}, {"ncdloadbalance", {NULL}, 2683, "tcp"}, {"ncdloadbalance", {NULL}, 2683, "udp"}, {"mpnjsosv", {NULL}, 2684, "tcp"}, {"mpnjsosv", {NULL}, 2684, "udp"}, {"mpnjsocl", {NULL}, 2685, "tcp"}, {"mpnjsocl", {NULL}, 2685, "udp"}, {"mpnjsomg", {NULL}, 2686, "tcp"}, {"mpnjsomg", {NULL}, 2686, "udp"}, {"pq-lic-mgmt", {NULL}, 2687, "tcp"}, {"pq-lic-mgmt", {NULL}, 2687, "udp"}, {"md-cg-http", {NULL}, 2688, "tcp"}, {"md-cg-http", {NULL}, 2688, "udp"}, {"fastlynx", {NULL}, 2689, "tcp"}, {"fastlynx", {NULL}, 2689, "udp"}, {"hp-nnm-data", {NULL}, 2690, "tcp"}, {"hp-nnm-data", {NULL}, 2690, "udp"}, {"itinternet", {NULL}, 2691, "tcp"}, {"itinternet", {NULL}, 2691, "udp"}, {"admins-lms", {NULL}, 2692, "tcp"}, {"admins-lms", {NULL}, 2692, "udp"}, {"pwrsevent", {NULL}, 2694, "tcp"}, {"pwrsevent", {NULL}, 2694, "udp"}, {"vspread", {NULL}, 2695, "tcp"}, {"vspread", {NULL}, 2695, "udp"}, {"unifyadmin", {NULL}, 2696, "tcp"}, {"unifyadmin", {NULL}, 2696, "udp"}, {"oce-snmp-trap", {NULL}, 2697, "tcp"}, {"oce-snmp-trap", {NULL}, 2697, "udp"}, {"mck-ivpip", {NULL}, 2698, "tcp"}, {"mck-ivpip", {NULL}, 2698, "udp"}, {"csoft-plusclnt", {NULL}, 2699, "tcp"}, {"csoft-plusclnt", {NULL}, 2699, "udp"}, {"tqdata", {NULL}, 2700, "tcp"}, {"tqdata", {NULL}, 2700, "udp"}, {"sms-rcinfo", {NULL}, 2701, "tcp"}, {"sms-rcinfo", {NULL}, 2701, "udp"}, {"sms-xfer", {NULL}, 2702, "tcp"}, {"sms-xfer", {NULL}, 2702, "udp"}, {"sms-chat", {NULL}, 2703, "tcp"}, {"sms-chat", {NULL}, 2703, "udp"}, {"sms-remctrl", {NULL}, 2704, "tcp"}, {"sms-remctrl", {NULL}, 2704, "udp"}, {"sds-admin", {NULL}, 2705, "tcp"}, {"sds-admin", {NULL}, 2705, "udp"}, {"ncdmirroring", {NULL}, 2706, "tcp"}, {"ncdmirroring", {NULL}, 2706, "udp"}, {"emcsymapiport", {NULL}, 2707, "tcp"}, {"emcsymapiport", {NULL}, 2707, "udp"}, {"banyan-net", {NULL}, 2708, "tcp"}, {"banyan-net", {NULL}, 2708, "udp"}, {"supermon", {NULL}, 2709, "tcp"}, {"supermon", {NULL}, 2709, "udp"}, {"sso-service", {NULL}, 2710, "tcp"}, {"sso-service", {NULL}, 2710, "udp"}, {"sso-control", {NULL}, 2711, "tcp"}, {"sso-control", {NULL}, 2711, "udp"}, {"aocp", {NULL}, 2712, "tcp"}, {"aocp", {NULL}, 2712, "udp"}, {"raventbs", {NULL}, 2713, "tcp"}, {"raventbs", {NULL}, 2713, "udp"}, {"raventdm", {NULL}, 2714, "tcp"}, {"raventdm", {NULL}, 2714, "udp"}, {"hpstgmgr2", {NULL}, 2715, "tcp"}, {"hpstgmgr2", {NULL}, 2715, "udp"}, {"inova-ip-disco", {NULL}, 2716, "tcp"}, {"inova-ip-disco", {NULL}, 2716, "udp"}, {"pn-requester", {NULL}, 2717, "tcp"}, {"pn-requester", {NULL}, 2717, "udp"}, {"pn-requester2", {NULL}, 2718, "tcp"}, {"pn-requester2", {NULL}, 2718, "udp"}, {"scan-change", {NULL}, 2719, "tcp"}, {"scan-change", {NULL}, 2719, "udp"}, {"wkars", {NULL}, 2720, "tcp"}, {"wkars", {NULL}, 2720, "udp"}, {"smart-diagnose", {NULL}, 2721, "tcp"}, {"smart-diagnose", {NULL}, 2721, "udp"}, {"proactivesrvr", {NULL}, 2722, "tcp"}, {"proactivesrvr", {NULL}, 2722, "udp"}, {"watchdog-nt", {NULL}, 2723, "tcp"}, {"watchdog-nt", {NULL}, 2723, "udp"}, {"qotps", {NULL}, 2724, "tcp"}, {"qotps", {NULL}, 2724, "udp"}, {"msolap-ptp2", {NULL}, 2725, "tcp"}, {"msolap-ptp2", {NULL}, 2725, "udp"}, {"tams", {NULL}, 2726, "tcp"}, {"tams", {NULL}, 2726, "udp"}, {"mgcp-callagent", {NULL}, 2727, "tcp"}, {"mgcp-callagent", {NULL}, 2727, "udp"}, {"sqdr", {NULL}, 2728, "tcp"}, {"sqdr", {NULL}, 2728, "udp"}, {"tcim-control", {NULL}, 2729, "tcp"}, {"tcim-control", {NULL}, 2729, "udp"}, {"nec-raidplus", {NULL}, 2730, "tcp"}, {"nec-raidplus", {NULL}, 2730, "udp"}, {"fyre-messanger", {NULL}, 2731, "tcp"}, {"fyre-messanger", {NULL}, 2731, "udp"}, {"g5m", {NULL}, 2732, "tcp"}, {"g5m", {NULL}, 2732, "udp"}, {"signet-ctf", {NULL}, 2733, "tcp"}, {"signet-ctf", {NULL}, 2733, "udp"}, {"ccs-software", {NULL}, 2734, "tcp"}, {"ccs-software", {NULL}, 2734, "udp"}, {"netiq-mc", {NULL}, 2735, "tcp"}, {"netiq-mc", {NULL}, 2735, "udp"}, {"radwiz-nms-srv", {NULL}, 2736, "tcp"}, {"radwiz-nms-srv", {NULL}, 2736, "udp"}, {"srp-feedback", {NULL}, 2737, "tcp"}, {"srp-feedback", {NULL}, 2737, "udp"}, {"ndl-tcp-ois-gw", {NULL}, 2738, "tcp"}, {"ndl-tcp-ois-gw", {NULL}, 2738, "udp"}, {"tn-timing", {NULL}, 2739, "tcp"}, {"tn-timing", {NULL}, 2739, "udp"}, {"alarm", {NULL}, 2740, "tcp"}, {"alarm", {NULL}, 2740, "udp"}, {"tsb", {NULL}, 2741, "tcp"}, {"tsb", {NULL}, 2741, "udp"}, {"tsb2", {NULL}, 2742, "tcp"}, {"tsb2", {NULL}, 2742, "udp"}, {"murx", {NULL}, 2743, "tcp"}, {"murx", {NULL}, 2743, "udp"}, {"honyaku", {NULL}, 2744, "tcp"}, {"honyaku", {NULL}, 2744, "udp"}, {"urbisnet", {NULL}, 2745, "tcp"}, {"urbisnet", {NULL}, 2745, "udp"}, {"cpudpencap", {NULL}, 2746, "tcp"}, {"cpudpencap", {NULL}, 2746, "udp"}, {"fjippol-swrly", {NULL}, 2747, "tcp"}, {"fjippol-swrly", {NULL}, 2747, "udp"}, {"fjippol-polsvr", {NULL}, 2748, "tcp"}, {"fjippol-polsvr", {NULL}, 2748, "udp"}, {"fjippol-cnsl", {NULL}, 2749, "tcp"}, {"fjippol-cnsl", {NULL}, 2749, "udp"}, {"fjippol-port1", {NULL}, 2750, "tcp"}, {"fjippol-port1", {NULL}, 2750, "udp"}, {"fjippol-port2", {NULL}, 2751, "tcp"}, {"fjippol-port2", {NULL}, 2751, "udp"}, {"rsisysaccess", {NULL}, 2752, "tcp"}, {"rsisysaccess", {NULL}, 2752, "udp"}, {"de-spot", {NULL}, 2753, "tcp"}, {"de-spot", {NULL}, 2753, "udp"}, {"apollo-cc", {NULL}, 2754, "tcp"}, {"apollo-cc", {NULL}, 2754, "udp"}, {"expresspay", {NULL}, 2755, "tcp"}, {"expresspay", {NULL}, 2755, "udp"}, {"simplement-tie", {NULL}, 2756, "tcp"}, {"simplement-tie", {NULL}, 2756, "udp"}, {"cnrp", {NULL}, 2757, "tcp"}, {"cnrp", {NULL}, 2757, "udp"}, {"apollo-status", {NULL}, 2758, "tcp"}, {"apollo-status", {NULL}, 2758, "udp"}, {"apollo-gms", {NULL}, 2759, "tcp"}, {"apollo-gms", {NULL}, 2759, "udp"}, {"sabams", {NULL}, 2760, "tcp"}, {"sabams", {NULL}, 2760, "udp"}, {"dicom-iscl", {NULL}, 2761, "tcp"}, {"dicom-iscl", {NULL}, 2761, "udp"}, {"dicom-tls", {NULL}, 2762, "tcp"}, {"dicom-tls", {NULL}, 2762, "udp"}, {"desktop-dna", {NULL}, 2763, "tcp"}, {"desktop-dna", {NULL}, 2763, "udp"}, {"data-insurance", {NULL}, 2764, "tcp"}, {"data-insurance", {NULL}, 2764, "udp"}, {"qip-audup", {NULL}, 2765, "tcp"}, {"qip-audup", {NULL}, 2765, "udp"}, {"compaq-scp", {NULL}, 2766, "tcp"}, {"compaq-scp", {NULL}, 2766, "udp"}, {"uadtc", {NULL}, 2767, "tcp"}, {"uadtc", {NULL}, 2767, "udp"}, {"uacs", {NULL}, 2768, "tcp"}, {"uacs", {NULL}, 2768, "udp"}, {"exce", {NULL}, 2769, "tcp"}, {"exce", {NULL}, 2769, "udp"}, {"veronica", {NULL}, 2770, "tcp"}, {"veronica", {NULL}, 2770, "udp"}, {"vergencecm", {NULL}, 2771, "tcp"}, {"vergencecm", {NULL}, 2771, "udp"}, {"auris", {NULL}, 2772, "tcp"}, {"auris", {NULL}, 2772, "udp"}, {"rbakcup1", {NULL}, 2773, "tcp"}, {"rbakcup1", {NULL}, 2773, "udp"}, {"rbakcup2", {NULL}, 2774, "tcp"}, {"rbakcup2", {NULL}, 2774, "udp"}, {"smpp", {NULL}, 2775, "tcp"}, {"smpp", {NULL}, 2775, "udp"}, {"ridgeway1", {NULL}, 2776, "tcp"}, {"ridgeway1", {NULL}, 2776, "udp"}, {"ridgeway2", {NULL}, 2777, "tcp"}, {"ridgeway2", {NULL}, 2777, "udp"}, {"gwen-sonya", {NULL}, 2778, "tcp"}, {"gwen-sonya", {NULL}, 2778, "udp"}, {"lbc-sync", {NULL}, 2779, "tcp"}, {"lbc-sync", {NULL}, 2779, "udp"}, {"lbc-control", {NULL}, 2780, "tcp"}, {"lbc-control", {NULL}, 2780, "udp"}, {"whosells", {NULL}, 2781, "tcp"}, {"whosells", {NULL}, 2781, "udp"}, {"everydayrc", {NULL}, 2782, "tcp"}, {"everydayrc", {NULL}, 2782, "udp"}, {"aises", {NULL}, 2783, "tcp"}, {"aises", {NULL}, 2783, "udp"}, {"www-dev", {NULL}, 2784, "tcp"}, {"www-dev", {NULL}, 2784, "udp"}, {"aic-np", {NULL}, 2785, "tcp"}, {"aic-np", {NULL}, 2785, "udp"}, {"aic-oncrpc", {NULL}, 2786, "tcp"}, {"aic-oncrpc", {NULL}, 2786, "udp"}, {"piccolo", {NULL}, 2787, "tcp"}, {"piccolo", {NULL}, 2787, "udp"}, {"fryeserv", {NULL}, 2788, "tcp"}, {"fryeserv", {NULL}, 2788, "udp"}, {"media-agent", {NULL}, 2789, "tcp"}, {"media-agent", {NULL}, 2789, "udp"}, {"plgproxy", {NULL}, 2790, "tcp"}, {"plgproxy", {NULL}, 2790, "udp"}, {"mtport-regist", {NULL}, 2791, "tcp"}, {"mtport-regist", {NULL}, 2791, "udp"}, {"f5-globalsite", {NULL}, 2792, "tcp"}, {"f5-globalsite", {NULL}, 2792, "udp"}, {"initlsmsad", {NULL}, 2793, "tcp"}, {"initlsmsad", {NULL}, 2793, "udp"}, {"livestats", {NULL}, 2795, "tcp"}, {"livestats", {NULL}, 2795, "udp"}, {"ac-tech", {NULL}, 2796, "tcp"}, {"ac-tech", {NULL}, 2796, "udp"}, {"esp-encap", {NULL}, 2797, "tcp"}, {"esp-encap", {NULL}, 2797, "udp"}, {"tmesis-upshot", {NULL}, 2798, "tcp"}, {"tmesis-upshot", {NULL}, 2798, "udp"}, {"icon-discover", {NULL}, 2799, "tcp"}, {"icon-discover", {NULL}, 2799, "udp"}, {"acc-raid", {NULL}, 2800, "tcp"}, {"acc-raid", {NULL}, 2800, "udp"}, {"igcp", {NULL}, 2801, "tcp"}, {"igcp", {NULL}, 2801, "udp"}, {"veritas-tcp1", {NULL}, 2802, "tcp"}, {"veritas-udp1", {NULL}, 2802, "udp"}, {"btprjctrl", {NULL}, 2803, "tcp"}, {"btprjctrl", {NULL}, 2803, "udp"}, {"dvr-esm", {NULL}, 2804, "tcp"}, {"dvr-esm", {NULL}, 2804, "udp"}, {"wta-wsp-s", {NULL}, 2805, "tcp"}, {"wta-wsp-s", {NULL}, 2805, "udp"}, {"cspuni", {NULL}, 2806, "tcp"}, {"cspuni", {NULL}, 2806, "udp"}, {"cspmulti", {NULL}, 2807, "tcp"}, {"cspmulti", {NULL}, 2807, "udp"}, {"j-lan-p", {NULL}, 2808, "tcp"}, {"j-lan-p", {NULL}, 2808, "udp"}, {"corbaloc", {NULL}, 2809, "tcp"}, {"corbaloc", {NULL}, 2809, "udp"}, {"netsteward", {NULL}, 2810, "tcp"}, {"netsteward", {NULL}, 2810, "udp"}, {"gsiftp", {NULL}, 2811, "tcp"}, {"gsiftp", {NULL}, 2811, "udp"}, {"atmtcp", {NULL}, 2812, "tcp"}, {"atmtcp", {NULL}, 2812, "udp"}, {"llm-pass", {NULL}, 2813, "tcp"}, {"llm-pass", {NULL}, 2813, "udp"}, {"llm-csv", {NULL}, 2814, "tcp"}, {"llm-csv", {NULL}, 2814, "udp"}, {"lbc-measure", {NULL}, 2815, "tcp"}, {"lbc-measure", {NULL}, 2815, "udp"}, {"lbc-watchdog", {NULL}, 2816, "tcp"}, {"lbc-watchdog", {NULL}, 2816, "udp"}, {"nmsigport", {NULL}, 2817, "tcp"}, {"nmsigport", {NULL}, 2817, "udp"}, {"rmlnk", {NULL}, 2818, "tcp"}, {"rmlnk", {NULL}, 2818, "udp"}, {"fc-faultnotify", {NULL}, 2819, "tcp"}, {"fc-faultnotify", {NULL}, 2819, "udp"}, {"univision", {NULL}, 2820, "tcp"}, {"univision", {NULL}, 2820, "udp"}, {"vrts-at-port", {NULL}, 2821, "tcp"}, {"vrts-at-port", {NULL}, 2821, "udp"}, {"ka0wuc", {NULL}, 2822, "tcp"}, {"ka0wuc", {NULL}, 2822, "udp"}, {"cqg-netlan", {NULL}, 2823, "tcp"}, {"cqg-netlan", {NULL}, 2823, "udp"}, {"cqg-netlan-1", {NULL}, 2824, "tcp"}, {"cqg-netlan-1", {NULL}, 2824, "udp"}, {"slc-systemlog", {NULL}, 2826, "tcp"}, {"slc-systemlog", {NULL}, 2826, "udp"}, {"slc-ctrlrloops", {NULL}, 2827, "tcp"}, {"slc-ctrlrloops", {NULL}, 2827, "udp"}, {"itm-lm", {NULL}, 2828, "tcp"}, {"itm-lm", {NULL}, 2828, "udp"}, {"silkp1", {NULL}, 2829, "tcp"}, {"silkp1", {NULL}, 2829, "udp"}, {"silkp2", {NULL}, 2830, "tcp"}, {"silkp2", {NULL}, 2830, "udp"}, {"silkp3", {NULL}, 2831, "tcp"}, {"silkp3", {NULL}, 2831, "udp"}, {"silkp4", {NULL}, 2832, "tcp"}, {"silkp4", {NULL}, 2832, "udp"}, {"glishd", {NULL}, 2833, "tcp"}, {"glishd", {NULL}, 2833, "udp"}, {"evtp", {NULL}, 2834, "tcp"}, {"evtp", {NULL}, 2834, "udp"}, {"evtp-data", {NULL}, 2835, "tcp"}, {"evtp-data", {NULL}, 2835, "udp"}, {"catalyst", {NULL}, 2836, "tcp"}, {"catalyst", {NULL}, 2836, "udp"}, {"repliweb", {NULL}, 2837, "tcp"}, {"repliweb", {NULL}, 2837, "udp"}, {"starbot", {NULL}, 2838, "tcp"}, {"starbot", {NULL}, 2838, "udp"}, {"nmsigport", {NULL}, 2839, "tcp"}, {"nmsigport", {NULL}, 2839, "udp"}, {"l3-exprt", {NULL}, 2840, "tcp"}, {"l3-exprt", {NULL}, 2840, "udp"}, {"l3-ranger", {NULL}, 2841, "tcp"}, {"l3-ranger", {NULL}, 2841, "udp"}, {"l3-hawk", {NULL}, 2842, "tcp"}, {"l3-hawk", {NULL}, 2842, "udp"}, {"pdnet", {NULL}, 2843, "tcp"}, {"pdnet", {NULL}, 2843, "udp"}, {"bpcp-poll", {NULL}, 2844, "tcp"}, {"bpcp-poll", {NULL}, 2844, "udp"}, {"bpcp-trap", {NULL}, 2845, "tcp"}, {"bpcp-trap", {NULL}, 2845, "udp"}, {"aimpp-hello", {NULL}, 2846, "tcp"}, {"aimpp-hello", {NULL}, 2846, "udp"}, {"aimpp-port-req", {NULL}, 2847, "tcp"}, {"aimpp-port-req", {NULL}, 2847, "udp"}, {"amt-blc-port", {NULL}, 2848, "tcp"}, {"amt-blc-port", {NULL}, 2848, "udp"}, {"fxp", {NULL}, 2849, "tcp"}, {"fxp", {NULL}, 2849, "udp"}, {"metaconsole", {NULL}, 2850, "tcp"}, {"metaconsole", {NULL}, 2850, "udp"}, {"webemshttp", {NULL}, 2851, "tcp"}, {"webemshttp", {NULL}, 2851, "udp"}, {"bears-01", {NULL}, 2852, "tcp"}, {"bears-01", {NULL}, 2852, "udp"}, {"ispipes", {NULL}, 2853, "tcp"}, {"ispipes", {NULL}, 2853, "udp"}, {"infomover", {NULL}, 2854, "tcp"}, {"infomover", {NULL}, 2854, "udp"}, {"msrp", {NULL}, 2855, "tcp"}, {"msrp", {NULL}, 2855, "udp"}, {"cesdinv", {NULL}, 2856, "tcp"}, {"cesdinv", {NULL}, 2856, "udp"}, {"simctlp", {NULL}, 2857, "tcp"}, {"simctlp", {NULL}, 2857, "udp"}, {"ecnp", {NULL}, 2858, "tcp"}, {"ecnp", {NULL}, 2858, "udp"}, {"activememory", {NULL}, 2859, "tcp"}, {"activememory", {NULL}, 2859, "udp"}, {"dialpad-voice1", {NULL}, 2860, "tcp"}, {"dialpad-voice1", {NULL}, 2860, "udp"}, {"dialpad-voice2", {NULL}, 2861, "tcp"}, {"dialpad-voice2", {NULL}, 2861, "udp"}, {"ttg-protocol", {NULL}, 2862, "tcp"}, {"ttg-protocol", {NULL}, 2862, "udp"}, {"sonardata", {NULL}, 2863, "tcp"}, {"sonardata", {NULL}, 2863, "udp"}, {"astromed-main", {NULL}, 2864, "tcp"}, {"astromed-main", {NULL}, 2864, "udp"}, {"pit-vpn", {NULL}, 2865, "tcp"}, {"pit-vpn", {NULL}, 2865, "udp"}, {"iwlistener", {NULL}, 2866, "tcp"}, {"iwlistener", {NULL}, 2866, "udp"}, {"esps-portal", {NULL}, 2867, "tcp"}, {"esps-portal", {NULL}, 2867, "udp"}, {"npep-messaging", {NULL}, 2868, "tcp"}, {"npep-messaging", {NULL}, 2868, "udp"}, {"icslap", {NULL}, 2869, "tcp"}, {"icslap", {NULL}, 2869, "udp"}, {"daishi", {NULL}, 2870, "tcp"}, {"daishi", {NULL}, 2870, "udp"}, {"msi-selectplay", {NULL}, 2871, "tcp"}, {"msi-selectplay", {NULL}, 2871, "udp"}, {"radix", {NULL}, 2872, "tcp"}, {"radix", {NULL}, 2872, "udp"}, {"dxmessagebase1", {NULL}, 2874, "tcp"}, {"dxmessagebase1", {NULL}, 2874, "udp"}, {"dxmessagebase2", {NULL}, 2875, "tcp"}, {"dxmessagebase2", {NULL}, 2875, "udp"}, {"sps-tunnel", {NULL}, 2876, "tcp"}, {"sps-tunnel", {NULL}, 2876, "udp"}, {"bluelance", {NULL}, 2877, "tcp"}, {"bluelance", {NULL}, 2877, "udp"}, {"aap", {NULL}, 2878, "tcp"}, {"aap", {NULL}, 2878, "udp"}, {"ucentric-ds", {NULL}, 2879, "tcp"}, {"ucentric-ds", {NULL}, 2879, "udp"}, {"synapse", {NULL}, 2880, "tcp"}, {"synapse", {NULL}, 2880, "udp"}, {"ndsp", {NULL}, 2881, "tcp"}, {"ndsp", {NULL}, 2881, "udp"}, {"ndtp", {NULL}, 2882, "tcp"}, {"ndtp", {NULL}, 2882, "udp"}, {"ndnp", {NULL}, 2883, "tcp"}, {"ndnp", {NULL}, 2883, "udp"}, {"flashmsg", {NULL}, 2884, "tcp"}, {"flashmsg", {NULL}, 2884, "udp"}, {"topflow", {NULL}, 2885, "tcp"}, {"topflow", {NULL}, 2885, "udp"}, {"responselogic", {NULL}, 2886, "tcp"}, {"responselogic", {NULL}, 2886, "udp"}, {"aironetddp", {NULL}, 2887, "tcp"}, {"aironetddp", {NULL}, 2887, "udp"}, {"spcsdlobby", {NULL}, 2888, "tcp"}, {"spcsdlobby", {NULL}, 2888, "udp"}, {"rsom", {NULL}, 2889, "tcp"}, {"rsom", {NULL}, 2889, "udp"}, {"cspclmulti", {NULL}, 2890, "tcp"}, {"cspclmulti", {NULL}, 2890, "udp"}, {"cinegrfx-elmd", {NULL}, 2891, "tcp"}, {"cinegrfx-elmd", {NULL}, 2891, "udp"}, {"snifferdata", {NULL}, 2892, "tcp"}, {"snifferdata", {NULL}, 2892, "udp"}, {"vseconnector", {NULL}, 2893, "tcp"}, {"vseconnector", {NULL}, 2893, "udp"}, {"abacus-remote", {NULL}, 2894, "tcp"}, {"abacus-remote", {NULL}, 2894, "udp"}, {"natuslink", {NULL}, 2895, "tcp"}, {"natuslink", {NULL}, 2895, "udp"}, {"ecovisiong6-1", {NULL}, 2896, "tcp"}, {"ecovisiong6-1", {NULL}, 2896, "udp"}, {"citrix-rtmp", {NULL}, 2897, "tcp"}, {"citrix-rtmp", {NULL}, 2897, "udp"}, {"appliance-cfg", {NULL}, 2898, "tcp"}, {"appliance-cfg", {NULL}, 2898, "udp"}, {"powergemplus", {NULL}, 2899, "tcp"}, {"powergemplus", {NULL}, 2899, "udp"}, {"quicksuite", {NULL}, 2900, "tcp"}, {"quicksuite", {NULL}, 2900, "udp"}, {"allstorcns", {NULL}, 2901, "tcp"}, {"allstorcns", {NULL}, 2901, "udp"}, {"netaspi", {NULL}, 2902, "tcp"}, {"netaspi", {NULL}, 2902, "udp"}, {"suitcase", {NULL}, 2903, "tcp"}, {"suitcase", {NULL}, 2903, "udp"}, {"m2ua", {NULL}, 2904, "tcp"}, {"m2ua", {NULL}, 2904, "udp"}, {"m2ua", {NULL}, 2904, "sctp"}, {"m3ua", {NULL}, 2905, "tcp"}, {"m3ua", {NULL}, 2905, "sctp"}, {"caller9", {NULL}, 2906, "tcp"}, {"caller9", {NULL}, 2906, "udp"}, {"webmethods-b2b", {NULL}, 2907, "tcp"}, {"webmethods-b2b", {NULL}, 2907, "udp"}, {"mao", {NULL}, 2908, "tcp"}, {"mao", {NULL}, 2908, "udp"}, {"funk-dialout", {NULL}, 2909, "tcp"}, {"funk-dialout", {NULL}, 2909, "udp"}, {"tdaccess", {NULL}, 2910, "tcp"}, {"tdaccess", {NULL}, 2910, "udp"}, {"blockade", {NULL}, 2911, "tcp"}, {"blockade", {NULL}, 2911, "udp"}, {"epicon", {NULL}, 2912, "tcp"}, {"epicon", {NULL}, 2912, "udp"}, {"boosterware", {NULL}, 2913, "tcp"}, {"boosterware", {NULL}, 2913, "udp"}, {"gamelobby", {NULL}, 2914, "tcp"}, {"gamelobby", {NULL}, 2914, "udp"}, {"tksocket", {NULL}, 2915, "tcp"}, {"tksocket", {NULL}, 2915, "udp"}, {"elvin_server", {NULL}, 2916, "tcp"}, {"elvin_server", {NULL}, 2916, "udp"}, {"elvin_client", {NULL}, 2917, "tcp"}, {"elvin_client", {NULL}, 2917, "udp"}, {"kastenchasepad", {NULL}, 2918, "tcp"}, {"kastenchasepad", {NULL}, 2918, "udp"}, {"roboer", {NULL}, 2919, "tcp"}, {"roboer", {NULL}, 2919, "udp"}, {"roboeda", {NULL}, 2920, "tcp"}, {"roboeda", {NULL}, 2920, "udp"}, {"cesdcdman", {NULL}, 2921, "tcp"}, {"cesdcdman", {NULL}, 2921, "udp"}, {"cesdcdtrn", {NULL}, 2922, "tcp"}, {"cesdcdtrn", {NULL}, 2922, "udp"}, {"wta-wsp-wtp-s", {NULL}, 2923, "tcp"}, {"wta-wsp-wtp-s", {NULL}, 2923, "udp"}, {"precise-vip", {NULL}, 2924, "tcp"}, {"precise-vip", {NULL}, 2924, "udp"}, {"mobile-file-dl", {NULL}, 2926, "tcp"}, {"mobile-file-dl", {NULL}, 2926, "udp"}, {"unimobilectrl", {NULL}, 2927, "tcp"}, {"unimobilectrl", {NULL}, 2927, "udp"}, {"redstone-cpss", {NULL}, 2928, "tcp"}, {"redstone-cpss", {NULL}, 2928, "udp"}, {"amx-webadmin", {NULL}, 2929, "tcp"}, {"amx-webadmin", {NULL}, 2929, "udp"}, {"amx-weblinx", {NULL}, 2930, "tcp"}, {"amx-weblinx", {NULL}, 2930, "udp"}, {"circle-x", {NULL}, 2931, "tcp"}, {"circle-x", {NULL}, 2931, "udp"}, {"incp", {NULL}, 2932, "tcp"}, {"incp", {NULL}, 2932, "udp"}, {"4-tieropmgw", {NULL}, 2933, "tcp"}, {"4-tieropmgw", {NULL}, 2933, "udp"}, {"4-tieropmcli", {NULL}, 2934, "tcp"}, {"4-tieropmcli", {NULL}, 2934, "udp"}, {"qtp", {NULL}, 2935, "tcp"}, {"qtp", {NULL}, 2935, "udp"}, {"otpatch", {NULL}, 2936, "tcp"}, {"otpatch", {NULL}, 2936, "udp"}, {"pnaconsult-lm", {NULL}, 2937, "tcp"}, {"pnaconsult-lm", {NULL}, 2937, "udp"}, {"sm-pas-1", {NULL}, 2938, "tcp"}, {"sm-pas-1", {NULL}, 2938, "udp"}, {"sm-pas-2", {NULL}, 2939, "tcp"}, {"sm-pas-2", {NULL}, 2939, "udp"}, {"sm-pas-3", {NULL}, 2940, "tcp"}, {"sm-pas-3", {NULL}, 2940, "udp"}, {"sm-pas-4", {NULL}, 2941, "tcp"}, {"sm-pas-4", {NULL}, 2941, "udp"}, {"sm-pas-5", {NULL}, 2942, "tcp"}, {"sm-pas-5", {NULL}, 2942, "udp"}, {"ttnrepository", {NULL}, 2943, "tcp"}, {"ttnrepository", {NULL}, 2943, "udp"}, {"megaco-h248", {NULL}, 2944, "tcp"}, {"megaco-h248", {NULL}, 2944, "udp"}, {"megaco-h248", {NULL}, 2944, "sctp"}, {"h248-binary", {NULL}, 2945, "tcp"}, {"h248-binary", {NULL}, 2945, "udp"}, {"h248-binary", {NULL}, 2945, "sctp"}, {"fjsvmpor", {NULL}, 2946, "tcp"}, {"fjsvmpor", {NULL}, 2946, "udp"}, {"gpsd", {NULL}, 2947, "tcp"}, {"gpsd", {NULL}, 2947, "udp"}, {"wap-push", {NULL}, 2948, "tcp"}, {"wap-push", {NULL}, 2948, "udp"}, {"wap-pushsecure", {NULL}, 2949, "tcp"}, {"wap-pushsecure", {NULL}, 2949, "udp"}, {"esip", {NULL}, 2950, "tcp"}, {"esip", {NULL}, 2950, "udp"}, {"ottp", {NULL}, 2951, "tcp"}, {"ottp", {NULL}, 2951, "udp"}, {"mpfwsas", {NULL}, 2952, "tcp"}, {"mpfwsas", {NULL}, 2952, "udp"}, {"ovalarmsrv", {NULL}, 2953, "tcp"}, {"ovalarmsrv", {NULL}, 2953, "udp"}, {"ovalarmsrv-cmd", {NULL}, 2954, "tcp"}, {"ovalarmsrv-cmd", {NULL}, 2954, "udp"}, {"csnotify", {NULL}, 2955, "tcp"}, {"csnotify", {NULL}, 2955, "udp"}, {"ovrimosdbman", {NULL}, 2956, "tcp"}, {"ovrimosdbman", {NULL}, 2956, "udp"}, {"jmact5", {NULL}, 2957, "tcp"}, {"jmact5", {NULL}, 2957, "udp"}, {"jmact6", {NULL}, 2958, "tcp"}, {"jmact6", {NULL}, 2958, "udp"}, {"rmopagt", {NULL}, 2959, "tcp"}, {"rmopagt", {NULL}, 2959, "udp"}, {"dfoxserver", {NULL}, 2960, "tcp"}, {"dfoxserver", {NULL}, 2960, "udp"}, {"boldsoft-lm", {NULL}, 2961, "tcp"}, {"boldsoft-lm", {NULL}, 2961, "udp"}, {"iph-policy-cli", {NULL}, 2962, "tcp"}, {"iph-policy-cli", {NULL}, 2962, "udp"}, {"iph-policy-adm", {NULL}, 2963, "tcp"}, {"iph-policy-adm", {NULL}, 2963, "udp"}, {"bullant-srap", {NULL}, 2964, "tcp"}, {"bullant-srap", {NULL}, 2964, "udp"}, {"bullant-rap", {NULL}, 2965, "tcp"}, {"bullant-rap", {NULL}, 2965, "udp"}, {"idp-infotrieve", {NULL}, 2966, "tcp"}, {"idp-infotrieve", {NULL}, 2966, "udp"}, {"ssc-agent", {NULL}, 2967, "tcp"}, {"ssc-agent", {NULL}, 2967, "udp"}, {"enpp", {NULL}, 2968, "tcp"}, {"enpp", {NULL}, 2968, "udp"}, {"essp", {NULL}, 2969, "tcp"}, {"essp", {NULL}, 2969, "udp"}, {"index-net", {NULL}, 2970, "tcp"}, {"index-net", {NULL}, 2970, "udp"}, {"netclip", {NULL}, 2971, "tcp"}, {"netclip", {NULL}, 2971, "udp"}, {"pmsm-webrctl", {NULL}, 2972, "tcp"}, {"pmsm-webrctl", {NULL}, 2972, "udp"}, {"svnetworks", {NULL}, 2973, "tcp"}, {"svnetworks", {NULL}, 2973, "udp"}, {"signal", {NULL}, 2974, "tcp"}, {"signal", {NULL}, 2974, "udp"}, {"fjmpcm", {NULL}, 2975, "tcp"}, {"fjmpcm", {NULL}, 2975, "udp"}, {"cns-srv-port", {NULL}, 2976, "tcp"}, {"cns-srv-port", {NULL}, 2976, "udp"}, {"ttc-etap-ns", {NULL}, 2977, "tcp"}, {"ttc-etap-ns", {NULL}, 2977, "udp"}, {"ttc-etap-ds", {NULL}, 2978, "tcp"}, {"ttc-etap-ds", {NULL}, 2978, "udp"}, {"h263-video", {NULL}, 2979, "tcp"}, {"h263-video", {NULL}, 2979, "udp"}, {"wimd", {NULL}, 2980, "tcp"}, {"wimd", {NULL}, 2980, "udp"}, {"mylxamport", {NULL}, 2981, "tcp"}, {"mylxamport", {NULL}, 2981, "udp"}, {"iwb-whiteboard", {NULL}, 2982, "tcp"}, {"iwb-whiteboard", {NULL}, 2982, "udp"}, {"netplan", {NULL}, 2983, "tcp"}, {"netplan", {NULL}, 2983, "udp"}, {"hpidsadmin", {NULL}, 2984, "tcp"}, {"hpidsadmin", {NULL}, 2984, "udp"}, {"hpidsagent", {NULL}, 2985, "tcp"}, {"hpidsagent", {NULL}, 2985, "udp"}, {"stonefalls", {NULL}, 2986, "tcp"}, {"stonefalls", {NULL}, 2986, "udp"}, {"identify", {NULL}, 2987, "tcp"}, {"identify", {NULL}, 2987, "udp"}, {"hippad", {NULL}, 2988, "tcp"}, {"hippad", {NULL}, 2988, "udp"}, {"zarkov", {NULL}, 2989, "tcp"}, {"zarkov", {NULL}, 2989, "udp"}, {"boscap", {NULL}, 2990, "tcp"}, {"boscap", {NULL}, 2990, "udp"}, {"wkstn-mon", {NULL}, 2991, "tcp"}, {"wkstn-mon", {NULL}, 2991, "udp"}, {"avenyo", {NULL}, 2992, "tcp"}, {"avenyo", {NULL}, 2992, "udp"}, {"veritas-vis1", {NULL}, 2993, "tcp"}, {"veritas-vis1", {NULL}, 2993, "udp"}, {"veritas-vis2", {NULL}, 2994, "tcp"}, {"veritas-vis2", {NULL}, 2994, "udp"}, {"idrs", {NULL}, 2995, "tcp"}, {"idrs", {NULL}, 2995, "udp"}, {"vsixml", {NULL}, 2996, "tcp"}, {"vsixml", {NULL}, 2996, "udp"}, {"rebol", {NULL}, 2997, "tcp"}, {"rebol", {NULL}, 2997, "udp"}, {"realsecure", {NULL}, 2998, "tcp"}, {"realsecure", {NULL}, 2998, "udp"}, {"remoteware-un", {NULL}, 2999, "tcp"}, {"remoteware-un", {NULL}, 2999, "udp"}, {"hbci", {NULL}, 3000, "tcp"}, {"hbci", {NULL}, 3000, "udp"}, {"remoteware-cl", {NULL}, 3000, "tcp"}, {"remoteware-cl", {NULL}, 3000, "udp"}, {"exlm-agent", {NULL}, 3002, "tcp"}, {"exlm-agent", {NULL}, 3002, "udp"}, {"remoteware-srv", {NULL}, 3002, "tcp"}, {"remoteware-srv", {NULL}, 3002, "udp"}, {"cgms", {NULL}, 3003, "tcp"}, {"cgms", {NULL}, 3003, "udp"}, {"csoftragent", {NULL}, 3004, "tcp"}, {"csoftragent", {NULL}, 3004, "udp"}, {"geniuslm", {NULL}, 3005, "tcp"}, {"geniuslm", {NULL}, 3005, "udp"}, {"ii-admin", {NULL}, 3006, "tcp"}, {"ii-admin", {NULL}, 3006, "udp"}, {"lotusmtap", {NULL}, 3007, "tcp"}, {"lotusmtap", {NULL}, 3007, "udp"}, {"midnight-tech", {NULL}, 3008, "tcp"}, {"midnight-tech", {NULL}, 3008, "udp"}, {"pxc-ntfy", {NULL}, 3009, "tcp"}, {"pxc-ntfy", {NULL}, 3009, "udp"}, {"gw", {NULL}, 3010, "tcp"}, {"ping-pong", {NULL}, 3010, "udp"}, {"trusted-web", {NULL}, 3011, "tcp"}, {"trusted-web", {NULL}, 3011, "udp"}, {"twsdss", {NULL}, 3012, "tcp"}, {"twsdss", {NULL}, 3012, "udp"}, {"gilatskysurfer", {NULL}, 3013, "tcp"}, {"gilatskysurfer", {NULL}, 3013, "udp"}, {"broker_service", {NULL}, 3014, "tcp"}, {"broker_service", {NULL}, 3014, "udp"}, {"nati-dstp", {NULL}, 3015, "tcp"}, {"nati-dstp", {NULL}, 3015, "udp"}, {"notify_srvr", {NULL}, 3016, "tcp"}, {"notify_srvr", {NULL}, 3016, "udp"}, {"event_listener", {NULL}, 3017, "tcp"}, {"event_listener", {NULL}, 3017, "udp"}, {"srvc_registry", {NULL}, 3018, "tcp"}, {"srvc_registry", {NULL}, 3018, "udp"}, {"resource_mgr", {NULL}, 3019, "tcp"}, {"resource_mgr", {NULL}, 3019, "udp"}, {"cifs", {NULL}, 3020, "tcp"}, {"cifs", {NULL}, 3020, "udp"}, {"agriserver", {NULL}, 3021, "tcp"}, {"agriserver", {NULL}, 3021, "udp"}, {"csregagent", {NULL}, 3022, "tcp"}, {"csregagent", {NULL}, 3022, "udp"}, {"magicnotes", {NULL}, 3023, "tcp"}, {"magicnotes", {NULL}, 3023, "udp"}, {"nds_sso", {NULL}, 3024, "tcp"}, {"nds_sso", {NULL}, 3024, "udp"}, {"arepa-raft", {NULL}, 3025, "tcp"}, {"arepa-raft", {NULL}, 3025, "udp"}, {"agri-gateway", {NULL}, 3026, "tcp"}, {"agri-gateway", {NULL}, 3026, "udp"}, {"LiebDevMgmt_C", {NULL}, 3027, "tcp"}, {"LiebDevMgmt_C", {NULL}, 3027, "udp"}, {"LiebDevMgmt_DM", {NULL}, 3028, "tcp"}, {"LiebDevMgmt_DM", {NULL}, 3028, "udp"}, {"LiebDevMgmt_A", {NULL}, 3029, "tcp"}, {"LiebDevMgmt_A", {NULL}, 3029, "udp"}, {"arepa-cas", {NULL}, 3030, "tcp"}, {"arepa-cas", {NULL}, 3030, "udp"}, {"eppc", {NULL}, 3031, "tcp"}, {"eppc", {NULL}, 3031, "udp"}, {"redwood-chat", {NULL}, 3032, "tcp"}, {"redwood-chat", {NULL}, 3032, "udp"}, {"pdb", {NULL}, 3033, "tcp"}, {"pdb", {NULL}, 3033, "udp"}, {"osmosis-aeea", {NULL}, 3034, "tcp"}, {"osmosis-aeea", {NULL}, 3034, "udp"}, {"fjsv-gssagt", {NULL}, 3035, "tcp"}, {"fjsv-gssagt", {NULL}, 3035, "udp"}, {"hagel-dump", {NULL}, 3036, "tcp"}, {"hagel-dump", {NULL}, 3036, "udp"}, {"hp-san-mgmt", {NULL}, 3037, "tcp"}, {"hp-san-mgmt", {NULL}, 3037, "udp"}, {"santak-ups", {NULL}, 3038, "tcp"}, {"santak-ups", {NULL}, 3038, "udp"}, {"cogitate", {NULL}, 3039, "tcp"}, {"cogitate", {NULL}, 3039, "udp"}, {"tomato-springs", {NULL}, 3040, "tcp"}, {"tomato-springs", {NULL}, 3040, "udp"}, {"di-traceware", {NULL}, 3041, "tcp"}, {"di-traceware", {NULL}, 3041, "udp"}, {"journee", {NULL}, 3042, "tcp"}, {"journee", {NULL}, 3042, "udp"}, {"brp", {NULL}, 3043, "tcp"}, {"brp", {NULL}, 3043, "udp"}, {"epp", {NULL}, 3044, "tcp"}, {"epp", {NULL}, 3044, "udp"}, {"responsenet", {NULL}, 3045, "tcp"}, {"responsenet", {NULL}, 3045, "udp"}, {"di-ase", {NULL}, 3046, "tcp"}, {"di-ase", {NULL}, 3046, "udp"}, {"hlserver", {NULL}, 3047, "tcp"}, {"hlserver", {NULL}, 3047, "udp"}, {"pctrader", {NULL}, 3048, "tcp"}, {"pctrader", {NULL}, 3048, "udp"}, {"nsws", {NULL}, 3049, "tcp"}, {"nsws", {NULL}, 3049, "udp"}, {"gds_db", {NULL}, 3050, "tcp"}, {"gds_db", {NULL}, 3050, "udp"}, {"galaxy-server", {NULL}, 3051, "tcp"}, {"galaxy-server", {NULL}, 3051, "udp"}, {"apc-3052", {NULL}, 3052, "tcp"}, {"apc-3052", {NULL}, 3052, "udp"}, {"dsom-server", {NULL}, 3053, "tcp"}, {"dsom-server", {NULL}, 3053, "udp"}, {"amt-cnf-prot", {NULL}, 3054, "tcp"}, {"amt-cnf-prot", {NULL}, 3054, "udp"}, {"policyserver", {NULL}, 3055, "tcp"}, {"policyserver", {NULL}, 3055, "udp"}, {"cdl-server", {NULL}, 3056, "tcp"}, {"cdl-server", {NULL}, 3056, "udp"}, {"goahead-fldup", {NULL}, 3057, "tcp"}, {"goahead-fldup", {NULL}, 3057, "udp"}, {"videobeans", {NULL}, 3058, "tcp"}, {"videobeans", {NULL}, 3058, "udp"}, {"qsoft", {NULL}, 3059, "tcp"}, {"qsoft", {NULL}, 3059, "udp"}, {"interserver", {NULL}, 3060, "tcp"}, {"interserver", {NULL}, 3060, "udp"}, {"cautcpd", {NULL}, 3061, "tcp"}, {"cautcpd", {NULL}, 3061, "udp"}, {"ncacn-ip-tcp", {NULL}, 3062, "tcp"}, {"ncacn-ip-tcp", {NULL}, 3062, "udp"}, {"ncadg-ip-udp", {NULL}, 3063, "tcp"}, {"ncadg-ip-udp", {NULL}, 3063, "udp"}, {"rprt", {NULL}, 3064, "tcp"}, {"rprt", {NULL}, 3064, "udp"}, {"slinterbase", {NULL}, 3065, "tcp"}, {"slinterbase", {NULL}, 3065, "udp"}, {"netattachsdmp", {NULL}, 3066, "tcp"}, {"netattachsdmp", {NULL}, 3066, "udp"}, {"fjhpjp", {NULL}, 3067, "tcp"}, {"fjhpjp", {NULL}, 3067, "udp"}, {"ls3bcast", {NULL}, 3068, "tcp"}, {"ls3bcast", {NULL}, 3068, "udp"}, {"ls3", {NULL}, 3069, "tcp"}, {"ls3", {NULL}, 3069, "udp"}, {"mgxswitch", {NULL}, 3070, "tcp"}, {"mgxswitch", {NULL}, 3070, "udp"}, {"csd-mgmt-port", {NULL}, 3071, "tcp"}, {"csd-mgmt-port", {NULL}, 3071, "udp"}, {"csd-monitor", {NULL}, 3072, "tcp"}, {"csd-monitor", {NULL}, 3072, "udp"}, {"vcrp", {NULL}, 3073, "tcp"}, {"vcrp", {NULL}, 3073, "udp"}, {"xbox", {NULL}, 3074, "tcp"}, {"xbox", {NULL}, 3074, "udp"}, {"orbix-locator", {NULL}, 3075, "tcp"}, {"orbix-locator", {NULL}, 3075, "udp"}, {"orbix-config", {NULL}, 3076, "tcp"}, {"orbix-config", {NULL}, 3076, "udp"}, {"orbix-loc-ssl", {NULL}, 3077, "tcp"}, {"orbix-loc-ssl", {NULL}, 3077, "udp"}, {"orbix-cfg-ssl", {NULL}, 3078, "tcp"}, {"orbix-cfg-ssl", {NULL}, 3078, "udp"}, {"lv-frontpanel", {NULL}, 3079, "tcp"}, {"lv-frontpanel", {NULL}, 3079, "udp"}, {"stm_pproc", {NULL}, 3080, "tcp"}, {"stm_pproc", {NULL}, 3080, "udp"}, {"tl1-lv", {NULL}, 3081, "tcp"}, {"tl1-lv", {NULL}, 3081, "udp"}, {"tl1-raw", {NULL}, 3082, "tcp"}, {"tl1-raw", {NULL}, 3082, "udp"}, {"tl1-telnet", {NULL}, 3083, "tcp"}, {"tl1-telnet", {NULL}, 3083, "udp"}, {"itm-mccs", {NULL}, 3084, "tcp"}, {"itm-mccs", {NULL}, 3084, "udp"}, {"pcihreq", {NULL}, 3085, "tcp"}, {"pcihreq", {NULL}, 3085, "udp"}, {"jdl-dbkitchen", {NULL}, 3086, "tcp"}, {"jdl-dbkitchen", {NULL}, 3086, "udp"}, {"asoki-sma", {NULL}, 3087, "tcp"}, {"asoki-sma", {NULL}, 3087, "udp"}, {"xdtp", {NULL}, 3088, "tcp"}, {"xdtp", {NULL}, 3088, "udp"}, {"ptk-alink", {NULL}, 3089, "tcp"}, {"ptk-alink", {NULL}, 3089, "udp"}, {"stss", {NULL}, 3090, "tcp"}, {"stss", {NULL}, 3090, "udp"}, {"1ci-smcs", {NULL}, 3091, "tcp"}, {"1ci-smcs", {NULL}, 3091, "udp"}, {"rapidmq-center", {NULL}, 3093, "tcp"}, {"rapidmq-center", {NULL}, 3093, "udp"}, {"rapidmq-reg", {NULL}, 3094, "tcp"}, {"rapidmq-reg", {NULL}, 3094, "udp"}, {"panasas", {NULL}, 3095, "tcp"}, {"panasas", {NULL}, 3095, "udp"}, {"ndl-aps", {NULL}, 3096, "tcp"}, {"ndl-aps", {NULL}, 3096, "udp"}, {"itu-bicc-stc", {NULL}, 3097, "sctp"}, {"umm-port", {NULL}, 3098, "tcp"}, {"umm-port", {NULL}, 3098, "udp"}, {"chmd", {NULL}, 3099, "tcp"}, {"chmd", {NULL}, 3099, "udp"}, {"opcon-xps", {NULL}, 3100, "tcp"}, {"opcon-xps", {NULL}, 3100, "udp"}, {"hp-pxpib", {NULL}, 3101, "tcp"}, {"hp-pxpib", {NULL}, 3101, "udp"}, {"slslavemon", {NULL}, 3102, "tcp"}, {"slslavemon", {NULL}, 3102, "udp"}, {"autocuesmi", {NULL}, 3103, "tcp"}, {"autocuesmi", {NULL}, 3103, "udp"}, {"autocuelog", {NULL}, 3104, "tcp"}, {"autocuetime", {NULL}, 3104, "udp"}, {"cardbox", {NULL}, 3105, "tcp"}, {"cardbox", {NULL}, 3105, "udp"}, {"cardbox-http", {NULL}, 3106, "tcp"}, {"cardbox-http", {NULL}, 3106, "udp"}, {"business", {NULL}, 3107, "tcp"}, {"business", {NULL}, 3107, "udp"}, {"geolocate", {NULL}, 3108, "tcp"}, {"geolocate", {NULL}, 3108, "udp"}, {"personnel", {NULL}, 3109, "tcp"}, {"personnel", {NULL}, 3109, "udp"}, {"sim-control", {NULL}, 3110, "tcp"}, {"sim-control", {NULL}, 3110, "udp"}, {"wsynch", {NULL}, 3111, "tcp"}, {"wsynch", {NULL}, 3111, "udp"}, {"ksysguard", {NULL}, 3112, "tcp"}, {"ksysguard", {NULL}, 3112, "udp"}, {"cs-auth-svr", {NULL}, 3113, "tcp"}, {"cs-auth-svr", {NULL}, 3113, "udp"}, {"ccmad", {NULL}, 3114, "tcp"}, {"ccmad", {NULL}, 3114, "udp"}, {"mctet-master", {NULL}, 3115, "tcp"}, {"mctet-master", {NULL}, 3115, "udp"}, {"mctet-gateway", {NULL}, 3116, "tcp"}, {"mctet-gateway", {NULL}, 3116, "udp"}, {"mctet-jserv", {NULL}, 3117, "tcp"}, {"mctet-jserv", {NULL}, 3117, "udp"}, {"pkagent", {NULL}, 3118, "tcp"}, {"pkagent", {NULL}, 3118, "udp"}, {"d2000kernel", {NULL}, 3119, "tcp"}, {"d2000kernel", {NULL}, 3119, "udp"}, {"d2000webserver", {NULL}, 3120, "tcp"}, {"d2000webserver", {NULL}, 3120, "udp"}, {"vtr-emulator", {NULL}, 3122, "tcp"}, {"vtr-emulator", {NULL}, 3122, "udp"}, {"edix", {NULL}, 3123, "tcp"}, {"edix", {NULL}, 3123, "udp"}, {"beacon-port", {NULL}, 3124, "tcp"}, {"beacon-port", {NULL}, 3124, "udp"}, {"a13-an", {NULL}, 3125, "tcp"}, {"a13-an", {NULL}, 3125, "udp"}, {"ctx-bridge", {NULL}, 3127, "tcp"}, {"ctx-bridge", {NULL}, 3127, "udp"}, {"ndl-aas", {NULL}, 3128, "tcp"}, {"ndl-aas", {NULL}, 3128, "udp"}, {"netport-id", {NULL}, 3129, "tcp"}, {"netport-id", {NULL}, 3129, "udp"}, {"icpv2", {NULL}, 3130, "tcp"}, {"icpv2", {NULL}, 3130, "udp"}, {"netbookmark", {NULL}, 3131, "tcp"}, {"netbookmark", {NULL}, 3131, "udp"}, {"ms-rule-engine", {NULL}, 3132, "tcp"}, {"ms-rule-engine", {NULL}, 3132, "udp"}, {"prism-deploy", {NULL}, 3133, "tcp"}, {"prism-deploy", {NULL}, 3133, "udp"}, {"ecp", {NULL}, 3134, "tcp"}, {"ecp", {NULL}, 3134, "udp"}, {"peerbook-port", {NULL}, 3135, "tcp"}, {"peerbook-port", {NULL}, 3135, "udp"}, {"grubd", {NULL}, 3136, "tcp"}, {"grubd", {NULL}, 3136, "udp"}, {"rtnt-1", {NULL}, 3137, "tcp"}, {"rtnt-1", {NULL}, 3137, "udp"}, {"rtnt-2", {NULL}, 3138, "tcp"}, {"rtnt-2", {NULL}, 3138, "udp"}, {"incognitorv", {NULL}, 3139, "tcp"}, {"incognitorv", {NULL}, 3139, "udp"}, {"ariliamulti", {NULL}, 3140, "tcp"}, {"ariliamulti", {NULL}, 3140, "udp"}, {"vmodem", {NULL}, 3141, "tcp"}, {"vmodem", {NULL}, 3141, "udp"}, {"rdc-wh-eos", {NULL}, 3142, "tcp"}, {"rdc-wh-eos", {NULL}, 3142, "udp"}, {"seaview", {NULL}, 3143, "tcp"}, {"seaview", {NULL}, 3143, "udp"}, {"tarantella", {NULL}, 3144, "tcp"}, {"tarantella", {NULL}, 3144, "udp"}, {"csi-lfap", {NULL}, 3145, "tcp"}, {"csi-lfap", {NULL}, 3145, "udp"}, {"bears-02", {NULL}, 3146, "tcp"}, {"bears-02", {NULL}, 3146, "udp"}, {"rfio", {NULL}, 3147, "tcp"}, {"rfio", {NULL}, 3147, "udp"}, {"nm-game-admin", {NULL}, 3148, "tcp"}, {"nm-game-admin", {NULL}, 3148, "udp"}, {"nm-game-server", {NULL}, 3149, "tcp"}, {"nm-game-server", {NULL}, 3149, "udp"}, {"nm-asses-admin", {NULL}, 3150, "tcp"}, {"nm-asses-admin", {NULL}, 3150, "udp"}, {"nm-assessor", {NULL}, 3151, "tcp"}, {"nm-assessor", {NULL}, 3151, "udp"}, {"feitianrockey", {NULL}, 3152, "tcp"}, {"feitianrockey", {NULL}, 3152, "udp"}, {"s8-client-port", {NULL}, 3153, "tcp"}, {"s8-client-port", {NULL}, 3153, "udp"}, {"ccmrmi", {NULL}, 3154, "tcp"}, {"ccmrmi", {NULL}, 3154, "udp"}, {"jpegmpeg", {NULL}, 3155, "tcp"}, {"jpegmpeg", {NULL}, 3155, "udp"}, {"indura", {NULL}, 3156, "tcp"}, {"indura", {NULL}, 3156, "udp"}, {"e3consultants", {NULL}, 3157, "tcp"}, {"e3consultants", {NULL}, 3157, "udp"}, {"stvp", {NULL}, 3158, "tcp"}, {"stvp", {NULL}, 3158, "udp"}, {"navegaweb-port", {NULL}, 3159, "tcp"}, {"navegaweb-port", {NULL}, 3159, "udp"}, {"tip-app-server", {NULL}, 3160, "tcp"}, {"tip-app-server", {NULL}, 3160, "udp"}, {"doc1lm", {NULL}, 3161, "tcp"}, {"doc1lm", {NULL}, 3161, "udp"}, {"sflm", {NULL}, 3162, "tcp"}, {"sflm", {NULL}, 3162, "udp"}, {"res-sap", {NULL}, 3163, "tcp"}, {"res-sap", {NULL}, 3163, "udp"}, {"imprs", {NULL}, 3164, "tcp"}, {"imprs", {NULL}, 3164, "udp"}, {"newgenpay", {NULL}, 3165, "tcp"}, {"newgenpay", {NULL}, 3165, "udp"}, {"sossecollector", {NULL}, 3166, "tcp"}, {"sossecollector", {NULL}, 3166, "udp"}, {"nowcontact", {NULL}, 3167, "tcp"}, {"nowcontact", {NULL}, 3167, "udp"}, {"poweronnud", {NULL}, 3168, "tcp"}, {"poweronnud", {NULL}, 3168, "udp"}, {"serverview-as", {NULL}, 3169, "tcp"}, {"serverview-as", {NULL}, 3169, "udp"}, {"serverview-asn", {NULL}, 3170, "tcp"}, {"serverview-asn", {NULL}, 3170, "udp"}, {"serverview-gf", {NULL}, 3171, "tcp"}, {"serverview-gf", {NULL}, 3171, "udp"}, {"serverview-rm", {NULL}, 3172, "tcp"}, {"serverview-rm", {NULL}, 3172, "udp"}, {"serverview-icc", {NULL}, 3173, "tcp"}, {"serverview-icc", {NULL}, 3173, "udp"}, {"armi-server", {NULL}, 3174, "tcp"}, {"armi-server", {NULL}, 3174, "udp"}, {"t1-e1-over-ip", {NULL}, 3175, "tcp"}, {"t1-e1-over-ip", {NULL}, 3175, "udp"}, {"ars-master", {NULL}, 3176, "tcp"}, {"ars-master", {NULL}, 3176, "udp"}, {"phonex-port", {NULL}, 3177, "tcp"}, {"phonex-port", {NULL}, 3177, "udp"}, {"radclientport", {NULL}, 3178, "tcp"}, {"radclientport", {NULL}, 3178, "udp"}, {"h2gf-w-2m", {NULL}, 3179, "tcp"}, {"h2gf-w-2m", {NULL}, 3179, "udp"}, {"mc-brk-srv", {NULL}, 3180, "tcp"}, {"mc-brk-srv", {NULL}, 3180, "udp"}, {"bmcpatrolagent", {NULL}, 3181, "tcp"}, {"bmcpatrolagent", {NULL}, 3181, "udp"}, {"bmcpatrolrnvu", {NULL}, 3182, "tcp"}, {"bmcpatrolrnvu", {NULL}, 3182, "udp"}, {"cops-tls", {NULL}, 3183, "tcp"}, {"cops-tls", {NULL}, 3183, "udp"}, {"apogeex-port", {NULL}, 3184, "tcp"}, {"apogeex-port", {NULL}, 3184, "udp"}, {"smpppd", {NULL}, 3185, "tcp"}, {"smpppd", {NULL}, 3185, "udp"}, {"iiw-port", {NULL}, 3186, "tcp"}, {"iiw-port", {NULL}, 3186, "udp"}, {"odi-port", {NULL}, 3187, "tcp"}, {"odi-port", {NULL}, 3187, "udp"}, {"brcm-comm-port", {NULL}, 3188, "tcp"}, {"brcm-comm-port", {NULL}, 3188, "udp"}, {"pcle-infex", {NULL}, 3189, "tcp"}, {"pcle-infex", {NULL}, 3189, "udp"}, {"csvr-proxy", {NULL}, 3190, "tcp"}, {"csvr-proxy", {NULL}, 3190, "udp"}, {"csvr-sslproxy", {NULL}, 3191, "tcp"}, {"csvr-sslproxy", {NULL}, 3191, "udp"}, {"firemonrcc", {NULL}, 3192, "tcp"}, {"firemonrcc", {NULL}, 3192, "udp"}, {"spandataport", {NULL}, 3193, "tcp"}, {"spandataport", {NULL}, 3193, "udp"}, {"magbind", {NULL}, 3194, "tcp"}, {"magbind", {NULL}, 3194, "udp"}, {"ncu-1", {NULL}, 3195, "tcp"}, {"ncu-1", {NULL}, 3195, "udp"}, {"ncu-2", {NULL}, 3196, "tcp"}, {"ncu-2", {NULL}, 3196, "udp"}, {"embrace-dp-s", {NULL}, 3197, "tcp"}, {"embrace-dp-s", {NULL}, 3197, "udp"}, {"embrace-dp-c", {NULL}, 3198, "tcp"}, {"embrace-dp-c", {NULL}, 3198, "udp"}, {"dmod-workspace", {NULL}, 3199, "tcp"}, {"dmod-workspace", {NULL}, 3199, "udp"}, {"tick-port", {NULL}, 3200, "tcp"}, {"tick-port", {NULL}, 3200, "udp"}, {"cpq-tasksmart", {NULL}, 3201, "tcp"}, {"cpq-tasksmart", {NULL}, 3201, "udp"}, {"intraintra", {NULL}, 3202, "tcp"}, {"intraintra", {NULL}, 3202, "udp"}, {"netwatcher-mon", {NULL}, 3203, "tcp"}, {"netwatcher-mon", {NULL}, 3203, "udp"}, {"netwatcher-db", {NULL}, 3204, "tcp"}, {"netwatcher-db", {NULL}, 3204, "udp"}, {"isns", {NULL}, 3205, "tcp"}, {"isns", {NULL}, 3205, "udp"}, {"ironmail", {NULL}, 3206, "tcp"}, {"ironmail", {NULL}, 3206, "udp"}, {"vx-auth-port", {NULL}, 3207, "tcp"}, {"vx-auth-port", {NULL}, 3207, "udp"}, {"pfu-prcallback", {NULL}, 3208, "tcp"}, {"pfu-prcallback", {NULL}, 3208, "udp"}, {"netwkpathengine", {NULL}, 3209, "tcp"}, {"netwkpathengine", {NULL}, 3209, "udp"}, {"flamenco-proxy", {NULL}, 3210, "tcp"}, {"flamenco-proxy", {NULL}, 3210, "udp"}, {"avsecuremgmt", {NULL}, 3211, "tcp"}, {"avsecuremgmt", {NULL}, 3211, "udp"}, {"surveyinst", {NULL}, 3212, "tcp"}, {"surveyinst", {NULL}, 3212, "udp"}, {"neon24x7", {NULL}, 3213, "tcp"}, {"neon24x7", {NULL}, 3213, "udp"}, {"jmq-daemon-1", {NULL}, 3214, "tcp"}, {"jmq-daemon-1", {NULL}, 3214, "udp"}, {"jmq-daemon-2", {NULL}, 3215, "tcp"}, {"jmq-daemon-2", {NULL}, 3215, "udp"}, {"ferrari-foam", {NULL}, 3216, "tcp"}, {"ferrari-foam", {NULL}, 3216, "udp"}, {"unite", {NULL}, 3217, "tcp"}, {"unite", {NULL}, 3217, "udp"}, {"smartpackets", {NULL}, 3218, "tcp"}, {"smartpackets", {NULL}, 3218, "udp"}, {"wms-messenger", {NULL}, 3219, "tcp"}, {"wms-messenger", {NULL}, 3219, "udp"}, {"xnm-ssl", {NULL}, 3220, "tcp"}, {"xnm-ssl", {NULL}, 3220, "udp"}, {"xnm-clear-text", {NULL}, 3221, "tcp"}, {"xnm-clear-text", {NULL}, 3221, "udp"}, {"glbp", {NULL}, 3222, "tcp"}, {"glbp", {NULL}, 3222, "udp"}, {"digivote", {NULL}, 3223, "tcp"}, {"digivote", {NULL}, 3223, "udp"}, {"aes-discovery", {NULL}, 3224, "tcp"}, {"aes-discovery", {NULL}, 3224, "udp"}, {"fcip-port", {NULL}, 3225, "tcp"}, {"fcip-port", {NULL}, 3225, "udp"}, {"isi-irp", {NULL}, 3226, "tcp"}, {"isi-irp", {NULL}, 3226, "udp"}, {"dwnmshttp", {NULL}, 3227, "tcp"}, {"dwnmshttp", {NULL}, 3227, "udp"}, {"dwmsgserver", {NULL}, 3228, "tcp"}, {"dwmsgserver", {NULL}, 3228, "udp"}, {"global-cd-port", {NULL}, 3229, "tcp"}, {"global-cd-port", {NULL}, 3229, "udp"}, {"sftdst-port", {NULL}, 3230, "tcp"}, {"sftdst-port", {NULL}, 3230, "udp"}, {"vidigo", {NULL}, 3231, "tcp"}, {"vidigo", {NULL}, 3231, "udp"}, {"mdtp", {NULL}, 3232, "tcp"}, {"mdtp", {NULL}, 3232, "udp"}, {"whisker", {NULL}, 3233, "tcp"}, {"whisker", {NULL}, 3233, "udp"}, {"alchemy", {NULL}, 3234, "tcp"}, {"alchemy", {NULL}, 3234, "udp"}, {"mdap-port", {NULL}, 3235, "tcp"}, {"mdap-port", {NULL}, 3235, "udp"}, {"apparenet-ts", {NULL}, 3236, "tcp"}, {"apparenet-ts", {NULL}, 3236, "udp"}, {"apparenet-tps", {NULL}, 3237, "tcp"}, {"apparenet-tps", {NULL}, 3237, "udp"}, {"apparenet-as", {NULL}, 3238, "tcp"}, {"apparenet-as", {NULL}, 3238, "udp"}, {"apparenet-ui", {NULL}, 3239, "tcp"}, {"apparenet-ui", {NULL}, 3239, "udp"}, {"triomotion", {NULL}, 3240, "tcp"}, {"triomotion", {NULL}, 3240, "udp"}, {"sysorb", {NULL}, 3241, "tcp"}, {"sysorb", {NULL}, 3241, "udp"}, {"sdp-id-port", {NULL}, 3242, "tcp"}, {"sdp-id-port", {NULL}, 3242, "udp"}, {"timelot", {NULL}, 3243, "tcp"}, {"timelot", {NULL}, 3243, "udp"}, {"onesaf", {NULL}, 3244, "tcp"}, {"onesaf", {NULL}, 3244, "udp"}, {"vieo-fe", {NULL}, 3245, "tcp"}, {"vieo-fe", {NULL}, 3245, "udp"}, {"dvt-system", {NULL}, 3246, "tcp"}, {"dvt-system", {NULL}, 3246, "udp"}, {"dvt-data", {NULL}, 3247, "tcp"}, {"dvt-data", {NULL}, 3247, "udp"}, {"procos-lm", {NULL}, 3248, "tcp"}, {"procos-lm", {NULL}, 3248, "udp"}, {"ssp", {NULL}, 3249, "tcp"}, {"ssp", {NULL}, 3249, "udp"}, {"hicp", {NULL}, 3250, "tcp"}, {"hicp", {NULL}, 3250, "udp"}, {"sysscanner", {NULL}, 3251, "tcp"}, {"sysscanner", {NULL}, 3251, "udp"}, {"dhe", {NULL}, 3252, "tcp"}, {"dhe", {NULL}, 3252, "udp"}, {"pda-data", {NULL}, 3253, "tcp"}, {"pda-data", {NULL}, 3253, "udp"}, {"pda-sys", {NULL}, 3254, "tcp"}, {"pda-sys", {NULL}, 3254, "udp"}, {"semaphore", {NULL}, 3255, "tcp"}, {"semaphore", {NULL}, 3255, "udp"}, {"cpqrpm-agent", {NULL}, 3256, "tcp"}, {"cpqrpm-agent", {NULL}, 3256, "udp"}, {"cpqrpm-server", {NULL}, 3257, "tcp"}, {"cpqrpm-server", {NULL}, 3257, "udp"}, {"ivecon-port", {NULL}, 3258, "tcp"}, {"ivecon-port", {NULL}, 3258, "udp"}, {"epncdp2", {NULL}, 3259, "tcp"}, {"epncdp2", {NULL}, 3259, "udp"}, {"iscsi-target", {NULL}, 3260, "tcp"}, {"iscsi-target", {NULL}, 3260, "udp"}, {"winshadow", {NULL}, 3261, "tcp"}, {"winshadow", {NULL}, 3261, "udp"}, {"necp", {NULL}, 3262, "tcp"}, {"necp", {NULL}, 3262, "udp"}, {"ecolor-imager", {NULL}, 3263, "tcp"}, {"ecolor-imager", {NULL}, 3263, "udp"}, {"ccmail", {NULL}, 3264, "tcp"}, {"ccmail", {NULL}, 3264, "udp"}, {"altav-tunnel", {NULL}, 3265, "tcp"}, {"altav-tunnel", {NULL}, 3265, "udp"}, {"ns-cfg-server", {NULL}, 3266, "tcp"}, {"ns-cfg-server", {NULL}, 3266, "udp"}, {"ibm-dial-out", {NULL}, 3267, "tcp"}, {"ibm-dial-out", {NULL}, 3267, "udp"}, {"msft-gc", {NULL}, 3268, "tcp"}, {"msft-gc", {NULL}, 3268, "udp"}, {"msft-gc-ssl", {NULL}, 3269, "tcp"}, {"msft-gc-ssl", {NULL}, 3269, "udp"}, {"verismart", {NULL}, 3270, "tcp"}, {"verismart", {NULL}, 3270, "udp"}, {"csoft-prev", {NULL}, 3271, "tcp"}, {"csoft-prev", {NULL}, 3271, "udp"}, {"user-manager", {NULL}, 3272, "tcp"}, {"user-manager", {NULL}, 3272, "udp"}, {"sxmp", {NULL}, 3273, "tcp"}, {"sxmp", {NULL}, 3273, "udp"}, {"ordinox-server", {NULL}, 3274, "tcp"}, {"ordinox-server", {NULL}, 3274, "udp"}, {"samd", {NULL}, 3275, "tcp"}, {"samd", {NULL}, 3275, "udp"}, {"maxim-asics", {NULL}, 3276, "tcp"}, {"maxim-asics", {NULL}, 3276, "udp"}, {"awg-proxy", {NULL}, 3277, "tcp"}, {"awg-proxy", {NULL}, 3277, "udp"}, {"lkcmserver", {NULL}, 3278, "tcp"}, {"lkcmserver", {NULL}, 3278, "udp"}, {"admind", {NULL}, 3279, "tcp"}, {"admind", {NULL}, 3279, "udp"}, {"vs-server", {NULL}, 3280, "tcp"}, {"vs-server", {NULL}, 3280, "udp"}, {"sysopt", {NULL}, 3281, "tcp"}, {"sysopt", {NULL}, 3281, "udp"}, {"datusorb", {NULL}, 3282, "tcp"}, {"datusorb", {NULL}, 3282, "udp"}, {"net-assistant", {NULL}, 3283, "tcp"}, {"net-assistant", {NULL}, 3283, "udp"}, {"4talk", {NULL}, 3284, "tcp"}, {"4talk", {NULL}, 3284, "udp"}, {"plato", {NULL}, 3285, "tcp"}, {"plato", {NULL}, 3285, "udp"}, {"e-net", {NULL}, 3286, "tcp"}, {"e-net", {NULL}, 3286, "udp"}, {"directvdata", {NULL}, 3287, "tcp"}, {"directvdata", {NULL}, 3287, "udp"}, {"cops", {NULL}, 3288, "tcp"}, {"cops", {NULL}, 3288, "udp"}, {"enpc", {NULL}, 3289, "tcp"}, {"enpc", {NULL}, 3289, "udp"}, {"caps-lm", {NULL}, 3290, "tcp"}, {"caps-lm", {NULL}, 3290, "udp"}, {"sah-lm", {NULL}, 3291, "tcp"}, {"sah-lm", {NULL}, 3291, "udp"}, {"cart-o-rama", {NULL}, 3292, "tcp"}, {"cart-o-rama", {NULL}, 3292, "udp"}, {"fg-fps", {NULL}, 3293, "tcp"}, {"fg-fps", {NULL}, 3293, "udp"}, {"fg-gip", {NULL}, 3294, "tcp"}, {"fg-gip", {NULL}, 3294, "udp"}, {"dyniplookup", {NULL}, 3295, "tcp"}, {"dyniplookup", {NULL}, 3295, "udp"}, {"rib-slm", {NULL}, 3296, "tcp"}, {"rib-slm", {NULL}, 3296, "udp"}, {"cytel-lm", {NULL}, 3297, "tcp"}, {"cytel-lm", {NULL}, 3297, "udp"}, {"deskview", {NULL}, 3298, "tcp"}, {"deskview", {NULL}, 3298, "udp"}, {"pdrncs", {NULL}, 3299, "tcp"}, {"pdrncs", {NULL}, 3299, "udp"}, {"mcs-fastmail", {NULL}, 3302, "tcp"}, {"mcs-fastmail", {NULL}, 3302, "udp"}, {"opsession-clnt", {NULL}, 3303, "tcp"}, {"opsession-clnt", {NULL}, 3303, "udp"}, {"opsession-srvr", {NULL}, 3304, "tcp"}, {"opsession-srvr", {NULL}, 3304, "udp"}, {"odette-ftp", {NULL}, 3305, "tcp"}, {"odette-ftp", {NULL}, 3305, "udp"}, {"mysql", {NULL}, 3306, "tcp"}, {"mysql", {NULL}, 3306, "udp"}, {"opsession-prxy", {NULL}, 3307, "tcp"}, {"opsession-prxy", {NULL}, 3307, "udp"}, {"tns-server", {NULL}, 3308, "tcp"}, {"tns-server", {NULL}, 3308, "udp"}, {"tns-adv", {NULL}, 3309, "tcp"}, {"tns-adv", {NULL}, 3309, "udp"}, {"dyna-access", {NULL}, 3310, "tcp"}, {"dyna-access", {NULL}, 3310, "udp"}, {"mcns-tel-ret", {NULL}, 3311, "tcp"}, {"mcns-tel-ret", {NULL}, 3311, "udp"}, {"appman-server", {NULL}, 3312, "tcp"}, {"appman-server", {NULL}, 3312, "udp"}, {"uorb", {NULL}, 3313, "tcp"}, {"uorb", {NULL}, 3313, "udp"}, {"uohost", {NULL}, 3314, "tcp"}, {"uohost", {NULL}, 3314, "udp"}, {"cdid", {NULL}, 3315, "tcp"}, {"cdid", {NULL}, 3315, "udp"}, {"aicc-cmi", {NULL}, 3316, "tcp"}, {"aicc-cmi", {NULL}, 3316, "udp"}, {"vsaiport", {NULL}, 3317, "tcp"}, {"vsaiport", {NULL}, 3317, "udp"}, {"ssrip", {NULL}, 3318, "tcp"}, {"ssrip", {NULL}, 3318, "udp"}, {"sdt-lmd", {NULL}, 3319, "tcp"}, {"sdt-lmd", {NULL}, 3319, "udp"}, {"officelink2000", {NULL}, 3320, "tcp"}, {"officelink2000", {NULL}, 3320, "udp"}, {"vnsstr", {NULL}, 3321, "tcp"}, {"vnsstr", {NULL}, 3321, "udp"}, {"sftu", {NULL}, 3326, "tcp"}, {"sftu", {NULL}, 3326, "udp"}, {"bbars", {NULL}, 3327, "tcp"}, {"bbars", {NULL}, 3327, "udp"}, {"egptlm", {NULL}, 3328, "tcp"}, {"egptlm", {NULL}, 3328, "udp"}, {"hp-device-disc", {NULL}, 3329, "tcp"}, {"hp-device-disc", {NULL}, 3329, "udp"}, {"mcs-calypsoicf", {NULL}, 3330, "tcp"}, {"mcs-calypsoicf", {NULL}, 3330, "udp"}, {"mcs-messaging", {NULL}, 3331, "tcp"}, {"mcs-messaging", {NULL}, 3331, "udp"}, {"mcs-mailsvr", {NULL}, 3332, "tcp"}, {"mcs-mailsvr", {NULL}, 3332, "udp"}, {"dec-notes", {NULL}, 3333, "tcp"}, {"dec-notes", {NULL}, 3333, "udp"}, {"directv-web", {NULL}, 3334, "tcp"}, {"directv-web", {NULL}, 3334, "udp"}, {"directv-soft", {NULL}, 3335, "tcp"}, {"directv-soft", {NULL}, 3335, "udp"}, {"directv-tick", {NULL}, 3336, "tcp"}, {"directv-tick", {NULL}, 3336, "udp"}, {"directv-catlg", {NULL}, 3337, "tcp"}, {"directv-catlg", {NULL}, 3337, "udp"}, {"anet-b", {NULL}, 3338, "tcp"}, {"anet-b", {NULL}, 3338, "udp"}, {"anet-l", {NULL}, 3339, "tcp"}, {"anet-l", {NULL}, 3339, "udp"}, {"anet-m", {NULL}, 3340, "tcp"}, {"anet-m", {NULL}, 3340, "udp"}, {"anet-h", {NULL}, 3341, "tcp"}, {"anet-h", {NULL}, 3341, "udp"}, {"webtie", {NULL}, 3342, "tcp"}, {"webtie", {NULL}, 3342, "udp"}, {"ms-cluster-net", {NULL}, 3343, "tcp"}, {"ms-cluster-net", {NULL}, 3343, "udp"}, {"bnt-manager", {NULL}, 3344, "tcp"}, {"bnt-manager", {NULL}, 3344, "udp"}, {"influence", {NULL}, 3345, "tcp"}, {"influence", {NULL}, 3345, "udp"}, {"trnsprntproxy", {NULL}, 3346, "tcp"}, {"trnsprntproxy", {NULL}, 3346, "udp"}, {"phoenix-rpc", {NULL}, 3347, "tcp"}, {"phoenix-rpc", {NULL}, 3347, "udp"}, {"pangolin-laser", {NULL}, 3348, "tcp"}, {"pangolin-laser", {NULL}, 3348, "udp"}, {"chevinservices", {NULL}, 3349, "tcp"}, {"chevinservices", {NULL}, 3349, "udp"}, {"findviatv", {NULL}, 3350, "tcp"}, {"findviatv", {NULL}, 3350, "udp"}, {"btrieve", {NULL}, 3351, "tcp"}, {"btrieve", {NULL}, 3351, "udp"}, {"ssql", {NULL}, 3352, "tcp"}, {"ssql", {NULL}, 3352, "udp"}, {"fatpipe", {NULL}, 3353, "tcp"}, {"fatpipe", {NULL}, 3353, "udp"}, {"suitjd", {NULL}, 3354, "tcp"}, {"suitjd", {NULL}, 3354, "udp"}, {"ordinox-dbase", {NULL}, 3355, "tcp"}, {"ordinox-dbase", {NULL}, 3355, "udp"}, {"upnotifyps", {NULL}, 3356, "tcp"}, {"upnotifyps", {NULL}, 3356, "udp"}, {"adtech-test", {NULL}, 3357, "tcp"}, {"adtech-test", {NULL}, 3357, "udp"}, {"mpsysrmsvr", {NULL}, 3358, "tcp"}, {"mpsysrmsvr", {NULL}, 3358, "udp"}, {"wg-netforce", {NULL}, 3359, "tcp"}, {"wg-netforce", {NULL}, 3359, "udp"}, {"kv-server", {NULL}, 3360, "tcp"}, {"kv-server", {NULL}, 3360, "udp"}, {"kv-agent", {NULL}, 3361, "tcp"}, {"kv-agent", {NULL}, 3361, "udp"}, {"dj-ilm", {NULL}, 3362, "tcp"}, {"dj-ilm", {NULL}, 3362, "udp"}, {"nati-vi-server", {NULL}, 3363, "tcp"}, {"nati-vi-server", {NULL}, 3363, "udp"}, {"creativeserver", {NULL}, 3364, "tcp"}, {"creativeserver", {NULL}, 3364, "udp"}, {"contentserver", {NULL}, 3365, "tcp"}, {"contentserver", {NULL}, 3365, "udp"}, {"creativepartnr", {NULL}, 3366, "tcp"}, {"creativepartnr", {NULL}, 3366, "udp"}, {"tip2", {NULL}, 3372, "tcp"}, {"tip2", {NULL}, 3372, "udp"}, {"lavenir-lm", {NULL}, 3373, "tcp"}, {"lavenir-lm", {NULL}, 3373, "udp"}, {"cluster-disc", {NULL}, 3374, "tcp"}, {"cluster-disc", {NULL}, 3374, "udp"}, {"vsnm-agent", {NULL}, 3375, "tcp"}, {"vsnm-agent", {NULL}, 3375, "udp"}, {"cdbroker", {NULL}, 3376, "tcp"}, {"cdbroker", {NULL}, 3376, "udp"}, {"cogsys-lm", {NULL}, 3377, "tcp"}, {"cogsys-lm", {NULL}, 3377, "udp"}, {"wsicopy", {NULL}, 3378, "tcp"}, {"wsicopy", {NULL}, 3378, "udp"}, {"socorfs", {NULL}, 3379, "tcp"}, {"socorfs", {NULL}, 3379, "udp"}, {"sns-channels", {NULL}, 3380, "tcp"}, {"sns-channels", {NULL}, 3380, "udp"}, {"geneous", {NULL}, 3381, "tcp"}, {"geneous", {NULL}, 3381, "udp"}, {"fujitsu-neat", {NULL}, 3382, "tcp"}, {"fujitsu-neat", {NULL}, 3382, "udp"}, {"esp-lm", {NULL}, 3383, "tcp"}, {"esp-lm", {NULL}, 3383, "udp"}, {"hp-clic", {NULL}, 3384, "tcp"}, {"hp-clic", {NULL}, 3384, "udp"}, {"qnxnetman", {NULL}, 3385, "tcp"}, {"qnxnetman", {NULL}, 3385, "udp"}, {"gprs-data", {NULL}, 3386, "tcp"}, {"gprs-sig", {NULL}, 3386, "udp"}, {"backroomnet", {NULL}, 3387, "tcp"}, {"backroomnet", {NULL}, 3387, "udp"}, {"cbserver", {NULL}, 3388, "tcp"}, {"cbserver", {NULL}, 3388, "udp"}, {"ms-wbt-server", {NULL}, 3389, "tcp"}, {"ms-wbt-server", {NULL}, 3389, "udp"}, {"dsc", {NULL}, 3390, "tcp"}, {"dsc", {NULL}, 3390, "udp"}, {"savant", {NULL}, 3391, "tcp"}, {"savant", {NULL}, 3391, "udp"}, {"efi-lm", {NULL}, 3392, "tcp"}, {"efi-lm", {NULL}, 3392, "udp"}, {"d2k-tapestry1", {NULL}, 3393, "tcp"}, {"d2k-tapestry1", {NULL}, 3393, "udp"}, {"d2k-tapestry2", {NULL}, 3394, "tcp"}, {"d2k-tapestry2", {NULL}, 3394, "udp"}, {"dyna-lm", {NULL}, 3395, "tcp"}, {"dyna-lm", {NULL}, 3395, "udp"}, {"printer_agent", {NULL}, 3396, "tcp"}, {"printer_agent", {NULL}, 3396, "udp"}, {"cloanto-lm", {NULL}, 3397, "tcp"}, {"cloanto-lm", {NULL}, 3397, "udp"}, {"mercantile", {NULL}, 3398, "tcp"}, {"mercantile", {NULL}, 3398, "udp"}, {"csms", {NULL}, 3399, "tcp"}, {"csms", {NULL}, 3399, "udp"}, {"csms2", {NULL}, 3400, "tcp"}, {"csms2", {NULL}, 3400, "udp"}, {"filecast", {NULL}, 3401, "tcp"}, {"filecast", {NULL}, 3401, "udp"}, {"fxaengine-net", {NULL}, 3402, "tcp"}, {"fxaengine-net", {NULL}, 3402, "udp"}, {"nokia-ann-ch1", {NULL}, 3405, "tcp"}, {"nokia-ann-ch1", {NULL}, 3405, "udp"}, {"nokia-ann-ch2", {NULL}, 3406, "tcp"}, {"nokia-ann-ch2", {NULL}, 3406, "udp"}, {"ldap-admin", {NULL}, 3407, "tcp"}, {"ldap-admin", {NULL}, 3407, "udp"}, {"BESApi", {NULL}, 3408, "tcp"}, {"BESApi", {NULL}, 3408, "udp"}, {"networklens", {NULL}, 3409, "tcp"}, {"networklens", {NULL}, 3409, "udp"}, {"networklenss", {NULL}, 3410, "tcp"}, {"networklenss", {NULL}, 3410, "udp"}, {"biolink-auth", {NULL}, 3411, "tcp"}, {"biolink-auth", {NULL}, 3411, "udp"}, {"xmlblaster", {NULL}, 3412, "tcp"}, {"xmlblaster", {NULL}, 3412, "udp"}, {"svnet", {NULL}, 3413, "tcp"}, {"svnet", {NULL}, 3413, "udp"}, {"wip-port", {NULL}, 3414, "tcp"}, {"wip-port", {NULL}, 3414, "udp"}, {"bcinameservice", {NULL}, 3415, "tcp"}, {"bcinameservice", {NULL}, 3415, "udp"}, {"commandport", {NULL}, 3416, "tcp"}, {"commandport", {NULL}, 3416, "udp"}, {"csvr", {NULL}, 3417, "tcp"}, {"csvr", {NULL}, 3417, "udp"}, {"rnmap", {NULL}, 3418, "tcp"}, {"rnmap", {NULL}, 3418, "udp"}, {"softaudit", {NULL}, 3419, "tcp"}, {"softaudit", {NULL}, 3419, "udp"}, {"ifcp-port", {NULL}, 3420, "tcp"}, {"ifcp-port", {NULL}, 3420, "udp"}, {"bmap", {NULL}, 3421, "tcp"}, {"bmap", {NULL}, 3421, "udp"}, {"rusb-sys-port", {NULL}, 3422, "tcp"}, {"rusb-sys-port", {NULL}, 3422, "udp"}, {"xtrm", {NULL}, 3423, "tcp"}, {"xtrm", {NULL}, 3423, "udp"}, {"xtrms", {NULL}, 3424, "tcp"}, {"xtrms", {NULL}, 3424, "udp"}, {"agps-port", {NULL}, 3425, "tcp"}, {"agps-port", {NULL}, 3425, "udp"}, {"arkivio", {NULL}, 3426, "tcp"}, {"arkivio", {NULL}, 3426, "udp"}, {"websphere-snmp", {NULL}, 3427, "tcp"}, {"websphere-snmp", {NULL}, 3427, "udp"}, {"twcss", {NULL}, 3428, "tcp"}, {"twcss", {NULL}, 3428, "udp"}, {"gcsp", {NULL}, 3429, "tcp"}, {"gcsp", {NULL}, 3429, "udp"}, {"ssdispatch", {NULL}, 3430, "tcp"}, {"ssdispatch", {NULL}, 3430, "udp"}, {"ndl-als", {NULL}, 3431, "tcp"}, {"ndl-als", {NULL}, 3431, "udp"}, {"osdcp", {NULL}, 3432, "tcp"}, {"osdcp", {NULL}, 3432, "udp"}, {"alta-smp", {NULL}, 3433, "tcp"}, {"alta-smp", {NULL}, 3433, "udp"}, {"opencm", {NULL}, 3434, "tcp"}, {"opencm", {NULL}, 3434, "udp"}, {"pacom", {NULL}, 3435, "tcp"}, {"pacom", {NULL}, 3435, "udp"}, {"gc-config", {NULL}, 3436, "tcp"}, {"gc-config", {NULL}, 3436, "udp"}, {"autocueds", {NULL}, 3437, "tcp"}, {"autocueds", {NULL}, 3437, "udp"}, {"spiral-admin", {NULL}, 3438, "tcp"}, {"spiral-admin", {NULL}, 3438, "udp"}, {"hri-port", {NULL}, 3439, "tcp"}, {"hri-port", {NULL}, 3439, "udp"}, {"ans-console", {NULL}, 3440, "tcp"}, {"ans-console", {NULL}, 3440, "udp"}, {"connect-client", {NULL}, 3441, "tcp"}, {"connect-client", {NULL}, 3441, "udp"}, {"connect-server", {NULL}, 3442, "tcp"}, {"connect-server", {NULL}, 3442, "udp"}, {"ov-nnm-websrv", {NULL}, 3443, "tcp"}, {"ov-nnm-websrv", {NULL}, 3443, "udp"}, {"denali-server", {NULL}, 3444, "tcp"}, {"denali-server", {NULL}, 3444, "udp"}, {"monp", {NULL}, 3445, "tcp"}, {"monp", {NULL}, 3445, "udp"}, {"3comfaxrpc", {NULL}, 3446, "tcp"}, {"3comfaxrpc", {NULL}, 3446, "udp"}, {"directnet", {NULL}, 3447, "tcp"}, {"directnet", {NULL}, 3447, "udp"}, {"dnc-port", {NULL}, 3448, "tcp"}, {"dnc-port", {NULL}, 3448, "udp"}, {"hotu-chat", {NULL}, 3449, "tcp"}, {"hotu-chat", {NULL}, 3449, "udp"}, {"castorproxy", {NULL}, 3450, "tcp"}, {"castorproxy", {NULL}, 3450, "udp"}, {"asam", {NULL}, 3451, "tcp"}, {"asam", {NULL}, 3451, "udp"}, {"sabp-signal", {NULL}, 3452, "tcp"}, {"sabp-signal", {NULL}, 3452, "udp"}, {"pscupd", {NULL}, 3453, "tcp"}, {"pscupd", {NULL}, 3453, "udp"}, {"mira", {NULL}, 3454, "tcp"}, {"prsvp", {NULL}, 3455, "tcp"}, {"prsvp", {NULL}, 3455, "udp"}, {"vat", {NULL}, 3456, "tcp"}, {"vat", {NULL}, 3456, "udp"}, {"vat-control", {NULL}, 3457, "tcp"}, {"vat-control", {NULL}, 3457, "udp"}, {"d3winosfi", {NULL}, 3458, "tcp"}, {"d3winosfi", {NULL}, 3458, "udp"}, {"integral", {NULL}, 3459, "tcp"}, {"integral", {NULL}, 3459, "udp"}, {"edm-manager", {NULL}, 3460, "tcp"}, {"edm-manager", {NULL}, 3460, "udp"}, {"edm-stager", {NULL}, 3461, "tcp"}, {"edm-stager", {NULL}, 3461, "udp"}, {"edm-std-notify", {NULL}, 3462, "tcp"}, {"edm-std-notify", {NULL}, 3462, "udp"}, {"edm-adm-notify", {NULL}, 3463, "tcp"}, {"edm-adm-notify", {NULL}, 3463, "udp"}, {"edm-mgr-sync", {NULL}, 3464, "tcp"}, {"edm-mgr-sync", {NULL}, 3464, "udp"}, {"edm-mgr-cntrl", {NULL}, 3465, "tcp"}, {"edm-mgr-cntrl", {NULL}, 3465, "udp"}, {"workflow", {NULL}, 3466, "tcp"}, {"workflow", {NULL}, 3466, "udp"}, {"rcst", {NULL}, 3467, "tcp"}, {"rcst", {NULL}, 3467, "udp"}, {"ttcmremotectrl", {NULL}, 3468, "tcp"}, {"ttcmremotectrl", {NULL}, 3468, "udp"}, {"pluribus", {NULL}, 3469, "tcp"}, {"pluribus", {NULL}, 3469, "udp"}, {"jt400", {NULL}, 3470, "tcp"}, {"jt400", {NULL}, 3470, "udp"}, {"jt400-ssl", {NULL}, 3471, "tcp"}, {"jt400-ssl", {NULL}, 3471, "udp"}, {"jaugsremotec-1", {NULL}, 3472, "tcp"}, {"jaugsremotec-1", {NULL}, 3472, "udp"}, {"jaugsremotec-2", {NULL}, 3473, "tcp"}, {"jaugsremotec-2", {NULL}, 3473, "udp"}, {"ttntspauto", {NULL}, 3474, "tcp"}, {"ttntspauto", {NULL}, 3474, "udp"}, {"genisar-port", {NULL}, 3475, "tcp"}, {"genisar-port", {NULL}, 3475, "udp"}, {"nppmp", {NULL}, 3476, "tcp"}, {"nppmp", {NULL}, 3476, "udp"}, {"ecomm", {NULL}, 3477, "tcp"}, {"ecomm", {NULL}, 3477, "udp"}, {"stun", {NULL}, 3478, "tcp"}, {"stun", {NULL}, 3478, "udp"}, {"turn", {NULL}, 3478, "tcp"}, {"turn", {NULL}, 3478, "udp"}, {"stun-behavior", {NULL}, 3478, "tcp"}, {"stun-behavior", {NULL}, 3478, "udp"}, {"twrpc", {NULL}, 3479, "tcp"}, {"twrpc", {NULL}, 3479, "udp"}, {"plethora", {NULL}, 3480, "tcp"}, {"plethora", {NULL}, 3480, "udp"}, {"cleanerliverc", {NULL}, 3481, "tcp"}, {"cleanerliverc", {NULL}, 3481, "udp"}, {"vulture", {NULL}, 3482, "tcp"}, {"vulture", {NULL}, 3482, "udp"}, {"slim-devices", {NULL}, 3483, "tcp"}, {"slim-devices", {NULL}, 3483, "udp"}, {"gbs-stp", {NULL}, 3484, "tcp"}, {"gbs-stp", {NULL}, 3484, "udp"}, {"celatalk", {NULL}, 3485, "tcp"}, {"celatalk", {NULL}, 3485, "udp"}, {"ifsf-hb-port", {NULL}, 3486, "tcp"}, {"ifsf-hb-port", {NULL}, 3486, "udp"}, {"ltctcp", {NULL}, 3487, "tcp"}, {"ltcudp", {NULL}, 3487, "udp"}, {"fs-rh-srv", {NULL}, 3488, "tcp"}, {"fs-rh-srv", {NULL}, 3488, "udp"}, {"dtp-dia", {NULL}, 3489, "tcp"}, {"dtp-dia", {NULL}, 3489, "udp"}, {"colubris", {NULL}, 3490, "tcp"}, {"colubris", {NULL}, 3490, "udp"}, {"swr-port", {NULL}, 3491, "tcp"}, {"swr-port", {NULL}, 3491, "udp"}, {"tvdumtray-port", {NULL}, 3492, "tcp"}, {"tvdumtray-port", {NULL}, 3492, "udp"}, {"nut", {NULL}, 3493, "tcp"}, {"nut", {NULL}, 3493, "udp"}, {"ibm3494", {NULL}, 3494, "tcp"}, {"ibm3494", {NULL}, 3494, "udp"}, {"seclayer-tcp", {NULL}, 3495, "tcp"}, {"seclayer-tcp", {NULL}, 3495, "udp"}, {"seclayer-tls", {NULL}, 3496, "tcp"}, {"seclayer-tls", {NULL}, 3496, "udp"}, {"ipether232port", {NULL}, 3497, "tcp"}, {"ipether232port", {NULL}, 3497, "udp"}, {"dashpas-port", {NULL}, 3498, "tcp"}, {"dashpas-port", {NULL}, 3498, "udp"}, {"sccip-media", {NULL}, 3499, "tcp"}, {"sccip-media", {NULL}, 3499, "udp"}, {"rtmp-port", {NULL}, 3500, "tcp"}, {"rtmp-port", {NULL}, 3500, "udp"}, {"isoft-p2p", {NULL}, 3501, "tcp"}, {"isoft-p2p", {NULL}, 3501, "udp"}, {"avinstalldisc", {NULL}, 3502, "tcp"}, {"avinstalldisc", {NULL}, 3502, "udp"}, {"lsp-ping", {NULL}, 3503, "tcp"}, {"lsp-ping", {NULL}, 3503, "udp"}, {"ironstorm", {NULL}, 3504, "tcp"}, {"ironstorm", {NULL}, 3504, "udp"}, {"ccmcomm", {NULL}, 3505, "tcp"}, {"ccmcomm", {NULL}, 3505, "udp"}, {"apc-3506", {NULL}, 3506, "tcp"}, {"apc-3506", {NULL}, 3506, "udp"}, {"nesh-broker", {NULL}, 3507, "tcp"}, {"nesh-broker", {NULL}, 3507, "udp"}, {"interactionweb", {NULL}, 3508, "tcp"}, {"interactionweb", {NULL}, 3508, "udp"}, {"vt-ssl", {NULL}, 3509, "tcp"}, {"vt-ssl", {NULL}, 3509, "udp"}, {"xss-port", {NULL}, 3510, "tcp"}, {"xss-port", {NULL}, 3510, "udp"}, {"webmail-2", {NULL}, 3511, "tcp"}, {"webmail-2", {NULL}, 3511, "udp"}, {"aztec", {NULL}, 3512, "tcp"}, {"aztec", {NULL}, 3512, "udp"}, {"arcpd", {NULL}, 3513, "tcp"}, {"arcpd", {NULL}, 3513, "udp"}, {"must-p2p", {NULL}, 3514, "tcp"}, {"must-p2p", {NULL}, 3514, "udp"}, {"must-backplane", {NULL}, 3515, "tcp"}, {"must-backplane", {NULL}, 3515, "udp"}, {"smartcard-port", {NULL}, 3516, "tcp"}, {"smartcard-port", {NULL}, 3516, "udp"}, {"802-11-iapp", {NULL}, 3517, "tcp"}, {"802-11-iapp", {NULL}, 3517, "udp"}, {"artifact-msg", {NULL}, 3518, "tcp"}, {"artifact-msg", {NULL}, 3518, "udp"}, {"nvmsgd", {NULL}, 3519, "tcp"}, {"galileo", {NULL}, 3519, "udp"}, {"galileolog", {NULL}, 3520, "tcp"}, {"galileolog", {NULL}, 3520, "udp"}, {"mc3ss", {NULL}, 3521, "tcp"}, {"mc3ss", {NULL}, 3521, "udp"}, {"nssocketport", {NULL}, 3522, "tcp"}, {"nssocketport", {NULL}, 3522, "udp"}, {"odeumservlink", {NULL}, 3523, "tcp"}, {"odeumservlink", {NULL}, 3523, "udp"}, {"ecmport", {NULL}, 3524, "tcp"}, {"ecmport", {NULL}, 3524, "udp"}, {"eisport", {NULL}, 3525, "tcp"}, {"eisport", {NULL}, 3525, "udp"}, {"starquiz-port", {NULL}, 3526, "tcp"}, {"starquiz-port", {NULL}, 3526, "udp"}, {"beserver-msg-q", {NULL}, 3527, "tcp"}, {"beserver-msg-q", {NULL}, 3527, "udp"}, {"jboss-iiop", {NULL}, 3528, "tcp"}, {"jboss-iiop", {NULL}, 3528, "udp"}, {"jboss-iiop-ssl", {NULL}, 3529, "tcp"}, {"jboss-iiop-ssl", {NULL}, 3529, "udp"}, {"gf", {NULL}, 3530, "tcp"}, {"gf", {NULL}, 3530, "udp"}, {"joltid", {NULL}, 3531, "tcp"}, {"joltid", {NULL}, 3531, "udp"}, {"raven-rmp", {NULL}, 3532, "tcp"}, {"raven-rmp", {NULL}, 3532, "udp"}, {"raven-rdp", {NULL}, 3533, "tcp"}, {"raven-rdp", {NULL}, 3533, "udp"}, {"urld-port", {NULL}, 3534, "tcp"}, {"urld-port", {NULL}, 3534, "udp"}, {"ms-la", {NULL}, 3535, "tcp"}, {"ms-la", {NULL}, 3535, "udp"}, {"snac", {NULL}, 3536, "tcp"}, {"snac", {NULL}, 3536, "udp"}, {"ni-visa-remote", {NULL}, 3537, "tcp"}, {"ni-visa-remote", {NULL}, 3537, "udp"}, {"ibm-diradm", {NULL}, 3538, "tcp"}, {"ibm-diradm", {NULL}, 3538, "udp"}, {"ibm-diradm-ssl", {NULL}, 3539, "tcp"}, {"ibm-diradm-ssl", {NULL}, 3539, "udp"}, {"pnrp-port", {NULL}, 3540, "tcp"}, {"pnrp-port", {NULL}, 3540, "udp"}, {"voispeed-port", {NULL}, 3541, "tcp"}, {"voispeed-port", {NULL}, 3541, "udp"}, {"hacl-monitor", {NULL}, 3542, "tcp"}, {"hacl-monitor", {NULL}, 3542, "udp"}, {"qftest-lookup", {NULL}, 3543, "tcp"}, {"qftest-lookup", {NULL}, 3543, "udp"}, {"teredo", {NULL}, 3544, "tcp"}, {"teredo", {NULL}, 3544, "udp"}, {"camac", {NULL}, 3545, "tcp"}, {"camac", {NULL}, 3545, "udp"}, {"symantec-sim", {NULL}, 3547, "tcp"}, {"symantec-sim", {NULL}, 3547, "udp"}, {"interworld", {NULL}, 3548, "tcp"}, {"interworld", {NULL}, 3548, "udp"}, {"tellumat-nms", {NULL}, 3549, "tcp"}, {"tellumat-nms", {NULL}, 3549, "udp"}, {"ssmpp", {NULL}, 3550, "tcp"}, {"ssmpp", {NULL}, 3550, "udp"}, {"apcupsd", {NULL}, 3551, "tcp"}, {"apcupsd", {NULL}, 3551, "udp"}, {"taserver", {NULL}, 3552, "tcp"}, {"taserver", {NULL}, 3552, "udp"}, {"rbr-discovery", {NULL}, 3553, "tcp"}, {"rbr-discovery", {NULL}, 3553, "udp"}, {"questnotify", {NULL}, 3554, "tcp"}, {"questnotify", {NULL}, 3554, "udp"}, {"razor", {NULL}, 3555, "tcp"}, {"razor", {NULL}, 3555, "udp"}, {"sky-transport", {NULL}, 3556, "tcp"}, {"sky-transport", {NULL}, 3556, "udp"}, {"personalos-001", {NULL}, 3557, "tcp"}, {"personalos-001", {NULL}, 3557, "udp"}, {"mcp-port", {NULL}, 3558, "tcp"}, {"mcp-port", {NULL}, 3558, "udp"}, {"cctv-port", {NULL}, 3559, "tcp"}, {"cctv-port", {NULL}, 3559, "udp"}, {"iniserve-port", {NULL}, 3560, "tcp"}, {"iniserve-port", {NULL}, 3560, "udp"}, {"bmc-onekey", {NULL}, 3561, "tcp"}, {"bmc-onekey", {NULL}, 3561, "udp"}, {"sdbproxy", {NULL}, 3562, "tcp"}, {"sdbproxy", {NULL}, 3562, "udp"}, {"watcomdebug", {NULL}, 3563, "tcp"}, {"watcomdebug", {NULL}, 3563, "udp"}, {"esimport", {NULL}, 3564, "tcp"}, {"esimport", {NULL}, 3564, "udp"}, {"m2pa", {NULL}, 3565, "tcp"}, {"m2pa", {NULL}, 3565, "sctp"}, {"quest-data-hub", {NULL}, 3566, "tcp"}, {"oap", {NULL}, 3567, "tcp"}, {"oap", {NULL}, 3567, "udp"}, {"oap-s", {NULL}, 3568, "tcp"}, {"oap-s", {NULL}, 3568, "udp"}, {"mbg-ctrl", {NULL}, 3569, "tcp"}, {"mbg-ctrl", {NULL}, 3569, "udp"}, {"mccwebsvr-port", {NULL}, 3570, "tcp"}, {"mccwebsvr-port", {NULL}, 3570, "udp"}, {"megardsvr-port", {NULL}, 3571, "tcp"}, {"megardsvr-port", {NULL}, 3571, "udp"}, {"megaregsvrport", {NULL}, 3572, "tcp"}, {"megaregsvrport", {NULL}, 3572, "udp"}, {"tag-ups-1", {NULL}, 3573, "tcp"}, {"tag-ups-1", {NULL}, 3573, "udp"}, {"dmaf-server", {NULL}, 3574, "tcp"}, {"dmaf-caster", {NULL}, 3574, "udp"}, {"ccm-port", {NULL}, 3575, "tcp"}, {"ccm-port", {NULL}, 3575, "udp"}, {"cmc-port", {NULL}, 3576, "tcp"}, {"cmc-port", {NULL}, 3576, "udp"}, {"config-port", {NULL}, 3577, "tcp"}, {"config-port", {NULL}, 3577, "udp"}, {"data-port", {NULL}, 3578, "tcp"}, {"data-port", {NULL}, 3578, "udp"}, {"ttat3lb", {NULL}, 3579, "tcp"}, {"ttat3lb", {NULL}, 3579, "udp"}, {"nati-svrloc", {NULL}, 3580, "tcp"}, {"nati-svrloc", {NULL}, 3580, "udp"}, {"kfxaclicensing", {NULL}, 3581, "tcp"}, {"kfxaclicensing", {NULL}, 3581, "udp"}, {"press", {NULL}, 3582, "tcp"}, {"press", {NULL}, 3582, "udp"}, {"canex-watch", {NULL}, 3583, "tcp"}, {"canex-watch", {NULL}, 3583, "udp"}, {"u-dbap", {NULL}, 3584, "tcp"}, {"u-dbap", {NULL}, 3584, "udp"}, {"emprise-lls", {NULL}, 3585, "tcp"}, {"emprise-lls", {NULL}, 3585, "udp"}, {"emprise-lsc", {NULL}, 3586, "tcp"}, {"emprise-lsc", {NULL}, 3586, "udp"}, {"p2pgroup", {NULL}, 3587, "tcp"}, {"p2pgroup", {NULL}, 3587, "udp"}, {"sentinel", {NULL}, 3588, "tcp"}, {"sentinel", {NULL}, 3588, "udp"}, {"isomair", {NULL}, 3589, "tcp"}, {"isomair", {NULL}, 3589, "udp"}, {"wv-csp-sms", {NULL}, 3590, "tcp"}, {"wv-csp-sms", {NULL}, 3590, "udp"}, {"gtrack-server", {NULL}, 3591, "tcp"}, {"gtrack-server", {NULL}, 3591, "udp"}, {"gtrack-ne", {NULL}, 3592, "tcp"}, {"gtrack-ne", {NULL}, 3592, "udp"}, {"bpmd", {NULL}, 3593, "tcp"}, {"bpmd", {NULL}, 3593, "udp"}, {"mediaspace", {NULL}, 3594, "tcp"}, {"mediaspace", {NULL}, 3594, "udp"}, {"shareapp", {NULL}, 3595, "tcp"}, {"shareapp", {NULL}, 3595, "udp"}, {"iw-mmogame", {NULL}, 3596, "tcp"}, {"iw-mmogame", {NULL}, 3596, "udp"}, {"a14", {NULL}, 3597, "tcp"}, {"a14", {NULL}, 3597, "udp"}, {"a15", {NULL}, 3598, "tcp"}, {"a15", {NULL}, 3598, "udp"}, {"quasar-server", {NULL}, 3599, "tcp"}, {"quasar-server", {NULL}, 3599, "udp"}, {"trap-daemon", {NULL}, 3600, "tcp"}, {"trap-daemon", {NULL}, 3600, "udp"}, {"visinet-gui", {NULL}, 3601, "tcp"}, {"visinet-gui", {NULL}, 3601, "udp"}, {"infiniswitchcl", {NULL}, 3602, "tcp"}, {"infiniswitchcl", {NULL}, 3602, "udp"}, {"int-rcv-cntrl", {NULL}, 3603, "tcp"}, {"int-rcv-cntrl", {NULL}, 3603, "udp"}, {"bmc-jmx-port", {NULL}, 3604, "tcp"}, {"bmc-jmx-port", {NULL}, 3604, "udp"}, {"comcam-io", {NULL}, 3605, "tcp"}, {"comcam-io", {NULL}, 3605, "udp"}, {"splitlock", {NULL}, 3606, "tcp"}, {"splitlock", {NULL}, 3606, "udp"}, {"precise-i3", {NULL}, 3607, "tcp"}, {"precise-i3", {NULL}, 3607, "udp"}, {"trendchip-dcp", {NULL}, 3608, "tcp"}, {"trendchip-dcp", {NULL}, 3608, "udp"}, {"cpdi-pidas-cm", {NULL}, 3609, "tcp"}, {"cpdi-pidas-cm", {NULL}, 3609, "udp"}, {"echonet", {NULL}, 3610, "tcp"}, {"echonet", {NULL}, 3610, "udp"}, {"six-degrees", {NULL}, 3611, "tcp"}, {"six-degrees", {NULL}, 3611, "udp"}, {"hp-dataprotect", {NULL}, 3612, "tcp"}, {"hp-dataprotect", {NULL}, 3612, "udp"}, {"alaris-disc", {NULL}, 3613, "tcp"}, {"alaris-disc", {NULL}, 3613, "udp"}, {"sigma-port", {NULL}, 3614, "tcp"}, {"sigma-port", {NULL}, 3614, "udp"}, {"start-network", {NULL}, 3615, "tcp"}, {"start-network", {NULL}, 3615, "udp"}, {"cd3o-protocol", {NULL}, 3616, "tcp"}, {"cd3o-protocol", {NULL}, 3616, "udp"}, {"sharp-server", {NULL}, 3617, "tcp"}, {"sharp-server", {NULL}, 3617, "udp"}, {"aairnet-1", {NULL}, 3618, "tcp"}, {"aairnet-1", {NULL}, 3618, "udp"}, {"aairnet-2", {NULL}, 3619, "tcp"}, {"aairnet-2", {NULL}, 3619, "udp"}, {"ep-pcp", {NULL}, 3620, "tcp"}, {"ep-pcp", {NULL}, 3620, "udp"}, {"ep-nsp", {NULL}, 3621, "tcp"}, {"ep-nsp", {NULL}, 3621, "udp"}, {"ff-lr-port", {NULL}, 3622, "tcp"}, {"ff-lr-port", {NULL}, 3622, "udp"}, {"haipe-discover", {NULL}, 3623, "tcp"}, {"haipe-discover", {NULL}, 3623, "udp"}, {"dist-upgrade", {NULL}, 3624, "tcp"}, {"dist-upgrade", {NULL}, 3624, "udp"}, {"volley", {NULL}, 3625, "tcp"}, {"volley", {NULL}, 3625, "udp"}, {"bvcdaemon-port", {NULL}, 3626, "tcp"}, {"bvcdaemon-port", {NULL}, 3626, "udp"}, {"jamserverport", {NULL}, 3627, "tcp"}, {"jamserverport", {NULL}, 3627, "udp"}, {"ept-machine", {NULL}, 3628, "tcp"}, {"ept-machine", {NULL}, 3628, "udp"}, {"escvpnet", {NULL}, 3629, "tcp"}, {"escvpnet", {NULL}, 3629, "udp"}, {"cs-remote-db", {NULL}, 3630, "tcp"}, {"cs-remote-db", {NULL}, 3630, "udp"}, {"cs-services", {NULL}, 3631, "tcp"}, {"cs-services", {NULL}, 3631, "udp"}, {"distcc", {NULL}, 3632, "tcp"}, {"distcc", {NULL}, 3632, "udp"}, {"wacp", {NULL}, 3633, "tcp"}, {"wacp", {NULL}, 3633, "udp"}, {"hlibmgr", {NULL}, 3634, "tcp"}, {"hlibmgr", {NULL}, 3634, "udp"}, {"sdo", {NULL}, 3635, "tcp"}, {"sdo", {NULL}, 3635, "udp"}, {"servistaitsm", {NULL}, 3636, "tcp"}, {"servistaitsm", {NULL}, 3636, "udp"}, {"scservp", {NULL}, 3637, "tcp"}, {"scservp", {NULL}, 3637, "udp"}, {"ehp-backup", {NULL}, 3638, "tcp"}, {"ehp-backup", {NULL}, 3638, "udp"}, {"xap-ha", {NULL}, 3639, "tcp"}, {"xap-ha", {NULL}, 3639, "udp"}, {"netplay-port1", {NULL}, 3640, "tcp"}, {"netplay-port1", {NULL}, 3640, "udp"}, {"netplay-port2", {NULL}, 3641, "tcp"}, {"netplay-port2", {NULL}, 3641, "udp"}, {"juxml-port", {NULL}, 3642, "tcp"}, {"juxml-port", {NULL}, 3642, "udp"}, {"audiojuggler", {NULL}, 3643, "tcp"}, {"audiojuggler", {NULL}, 3643, "udp"}, {"ssowatch", {NULL}, 3644, "tcp"}, {"ssowatch", {NULL}, 3644, "udp"}, {"cyc", {NULL}, 3645, "tcp"}, {"cyc", {NULL}, 3645, "udp"}, {"xss-srv-port", {NULL}, 3646, "tcp"}, {"xss-srv-port", {NULL}, 3646, "udp"}, {"splitlock-gw", {NULL}, 3647, "tcp"}, {"splitlock-gw", {NULL}, 3647, "udp"}, {"fjcp", {NULL}, 3648, "tcp"}, {"fjcp", {NULL}, 3648, "udp"}, {"nmmp", {NULL}, 3649, "tcp"}, {"nmmp", {NULL}, 3649, "udp"}, {"prismiq-plugin", {NULL}, 3650, "tcp"}, {"prismiq-plugin", {NULL}, 3650, "udp"}, {"xrpc-registry", {NULL}, 3651, "tcp"}, {"xrpc-registry", {NULL}, 3651, "udp"}, {"vxcrnbuport", {NULL}, 3652, "tcp"}, {"vxcrnbuport", {NULL}, 3652, "udp"}, {"tsp", {NULL}, 3653, "tcp"}, {"tsp", {NULL}, 3653, "udp"}, {"vaprtm", {NULL}, 3654, "tcp"}, {"vaprtm", {NULL}, 3654, "udp"}, {"abatemgr", {NULL}, 3655, "tcp"}, {"abatemgr", {NULL}, 3655, "udp"}, {"abatjss", {NULL}, 3656, "tcp"}, {"abatjss", {NULL}, 3656, "udp"}, {"immedianet-bcn", {NULL}, 3657, "tcp"}, {"immedianet-bcn", {NULL}, 3657, "udp"}, {"ps-ams", {NULL}, 3658, "tcp"}, {"ps-ams", {NULL}, 3658, "udp"}, {"apple-sasl", {NULL}, 3659, "tcp"}, {"apple-sasl", {NULL}, 3659, "udp"}, {"can-nds-ssl", {NULL}, 3660, "tcp"}, {"can-nds-ssl", {NULL}, 3660, "udp"}, {"can-ferret-ssl", {NULL}, 3661, "tcp"}, {"can-ferret-ssl", {NULL}, 3661, "udp"}, {"pserver", {NULL}, 3662, "tcp"}, {"pserver", {NULL}, 3662, "udp"}, {"dtp", {NULL}, 3663, "tcp"}, {"dtp", {NULL}, 3663, "udp"}, {"ups-engine", {NULL}, 3664, "tcp"}, {"ups-engine", {NULL}, 3664, "udp"}, {"ent-engine", {NULL}, 3665, "tcp"}, {"ent-engine", {NULL}, 3665, "udp"}, {"eserver-pap", {NULL}, 3666, "tcp"}, {"eserver-pap", {NULL}, 3666, "udp"}, {"infoexch", {NULL}, 3667, "tcp"}, {"infoexch", {NULL}, 3667, "udp"}, {"dell-rm-port", {NULL}, 3668, "tcp"}, {"dell-rm-port", {NULL}, 3668, "udp"}, {"casanswmgmt", {NULL}, 3669, "tcp"}, {"casanswmgmt", {NULL}, 3669, "udp"}, {"smile", {NULL}, 3670, "tcp"}, {"smile", {NULL}, 3670, "udp"}, {"efcp", {NULL}, 3671, "tcp"}, {"efcp", {NULL}, 3671, "udp"}, {"lispworks-orb", {NULL}, 3672, "tcp"}, {"lispworks-orb", {NULL}, 3672, "udp"}, {"mediavault-gui", {NULL}, 3673, "tcp"}, {"mediavault-gui", {NULL}, 3673, "udp"}, {"wininstall-ipc", {NULL}, 3674, "tcp"}, {"wininstall-ipc", {NULL}, 3674, "udp"}, {"calltrax", {NULL}, 3675, "tcp"}, {"calltrax", {NULL}, 3675, "udp"}, {"va-pacbase", {NULL}, 3676, "tcp"}, {"va-pacbase", {NULL}, 3676, "udp"}, {"roverlog", {NULL}, 3677, "tcp"}, {"roverlog", {NULL}, 3677, "udp"}, {"ipr-dglt", {NULL}, 3678, "tcp"}, {"ipr-dglt", {NULL}, 3678, "udp"}, {"newton-dock", {NULL}, 3679, "tcp"}, {"newton-dock", {NULL}, 3679, "udp"}, {"npds-tracker", {NULL}, 3680, "tcp"}, {"npds-tracker", {NULL}, 3680, "udp"}, {"bts-x73", {NULL}, 3681, "tcp"}, {"bts-x73", {NULL}, 3681, "udp"}, {"cas-mapi", {NULL}, 3682, "tcp"}, {"cas-mapi", {NULL}, 3682, "udp"}, {"bmc-ea", {NULL}, 3683, "tcp"}, {"bmc-ea", {NULL}, 3683, "udp"}, {"faxstfx-port", {NULL}, 3684, "tcp"}, {"faxstfx-port", {NULL}, 3684, "udp"}, {"dsx-agent", {NULL}, 3685, "tcp"}, {"dsx-agent", {NULL}, 3685, "udp"}, {"tnmpv2", {NULL}, 3686, "tcp"}, {"tnmpv2", {NULL}, 3686, "udp"}, {"simple-push", {NULL}, 3687, "tcp"}, {"simple-push", {NULL}, 3687, "udp"}, {"simple-push-s", {NULL}, 3688, "tcp"}, {"simple-push-s", {NULL}, 3688, "udp"}, {"daap", {NULL}, 3689, "tcp"}, {"daap", {NULL}, 3689, "udp"}, {"svn", {NULL}, 3690, "tcp"}, {"svn", {NULL}, 3690, "udp"}, {"magaya-network", {NULL}, 3691, "tcp"}, {"magaya-network", {NULL}, 3691, "udp"}, {"intelsync", {NULL}, 3692, "tcp"}, {"intelsync", {NULL}, 3692, "udp"}, {"bmc-data-coll", {NULL}, 3695, "tcp"}, {"bmc-data-coll", {NULL}, 3695, "udp"}, {"telnetcpcd", {NULL}, 3696, "tcp"}, {"telnetcpcd", {NULL}, 3696, "udp"}, {"nw-license", {NULL}, 3697, "tcp"}, {"nw-license", {NULL}, 3697, "udp"}, {"sagectlpanel", {NULL}, 3698, "tcp"}, {"sagectlpanel", {NULL}, 3698, "udp"}, {"kpn-icw", {NULL}, 3699, "tcp"}, {"kpn-icw", {NULL}, 3699, "udp"}, {"lrs-paging", {NULL}, 3700, "tcp"}, {"lrs-paging", {NULL}, 3700, "udp"}, {"netcelera", {NULL}, 3701, "tcp"}, {"netcelera", {NULL}, 3701, "udp"}, {"ws-discovery", {NULL}, 3702, "tcp"}, {"ws-discovery", {NULL}, 3702, "udp"}, {"adobeserver-3", {NULL}, 3703, "tcp"}, {"adobeserver-3", {NULL}, 3703, "udp"}, {"adobeserver-4", {NULL}, 3704, "tcp"}, {"adobeserver-4", {NULL}, 3704, "udp"}, {"adobeserver-5", {NULL}, 3705, "tcp"}, {"adobeserver-5", {NULL}, 3705, "udp"}, {"rt-event", {NULL}, 3706, "tcp"}, {"rt-event", {NULL}, 3706, "udp"}, {"rt-event-s", {NULL}, 3707, "tcp"}, {"rt-event-s", {NULL}, 3707, "udp"}, {"sun-as-iiops", {NULL}, 3708, "tcp"}, {"sun-as-iiops", {NULL}, 3708, "udp"}, {"ca-idms", {NULL}, 3709, "tcp"}, {"ca-idms", {NULL}, 3709, "udp"}, {"portgate-auth", {NULL}, 3710, "tcp"}, {"portgate-auth", {NULL}, 3710, "udp"}, {"edb-server2", {NULL}, 3711, "tcp"}, {"edb-server2", {NULL}, 3711, "udp"}, {"sentinel-ent", {NULL}, 3712, "tcp"}, {"sentinel-ent", {NULL}, 3712, "udp"}, {"tftps", {NULL}, 3713, "tcp"}, {"tftps", {NULL}, 3713, "udp"}, {"delos-dms", {NULL}, 3714, "tcp"}, {"delos-dms", {NULL}, 3714, "udp"}, {"anoto-rendezv", {NULL}, 3715, "tcp"}, {"anoto-rendezv", {NULL}, 3715, "udp"}, {"wv-csp-sms-cir", {NULL}, 3716, "tcp"}, {"wv-csp-sms-cir", {NULL}, 3716, "udp"}, {"wv-csp-udp-cir", {NULL}, 3717, "tcp"}, {"wv-csp-udp-cir", {NULL}, 3717, "udp"}, {"opus-services", {NULL}, 3718, "tcp"}, {"opus-services", {NULL}, 3718, "udp"}, {"itelserverport", {NULL}, 3719, "tcp"}, {"itelserverport", {NULL}, 3719, "udp"}, {"ufastro-instr", {NULL}, 3720, "tcp"}, {"ufastro-instr", {NULL}, 3720, "udp"}, {"xsync", {NULL}, 3721, "tcp"}, {"xsync", {NULL}, 3721, "udp"}, {"xserveraid", {NULL}, 3722, "tcp"}, {"xserveraid", {NULL}, 3722, "udp"}, {"sychrond", {NULL}, 3723, "tcp"}, {"sychrond", {NULL}, 3723, "udp"}, {"blizwow", {NULL}, 3724, "tcp"}, {"blizwow", {NULL}, 3724, "udp"}, {"na-er-tip", {NULL}, 3725, "tcp"}, {"na-er-tip", {NULL}, 3725, "udp"}, {"array-manager", {NULL}, 3726, "tcp"}, {"array-manager", {NULL}, 3726, "udp"}, {"e-mdu", {NULL}, 3727, "tcp"}, {"e-mdu", {NULL}, 3727, "udp"}, {"e-woa", {NULL}, 3728, "tcp"}, {"e-woa", {NULL}, 3728, "udp"}, {"fksp-audit", {NULL}, 3729, "tcp"}, {"fksp-audit", {NULL}, 3729, "udp"}, {"client-ctrl", {NULL}, 3730, "tcp"}, {"client-ctrl", {NULL}, 3730, "udp"}, {"smap", {NULL}, 3731, "tcp"}, {"smap", {NULL}, 3731, "udp"}, {"m-wnn", {NULL}, 3732, "tcp"}, {"m-wnn", {NULL}, 3732, "udp"}, {"multip-msg", {NULL}, 3733, "tcp"}, {"multip-msg", {NULL}, 3733, "udp"}, {"synel-data", {NULL}, 3734, "tcp"}, {"synel-data", {NULL}, 3734, "udp"}, {"pwdis", {NULL}, 3735, "tcp"}, {"pwdis", {NULL}, 3735, "udp"}, {"rs-rmi", {NULL}, 3736, "tcp"}, {"rs-rmi", {NULL}, 3736, "udp"}, {"xpanel", {NULL}, 3737, "tcp"}, {"versatalk", {NULL}, 3738, "tcp"}, {"versatalk", {NULL}, 3738, "udp"}, {"launchbird-lm", {NULL}, 3739, "tcp"}, {"launchbird-lm", {NULL}, 3739, "udp"}, {"heartbeat", {NULL}, 3740, "tcp"}, {"heartbeat", {NULL}, 3740, "udp"}, {"wysdma", {NULL}, 3741, "tcp"}, {"wysdma", {NULL}, 3741, "udp"}, {"cst-port", {NULL}, 3742, "tcp"}, {"cst-port", {NULL}, 3742, "udp"}, {"ipcs-command", {NULL}, 3743, "tcp"}, {"ipcs-command", {NULL}, 3743, "udp"}, {"sasg", {NULL}, 3744, "tcp"}, {"sasg", {NULL}, 3744, "udp"}, {"gw-call-port", {NULL}, 3745, "tcp"}, {"gw-call-port", {NULL}, 3745, "udp"}, {"linktest", {NULL}, 3746, "tcp"}, {"linktest", {NULL}, 3746, "udp"}, {"linktest-s", {NULL}, 3747, "tcp"}, {"linktest-s", {NULL}, 3747, "udp"}, {"webdata", {NULL}, 3748, "tcp"}, {"webdata", {NULL}, 3748, "udp"}, {"cimtrak", {NULL}, 3749, "tcp"}, {"cimtrak", {NULL}, 3749, "udp"}, {"cbos-ip-port", {NULL}, 3750, "tcp"}, {"cbos-ip-port", {NULL}, 3750, "udp"}, {"gprs-cube", {NULL}, 3751, "tcp"}, {"gprs-cube", {NULL}, 3751, "udp"}, {"vipremoteagent", {NULL}, 3752, "tcp"}, {"vipremoteagent", {NULL}, 3752, "udp"}, {"nattyserver", {NULL}, 3753, "tcp"}, {"nattyserver", {NULL}, 3753, "udp"}, {"timestenbroker", {NULL}, 3754, "tcp"}, {"timestenbroker", {NULL}, 3754, "udp"}, {"sas-remote-hlp", {NULL}, 3755, "tcp"}, {"sas-remote-hlp", {NULL}, 3755, "udp"}, {"canon-capt", {NULL}, 3756, "tcp"}, {"canon-capt", {NULL}, 3756, "udp"}, {"grf-port", {NULL}, 3757, "tcp"}, {"grf-port", {NULL}, 3757, "udp"}, {"apw-registry", {NULL}, 3758, "tcp"}, {"apw-registry", {NULL}, 3758, "udp"}, {"exapt-lmgr", {NULL}, 3759, "tcp"}, {"exapt-lmgr", {NULL}, 3759, "udp"}, {"adtempusclient", {NULL}, 3760, "tcp"}, {"adtempusclient", {NULL}, 3760, "udp"}, {"gsakmp", {NULL}, 3761, "tcp"}, {"gsakmp", {NULL}, 3761, "udp"}, {"gbs-smp", {NULL}, 3762, "tcp"}, {"gbs-smp", {NULL}, 3762, "udp"}, {"xo-wave", {NULL}, 3763, "tcp"}, {"xo-wave", {NULL}, 3763, "udp"}, {"mni-prot-rout", {NULL}, 3764, "tcp"}, {"mni-prot-rout", {NULL}, 3764, "udp"}, {"rtraceroute", {NULL}, 3765, "tcp"}, {"rtraceroute", {NULL}, 3765, "udp"}, {"listmgr-port", {NULL}, 3767, "tcp"}, {"listmgr-port", {NULL}, 3767, "udp"}, {"rblcheckd", {NULL}, 3768, "tcp"}, {"rblcheckd", {NULL}, 3768, "udp"}, {"haipe-otnk", {NULL}, 3769, "tcp"}, {"haipe-otnk", {NULL}, 3769, "udp"}, {"cindycollab", {NULL}, 3770, "tcp"}, {"cindycollab", {NULL}, 3770, "udp"}, {"paging-port", {NULL}, 3771, "tcp"}, {"paging-port", {NULL}, 3771, "udp"}, {"ctp", {NULL}, 3772, "tcp"}, {"ctp", {NULL}, 3772, "udp"}, {"ctdhercules", {NULL}, 3773, "tcp"}, {"ctdhercules", {NULL}, 3773, "udp"}, {"zicom", {NULL}, 3774, "tcp"}, {"zicom", {NULL}, 3774, "udp"}, {"ispmmgr", {NULL}, 3775, "tcp"}, {"ispmmgr", {NULL}, 3775, "udp"}, {"dvcprov-port", {NULL}, 3776, "tcp"}, {"dvcprov-port", {NULL}, 3776, "udp"}, {"jibe-eb", {NULL}, 3777, "tcp"}, {"jibe-eb", {NULL}, 3777, "udp"}, {"c-h-it-port", {NULL}, 3778, "tcp"}, {"c-h-it-port", {NULL}, 3778, "udp"}, {"cognima", {NULL}, 3779, "tcp"}, {"cognima", {NULL}, 3779, "udp"}, {"nnp", {NULL}, 3780, "tcp"}, {"nnp", {NULL}, 3780, "udp"}, {"abcvoice-port", {NULL}, 3781, "tcp"}, {"abcvoice-port", {NULL}, 3781, "udp"}, {"iso-tp0s", {NULL}, 3782, "tcp"}, {"iso-tp0s", {NULL}, 3782, "udp"}, {"bim-pem", {NULL}, 3783, "tcp"}, {"bim-pem", {NULL}, 3783, "udp"}, {"bfd-control", {NULL}, 3784, "tcp"}, {"bfd-control", {NULL}, 3784, "udp"}, {"bfd-echo", {NULL}, 3785, "tcp"}, {"bfd-echo", {NULL}, 3785, "udp"}, {"upstriggervsw", {NULL}, 3786, "tcp"}, {"upstriggervsw", {NULL}, 3786, "udp"}, {"fintrx", {NULL}, 3787, "tcp"}, {"fintrx", {NULL}, 3787, "udp"}, {"isrp-port", {NULL}, 3788, "tcp"}, {"isrp-port", {NULL}, 3788, "udp"}, {"remotedeploy", {NULL}, 3789, "tcp"}, {"remotedeploy", {NULL}, 3789, "udp"}, {"quickbooksrds", {NULL}, 3790, "tcp"}, {"quickbooksrds", {NULL}, 3790, "udp"}, {"tvnetworkvideo", {NULL}, 3791, "tcp"}, {"tvnetworkvideo", {NULL}, 3791, "udp"}, {"sitewatch", {NULL}, 3792, "tcp"}, {"sitewatch", {NULL}, 3792, "udp"}, {"dcsoftware", {NULL}, 3793, "tcp"}, {"dcsoftware", {NULL}, 3793, "udp"}, {"jaus", {NULL}, 3794, "tcp"}, {"jaus", {NULL}, 3794, "udp"}, {"myblast", {NULL}, 3795, "tcp"}, {"myblast", {NULL}, 3795, "udp"}, {"spw-dialer", {NULL}, 3796, "tcp"}, {"spw-dialer", {NULL}, 3796, "udp"}, {"idps", {NULL}, 3797, "tcp"}, {"idps", {NULL}, 3797, "udp"}, {"minilock", {NULL}, 3798, "tcp"}, {"minilock", {NULL}, 3798, "udp"}, {"radius-dynauth", {NULL}, 3799, "tcp"}, {"radius-dynauth", {NULL}, 3799, "udp"}, {"pwgpsi", {NULL}, 3800, "tcp"}, {"pwgpsi", {NULL}, 3800, "udp"}, {"ibm-mgr", {NULL}, 3801, "tcp"}, {"ibm-mgr", {NULL}, 3801, "udp"}, {"vhd", {NULL}, 3802, "tcp"}, {"vhd", {NULL}, 3802, "udp"}, {"soniqsync", {NULL}, 3803, "tcp"}, {"soniqsync", {NULL}, 3803, "udp"}, {"iqnet-port", {NULL}, 3804, "tcp"}, {"iqnet-port", {NULL}, 3804, "udp"}, {"tcpdataserver", {NULL}, 3805, "tcp"}, {"tcpdataserver", {NULL}, 3805, "udp"}, {"wsmlb", {NULL}, 3806, "tcp"}, {"wsmlb", {NULL}, 3806, "udp"}, {"spugna", {NULL}, 3807, "tcp"}, {"spugna", {NULL}, 3807, "udp"}, {"sun-as-iiops-ca", {NULL}, 3808, "tcp"}, {"sun-as-iiops-ca", {NULL}, 3808, "udp"}, {"apocd", {NULL}, 3809, "tcp"}, {"apocd", {NULL}, 3809, "udp"}, {"wlanauth", {NULL}, 3810, "tcp"}, {"wlanauth", {NULL}, 3810, "udp"}, {"amp", {NULL}, 3811, "tcp"}, {"amp", {NULL}, 3811, "udp"}, {"neto-wol-server", {NULL}, 3812, "tcp"}, {"neto-wol-server", {NULL}, 3812, "udp"}, {"rap-ip", {NULL}, 3813, "tcp"}, {"rap-ip", {NULL}, 3813, "udp"}, {"neto-dcs", {NULL}, 3814, "tcp"}, {"neto-dcs", {NULL}, 3814, "udp"}, {"lansurveyorxml", {NULL}, 3815, "tcp"}, {"lansurveyorxml", {NULL}, 3815, "udp"}, {"sunlps-http", {NULL}, 3816, "tcp"}, {"sunlps-http", {NULL}, 3816, "udp"}, {"tapeware", {NULL}, 3817, "tcp"}, {"tapeware", {NULL}, 3817, "udp"}, {"crinis-hb", {NULL}, 3818, "tcp"}, {"crinis-hb", {NULL}, 3818, "udp"}, {"epl-slp", {NULL}, 3819, "tcp"}, {"epl-slp", {NULL}, 3819, "udp"}, {"scp", {NULL}, 3820, "tcp"}, {"scp", {NULL}, 3820, "udp"}, {"pmcp", {NULL}, 3821, "tcp"}, {"pmcp", {NULL}, 3821, "udp"}, {"acp-discovery", {NULL}, 3822, "tcp"}, {"acp-discovery", {NULL}, 3822, "udp"}, {"acp-conduit", {NULL}, 3823, "tcp"}, {"acp-conduit", {NULL}, 3823, "udp"}, {"acp-policy", {NULL}, 3824, "tcp"}, {"acp-policy", {NULL}, 3824, "udp"}, {"ffserver", {NULL}, 3825, "tcp"}, {"ffserver", {NULL}, 3825, "udp"}, {"wormux", {NULL}, 3826, "tcp"}, {"wormux", {NULL}, 3826, "udp"}, {"netmpi", {NULL}, 3827, "tcp"}, {"netmpi", {NULL}, 3827, "udp"}, {"neteh", {NULL}, 3828, "tcp"}, {"neteh", {NULL}, 3828, "udp"}, {"neteh-ext", {NULL}, 3829, "tcp"}, {"neteh-ext", {NULL}, 3829, "udp"}, {"cernsysmgmtagt", {NULL}, 3830, "tcp"}, {"cernsysmgmtagt", {NULL}, 3830, "udp"}, {"dvapps", {NULL}, 3831, "tcp"}, {"dvapps", {NULL}, 3831, "udp"}, {"xxnetserver", {NULL}, 3832, "tcp"}, {"xxnetserver", {NULL}, 3832, "udp"}, {"aipn-auth", {NULL}, 3833, "tcp"}, {"aipn-auth", {NULL}, 3833, "udp"}, {"spectardata", {NULL}, 3834, "tcp"}, {"spectardata", {NULL}, 3834, "udp"}, {"spectardb", {NULL}, 3835, "tcp"}, {"spectardb", {NULL}, 3835, "udp"}, {"markem-dcp", {NULL}, 3836, "tcp"}, {"markem-dcp", {NULL}, 3836, "udp"}, {"mkm-discovery", {NULL}, 3837, "tcp"}, {"mkm-discovery", {NULL}, 3837, "udp"}, {"sos", {NULL}, 3838, "tcp"}, {"sos", {NULL}, 3838, "udp"}, {"amx-rms", {NULL}, 3839, "tcp"}, {"amx-rms", {NULL}, 3839, "udp"}, {"flirtmitmir", {NULL}, 3840, "tcp"}, {"flirtmitmir", {NULL}, 3840, "udp"}, {"zfirm-shiprush3", {NULL}, 3841, "tcp"}, {"zfirm-shiprush3", {NULL}, 3841, "udp"}, {"nhci", {NULL}, 3842, "tcp"}, {"nhci", {NULL}, 3842, "udp"}, {"quest-agent", {NULL}, 3843, "tcp"}, {"quest-agent", {NULL}, 3843, "udp"}, {"rnm", {NULL}, 3844, "tcp"}, {"rnm", {NULL}, 3844, "udp"}, {"v-one-spp", {NULL}, 3845, "tcp"}, {"v-one-spp", {NULL}, 3845, "udp"}, {"an-pcp", {NULL}, 3846, "tcp"}, {"an-pcp", {NULL}, 3846, "udp"}, {"msfw-control", {NULL}, 3847, "tcp"}, {"msfw-control", {NULL}, 3847, "udp"}, {"item", {NULL}, 3848, "tcp"}, {"item", {NULL}, 3848, "udp"}, {"spw-dnspreload", {NULL}, 3849, "tcp"}, {"spw-dnspreload", {NULL}, 3849, "udp"}, {"qtms-bootstrap", {NULL}, 3850, "tcp"}, {"qtms-bootstrap", {NULL}, 3850, "udp"}, {"spectraport", {NULL}, 3851, "tcp"}, {"spectraport", {NULL}, 3851, "udp"}, {"sse-app-config", {NULL}, 3852, "tcp"}, {"sse-app-config", {NULL}, 3852, "udp"}, {"sscan", {NULL}, 3853, "tcp"}, {"sscan", {NULL}, 3853, "udp"}, {"stryker-com", {NULL}, 3854, "tcp"}, {"stryker-com", {NULL}, 3854, "udp"}, {"opentrac", {NULL}, 3855, "tcp"}, {"opentrac", {NULL}, 3855, "udp"}, {"informer", {NULL}, 3856, "tcp"}, {"informer", {NULL}, 3856, "udp"}, {"trap-port", {NULL}, 3857, "tcp"}, {"trap-port", {NULL}, 3857, "udp"}, {"trap-port-mom", {NULL}, 3858, "tcp"}, {"trap-port-mom", {NULL}, 3858, "udp"}, {"nav-port", {NULL}, 3859, "tcp"}, {"nav-port", {NULL}, 3859, "udp"}, {"sasp", {NULL}, 3860, "tcp"}, {"sasp", {NULL}, 3860, "udp"}, {"winshadow-hd", {NULL}, 3861, "tcp"}, {"winshadow-hd", {NULL}, 3861, "udp"}, {"giga-pocket", {NULL}, 3862, "tcp"}, {"giga-pocket", {NULL}, 3862, "udp"}, {"asap-tcp", {NULL}, 3863, "tcp"}, {"asap-udp", {NULL}, 3863, "udp"}, {"asap-sctp", {NULL}, 3863, "sctp"}, {"asap-tcp-tls", {NULL}, 3864, "tcp"}, {"asap-sctp-tls", {NULL}, 3864, "sctp"}, {"xpl", {NULL}, 3865, "tcp"}, {"xpl", {NULL}, 3865, "udp"}, {"dzdaemon", {NULL}, 3866, "tcp"}, {"dzdaemon", {NULL}, 3866, "udp"}, {"dzoglserver", {NULL}, 3867, "tcp"}, {"dzoglserver", {NULL}, 3867, "udp"}, {"diameter", {NULL}, 3868, "tcp"}, {"diameter", {NULL}, 3868, "sctp"}, {"ovsam-mgmt", {NULL}, 3869, "tcp"}, {"ovsam-mgmt", {NULL}, 3869, "udp"}, {"ovsam-d-agent", {NULL}, 3870, "tcp"}, {"ovsam-d-agent", {NULL}, 3870, "udp"}, {"avocent-adsap", {NULL}, 3871, "tcp"}, {"avocent-adsap", {NULL}, 3871, "udp"}, {"oem-agent", {NULL}, 3872, "tcp"}, {"oem-agent", {NULL}, 3872, "udp"}, {"fagordnc", {NULL}, 3873, "tcp"}, {"fagordnc", {NULL}, 3873, "udp"}, {"sixxsconfig", {NULL}, 3874, "tcp"}, {"sixxsconfig", {NULL}, 3874, "udp"}, {"pnbscada", {NULL}, 3875, "tcp"}, {"pnbscada", {NULL}, 3875, "udp"}, {"dl_agent", {NULL}, 3876, "tcp"}, {"dl_agent", {NULL}, 3876, "udp"}, {"xmpcr-interface", {NULL}, 3877, "tcp"}, {"xmpcr-interface", {NULL}, 3877, "udp"}, {"fotogcad", {NULL}, 3878, "tcp"}, {"fotogcad", {NULL}, 3878, "udp"}, {"appss-lm", {NULL}, 3879, "tcp"}, {"appss-lm", {NULL}, 3879, "udp"}, {"igrs", {NULL}, 3880, "tcp"}, {"igrs", {NULL}, 3880, "udp"}, {"idac", {NULL}, 3881, "tcp"}, {"idac", {NULL}, 3881, "udp"}, {"msdts1", {NULL}, 3882, "tcp"}, {"msdts1", {NULL}, 3882, "udp"}, {"vrpn", {NULL}, 3883, "tcp"}, {"vrpn", {NULL}, 3883, "udp"}, {"softrack-meter", {NULL}, 3884, "tcp"}, {"softrack-meter", {NULL}, 3884, "udp"}, {"topflow-ssl", {NULL}, 3885, "tcp"}, {"topflow-ssl", {NULL}, 3885, "udp"}, {"nei-management", {NULL}, 3886, "tcp"}, {"nei-management", {NULL}, 3886, "udp"}, {"ciphire-data", {NULL}, 3887, "tcp"}, {"ciphire-data", {NULL}, 3887, "udp"}, {"ciphire-serv", {NULL}, 3888, "tcp"}, {"ciphire-serv", {NULL}, 3888, "udp"}, {"dandv-tester", {NULL}, 3889, "tcp"}, {"dandv-tester", {NULL}, 3889, "udp"}, {"ndsconnect", {NULL}, 3890, "tcp"}, {"ndsconnect", {NULL}, 3890, "udp"}, {"rtc-pm-port", {NULL}, 3891, "tcp"}, {"rtc-pm-port", {NULL}, 3891, "udp"}, {"pcc-image-port", {NULL}, 3892, "tcp"}, {"pcc-image-port", {NULL}, 3892, "udp"}, {"cgi-starapi", {NULL}, 3893, "tcp"}, {"cgi-starapi", {NULL}, 3893, "udp"}, {"syam-agent", {NULL}, 3894, "tcp"}, {"syam-agent", {NULL}, 3894, "udp"}, {"syam-smc", {NULL}, 3895, "tcp"}, {"syam-smc", {NULL}, 3895, "udp"}, {"sdo-tls", {NULL}, 3896, "tcp"}, {"sdo-tls", {NULL}, 3896, "udp"}, {"sdo-ssh", {NULL}, 3897, "tcp"}, {"sdo-ssh", {NULL}, 3897, "udp"}, {"senip", {NULL}, 3898, "tcp"}, {"senip", {NULL}, 3898, "udp"}, {"itv-control", {NULL}, 3899, "tcp"}, {"itv-control", {NULL}, 3899, "udp"}, {"udt_os", {NULL}, 3900, "tcp"}, {"udt_os", {NULL}, 3900, "udp"}, {"nimsh", {NULL}, 3901, "tcp"}, {"nimsh", {NULL}, 3901, "udp"}, {"nimaux", {NULL}, 3902, "tcp"}, {"nimaux", {NULL}, 3902, "udp"}, {"charsetmgr", {NULL}, 3903, "tcp"}, {"charsetmgr", {NULL}, 3903, "udp"}, {"omnilink-port", {NULL}, 3904, "tcp"}, {"omnilink-port", {NULL}, 3904, "udp"}, {"mupdate", {NULL}, 3905, "tcp"}, {"mupdate", {NULL}, 3905, "udp"}, {"topovista-data", {NULL}, 3906, "tcp"}, {"topovista-data", {NULL}, 3906, "udp"}, {"imoguia-port", {NULL}, 3907, "tcp"}, {"imoguia-port", {NULL}, 3907, "udp"}, {"hppronetman", {NULL}, 3908, "tcp"}, {"hppronetman", {NULL}, 3908, "udp"}, {"surfcontrolcpa", {NULL}, 3909, "tcp"}, {"surfcontrolcpa", {NULL}, 3909, "udp"}, {"prnrequest", {NULL}, 3910, "tcp"}, {"prnrequest", {NULL}, 3910, "udp"}, {"prnstatus", {NULL}, 3911, "tcp"}, {"prnstatus", {NULL}, 3911, "udp"}, {"gbmt-stars", {NULL}, 3912, "tcp"}, {"gbmt-stars", {NULL}, 3912, "udp"}, {"listcrt-port", {NULL}, 3913, "tcp"}, {"listcrt-port", {NULL}, 3913, "udp"}, {"listcrt-port-2", {NULL}, 3914, "tcp"}, {"listcrt-port-2", {NULL}, 3914, "udp"}, {"agcat", {NULL}, 3915, "tcp"}, {"agcat", {NULL}, 3915, "udp"}, {"wysdmc", {NULL}, 3916, "tcp"}, {"wysdmc", {NULL}, 3916, "udp"}, {"aftmux", {NULL}, 3917, "tcp"}, {"aftmux", {NULL}, 3917, "udp"}, {"pktcablemmcops", {NULL}, 3918, "tcp"}, {"pktcablemmcops", {NULL}, 3918, "udp"}, {"hyperip", {NULL}, 3919, "tcp"}, {"hyperip", {NULL}, 3919, "udp"}, {"exasoftport1", {NULL}, 3920, "tcp"}, {"exasoftport1", {NULL}, 3920, "udp"}, {"herodotus-net", {NULL}, 3921, "tcp"}, {"herodotus-net", {NULL}, 3921, "udp"}, {"sor-update", {NULL}, 3922, "tcp"}, {"sor-update", {NULL}, 3922, "udp"}, {"symb-sb-port", {NULL}, 3923, "tcp"}, {"symb-sb-port", {NULL}, 3923, "udp"}, {"mpl-gprs-port", {NULL}, 3924, "tcp"}, {"mpl-gprs-port", {NULL}, 3924, "udp"}, {"zmp", {NULL}, 3925, "tcp"}, {"zmp", {NULL}, 3925, "udp"}, {"winport", {NULL}, 3926, "tcp"}, {"winport", {NULL}, 3926, "udp"}, {"natdataservice", {NULL}, 3927, "tcp"}, {"natdataservice", {NULL}, 3927, "udp"}, {"netboot-pxe", {NULL}, 3928, "tcp"}, {"netboot-pxe", {NULL}, 3928, "udp"}, {"smauth-port", {NULL}, 3929, "tcp"}, {"smauth-port", {NULL}, 3929, "udp"}, {"syam-webserver", {NULL}, 3930, "tcp"}, {"syam-webserver", {NULL}, 3930, "udp"}, {"msr-plugin-port", {NULL}, 3931, "tcp"}, {"msr-plugin-port", {NULL}, 3931, "udp"}, {"dyn-site", {NULL}, 3932, "tcp"}, {"dyn-site", {NULL}, 3932, "udp"}, {"plbserve-port", {NULL}, 3933, "tcp"}, {"plbserve-port", {NULL}, 3933, "udp"}, {"sunfm-port", {NULL}, 3934, "tcp"}, {"sunfm-port", {NULL}, 3934, "udp"}, {"sdp-portmapper", {NULL}, 3935, "tcp"}, {"sdp-portmapper", {NULL}, 3935, "udp"}, {"mailprox", {NULL}, 3936, "tcp"}, {"mailprox", {NULL}, 3936, "udp"}, {"dvbservdsc", {NULL}, 3937, "tcp"}, {"dvbservdsc", {NULL}, 3937, "udp"}, {"dbcontrol_agent", {NULL}, 3938, "tcp"}, {"dbcontrol_agent", {NULL}, 3938, "udp"}, {"aamp", {NULL}, 3939, "tcp"}, {"aamp", {NULL}, 3939, "udp"}, {"xecp-node", {NULL}, 3940, "tcp"}, {"xecp-node", {NULL}, 3940, "udp"}, {"homeportal-web", {NULL}, 3941, "tcp"}, {"homeportal-web", {NULL}, 3941, "udp"}, {"srdp", {NULL}, 3942, "tcp"}, {"srdp", {NULL}, 3942, "udp"}, {"tig", {NULL}, 3943, "tcp"}, {"tig", {NULL}, 3943, "udp"}, {"sops", {NULL}, 3944, "tcp"}, {"sops", {NULL}, 3944, "udp"}, {"emcads", {NULL}, 3945, "tcp"}, {"emcads", {NULL}, 3945, "udp"}, {"backupedge", {NULL}, 3946, "tcp"}, {"backupedge", {NULL}, 3946, "udp"}, {"ccp", {NULL}, 3947, "tcp"}, {"ccp", {NULL}, 3947, "udp"}, {"apdap", {NULL}, 3948, "tcp"}, {"apdap", {NULL}, 3948, "udp"}, {"drip", {NULL}, 3949, "tcp"}, {"drip", {NULL}, 3949, "udp"}, {"namemunge", {NULL}, 3950, "tcp"}, {"namemunge", {NULL}, 3950, "udp"}, {"pwgippfax", {NULL}, 3951, "tcp"}, {"pwgippfax", {NULL}, 3951, "udp"}, {"i3-sessionmgr", {NULL}, 3952, "tcp"}, {"i3-sessionmgr", {NULL}, 3952, "udp"}, {"xmlink-connect", {NULL}, 3953, "tcp"}, {"xmlink-connect", {NULL}, 3953, "udp"}, {"adrep", {NULL}, 3954, "tcp"}, {"adrep", {NULL}, 3954, "udp"}, {"p2pcommunity", {NULL}, 3955, "tcp"}, {"p2pcommunity", {NULL}, 3955, "udp"}, {"gvcp", {NULL}, 3956, "tcp"}, {"gvcp", {NULL}, 3956, "udp"}, {"mqe-broker", {NULL}, 3957, "tcp"}, {"mqe-broker", {NULL}, 3957, "udp"}, {"mqe-agent", {NULL}, 3958, "tcp"}, {"mqe-agent", {NULL}, 3958, "udp"}, {"treehopper", {NULL}, 3959, "tcp"}, {"treehopper", {NULL}, 3959, "udp"}, {"bess", {NULL}, 3960, "tcp"}, {"bess", {NULL}, 3960, "udp"}, {"proaxess", {NULL}, 3961, "tcp"}, {"proaxess", {NULL}, 3961, "udp"}, {"sbi-agent", {NULL}, 3962, "tcp"}, {"sbi-agent", {NULL}, 3962, "udp"}, {"thrp", {NULL}, 3963, "tcp"}, {"thrp", {NULL}, 3963, "udp"}, {"sasggprs", {NULL}, 3964, "tcp"}, {"sasggprs", {NULL}, 3964, "udp"}, {"ati-ip-to-ncpe", {NULL}, 3965, "tcp"}, {"ati-ip-to-ncpe", {NULL}, 3965, "udp"}, {"bflckmgr", {NULL}, 3966, "tcp"}, {"bflckmgr", {NULL}, 3966, "udp"}, {"ppsms", {NULL}, 3967, "tcp"}, {"ppsms", {NULL}, 3967, "udp"}, {"ianywhere-dbns", {NULL}, 3968, "tcp"}, {"ianywhere-dbns", {NULL}, 3968, "udp"}, {"landmarks", {NULL}, 3969, "tcp"}, {"landmarks", {NULL}, 3969, "udp"}, {"lanrevagent", {NULL}, 3970, "tcp"}, {"lanrevagent", {NULL}, 3970, "udp"}, {"lanrevserver", {NULL}, 3971, "tcp"}, {"lanrevserver", {NULL}, 3971, "udp"}, {"iconp", {NULL}, 3972, "tcp"}, {"iconp", {NULL}, 3972, "udp"}, {"progistics", {NULL}, 3973, "tcp"}, {"progistics", {NULL}, 3973, "udp"}, {"citysearch", {NULL}, 3974, "tcp"}, {"citysearch", {NULL}, 3974, "udp"}, {"airshot", {NULL}, 3975, "tcp"}, {"airshot", {NULL}, 3975, "udp"}, {"opswagent", {NULL}, 3976, "tcp"}, {"opswagent", {NULL}, 3976, "udp"}, {"opswmanager", {NULL}, 3977, "tcp"}, {"opswmanager", {NULL}, 3977, "udp"}, {"secure-cfg-svr", {NULL}, 3978, "tcp"}, {"secure-cfg-svr", {NULL}, 3978, "udp"}, {"smwan", {NULL}, 3979, "tcp"}, {"smwan", {NULL}, 3979, "udp"}, {"acms", {NULL}, 3980, "tcp"}, {"acms", {NULL}, 3980, "udp"}, {"starfish", {NULL}, 3981, "tcp"}, {"starfish", {NULL}, 3981, "udp"}, {"eis", {NULL}, 3982, "tcp"}, {"eis", {NULL}, 3982, "udp"}, {"eisp", {NULL}, 3983, "tcp"}, {"eisp", {NULL}, 3983, "udp"}, {"mapper-nodemgr", {NULL}, 3984, "tcp"}, {"mapper-nodemgr", {NULL}, 3984, "udp"}, {"mapper-mapethd", {NULL}, 3985, "tcp"}, {"mapper-mapethd", {NULL}, 3985, "udp"}, {"mapper-ws_ethd", {NULL}, 3986, "tcp"}, {"mapper-ws_ethd", {NULL}, 3986, "udp"}, {"centerline", {NULL}, 3987, "tcp"}, {"centerline", {NULL}, 3987, "udp"}, {"dcs-config", {NULL}, 3988, "tcp"}, {"dcs-config", {NULL}, 3988, "udp"}, {"bv-queryengine", {NULL}, 3989, "tcp"}, {"bv-queryengine", {NULL}, 3989, "udp"}, {"bv-is", {NULL}, 3990, "tcp"}, {"bv-is", {NULL}, 3990, "udp"}, {"bv-smcsrv", {NULL}, 3991, "tcp"}, {"bv-smcsrv", {NULL}, 3991, "udp"}, {"bv-ds", {NULL}, 3992, "tcp"}, {"bv-ds", {NULL}, 3992, "udp"}, {"bv-agent", {NULL}, 3993, "tcp"}, {"bv-agent", {NULL}, 3993, "udp"}, {"iss-mgmt-ssl", {NULL}, 3995, "tcp"}, {"iss-mgmt-ssl", {NULL}, 3995, "udp"}, {"abcsoftware", {NULL}, 3996, "tcp"}, {"abcsoftware", {NULL}, 3996, "udp"}, {"agentsease-db", {NULL}, 3997, "tcp"}, {"agentsease-db", {NULL}, 3997, "udp"}, {"dnx", {NULL}, 3998, "tcp"}, {"dnx", {NULL}, 3998, "udp"}, {"nvcnet", {NULL}, 3999, "tcp"}, {"nvcnet", {NULL}, 3999, "udp"}, {"terabase", {NULL}, 4000, "tcp"}, {"terabase", {NULL}, 4000, "udp"}, {"newoak", {NULL}, 4001, "tcp"}, {"newoak", {NULL}, 4001, "udp"}, {"pxc-spvr-ft", {NULL}, 4002, "tcp"}, {"pxc-spvr-ft", {NULL}, 4002, "udp"}, {"pxc-splr-ft", {NULL}, 4003, "tcp"}, {"pxc-splr-ft", {NULL}, 4003, "udp"}, {"pxc-roid", {NULL}, 4004, "tcp"}, {"pxc-roid", {NULL}, 4004, "udp"}, {"pxc-pin", {NULL}, 4005, "tcp"}, {"pxc-pin", {NULL}, 4005, "udp"}, {"pxc-spvr", {NULL}, 4006, "tcp"}, {"pxc-spvr", {NULL}, 4006, "udp"}, {"pxc-splr", {NULL}, 4007, "tcp"}, {"pxc-splr", {NULL}, 4007, "udp"}, {"netcheque", {NULL}, 4008, "tcp"}, {"netcheque", {NULL}, 4008, "udp"}, {"chimera-hwm", {NULL}, 4009, "tcp"}, {"chimera-hwm", {NULL}, 4009, "udp"}, {"samsung-unidex", {NULL}, 4010, "tcp"}, {"samsung-unidex", {NULL}, 4010, "udp"}, {"altserviceboot", {NULL}, 4011, "tcp"}, {"altserviceboot", {NULL}, 4011, "udp"}, {"pda-gate", {NULL}, 4012, "tcp"}, {"pda-gate", {NULL}, 4012, "udp"}, {"acl-manager", {NULL}, 4013, "tcp"}, {"acl-manager", {NULL}, 4013, "udp"}, {"taiclock", {NULL}, 4014, "tcp"}, {"taiclock", {NULL}, 4014, "udp"}, {"talarian-mcast1", {NULL}, 4015, "tcp"}, {"talarian-mcast1", {NULL}, 4015, "udp"}, {"talarian-mcast2", {NULL}, 4016, "tcp"}, {"talarian-mcast2", {NULL}, 4016, "udp"}, {"talarian-mcast3", {NULL}, 4017, "tcp"}, {"talarian-mcast3", {NULL}, 4017, "udp"}, {"talarian-mcast4", {NULL}, 4018, "tcp"}, {"talarian-mcast4", {NULL}, 4018, "udp"}, {"talarian-mcast5", {NULL}, 4019, "tcp"}, {"talarian-mcast5", {NULL}, 4019, "udp"}, {"trap", {NULL}, 4020, "tcp"}, {"trap", {NULL}, 4020, "udp"}, {"nexus-portal", {NULL}, 4021, "tcp"}, {"nexus-portal", {NULL}, 4021, "udp"}, {"dnox", {NULL}, 4022, "tcp"}, {"dnox", {NULL}, 4022, "udp"}, {"esnm-zoning", {NULL}, 4023, "tcp"}, {"esnm-zoning", {NULL}, 4023, "udp"}, {"tnp1-port", {NULL}, 4024, "tcp"}, {"tnp1-port", {NULL}, 4024, "udp"}, {"partimage", {NULL}, 4025, "tcp"}, {"partimage", {NULL}, 4025, "udp"}, {"as-debug", {NULL}, 4026, "tcp"}, {"as-debug", {NULL}, 4026, "udp"}, {"bxp", {NULL}, 4027, "tcp"}, {"bxp", {NULL}, 4027, "udp"}, {"dtserver-port", {NULL}, 4028, "tcp"}, {"dtserver-port", {NULL}, 4028, "udp"}, {"ip-qsig", {NULL}, 4029, "tcp"}, {"ip-qsig", {NULL}, 4029, "udp"}, {"jdmn-port", {NULL}, 4030, "tcp"}, {"jdmn-port", {NULL}, 4030, "udp"}, {"suucp", {NULL}, 4031, "tcp"}, {"suucp", {NULL}, 4031, "udp"}, {"vrts-auth-port", {NULL}, 4032, "tcp"}, {"vrts-auth-port", {NULL}, 4032, "udp"}, {"sanavigator", {NULL}, 4033, "tcp"}, {"sanavigator", {NULL}, 4033, "udp"}, {"ubxd", {NULL}, 4034, "tcp"}, {"ubxd", {NULL}, 4034, "udp"}, {"wap-push-http", {NULL}, 4035, "tcp"}, {"wap-push-http", {NULL}, 4035, "udp"}, {"wap-push-https", {NULL}, 4036, "tcp"}, {"wap-push-https", {NULL}, 4036, "udp"}, {"ravehd", {NULL}, 4037, "tcp"}, {"ravehd", {NULL}, 4037, "udp"}, {"fazzt-ptp", {NULL}, 4038, "tcp"}, {"fazzt-ptp", {NULL}, 4038, "udp"}, {"fazzt-admin", {NULL}, 4039, "tcp"}, {"fazzt-admin", {NULL}, 4039, "udp"}, {"yo-main", {NULL}, 4040, "tcp"}, {"yo-main", {NULL}, 4040, "udp"}, {"houston", {NULL}, 4041, "tcp"}, {"houston", {NULL}, 4041, "udp"}, {"ldxp", {NULL}, 4042, "tcp"}, {"ldxp", {NULL}, 4042, "udp"}, {"nirp", {NULL}, 4043, "tcp"}, {"nirp", {NULL}, 4043, "udp"}, {"ltp", {NULL}, 4044, "tcp"}, {"ltp", {NULL}, 4044, "udp"}, {"npp", {NULL}, 4045, "tcp"}, {"npp", {NULL}, 4045, "udp"}, {"acp-proto", {NULL}, 4046, "tcp"}, {"acp-proto", {NULL}, 4046, "udp"}, {"ctp-state", {NULL}, 4047, "tcp"}, {"ctp-state", {NULL}, 4047, "udp"}, {"wafs", {NULL}, 4049, "tcp"}, {"wafs", {NULL}, 4049, "udp"}, {"cisco-wafs", {NULL}, 4050, "tcp"}, {"cisco-wafs", {NULL}, 4050, "udp"}, {"cppdp", {NULL}, 4051, "tcp"}, {"cppdp", {NULL}, 4051, "udp"}, {"interact", {NULL}, 4052, "tcp"}, {"interact", {NULL}, 4052, "udp"}, {"ccu-comm-1", {NULL}, 4053, "tcp"}, {"ccu-comm-1", {NULL}, 4053, "udp"}, {"ccu-comm-2", {NULL}, 4054, "tcp"}, {"ccu-comm-2", {NULL}, 4054, "udp"}, {"ccu-comm-3", {NULL}, 4055, "tcp"}, {"ccu-comm-3", {NULL}, 4055, "udp"}, {"lms", {NULL}, 4056, "tcp"}, {"lms", {NULL}, 4056, "udp"}, {"wfm", {NULL}, 4057, "tcp"}, {"wfm", {NULL}, 4057, "udp"}, {"kingfisher", {NULL}, 4058, "tcp"}, {"kingfisher", {NULL}, 4058, "udp"}, {"dlms-cosem", {NULL}, 4059, "tcp"}, {"dlms-cosem", {NULL}, 4059, "udp"}, {"dsmeter_iatc", {NULL}, 4060, "tcp"}, {"dsmeter_iatc", {NULL}, 4060, "udp"}, {"ice-location", {NULL}, 4061, "tcp"}, {"ice-location", {NULL}, 4061, "udp"}, {"ice-slocation", {NULL}, 4062, "tcp"}, {"ice-slocation", {NULL}, 4062, "udp"}, {"ice-router", {NULL}, 4063, "tcp"}, {"ice-router", {NULL}, 4063, "udp"}, {"ice-srouter", {NULL}, 4064, "tcp"}, {"ice-srouter", {NULL}, 4064, "udp"}, {"avanti_cdp", {NULL}, 4065, "tcp"}, {"avanti_cdp", {NULL}, 4065, "udp"}, {"pmas", {NULL}, 4066, "tcp"}, {"pmas", {NULL}, 4066, "udp"}, {"idp", {NULL}, 4067, "tcp"}, {"idp", {NULL}, 4067, "udp"}, {"ipfltbcst", {NULL}, 4068, "tcp"}, {"ipfltbcst", {NULL}, 4068, "udp"}, {"minger", {NULL}, 4069, "tcp"}, {"minger", {NULL}, 4069, "udp"}, {"tripe", {NULL}, 4070, "tcp"}, {"tripe", {NULL}, 4070, "udp"}, {"aibkup", {NULL}, 4071, "tcp"}, {"aibkup", {NULL}, 4071, "udp"}, {"zieto-sock", {NULL}, 4072, "tcp"}, {"zieto-sock", {NULL}, 4072, "udp"}, {"iRAPP", {NULL}, 4073, "tcp"}, {"iRAPP", {NULL}, 4073, "udp"}, {"cequint-cityid", {NULL}, 4074, "tcp"}, {"cequint-cityid", {NULL}, 4074, "udp"}, {"perimlan", {NULL}, 4075, "tcp"}, {"perimlan", {NULL}, 4075, "udp"}, {"seraph", {NULL}, 4076, "tcp"}, {"seraph", {NULL}, 4076, "udp"}, {"ascomalarm", {NULL}, 4077, "udp"}, {"cssp", {NULL}, 4078, "tcp"}, {"santools", {NULL}, 4079, "tcp"}, {"santools", {NULL}, 4079, "udp"}, {"lorica-in", {NULL}, 4080, "tcp"}, {"lorica-in", {NULL}, 4080, "udp"}, {"lorica-in-sec", {NULL}, 4081, "tcp"}, {"lorica-in-sec", {NULL}, 4081, "udp"}, {"lorica-out", {NULL}, 4082, "tcp"}, {"lorica-out", {NULL}, 4082, "udp"}, {"lorica-out-sec", {NULL}, 4083, "tcp"}, {"lorica-out-sec", {NULL}, 4083, "udp"}, {"fortisphere-vm", {NULL}, 4084, "udp"}, {"ezmessagesrv", {NULL}, 4085, "tcp"}, {"ftsync", {NULL}, 4086, "udp"}, {"applusservice", {NULL}, 4087, "tcp"}, {"npsp", {NULL}, 4088, "tcp"}, {"opencore", {NULL}, 4089, "tcp"}, {"opencore", {NULL}, 4089, "udp"}, {"omasgport", {NULL}, 4090, "tcp"}, {"omasgport", {NULL}, 4090, "udp"}, {"ewinstaller", {NULL}, 4091, "tcp"}, {"ewinstaller", {NULL}, 4091, "udp"}, {"ewdgs", {NULL}, 4092, "tcp"}, {"ewdgs", {NULL}, 4092, "udp"}, {"pvxpluscs", {NULL}, 4093, "tcp"}, {"pvxpluscs", {NULL}, 4093, "udp"}, {"sysrqd", {NULL}, 4094, "tcp"}, {"sysrqd", {NULL}, 4094, "udp"}, {"xtgui", {NULL}, 4095, "tcp"}, {"xtgui", {NULL}, 4095, "udp"}, {"bre", {NULL}, 4096, "tcp"}, {"bre", {NULL}, 4096, "udp"}, {"patrolview", {NULL}, 4097, "tcp"}, {"patrolview", {NULL}, 4097, "udp"}, {"drmsfsd", {NULL}, 4098, "tcp"}, {"drmsfsd", {NULL}, 4098, "udp"}, {"dpcp", {NULL}, 4099, "tcp"}, {"dpcp", {NULL}, 4099, "udp"}, {"igo-incognito", {NULL}, 4100, "tcp"}, {"igo-incognito", {NULL}, 4100, "udp"}, {"brlp-0", {NULL}, 4101, "tcp"}, {"brlp-0", {NULL}, 4101, "udp"}, {"brlp-1", {NULL}, 4102, "tcp"}, {"brlp-1", {NULL}, 4102, "udp"}, {"brlp-2", {NULL}, 4103, "tcp"}, {"brlp-2", {NULL}, 4103, "udp"}, {"brlp-3", {NULL}, 4104, "tcp"}, {"brlp-3", {NULL}, 4104, "udp"}, {"shofarplayer", {NULL}, 4105, "tcp"}, {"shofarplayer", {NULL}, 4105, "udp"}, {"synchronite", {NULL}, 4106, "tcp"}, {"synchronite", {NULL}, 4106, "udp"}, {"j-ac", {NULL}, 4107, "tcp"}, {"j-ac", {NULL}, 4107, "udp"}, {"accel", {NULL}, 4108, "tcp"}, {"accel", {NULL}, 4108, "udp"}, {"izm", {NULL}, 4109, "tcp"}, {"izm", {NULL}, 4109, "udp"}, {"g2tag", {NULL}, 4110, "tcp"}, {"g2tag", {NULL}, 4110, "udp"}, {"xgrid", {NULL}, 4111, "tcp"}, {"xgrid", {NULL}, 4111, "udp"}, {"apple-vpns-rp", {NULL}, 4112, "tcp"}, {"apple-vpns-rp", {NULL}, 4112, "udp"}, {"aipn-reg", {NULL}, 4113, "tcp"}, {"aipn-reg", {NULL}, 4113, "udp"}, {"jomamqmonitor", {NULL}, 4114, "tcp"}, {"jomamqmonitor", {NULL}, 4114, "udp"}, {"cds", {NULL}, 4115, "tcp"}, {"cds", {NULL}, 4115, "udp"}, {"smartcard-tls", {NULL}, 4116, "tcp"}, {"smartcard-tls", {NULL}, 4116, "udp"}, {"hillrserv", {NULL}, 4117, "tcp"}, {"hillrserv", {NULL}, 4117, "udp"}, {"netscript", {NULL}, 4118, "tcp"}, {"netscript", {NULL}, 4118, "udp"}, {"assuria-slm", {NULL}, 4119, "tcp"}, {"assuria-slm", {NULL}, 4119, "udp"}, {"e-builder", {NULL}, 4121, "tcp"}, {"e-builder", {NULL}, 4121, "udp"}, {"fprams", {NULL}, 4122, "tcp"}, {"fprams", {NULL}, 4122, "udp"}, {"z-wave", {NULL}, 4123, "tcp"}, {"z-wave", {NULL}, 4123, "udp"}, {"tigv2", {NULL}, 4124, "tcp"}, {"tigv2", {NULL}, 4124, "udp"}, {"opsview-envoy", {NULL}, 4125, "tcp"}, {"opsview-envoy", {NULL}, 4125, "udp"}, {"ddrepl", {NULL}, 4126, "tcp"}, {"ddrepl", {NULL}, 4126, "udp"}, {"unikeypro", {NULL}, 4127, "tcp"}, {"unikeypro", {NULL}, 4127, "udp"}, {"nufw", {NULL}, 4128, "tcp"}, {"nufw", {NULL}, 4128, "udp"}, {"nuauth", {NULL}, 4129, "tcp"}, {"nuauth", {NULL}, 4129, "udp"}, {"fronet", {NULL}, 4130, "tcp"}, {"fronet", {NULL}, 4130, "udp"}, {"stars", {NULL}, 4131, "tcp"}, {"stars", {NULL}, 4131, "udp"}, {"nuts_dem", {NULL}, 4132, "tcp"}, {"nuts_dem", {NULL}, 4132, "udp"}, {"nuts_bootp", {NULL}, 4133, "tcp"}, {"nuts_bootp", {NULL}, 4133, "udp"}, {"nifty-hmi", {NULL}, 4134, "tcp"}, {"nifty-hmi", {NULL}, 4134, "udp"}, {"cl-db-attach", {NULL}, 4135, "tcp"}, {"cl-db-attach", {NULL}, 4135, "udp"}, {"cl-db-request", {NULL}, 4136, "tcp"}, {"cl-db-request", {NULL}, 4136, "udp"}, {"cl-db-remote", {NULL}, 4137, "tcp"}, {"cl-db-remote", {NULL}, 4137, "udp"}, {"nettest", {NULL}, 4138, "tcp"}, {"nettest", {NULL}, 4138, "udp"}, {"thrtx", {NULL}, 4139, "tcp"}, {"thrtx", {NULL}, 4139, "udp"}, {"cedros_fds", {NULL}, 4140, "tcp"}, {"cedros_fds", {NULL}, 4140, "udp"}, {"oirtgsvc", {NULL}, 4141, "tcp"}, {"oirtgsvc", {NULL}, 4141, "udp"}, {"oidocsvc", {NULL}, 4142, "tcp"}, {"oidocsvc", {NULL}, 4142, "udp"}, {"oidsr", {NULL}, 4143, "tcp"}, {"oidsr", {NULL}, 4143, "udp"}, {"vvr-control", {NULL}, 4145, "tcp"}, {"vvr-control", {NULL}, 4145, "udp"}, {"tgcconnect", {NULL}, 4146, "tcp"}, {"tgcconnect", {NULL}, 4146, "udp"}, {"vrxpservman", {NULL}, 4147, "tcp"}, {"vrxpservman", {NULL}, 4147, "udp"}, {"hhb-handheld", {NULL}, 4148, "tcp"}, {"hhb-handheld", {NULL}, 4148, "udp"}, {"agslb", {NULL}, 4149, "tcp"}, {"agslb", {NULL}, 4149, "udp"}, {"PowerAlert-nsa", {NULL}, 4150, "tcp"}, {"PowerAlert-nsa", {NULL}, 4150, "udp"}, {"menandmice_noh", {NULL}, 4151, "tcp"}, {"menandmice_noh", {NULL}, 4151, "udp"}, {"idig_mux", {NULL}, 4152, "tcp"}, {"idig_mux", {NULL}, 4152, "udp"}, {"mbl-battd", {NULL}, 4153, "tcp"}, {"mbl-battd", {NULL}, 4153, "udp"}, {"atlinks", {NULL}, 4154, "tcp"}, {"atlinks", {NULL}, 4154, "udp"}, {"bzr", {NULL}, 4155, "tcp"}, {"bzr", {NULL}, 4155, "udp"}, {"stat-results", {NULL}, 4156, "tcp"}, {"stat-results", {NULL}, 4156, "udp"}, {"stat-scanner", {NULL}, 4157, "tcp"}, {"stat-scanner", {NULL}, 4157, "udp"}, {"stat-cc", {NULL}, 4158, "tcp"}, {"stat-cc", {NULL}, 4158, "udp"}, {"nss", {NULL}, 4159, "tcp"}, {"nss", {NULL}, 4159, "udp"}, {"jini-discovery", {NULL}, 4160, "tcp"}, {"jini-discovery", {NULL}, 4160, "udp"}, {"omscontact", {NULL}, 4161, "tcp"}, {"omscontact", {NULL}, 4161, "udp"}, {"omstopology", {NULL}, 4162, "tcp"}, {"omstopology", {NULL}, 4162, "udp"}, {"silverpeakpeer", {NULL}, 4163, "tcp"}, {"silverpeakpeer", {NULL}, 4163, "udp"}, {"silverpeakcomm", {NULL}, 4164, "tcp"}, {"silverpeakcomm", {NULL}, 4164, "udp"}, {"altcp", {NULL}, 4165, "tcp"}, {"altcp", {NULL}, 4165, "udp"}, {"joost", {NULL}, 4166, "tcp"}, {"joost", {NULL}, 4166, "udp"}, {"ddgn", {NULL}, 4167, "tcp"}, {"ddgn", {NULL}, 4167, "udp"}, {"pslicser", {NULL}, 4168, "tcp"}, {"pslicser", {NULL}, 4168, "udp"}, {"iadt", {NULL}, 4169, "tcp"}, {"iadt-disc", {NULL}, 4169, "udp"}, {"d-cinema-csp", {NULL}, 4170, "tcp"}, {"ml-svnet", {NULL}, 4171, "tcp"}, {"pcoip", {NULL}, 4172, "tcp"}, {"pcoip", {NULL}, 4172, "udp"}, {"smcluster", {NULL}, 4174, "tcp"}, {"bccp", {NULL}, 4175, "tcp"}, {"tl-ipcproxy", {NULL}, 4176, "tcp"}, {"wello", {NULL}, 4177, "tcp"}, {"wello", {NULL}, 4177, "udp"}, {"storman", {NULL}, 4178, "tcp"}, {"storman", {NULL}, 4178, "udp"}, {"MaxumSP", {NULL}, 4179, "tcp"}, {"MaxumSP", {NULL}, 4179, "udp"}, {"httpx", {NULL}, 4180, "tcp"}, {"httpx", {NULL}, 4180, "udp"}, {"macbak", {NULL}, 4181, "tcp"}, {"macbak", {NULL}, 4181, "udp"}, {"pcptcpservice", {NULL}, 4182, "tcp"}, {"pcptcpservice", {NULL}, 4182, "udp"}, {"gmmp", {NULL}, 4183, "tcp"}, {"gmmp", {NULL}, 4183, "udp"}, {"universe_suite", {NULL}, 4184, "tcp"}, {"universe_suite", {NULL}, 4184, "udp"}, {"wcpp", {NULL}, 4185, "tcp"}, {"wcpp", {NULL}, 4185, "udp"}, {"boxbackupstore", {NULL}, 4186, "tcp"}, {"csc_proxy", {NULL}, 4187, "tcp"}, {"vatata", {NULL}, 4188, "tcp"}, {"vatata", {NULL}, 4188, "udp"}, {"pcep", {NULL}, 4189, "tcp"}, {"sieve", {NULL}, 4190, "tcp"}, {"dsmipv6", {NULL}, 4191, "udp"}, {"azeti", {NULL}, 4192, "tcp"}, {"azeti-bd", {NULL}, 4192, "udp"}, {"pvxplusio", {NULL}, 4193, "tcp"}, {"eims-admin", {NULL}, 4199, "tcp"}, {"eims-admin", {NULL}, 4199, "udp"}, {"corelccam", {NULL}, 4300, "tcp"}, {"corelccam", {NULL}, 4300, "udp"}, {"d-data", {NULL}, 4301, "tcp"}, {"d-data", {NULL}, 4301, "udp"}, {"d-data-control", {NULL}, 4302, "tcp"}, {"d-data-control", {NULL}, 4302, "udp"}, {"srcp", {NULL}, 4303, "tcp"}, {"srcp", {NULL}, 4303, "udp"}, {"owserver", {NULL}, 4304, "tcp"}, {"owserver", {NULL}, 4304, "udp"}, {"batman", {NULL}, 4305, "tcp"}, {"batman", {NULL}, 4305, "udp"}, {"pinghgl", {NULL}, 4306, "tcp"}, {"pinghgl", {NULL}, 4306, "udp"}, {"visicron-vs", {NULL}, 4307, "tcp"}, {"visicron-vs", {NULL}, 4307, "udp"}, {"compx-lockview", {NULL}, 4308, "tcp"}, {"compx-lockview", {NULL}, 4308, "udp"}, {"dserver", {NULL}, 4309, "tcp"}, {"dserver", {NULL}, 4309, "udp"}, {"mirrtex", {NULL}, 4310, "tcp"}, {"mirrtex", {NULL}, 4310, "udp"}, {"p6ssmc", {NULL}, 4311, "tcp"}, {"pscl-mgt", {NULL}, 4312, "tcp"}, {"perrla", {NULL}, 4313, "tcp"}, {"fdt-rcatp", {NULL}, 4320, "tcp"}, {"fdt-rcatp", {NULL}, 4320, "udp"}, {"rwhois", {NULL}, 4321, "tcp"}, {"rwhois", {NULL}, 4321, "udp"}, {"trim-event", {NULL}, 4322, "tcp"}, {"trim-event", {NULL}, 4322, "udp"}, {"trim-ice", {NULL}, 4323, "tcp"}, {"trim-ice", {NULL}, 4323, "udp"}, {"balour", {NULL}, 4324, "tcp"}, {"balour", {NULL}, 4324, "udp"}, {"geognosisman", {NULL}, 4325, "tcp"}, {"geognosisman", {NULL}, 4325, "udp"}, {"geognosis", {NULL}, 4326, "tcp"}, {"geognosis", {NULL}, 4326, "udp"}, {"jaxer-web", {NULL}, 4327, "tcp"}, {"jaxer-web", {NULL}, 4327, "udp"}, {"jaxer-manager", {NULL}, 4328, "tcp"}, {"jaxer-manager", {NULL}, 4328, "udp"}, {"publiqare-sync", {NULL}, 4329, "tcp"}, {"gaia", {NULL}, 4340, "tcp"}, {"gaia", {NULL}, 4340, "udp"}, {"lisp-data", {NULL}, 4341, "tcp"}, {"lisp-data", {NULL}, 4341, "udp"}, {"lisp-cons", {NULL}, 4342, "tcp"}, {"lisp-control", {NULL}, 4342, "udp"}, {"unicall", {NULL}, 4343, "tcp"}, {"unicall", {NULL}, 4343, "udp"}, {"vinainstall", {NULL}, 4344, "tcp"}, {"vinainstall", {NULL}, 4344, "udp"}, {"m4-network-as", {NULL}, 4345, "tcp"}, {"m4-network-as", {NULL}, 4345, "udp"}, {"elanlm", {NULL}, 4346, "tcp"}, {"elanlm", {NULL}, 4346, "udp"}, {"lansurveyor", {NULL}, 4347, "tcp"}, {"lansurveyor", {NULL}, 4347, "udp"}, {"itose", {NULL}, 4348, "tcp"}, {"itose", {NULL}, 4348, "udp"}, {"fsportmap", {NULL}, 4349, "tcp"}, {"fsportmap", {NULL}, 4349, "udp"}, {"net-device", {NULL}, 4350, "tcp"}, {"net-device", {NULL}, 4350, "udp"}, {"plcy-net-svcs", {NULL}, 4351, "tcp"}, {"plcy-net-svcs", {NULL}, 4351, "udp"}, {"pjlink", {NULL}, 4352, "tcp"}, {"pjlink", {NULL}, 4352, "udp"}, {"f5-iquery", {NULL}, 4353, "tcp"}, {"f5-iquery", {NULL}, 4353, "udp"}, {"qsnet-trans", {NULL}, 4354, "tcp"}, {"qsnet-trans", {NULL}, 4354, "udp"}, {"qsnet-workst", {NULL}, 4355, "tcp"}, {"qsnet-workst", {NULL}, 4355, "udp"}, {"qsnet-assist", {NULL}, 4356, "tcp"}, {"qsnet-assist", {NULL}, 4356, "udp"}, {"qsnet-cond", {NULL}, 4357, "tcp"}, {"qsnet-cond", {NULL}, 4357, "udp"}, {"qsnet-nucl", {NULL}, 4358, "tcp"}, {"qsnet-nucl", {NULL}, 4358, "udp"}, {"omabcastltkm", {NULL}, 4359, "tcp"}, {"omabcastltkm", {NULL}, 4359, "udp"}, {"matrix_vnet", {NULL}, 4360, "tcp"}, {"nacnl", {NULL}, 4361, "udp"}, {"afore-vdp-disc", {NULL}, 4362, "udp"}, {"wxbrief", {NULL}, 4368, "tcp"}, {"wxbrief", {NULL}, 4368, "udp"}, {"epmd", {NULL}, 4369, "tcp"}, {"epmd", {NULL}, 4369, "udp"}, {"elpro_tunnel", {NULL}, 4370, "tcp"}, {"elpro_tunnel", {NULL}, 4370, "udp"}, {"l2c-control", {NULL}, 4371, "tcp"}, {"l2c-disc", {NULL}, 4371, "udp"}, {"l2c-data", {NULL}, 4372, "tcp"}, {"l2c-data", {NULL}, 4372, "udp"}, {"remctl", {NULL}, 4373, "tcp"}, {"remctl", {NULL}, 4373, "udp"}, {"psi-ptt", {NULL}, 4374, "tcp"}, {"tolteces", {NULL}, 4375, "tcp"}, {"tolteces", {NULL}, 4375, "udp"}, {"bip", {NULL}, 4376, "tcp"}, {"bip", {NULL}, 4376, "udp"}, {"cp-spxsvr", {NULL}, 4377, "tcp"}, {"cp-spxsvr", {NULL}, 4377, "udp"}, {"cp-spxdpy", {NULL}, 4378, "tcp"}, {"cp-spxdpy", {NULL}, 4378, "udp"}, {"ctdb", {NULL}, 4379, "tcp"}, {"ctdb", {NULL}, 4379, "udp"}, {"xandros-cms", {NULL}, 4389, "tcp"}, {"xandros-cms", {NULL}, 4389, "udp"}, {"wiegand", {NULL}, 4390, "tcp"}, {"wiegand", {NULL}, 4390, "udp"}, {"apwi-imserver", {NULL}, 4391, "tcp"}, {"apwi-rxserver", {NULL}, 4392, "tcp"}, {"apwi-rxspooler", {NULL}, 4393, "tcp"}, {"apwi-disc", {NULL}, 4394, "udp"}, {"omnivisionesx", {NULL}, 4395, "tcp"}, {"omnivisionesx", {NULL}, 4395, "udp"}, {"fly", {NULL}, 4396, "tcp"}, {"ds-srv", {NULL}, 4400, "tcp"}, {"ds-srv", {NULL}, 4400, "udp"}, {"ds-srvr", {NULL}, 4401, "tcp"}, {"ds-srvr", {NULL}, 4401, "udp"}, {"ds-clnt", {NULL}, 4402, "tcp"}, {"ds-clnt", {NULL}, 4402, "udp"}, {"ds-user", {NULL}, 4403, "tcp"}, {"ds-user", {NULL}, 4403, "udp"}, {"ds-admin", {NULL}, 4404, "tcp"}, {"ds-admin", {NULL}, 4404, "udp"}, {"ds-mail", {NULL}, 4405, "tcp"}, {"ds-mail", {NULL}, 4405, "udp"}, {"ds-slp", {NULL}, 4406, "tcp"}, {"ds-slp", {NULL}, 4406, "udp"}, {"nacagent", {NULL}, 4407, "tcp"}, {"slscc", {NULL}, 4408, "tcp"}, {"netcabinet-com", {NULL}, 4409, "tcp"}, {"itwo-server", {NULL}, 4410, "tcp"}, {"netrockey6", {NULL}, 4425, "tcp"}, {"netrockey6", {NULL}, 4425, "udp"}, {"beacon-port-2", {NULL}, 4426, "tcp"}, {"beacon-port-2", {NULL}, 4426, "udp"}, {"drizzle", {NULL}, 4427, "tcp"}, {"omviserver", {NULL}, 4428, "tcp"}, {"omviagent", {NULL}, 4429, "tcp"}, {"rsqlserver", {NULL}, 4430, "tcp"}, {"rsqlserver", {NULL}, 4430, "udp"}, {"wspipe", {NULL}, 4431, "tcp"}, {"netblox", {NULL}, 4441, "udp"}, {"saris", {NULL}, 4442, "tcp"}, {"saris", {NULL}, 4442, "udp"}, {"pharos", {NULL}, 4443, "tcp"}, {"pharos", {NULL}, 4443, "udp"}, {"krb524", {NULL}, 4444, "tcp"}, {"krb524", {NULL}, 4444, "udp"}, {"nv-video", {NULL}, 4444, "tcp"}, {"nv-video", {NULL}, 4444, "udp"}, {"upnotifyp", {NULL}, 4445, "tcp"}, {"upnotifyp", {NULL}, 4445, "udp"}, {"n1-fwp", {NULL}, 4446, "tcp"}, {"n1-fwp", {NULL}, 4446, "udp"}, {"n1-rmgmt", {NULL}, 4447, "tcp"}, {"n1-rmgmt", {NULL}, 4447, "udp"}, {"asc-slmd", {NULL}, 4448, "tcp"}, {"asc-slmd", {NULL}, 4448, "udp"}, {"privatewire", {NULL}, 4449, "tcp"}, {"privatewire", {NULL}, 4449, "udp"}, {"camp", {NULL}, 4450, "tcp"}, {"camp", {NULL}, 4450, "udp"}, {"ctisystemmsg", {NULL}, 4451, "tcp"}, {"ctisystemmsg", {NULL}, 4451, "udp"}, {"ctiprogramload", {NULL}, 4452, "tcp"}, {"ctiprogramload", {NULL}, 4452, "udp"}, {"nssalertmgr", {NULL}, 4453, "tcp"}, {"nssalertmgr", {NULL}, 4453, "udp"}, {"nssagentmgr", {NULL}, 4454, "tcp"}, {"nssagentmgr", {NULL}, 4454, "udp"}, {"prchat-user", {NULL}, 4455, "tcp"}, {"prchat-user", {NULL}, 4455, "udp"}, {"prchat-server", {NULL}, 4456, "tcp"}, {"prchat-server", {NULL}, 4456, "udp"}, {"prRegister", {NULL}, 4457, "tcp"}, {"prRegister", {NULL}, 4457, "udp"}, {"mcp", {NULL}, 4458, "tcp"}, {"mcp", {NULL}, 4458, "udp"}, {"hpssmgmt", {NULL}, 4484, "tcp"}, {"hpssmgmt", {NULL}, 4484, "udp"}, {"assyst-dr", {NULL}, 4485, "tcp"}, {"icms", {NULL}, 4486, "tcp"}, {"icms", {NULL}, 4486, "udp"}, {"prex-tcp", {NULL}, 4487, "tcp"}, {"awacs-ice", {NULL}, 4488, "tcp"}, {"awacs-ice", {NULL}, 4488, "udp"}, {"ipsec-nat-t", {NULL}, 4500, "tcp"}, {"ipsec-nat-t", {NULL}, 4500, "udp"}, {"ehs", {NULL}, 4535, "tcp"}, {"ehs", {NULL}, 4535, "udp"}, {"ehs-ssl", {NULL}, 4536, "tcp"}, {"ehs-ssl", {NULL}, 4536, "udp"}, {"wssauthsvc", {NULL}, 4537, "tcp"}, {"wssauthsvc", {NULL}, 4537, "udp"}, {"swx-gate", {NULL}, 4538, "tcp"}, {"swx-gate", {NULL}, 4538, "udp"}, {"worldscores", {NULL}, 4545, "tcp"}, {"worldscores", {NULL}, 4545, "udp"}, {"sf-lm", {NULL}, 4546, "tcp"}, {"sf-lm", {NULL}, 4546, "udp"}, {"lanner-lm", {NULL}, 4547, "tcp"}, {"lanner-lm", {NULL}, 4547, "udp"}, {"synchromesh", {NULL}, 4548, "tcp"}, {"synchromesh", {NULL}, 4548, "udp"}, {"aegate", {NULL}, 4549, "tcp"}, {"aegate", {NULL}, 4549, "udp"}, {"gds-adppiw-db", {NULL}, 4550, "tcp"}, {"gds-adppiw-db", {NULL}, 4550, "udp"}, {"ieee-mih", {NULL}, 4551, "tcp"}, {"ieee-mih", {NULL}, 4551, "udp"}, {"menandmice-mon", {NULL}, 4552, "tcp"}, {"menandmice-mon", {NULL}, 4552, "udp"}, {"icshostsvc", {NULL}, 4553, "tcp"}, {"msfrs", {NULL}, 4554, "tcp"}, {"msfrs", {NULL}, 4554, "udp"}, {"rsip", {NULL}, 4555, "tcp"}, {"rsip", {NULL}, 4555, "udp"}, {"dtn-bundle-tcp", {NULL}, 4556, "tcp"}, {"dtn-bundle-udp", {NULL}, 4556, "udp"}, {"mtcevrunqss", {NULL}, 4557, "udp"}, {"mtcevrunqman", {NULL}, 4558, "udp"}, {"hylafax", {NULL}, 4559, "tcp"}, {"hylafax", {NULL}, 4559, "udp"}, {"kwtc", {NULL}, 4566, "tcp"}, {"kwtc", {NULL}, 4566, "udp"}, {"tram", {NULL}, 4567, "tcp"}, {"tram", {NULL}, 4567, "udp"}, {"bmc-reporting", {NULL}, 4568, "tcp"}, {"bmc-reporting", {NULL}, 4568, "udp"}, {"iax", {NULL}, 4569, "tcp"}, {"iax", {NULL}, 4569, "udp"}, {"rid", {NULL}, 4590, "tcp"}, {"l3t-at-an", {NULL}, 4591, "tcp"}, {"l3t-at-an", {NULL}, 4591, "udp"}, {"hrpd-ith-at-an", {NULL}, 4592, "udp"}, {"ipt-anri-anri", {NULL}, 4593, "tcp"}, {"ipt-anri-anri", {NULL}, 4593, "udp"}, {"ias-session", {NULL}, 4594, "tcp"}, {"ias-session", {NULL}, 4594, "udp"}, {"ias-paging", {NULL}, 4595, "tcp"}, {"ias-paging", {NULL}, 4595, "udp"}, {"ias-neighbor", {NULL}, 4596, "tcp"}, {"ias-neighbor", {NULL}, 4596, "udp"}, {"a21-an-1xbs", {NULL}, 4597, "tcp"}, {"a21-an-1xbs", {NULL}, 4597, "udp"}, {"a16-an-an", {NULL}, 4598, "tcp"}, {"a16-an-an", {NULL}, 4598, "udp"}, {"a17-an-an", {NULL}, 4599, "tcp"}, {"a17-an-an", {NULL}, 4599, "udp"}, {"piranha1", {NULL}, 4600, "tcp"}, {"piranha1", {NULL}, 4600, "udp"}, {"piranha2", {NULL}, 4601, "tcp"}, {"piranha2", {NULL}, 4601, "udp"}, {"mtsserver", {NULL}, 4602, "tcp"}, {"menandmice-upg", {NULL}, 4603, "tcp"}, {"playsta2-app", {NULL}, 4658, "tcp"}, {"playsta2-app", {NULL}, 4658, "udp"}, {"playsta2-lob", {NULL}, 4659, "tcp"}, {"playsta2-lob", {NULL}, 4659, "udp"}, {"smaclmgr", {NULL}, 4660, "tcp"}, {"smaclmgr", {NULL}, 4660, "udp"}, {"kar2ouche", {NULL}, 4661, "tcp"}, {"kar2ouche", {NULL}, 4661, "udp"}, {"oms", {NULL}, 4662, "tcp"}, {"oms", {NULL}, 4662, "udp"}, {"noteit", {NULL}, 4663, "tcp"}, {"noteit", {NULL}, 4663, "udp"}, {"ems", {NULL}, 4664, "tcp"}, {"ems", {NULL}, 4664, "udp"}, {"contclientms", {NULL}, 4665, "tcp"}, {"contclientms", {NULL}, 4665, "udp"}, {"eportcomm", {NULL}, 4666, "tcp"}, {"eportcomm", {NULL}, 4666, "udp"}, {"mmacomm", {NULL}, 4667, "tcp"}, {"mmacomm", {NULL}, 4667, "udp"}, {"mmaeds", {NULL}, 4668, "tcp"}, {"mmaeds", {NULL}, 4668, "udp"}, {"eportcommdata", {NULL}, 4669, "tcp"}, {"eportcommdata", {NULL}, 4669, "udp"}, {"light", {NULL}, 4670, "tcp"}, {"light", {NULL}, 4670, "udp"}, {"acter", {NULL}, 4671, "tcp"}, {"acter", {NULL}, 4671, "udp"}, {"rfa", {NULL}, 4672, "tcp"}, {"rfa", {NULL}, 4672, "udp"}, {"cxws", {NULL}, 4673, "tcp"}, {"cxws", {NULL}, 4673, "udp"}, {"appiq-mgmt", {NULL}, 4674, "tcp"}, {"appiq-mgmt", {NULL}, 4674, "udp"}, {"dhct-status", {NULL}, 4675, "tcp"}, {"dhct-status", {NULL}, 4675, "udp"}, {"dhct-alerts", {NULL}, 4676, "tcp"}, {"dhct-alerts", {NULL}, 4676, "udp"}, {"bcs", {NULL}, 4677, "tcp"}, {"bcs", {NULL}, 4677, "udp"}, {"traversal", {NULL}, 4678, "tcp"}, {"traversal", {NULL}, 4678, "udp"}, {"mgesupervision", {NULL}, 4679, "tcp"}, {"mgesupervision", {NULL}, 4679, "udp"}, {"mgemanagement", {NULL}, 4680, "tcp"}, {"mgemanagement", {NULL}, 4680, "udp"}, {"parliant", {NULL}, 4681, "tcp"}, {"parliant", {NULL}, 4681, "udp"}, {"finisar", {NULL}, 4682, "tcp"}, {"finisar", {NULL}, 4682, "udp"}, {"spike", {NULL}, 4683, "tcp"}, {"spike", {NULL}, 4683, "udp"}, {"rfid-rp1", {NULL}, 4684, "tcp"}, {"rfid-rp1", {NULL}, 4684, "udp"}, {"autopac", {NULL}, 4685, "tcp"}, {"autopac", {NULL}, 4685, "udp"}, {"msp-os", {NULL}, 4686, "tcp"}, {"msp-os", {NULL}, 4686, "udp"}, {"nst", {NULL}, 4687, "tcp"}, {"nst", {NULL}, 4687, "udp"}, {"mobile-p2p", {NULL}, 4688, "tcp"}, {"mobile-p2p", {NULL}, 4688, "udp"}, {"altovacentral", {NULL}, 4689, "tcp"}, {"altovacentral", {NULL}, 4689, "udp"}, {"prelude", {NULL}, 4690, "tcp"}, {"prelude", {NULL}, 4690, "udp"}, {"mtn", {NULL}, 4691, "tcp"}, {"mtn", {NULL}, 4691, "udp"}, {"conspiracy", {NULL}, 4692, "tcp"}, {"conspiracy", {NULL}, 4692, "udp"}, {"netxms-agent", {NULL}, 4700, "tcp"}, {"netxms-agent", {NULL}, 4700, "udp"}, {"netxms-mgmt", {NULL}, 4701, "tcp"}, {"netxms-mgmt", {NULL}, 4701, "udp"}, {"netxms-sync", {NULL}, 4702, "tcp"}, {"netxms-sync", {NULL}, 4702, "udp"}, {"npqes-test", {NULL}, 4703, "tcp"}, {"assuria-ins", {NULL}, 4704, "tcp"}, {"truckstar", {NULL}, 4725, "tcp"}, {"truckstar", {NULL}, 4725, "udp"}, {"a26-fap-fgw", {NULL}, 4726, "udp"}, {"fcis", {NULL}, 4727, "tcp"}, {"fcis-disc", {NULL}, 4727, "udp"}, {"capmux", {NULL}, 4728, "tcp"}, {"capmux", {NULL}, 4728, "udp"}, {"gsmtap", {NULL}, 4729, "udp"}, {"gearman", {NULL}, 4730, "tcp"}, {"gearman", {NULL}, 4730, "udp"}, {"remcap", {NULL}, 4731, "tcp"}, {"ohmtrigger", {NULL}, 4732, "udp"}, {"resorcs", {NULL}, 4733, "tcp"}, {"ipdr-sp", {NULL}, 4737, "tcp"}, {"ipdr-sp", {NULL}, 4737, "udp"}, {"solera-lpn", {NULL}, 4738, "tcp"}, {"solera-lpn", {NULL}, 4738, "udp"}, {"ipfix", {NULL}, 4739, "tcp"}, {"ipfix", {NULL}, 4739, "udp"}, {"ipfix", {NULL}, 4739, "sctp"}, {"ipfixs", {NULL}, 4740, "tcp"}, {"ipfixs", {NULL}, 4740, "sctp"}, {"ipfixs", {NULL}, 4740, "udp"}, {"lumimgrd", {NULL}, 4741, "tcp"}, {"lumimgrd", {NULL}, 4741, "udp"}, {"sicct", {NULL}, 4742, "tcp"}, {"sicct-sdp", {NULL}, 4742, "udp"}, {"openhpid", {NULL}, 4743, "tcp"}, {"openhpid", {NULL}, 4743, "udp"}, {"ifsp", {NULL}, 4744, "tcp"}, {"ifsp", {NULL}, 4744, "udp"}, {"fmp", {NULL}, 4745, "tcp"}, {"fmp", {NULL}, 4745, "udp"}, {"profilemac", {NULL}, 4749, "tcp"}, {"profilemac", {NULL}, 4749, "udp"}, {"ssad", {NULL}, 4750, "tcp"}, {"ssad", {NULL}, 4750, "udp"}, {"spocp", {NULL}, 4751, "tcp"}, {"spocp", {NULL}, 4751, "udp"}, {"snap", {NULL}, 4752, "tcp"}, {"snap", {NULL}, 4752, "udp"}, {"bfd-multi-ctl", {NULL}, 4784, "tcp"}, {"bfd-multi-ctl", {NULL}, 4784, "udp"}, {"cncp", {NULL}, 4785, "udp"}, {"smart-install", {NULL}, 4786, "tcp"}, {"sia-ctrl-plane", {NULL}, 4787, "tcp"}, {"iims", {NULL}, 4800, "tcp"}, {"iims", {NULL}, 4800, "udp"}, {"iwec", {NULL}, 4801, "tcp"}, {"iwec", {NULL}, 4801, "udp"}, {"ilss", {NULL}, 4802, "tcp"}, {"ilss", {NULL}, 4802, "udp"}, {"notateit", {NULL}, 4803, "tcp"}, {"notateit-disc", {NULL}, 4803, "udp"}, {"aja-ntv4-disc", {NULL}, 4804, "udp"}, {"htcp", {NULL}, 4827, "tcp"}, {"htcp", {NULL}, 4827, "udp"}, {"varadero-0", {NULL}, 4837, "tcp"}, {"varadero-0", {NULL}, 4837, "udp"}, {"varadero-1", {NULL}, 4838, "tcp"}, {"varadero-1", {NULL}, 4838, "udp"}, {"varadero-2", {NULL}, 4839, "tcp"}, {"varadero-2", {NULL}, 4839, "udp"}, {"opcua-tcp", {NULL}, 4840, "tcp"}, {"opcua-udp", {NULL}, 4840, "udp"}, {"quosa", {NULL}, 4841, "tcp"}, {"quosa", {NULL}, 4841, "udp"}, {"gw-asv", {NULL}, 4842, "tcp"}, {"gw-asv", {NULL}, 4842, "udp"}, {"opcua-tls", {NULL}, 4843, "tcp"}, {"opcua-tls", {NULL}, 4843, "udp"}, {"gw-log", {NULL}, 4844, "tcp"}, {"gw-log", {NULL}, 4844, "udp"}, {"wcr-remlib", {NULL}, 4845, "tcp"}, {"wcr-remlib", {NULL}, 4845, "udp"}, {"contamac_icm", {NULL}, 4846, "tcp"}, {"contamac_icm", {NULL}, 4846, "udp"}, {"wfc", {NULL}, 4847, "tcp"}, {"wfc", {NULL}, 4847, "udp"}, {"appserv-http", {NULL}, 4848, "tcp"}, {"appserv-http", {NULL}, 4848, "udp"}, {"appserv-https", {NULL}, 4849, "tcp"}, {"appserv-https", {NULL}, 4849, "udp"}, {"sun-as-nodeagt", {NULL}, 4850, "tcp"}, {"sun-as-nodeagt", {NULL}, 4850, "udp"}, {"derby-repli", {NULL}, 4851, "tcp"}, {"derby-repli", {NULL}, 4851, "udp"}, {"unify-debug", {NULL}, 4867, "tcp"}, {"unify-debug", {NULL}, 4867, "udp"}, {"phrelay", {NULL}, 4868, "tcp"}, {"phrelay", {NULL}, 4868, "udp"}, {"phrelaydbg", {NULL}, 4869, "tcp"}, {"phrelaydbg", {NULL}, 4869, "udp"}, {"cc-tracking", {NULL}, 4870, "tcp"}, {"cc-tracking", {NULL}, 4870, "udp"}, {"wired", {NULL}, 4871, "tcp"}, {"wired", {NULL}, 4871, "udp"}, {"tritium-can", {NULL}, 4876, "tcp"}, {"tritium-can", {NULL}, 4876, "udp"}, {"lmcs", {NULL}, 4877, "tcp"}, {"lmcs", {NULL}, 4877, "udp"}, {"inst-discovery", {NULL}, 4878, "udp"}, {"wsdl-event", {NULL}, 4879, "tcp"}, {"hislip", {NULL}, 4880, "tcp"}, {"socp-t", {NULL}, 4881, "udp"}, {"socp-c", {NULL}, 4882, "udp"}, {"wmlserver", {NULL}, 4883, "tcp"}, {"hivestor", {NULL}, 4884, "tcp"}, {"hivestor", {NULL}, 4884, "udp"}, {"abbs", {NULL}, 4885, "tcp"}, {"abbs", {NULL}, 4885, "udp"}, {"lyskom", {NULL}, 4894, "tcp"}, {"lyskom", {NULL}, 4894, "udp"}, {"radmin-port", {NULL}, 4899, "tcp"}, {"radmin-port", {NULL}, 4899, "udp"}, {"hfcs", {NULL}, 4900, "tcp"}, {"hfcs", {NULL}, 4900, "udp"}, {"flr_agent", {NULL}, 4901, "tcp"}, {"magiccontrol", {NULL}, 4902, "tcp"}, {"lutap", {NULL}, 4912, "tcp"}, {"lutcp", {NULL}, 4913, "tcp"}, {"bones", {NULL}, 4914, "tcp"}, {"bones", {NULL}, 4914, "udp"}, {"frcs", {NULL}, 4915, "tcp"}, {"atsc-mh-ssc", {NULL}, 4937, "udp"}, {"eq-office-4940", {NULL}, 4940, "tcp"}, {"eq-office-4940", {NULL}, 4940, "udp"}, {"eq-office-4941", {NULL}, 4941, "tcp"}, {"eq-office-4941", {NULL}, 4941, "udp"}, {"eq-office-4942", {NULL}, 4942, "tcp"}, {"eq-office-4942", {NULL}, 4942, "udp"}, {"munin", {NULL}, 4949, "tcp"}, {"munin", {NULL}, 4949, "udp"}, {"sybasesrvmon", {NULL}, 4950, "tcp"}, {"sybasesrvmon", {NULL}, 4950, "udp"}, {"pwgwims", {NULL}, 4951, "tcp"}, {"pwgwims", {NULL}, 4951, "udp"}, {"sagxtsds", {NULL}, 4952, "tcp"}, {"sagxtsds", {NULL}, 4952, "udp"}, {"dbsyncarbiter", {NULL}, 4953, "tcp"}, {"ccss-qmm", {NULL}, 4969, "tcp"}, {"ccss-qmm", {NULL}, 4969, "udp"}, {"ccss-qsm", {NULL}, 4970, "tcp"}, {"ccss-qsm", {NULL}, 4970, "udp"}, {"webyast", {NULL}, 4984, "tcp"}, {"gerhcs", {NULL}, 4985, "tcp"}, {"mrip", {NULL}, 4986, "tcp"}, {"mrip", {NULL}, 4986, "udp"}, {"smar-se-port1", {NULL}, 4987, "tcp"}, {"smar-se-port1", {NULL}, 4987, "udp"}, {"smar-se-port2", {NULL}, 4988, "tcp"}, {"smar-se-port2", {NULL}, 4988, "udp"}, {"parallel", {NULL}, 4989, "tcp"}, {"parallel", {NULL}, 4989, "udp"}, {"busycal", {NULL}, 4990, "tcp"}, {"busycal", {NULL}, 4990, "udp"}, {"vrt", {NULL}, 4991, "tcp"}, {"vrt", {NULL}, 4991, "udp"}, {"hfcs-manager", {NULL}, 4999, "tcp"}, {"hfcs-manager", {NULL}, 4999, "udp"}, {"commplex-main", {NULL}, 5000, "tcp"}, {"commplex-main", {NULL}, 5000, "udp"}, {"commplex-link", {NULL}, 5001, "tcp"}, {"commplex-link", {NULL}, 5001, "udp"}, {"rfe", {NULL}, 5002, "tcp"}, {"rfe", {NULL}, 5002, "udp"}, {"fmpro-internal", {NULL}, 5003, "tcp"}, {"fmpro-internal", {NULL}, 5003, "udp"}, {"avt-profile-1", {NULL}, 5004, "tcp"}, {"avt-profile-1", {NULL}, 5004, "udp"}, {"avt-profile-1", {NULL}, 5004, "dccp"}, {"avt-profile-2", {NULL}, 5005, "tcp"}, {"avt-profile-2", {NULL}, 5005, "udp"}, {"avt-profile-2", {NULL}, 5005, "dccp"}, {"wsm-server", {NULL}, 5006, "tcp"}, {"wsm-server", {NULL}, 5006, "udp"}, {"wsm-server-ssl", {NULL}, 5007, "tcp"}, {"wsm-server-ssl", {NULL}, 5007, "udp"}, {"synapsis-edge", {NULL}, 5008, "tcp"}, {"synapsis-edge", {NULL}, 5008, "udp"}, {"winfs", {NULL}, 5009, "tcp"}, {"winfs", {NULL}, 5009, "udp"}, {"telelpathstart", {NULL}, 5010, "tcp"}, {"telelpathstart", {NULL}, 5010, "udp"}, {"telelpathattack", {NULL}, 5011, "tcp"}, {"telelpathattack", {NULL}, 5011, "udp"}, {"nsp", {NULL}, 5012, "tcp"}, {"nsp", {NULL}, 5012, "udp"}, {"fmpro-v6", {NULL}, 5013, "tcp"}, {"fmpro-v6", {NULL}, 5013, "udp"}, {"onpsocket", {NULL}, 5014, "udp"}, {"fmwp", {NULL}, 5015, "tcp"}, {"zenginkyo-1", {NULL}, 5020, "tcp"}, {"zenginkyo-1", {NULL}, 5020, "udp"}, {"zenginkyo-2", {NULL}, 5021, "tcp"}, {"zenginkyo-2", {NULL}, 5021, "udp"}, {"mice", {NULL}, 5022, "tcp"}, {"mice", {NULL}, 5022, "udp"}, {"htuilsrv", {NULL}, 5023, "tcp"}, {"htuilsrv", {NULL}, 5023, "udp"}, {"scpi-telnet", {NULL}, 5024, "tcp"}, {"scpi-telnet", {NULL}, 5024, "udp"}, {"scpi-raw", {NULL}, 5025, "tcp"}, {"scpi-raw", {NULL}, 5025, "udp"}, {"strexec-d", {NULL}, 5026, "tcp"}, {"strexec-d", {NULL}, 5026, "udp"}, {"strexec-s", {NULL}, 5027, "tcp"}, {"strexec-s", {NULL}, 5027, "udp"}, {"qvr", {NULL}, 5028, "tcp"}, {"infobright", {NULL}, 5029, "tcp"}, {"infobright", {NULL}, 5029, "udp"}, {"surfpass", {NULL}, 5030, "tcp"}, {"surfpass", {NULL}, 5030, "udp"}, {"dmp", {NULL}, 5031, "udp"}, {"asnaacceler8db", {NULL}, 5042, "tcp"}, {"asnaacceler8db", {NULL}, 5042, "udp"}, {"swxadmin", {NULL}, 5043, "tcp"}, {"swxadmin", {NULL}, 5043, "udp"}, {"lxi-evntsvc", {NULL}, 5044, "tcp"}, {"lxi-evntsvc", {NULL}, 5044, "udp"}, {"osp", {NULL}, 5045, "tcp"}, {"vpm-udp", {NULL}, 5046, "udp"}, {"iscape", {NULL}, 5047, "udp"}, {"texai", {NULL}, 5048, "tcp"}, {"ivocalize", {NULL}, 5049, "tcp"}, {"ivocalize", {NULL}, 5049, "udp"}, {"mmcc", {NULL}, 5050, "tcp"}, {"mmcc", {NULL}, 5050, "udp"}, {"ita-agent", {NULL}, 5051, "tcp"}, {"ita-agent", {NULL}, 5051, "udp"}, {"ita-manager", {NULL}, 5052, "tcp"}, {"ita-manager", {NULL}, 5052, "udp"}, {"rlm", {NULL}, 5053, "tcp"}, {"rlm-admin", {NULL}, 5054, "tcp"}, {"unot", {NULL}, 5055, "tcp"}, {"unot", {NULL}, 5055, "udp"}, {"intecom-ps1", {NULL}, 5056, "tcp"}, {"intecom-ps1", {NULL}, 5056, "udp"}, {"intecom-ps2", {NULL}, 5057, "tcp"}, {"intecom-ps2", {NULL}, 5057, "udp"}, {"locus-disc", {NULL}, 5058, "udp"}, {"sds", {NULL}, 5059, "tcp"}, {"sds", {NULL}, 5059, "udp"}, {"sip", {NULL}, 5060, "tcp"}, {"sip", {NULL}, 5060, "udp"}, {"sip-tls", {NULL}, 5061, "tcp"}, {"sip-tls", {NULL}, 5061, "udp"}, {"na-localise", {NULL}, 5062, "tcp"}, {"na-localise", {NULL}, 5062, "udp"}, {"csrpc", {NULL}, 5063, "tcp"}, {"ca-1", {NULL}, 5064, "tcp"}, {"ca-1", {NULL}, 5064, "udp"}, {"ca-2", {NULL}, 5065, "tcp"}, {"ca-2", {NULL}, 5065, "udp"}, {"stanag-5066", {NULL}, 5066, "tcp"}, {"stanag-5066", {NULL}, 5066, "udp"}, {"authentx", {NULL}, 5067, "tcp"}, {"authentx", {NULL}, 5067, "udp"}, {"bitforestsrv", {NULL}, 5068, "tcp"}, {"i-net-2000-npr", {NULL}, 5069, "tcp"}, {"i-net-2000-npr", {NULL}, 5069, "udp"}, {"vtsas", {NULL}, 5070, "tcp"}, {"vtsas", {NULL}, 5070, "udp"}, {"powerschool", {NULL}, 5071, "tcp"}, {"powerschool", {NULL}, 5071, "udp"}, {"ayiya", {NULL}, 5072, "tcp"}, {"ayiya", {NULL}, 5072, "udp"}, {"tag-pm", {NULL}, 5073, "tcp"}, {"tag-pm", {NULL}, 5073, "udp"}, {"alesquery", {NULL}, 5074, "tcp"}, {"alesquery", {NULL}, 5074, "udp"}, {"cp-spxrpts", {NULL}, 5079, "udp"}, {"onscreen", {NULL}, 5080, "tcp"}, {"onscreen", {NULL}, 5080, "udp"}, {"sdl-ets", {NULL}, 5081, "tcp"}, {"sdl-ets", {NULL}, 5081, "udp"}, {"qcp", {NULL}, 5082, "tcp"}, {"qcp", {NULL}, 5082, "udp"}, {"qfp", {NULL}, 5083, "tcp"}, {"qfp", {NULL}, 5083, "udp"}, {"llrp", {NULL}, 5084, "tcp"}, {"llrp", {NULL}, 5084, "udp"}, {"encrypted-llrp", {NULL}, 5085, "tcp"}, {"encrypted-llrp", {NULL}, 5085, "udp"}, {"aprigo-cs", {NULL}, 5086, "tcp"}, {"car", {NULL}, 5090, "sctp"}, {"cxtp", {NULL}, 5091, "sctp"}, {"magpie", {NULL}, 5092, "udp"}, {"sentinel-lm", {NULL}, 5093, "tcp"}, {"sentinel-lm", {NULL}, 5093, "udp"}, {"hart-ip", {NULL}, 5094, "tcp"}, {"hart-ip", {NULL}, 5094, "udp"}, {"sentlm-srv2srv", {NULL}, 5099, "tcp"}, {"sentlm-srv2srv", {NULL}, 5099, "udp"}, {"socalia", {NULL}, 5100, "tcp"}, {"socalia", {NULL}, 5100, "udp"}, {"talarian-tcp", {NULL}, 5101, "tcp"}, {"talarian-udp", {NULL}, 5101, "udp"}, {"oms-nonsecure", {NULL}, 5102, "tcp"}, {"oms-nonsecure", {NULL}, 5102, "udp"}, {"actifio-c2c", {NULL}, 5103, "tcp"}, {"tinymessage", {NULL}, 5104, "udp"}, {"hughes-ap", {NULL}, 5105, "udp"}, {"taep-as-svc", {NULL}, 5111, "tcp"}, {"taep-as-svc", {NULL}, 5111, "udp"}, {"pm-cmdsvr", {NULL}, 5112, "tcp"}, {"pm-cmdsvr", {NULL}, 5112, "udp"}, {"ev-services", {NULL}, 5114, "tcp"}, {"autobuild", {NULL}, 5115, "tcp"}, {"emb-proj-cmd", {NULL}, 5116, "udp"}, {"gradecam", {NULL}, 5117, "tcp"}, {"nbt-pc", {NULL}, 5133, "tcp"}, {"nbt-pc", {NULL}, 5133, "udp"}, {"ppactivation", {NULL}, 5134, "tcp"}, {"erp-scale", {NULL}, 5135, "tcp"}, {"minotaur-sa", {NULL}, 5136, "udp"}, {"ctsd", {NULL}, 5137, "tcp"}, {"ctsd", {NULL}, 5137, "udp"}, {"rmonitor_secure", {NULL}, 5145, "tcp"}, {"rmonitor_secure", {NULL}, 5145, "udp"}, {"social-alarm", {NULL}, 5146, "tcp"}, {"atmp", {NULL}, 5150, "tcp"}, {"atmp", {NULL}, 5150, "udp"}, {"esri_sde", {NULL}, 5151, "tcp"}, {"esri_sde", {NULL}, 5151, "udp"}, {"sde-discovery", {NULL}, 5152, "tcp"}, {"sde-discovery", {NULL}, 5152, "udp"}, {"toruxserver", {NULL}, 5153, "tcp"}, {"bzflag", {NULL}, 5154, "tcp"}, {"bzflag", {NULL}, 5154, "udp"}, {"asctrl-agent", {NULL}, 5155, "tcp"}, {"asctrl-agent", {NULL}, 5155, "udp"}, {"rugameonline", {NULL}, 5156, "tcp"}, {"mediat", {NULL}, 5157, "tcp"}, {"snmpssh", {NULL}, 5161, "tcp"}, {"snmpssh-trap", {NULL}, 5162, "tcp"}, {"sbackup", {NULL}, 5163, "tcp"}, {"vpa", {NULL}, 5164, "tcp"}, {"vpa-disc", {NULL}, 5164, "udp"}, {"ife_icorp", {NULL}, 5165, "tcp"}, {"ife_icorp", {NULL}, 5165, "udp"}, {"winpcs", {NULL}, 5166, "tcp"}, {"winpcs", {NULL}, 5166, "udp"}, {"scte104", {NULL}, 5167, "tcp"}, {"scte104", {NULL}, 5167, "udp"}, {"scte30", {NULL}, 5168, "tcp"}, {"scte30", {NULL}, 5168, "udp"}, {"aol", {NULL}, 5190, "tcp"}, {"aol", {NULL}, 5190, "udp"}, {"aol-1", {NULL}, 5191, "tcp"}, {"aol-1", {NULL}, 5191, "udp"}, {"aol-2", {NULL}, 5192, "tcp"}, {"aol-2", {NULL}, 5192, "udp"}, {"aol-3", {NULL}, 5193, "tcp"}, {"aol-3", {NULL}, 5193, "udp"}, {"cpscomm", {NULL}, 5194, "tcp"}, {"targus-getdata", {NULL}, 5200, "tcp"}, {"targus-getdata", {NULL}, 5200, "udp"}, {"targus-getdata1", {NULL}, 5201, "tcp"}, {"targus-getdata1", {NULL}, 5201, "udp"}, {"targus-getdata2", {NULL}, 5202, "tcp"}, {"targus-getdata2", {NULL}, 5202, "udp"}, {"targus-getdata3", {NULL}, 5203, "tcp"}, {"targus-getdata3", {NULL}, 5203, "udp"}, {"3exmp", {NULL}, 5221, "tcp"}, {"xmpp-client", {NULL}, 5222, "tcp"}, {"hpvirtgrp", {NULL}, 5223, "tcp"}, {"hpvirtgrp", {NULL}, 5223, "udp"}, {"hpvirtctrl", {NULL}, 5224, "tcp"}, {"hpvirtctrl", {NULL}, 5224, "udp"}, {"hp-server", {NULL}, 5225, "tcp"}, {"hp-server", {NULL}, 5225, "udp"}, {"hp-status", {NULL}, 5226, "tcp"}, {"hp-status", {NULL}, 5226, "udp"}, {"perfd", {NULL}, 5227, "tcp"}, {"perfd", {NULL}, 5227, "udp"}, {"hpvroom", {NULL}, 5228, "tcp"}, {"csedaemon", {NULL}, 5232, "tcp"}, {"enfs", {NULL}, 5233, "tcp"}, {"eenet", {NULL}, 5234, "tcp"}, {"eenet", {NULL}, 5234, "udp"}, {"galaxy-network", {NULL}, 5235, "tcp"}, {"galaxy-network", {NULL}, 5235, "udp"}, {"padl2sim", {NULL}, 5236, "tcp"}, {"padl2sim", {NULL}, 5236, "udp"}, {"mnet-discovery", {NULL}, 5237, "tcp"}, {"mnet-discovery", {NULL}, 5237, "udp"}, {"downtools", {NULL}, 5245, "tcp"}, {"downtools-disc", {NULL}, 5245, "udp"}, {"capwap-control", {NULL}, 5246, "udp"}, {"capwap-data", {NULL}, 5247, "udp"}, {"caacws", {NULL}, 5248, "tcp"}, {"caacws", {NULL}, 5248, "udp"}, {"caaclang2", {NULL}, 5249, "tcp"}, {"caaclang2", {NULL}, 5249, "udp"}, {"soagateway", {NULL}, 5250, "tcp"}, {"soagateway", {NULL}, 5250, "udp"}, {"caevms", {NULL}, 5251, "tcp"}, {"caevms", {NULL}, 5251, "udp"}, {"movaz-ssc", {NULL}, 5252, "tcp"}, {"movaz-ssc", {NULL}, 5252, "udp"}, {"kpdp", {NULL}, 5253, "tcp"}, {"3com-njack-1", {NULL}, 5264, "tcp"}, {"3com-njack-1", {NULL}, 5264, "udp"}, {"3com-njack-2", {NULL}, 5265, "tcp"}, {"3com-njack-2", {NULL}, 5265, "udp"}, {"xmpp-server", {NULL}, 5269, "tcp"}, {"xmp", {NULL}, 5270, "tcp"}, {"xmp", {NULL}, 5270, "udp"}, {"cuelink", {NULL}, 5271, "tcp"}, {"cuelink-disc", {NULL}, 5271, "udp"}, {"pk", {NULL}, 5272, "tcp"}, {"pk", {NULL}, 5272, "udp"}, {"xmpp-bosh", {NULL}, 5280, "tcp"}, {"undo-lm", {NULL}, 5281, "tcp"}, {"transmit-port", {NULL}, 5282, "tcp"}, {"transmit-port", {NULL}, 5282, "udp"}, {"presence", {NULL}, 5298, "tcp"}, {"presence", {NULL}, 5298, "udp"}, {"nlg-data", {NULL}, 5299, "tcp"}, {"nlg-data", {NULL}, 5299, "udp"}, {"hacl-hb", {NULL}, 5300, "tcp"}, {"hacl-hb", {NULL}, 5300, "udp"}, {"hacl-gs", {NULL}, 5301, "tcp"}, {"hacl-gs", {NULL}, 5301, "udp"}, {"hacl-cfg", {NULL}, 5302, "tcp"}, {"hacl-cfg", {NULL}, 5302, "udp"}, {"hacl-probe", {NULL}, 5303, "tcp"}, {"hacl-probe", {NULL}, 5303, "udp"}, {"hacl-local", {NULL}, 5304, "tcp"}, {"hacl-local", {NULL}, 5304, "udp"}, {"hacl-test", {NULL}, 5305, "tcp"}, {"hacl-test", {NULL}, 5305, "udp"}, {"sun-mc-grp", {NULL}, 5306, "tcp"}, {"sun-mc-grp", {NULL}, 5306, "udp"}, {"sco-aip", {NULL}, 5307, "tcp"}, {"sco-aip", {NULL}, 5307, "udp"}, {"cfengine", {NULL}, 5308, "tcp"}, {"cfengine", {NULL}, 5308, "udp"}, {"jprinter", {NULL}, 5309, "tcp"}, {"jprinter", {NULL}, 5309, "udp"}, {"outlaws", {NULL}, 5310, "tcp"}, {"outlaws", {NULL}, 5310, "udp"}, {"permabit-cs", {NULL}, 5312, "tcp"}, {"permabit-cs", {NULL}, 5312, "udp"}, {"rrdp", {NULL}, 5313, "tcp"}, {"rrdp", {NULL}, 5313, "udp"}, {"opalis-rbt-ipc", {NULL}, 5314, "tcp"}, {"opalis-rbt-ipc", {NULL}, 5314, "udp"}, {"hacl-poll", {NULL}, 5315, "tcp"}, {"hacl-poll", {NULL}, 5315, "udp"}, {"hpdevms", {NULL}, 5316, "tcp"}, {"hpdevms", {NULL}, 5316, "udp"}, {"bsfserver-zn", {NULL}, 5320, "tcp"}, {"bsfsvr-zn-ssl", {NULL}, 5321, "tcp"}, {"kfserver", {NULL}, 5343, "tcp"}, {"kfserver", {NULL}, 5343, "udp"}, {"xkotodrcp", {NULL}, 5344, "tcp"}, {"xkotodrcp", {NULL}, 5344, "udp"}, {"stuns", {NULL}, 5349, "tcp"}, {"stuns", {NULL}, 5349, "udp"}, {"turns", {NULL}, 5349, "tcp"}, {"turns", {NULL}, 5349, "udp"}, {"stun-behaviors", {NULL}, 5349, "tcp"}, {"stun-behaviors", {NULL}, 5349, "udp"}, {"nat-pmp-status", {NULL}, 5350, "tcp"}, {"nat-pmp-status", {NULL}, 5350, "udp"}, {"nat-pmp", {NULL}, 5351, "tcp"}, {"nat-pmp", {NULL}, 5351, "udp"}, {"dns-llq", {NULL}, 5352, "tcp"}, {"dns-llq", {NULL}, 5352, "udp"}, {"mdns", {NULL}, 5353, "tcp"}, {"mdns", {NULL}, 5353, "udp"}, {"mdnsresponder", {NULL}, 5354, "tcp"}, {"mdnsresponder", {NULL}, 5354, "udp"}, {"llmnr", {NULL}, 5355, "tcp"}, {"llmnr", {NULL}, 5355, "udp"}, {"ms-smlbiz", {NULL}, 5356, "tcp"}, {"ms-smlbiz", {NULL}, 5356, "udp"}, {"wsdapi", {NULL}, 5357, "tcp"}, {"wsdapi", {NULL}, 5357, "udp"}, {"wsdapi-s", {NULL}, 5358, "tcp"}, {"wsdapi-s", {NULL}, 5358, "udp"}, {"ms-alerter", {NULL}, 5359, "tcp"}, {"ms-alerter", {NULL}, 5359, "udp"}, {"ms-sideshow", {NULL}, 5360, "tcp"}, {"ms-sideshow", {NULL}, 5360, "udp"}, {"ms-s-sideshow", {NULL}, 5361, "tcp"}, {"ms-s-sideshow", {NULL}, 5361, "udp"}, {"serverwsd2", {NULL}, 5362, "tcp"}, {"serverwsd2", {NULL}, 5362, "udp"}, {"net-projection", {NULL}, 5363, "tcp"}, {"net-projection", {NULL}, 5363, "udp"}, {"stresstester", {NULL}, 5397, "tcp"}, {"stresstester", {NULL}, 5397, "udp"}, {"elektron-admin", {NULL}, 5398, "tcp"}, {"elektron-admin", {NULL}, 5398, "udp"}, {"securitychase", {NULL}, 5399, "tcp"}, {"securitychase", {NULL}, 5399, "udp"}, {"excerpt", {NULL}, 5400, "tcp"}, {"excerpt", {NULL}, 5400, "udp"}, {"excerpts", {NULL}, 5401, "tcp"}, {"excerpts", {NULL}, 5401, "udp"}, {"mftp", {NULL}, 5402, "tcp"}, {"mftp", {NULL}, 5402, "udp"}, {"hpoms-ci-lstn", {NULL}, 5403, "tcp"}, {"hpoms-ci-lstn", {NULL}, 5403, "udp"}, {"hpoms-dps-lstn", {NULL}, 5404, "tcp"}, {"hpoms-dps-lstn", {NULL}, 5404, "udp"}, {"netsupport", {NULL}, 5405, "tcp"}, {"netsupport", {NULL}, 5405, "udp"}, {"systemics-sox", {NULL}, 5406, "tcp"}, {"systemics-sox", {NULL}, 5406, "udp"}, {"foresyte-clear", {NULL}, 5407, "tcp"}, {"foresyte-clear", {NULL}, 5407, "udp"}, {"foresyte-sec", {NULL}, 5408, "tcp"}, {"foresyte-sec", {NULL}, 5408, "udp"}, {"salient-dtasrv", {NULL}, 5409, "tcp"}, {"salient-dtasrv", {NULL}, 5409, "udp"}, {"salient-usrmgr", {NULL}, 5410, "tcp"}, {"salient-usrmgr", {NULL}, 5410, "udp"}, {"actnet", {NULL}, 5411, "tcp"}, {"actnet", {NULL}, 5411, "udp"}, {"continuus", {NULL}, 5412, "tcp"}, {"continuus", {NULL}, 5412, "udp"}, {"wwiotalk", {NULL}, 5413, "tcp"}, {"wwiotalk", {NULL}, 5413, "udp"}, {"statusd", {NULL}, 5414, "tcp"}, {"statusd", {NULL}, 5414, "udp"}, {"ns-server", {NULL}, 5415, "tcp"}, {"ns-server", {NULL}, 5415, "udp"}, {"sns-gateway", {NULL}, 5416, "tcp"}, {"sns-gateway", {NULL}, 5416, "udp"}, {"sns-agent", {NULL}, 5417, "tcp"}, {"sns-agent", {NULL}, 5417, "udp"}, {"mcntp", {NULL}, 5418, "tcp"}, {"mcntp", {NULL}, 5418, "udp"}, {"dj-ice", {NULL}, 5419, "tcp"}, {"dj-ice", {NULL}, 5419, "udp"}, {"cylink-c", {NULL}, 5420, "tcp"}, {"cylink-c", {NULL}, 5420, "udp"}, {"netsupport2", {NULL}, 5421, "tcp"}, {"netsupport2", {NULL}, 5421, "udp"}, {"salient-mux", {NULL}, 5422, "tcp"}, {"salient-mux", {NULL}, 5422, "udp"}, {"virtualuser", {NULL}, 5423, "tcp"}, {"virtualuser", {NULL}, 5423, "udp"}, {"beyond-remote", {NULL}, 5424, "tcp"}, {"beyond-remote", {NULL}, 5424, "udp"}, {"br-channel", {NULL}, 5425, "tcp"}, {"br-channel", {NULL}, 5425, "udp"}, {"devbasic", {NULL}, 5426, "tcp"}, {"devbasic", {NULL}, 5426, "udp"}, {"sco-peer-tta", {NULL}, 5427, "tcp"}, {"sco-peer-tta", {NULL}, 5427, "udp"}, {"telaconsole", {NULL}, 5428, "tcp"}, {"telaconsole", {NULL}, 5428, "udp"}, {"base", {NULL}, 5429, "tcp"}, {"base", {NULL}, 5429, "udp"}, {"radec-corp", {NULL}, 5430, "tcp"}, {"radec-corp", {NULL}, 5430, "udp"}, {"park-agent", {NULL}, 5431, "tcp"}, {"park-agent", {NULL}, 5431, "udp"}, {"postgresql", {NULL}, 5432, "tcp"}, {"postgresql", {NULL}, 5432, "udp"}, {"pyrrho", {NULL}, 5433, "tcp"}, {"pyrrho", {NULL}, 5433, "udp"}, {"sgi-arrayd", {NULL}, 5434, "tcp"}, {"sgi-arrayd", {NULL}, 5434, "udp"}, {"sceanics", {NULL}, 5435, "tcp"}, {"sceanics", {NULL}, 5435, "udp"}, {"pmip6-cntl", {NULL}, 5436, "udp"}, {"pmip6-data", {NULL}, 5437, "udp"}, {"spss", {NULL}, 5443, "tcp"}, {"spss", {NULL}, 5443, "udp"}, {"surebox", {NULL}, 5453, "tcp"}, {"surebox", {NULL}, 5453, "udp"}, {"apc-5454", {NULL}, 5454, "tcp"}, {"apc-5454", {NULL}, 5454, "udp"}, {"apc-5455", {NULL}, 5455, "tcp"}, {"apc-5455", {NULL}, 5455, "udp"}, {"apc-5456", {NULL}, 5456, "tcp"}, {"apc-5456", {NULL}, 5456, "udp"}, {"silkmeter", {NULL}, 5461, "tcp"}, {"silkmeter", {NULL}, 5461, "udp"}, {"ttl-publisher", {NULL}, 5462, "tcp"}, {"ttl-publisher", {NULL}, 5462, "udp"}, {"ttlpriceproxy", {NULL}, 5463, "tcp"}, {"ttlpriceproxy", {NULL}, 5463, "udp"}, {"quailnet", {NULL}, 5464, "tcp"}, {"quailnet", {NULL}, 5464, "udp"}, {"netops-broker", {NULL}, 5465, "tcp"}, {"netops-broker", {NULL}, 5465, "udp"}, {"fcp-addr-srvr1", {NULL}, 5500, "tcp"}, {"fcp-addr-srvr1", {NULL}, 5500, "udp"}, {"fcp-addr-srvr2", {NULL}, 5501, "tcp"}, {"fcp-addr-srvr2", {NULL}, 5501, "udp"}, {"fcp-srvr-inst1", {NULL}, 5502, "tcp"}, {"fcp-srvr-inst1", {NULL}, 5502, "udp"}, {"fcp-srvr-inst2", {NULL}, 5503, "tcp"}, {"fcp-srvr-inst2", {NULL}, 5503, "udp"}, {"fcp-cics-gw1", {NULL}, 5504, "tcp"}, {"fcp-cics-gw1", {NULL}, 5504, "udp"}, {"checkoutdb", {NULL}, 5505, "tcp"}, {"checkoutdb", {NULL}, 5505, "udp"}, {"amc", {NULL}, 5506, "tcp"}, {"amc", {NULL}, 5506, "udp"}, {"sgi-eventmond", {NULL}, 5553, "tcp"}, {"sgi-eventmond", {NULL}, 5553, "udp"}, {"sgi-esphttp", {NULL}, 5554, "tcp"}, {"sgi-esphttp", {NULL}, 5554, "udp"}, {"personal-agent", {NULL}, 5555, "tcp"}, {"personal-agent", {NULL}, 5555, "udp"}, {"freeciv", {NULL}, 5556, "tcp"}, {"freeciv", {NULL}, 5556, "udp"}, {"farenet", {NULL}, 5557, "tcp"}, {"westec-connect", {NULL}, 5566, "tcp"}, {"m-oap", {NULL}, 5567, "tcp"}, {"m-oap", {NULL}, 5567, "udp"}, {"sdt", {NULL}, 5568, "tcp"}, {"sdt", {NULL}, 5568, "udp"}, {"sdmmp", {NULL}, 5573, "tcp"}, {"sdmmp", {NULL}, 5573, "udp"}, {"lsi-bobcat", {NULL}, 5574, "tcp"}, {"ora-oap", {NULL}, 5575, "tcp"}, {"fdtracks", {NULL}, 5579, "tcp"}, {"tmosms0", {NULL}, 5580, "tcp"}, {"tmosms0", {NULL}, 5580, "udp"}, {"tmosms1", {NULL}, 5581, "tcp"}, {"tmosms1", {NULL}, 5581, "udp"}, {"fac-restore", {NULL}, 5582, "tcp"}, {"fac-restore", {NULL}, 5582, "udp"}, {"tmo-icon-sync", {NULL}, 5583, "tcp"}, {"tmo-icon-sync", {NULL}, 5583, "udp"}, {"bis-web", {NULL}, 5584, "tcp"}, {"bis-web", {NULL}, 5584, "udp"}, {"bis-sync", {NULL}, 5585, "tcp"}, {"bis-sync", {NULL}, 5585, "udp"}, {"ininmessaging", {NULL}, 5597, "tcp"}, {"ininmessaging", {NULL}, 5597, "udp"}, {"mctfeed", {NULL}, 5598, "tcp"}, {"mctfeed", {NULL}, 5598, "udp"}, {"esinstall", {NULL}, 5599, "tcp"}, {"esinstall", {NULL}, 5599, "udp"}, {"esmmanager", {NULL}, 5600, "tcp"}, {"esmmanager", {NULL}, 5600, "udp"}, {"esmagent", {NULL}, 5601, "tcp"}, {"esmagent", {NULL}, 5601, "udp"}, {"a1-msc", {NULL}, 5602, "tcp"}, {"a1-msc", {NULL}, 5602, "udp"}, {"a1-bs", {NULL}, 5603, "tcp"}, {"a1-bs", {NULL}, 5603, "udp"}, {"a3-sdunode", {NULL}, 5604, "tcp"}, {"a3-sdunode", {NULL}, 5604, "udp"}, {"a4-sdunode", {NULL}, 5605, "tcp"}, {"a4-sdunode", {NULL}, 5605, "udp"}, {"ninaf", {NULL}, 5627, "tcp"}, {"ninaf", {NULL}, 5627, "udp"}, {"htrust", {NULL}, 5628, "tcp"}, {"htrust", {NULL}, 5628, "udp"}, {"symantec-sfdb", {NULL}, 5629, "tcp"}, {"symantec-sfdb", {NULL}, 5629, "udp"}, {"precise-comm", {NULL}, 5630, "tcp"}, {"precise-comm", {NULL}, 5630, "udp"}, {"pcanywheredata", {NULL}, 5631, "tcp"}, {"pcanywheredata", {NULL}, 5631, "udp"}, {"pcanywherestat", {NULL}, 5632, "tcp"}, {"pcanywherestat", {NULL}, 5632, "udp"}, {"beorl", {NULL}, 5633, "tcp"}, {"beorl", {NULL}, 5633, "udp"}, {"xprtld", {NULL}, 5634, "tcp"}, {"xprtld", {NULL}, 5634, "udp"}, {"sfmsso", {NULL}, 5635, "tcp"}, {"sfm-db-server", {NULL}, 5636, "tcp"}, {"cssc", {NULL}, 5637, "tcp"}, {"amqps", {NULL}, 5671, "tcp"}, {"amqps", {NULL}, 5671, "udp"}, {"amqp", {NULL}, 5672, "tcp"}, {"amqp", {NULL}, 5672, "udp"}, {"amqp", {NULL}, 5672, "sctp"}, {"jms", {NULL}, 5673, "tcp"}, {"jms", {NULL}, 5673, "udp"}, {"hyperscsi-port", {NULL}, 5674, "tcp"}, {"hyperscsi-port", {NULL}, 5674, "udp"}, {"v5ua", {NULL}, 5675, "tcp"}, {"v5ua", {NULL}, 5675, "udp"}, {"v5ua", {NULL}, 5675, "sctp"}, {"raadmin", {NULL}, 5676, "tcp"}, {"raadmin", {NULL}, 5676, "udp"}, {"questdb2-lnchr", {NULL}, 5677, "tcp"}, {"questdb2-lnchr", {NULL}, 5677, "udp"}, {"rrac", {NULL}, 5678, "tcp"}, {"rrac", {NULL}, 5678, "udp"}, {"dccm", {NULL}, 5679, "tcp"}, {"dccm", {NULL}, 5679, "udp"}, {"auriga-router", {NULL}, 5680, "tcp"}, {"auriga-router", {NULL}, 5680, "udp"}, {"ncxcp", {NULL}, 5681, "tcp"}, {"ncxcp", {NULL}, 5681, "udp"}, {"brightcore", {NULL}, 5682, "udp"}, {"ggz", {NULL}, 5688, "tcp"}, {"ggz", {NULL}, 5688, "udp"}, {"qmvideo", {NULL}, 5689, "tcp"}, {"qmvideo", {NULL}, 5689, "udp"}, {"proshareaudio", {NULL}, 5713, "tcp"}, {"proshareaudio", {NULL}, 5713, "udp"}, {"prosharevideo", {NULL}, 5714, "tcp"}, {"prosharevideo", {NULL}, 5714, "udp"}, {"prosharedata", {NULL}, 5715, "tcp"}, {"prosharedata", {NULL}, 5715, "udp"}, {"prosharerequest", {NULL}, 5716, "tcp"}, {"prosharerequest", {NULL}, 5716, "udp"}, {"prosharenotify", {NULL}, 5717, "tcp"}, {"prosharenotify", {NULL}, 5717, "udp"}, {"dpm", {NULL}, 5718, "tcp"}, {"dpm", {NULL}, 5718, "udp"}, {"dpm-agent", {NULL}, 5719, "tcp"}, {"dpm-agent", {NULL}, 5719, "udp"}, {"ms-licensing", {NULL}, 5720, "tcp"}, {"ms-licensing", {NULL}, 5720, "udp"}, {"dtpt", {NULL}, 5721, "tcp"}, {"dtpt", {NULL}, 5721, "udp"}, {"msdfsr", {NULL}, 5722, "tcp"}, {"msdfsr", {NULL}, 5722, "udp"}, {"omhs", {NULL}, 5723, "tcp"}, {"omhs", {NULL}, 5723, "udp"}, {"omsdk", {NULL}, 5724, "tcp"}, {"omsdk", {NULL}, 5724, "udp"}, {"ms-ilm", {NULL}, 5725, "tcp"}, {"ms-ilm-sts", {NULL}, 5726, "tcp"}, {"asgenf", {NULL}, 5727, "tcp"}, {"io-dist-data", {NULL}, 5728, "tcp"}, {"io-dist-group", {NULL}, 5728, "udp"}, {"openmail", {NULL}, 5729, "tcp"}, {"openmail", {NULL}, 5729, "udp"}, {"unieng", {NULL}, 5730, "tcp"}, {"unieng", {NULL}, 5730, "udp"}, {"ida-discover1", {NULL}, 5741, "tcp"}, {"ida-discover1", {NULL}, 5741, "udp"}, {"ida-discover2", {NULL}, 5742, "tcp"}, {"ida-discover2", {NULL}, 5742, "udp"}, {"watchdoc-pod", {NULL}, 5743, "tcp"}, {"watchdoc-pod", {NULL}, 5743, "udp"}, {"watchdoc", {NULL}, 5744, "tcp"}, {"watchdoc", {NULL}, 5744, "udp"}, {"fcopy-server", {NULL}, 5745, "tcp"}, {"fcopy-server", {NULL}, 5745, "udp"}, {"fcopys-server", {NULL}, 5746, "tcp"}, {"fcopys-server", {NULL}, 5746, "udp"}, {"tunatic", {NULL}, 5747, "tcp"}, {"tunatic", {NULL}, 5747, "udp"}, {"tunalyzer", {NULL}, 5748, "tcp"}, {"tunalyzer", {NULL}, 5748, "udp"}, {"rscd", {NULL}, 5750, "tcp"}, {"rscd", {NULL}, 5750, "udp"}, {"openmailg", {NULL}, 5755, "tcp"}, {"openmailg", {NULL}, 5755, "udp"}, {"x500ms", {NULL}, 5757, "tcp"}, {"x500ms", {NULL}, 5757, "udp"}, {"openmailns", {NULL}, 5766, "tcp"}, {"openmailns", {NULL}, 5766, "udp"}, {"s-openmail", {NULL}, 5767, "tcp"}, {"s-openmail", {NULL}, 5767, "udp"}, {"openmailpxy", {NULL}, 5768, "tcp"}, {"openmailpxy", {NULL}, 5768, "udp"}, {"spramsca", {NULL}, 5769, "tcp"}, {"spramsca", {NULL}, 5769, "udp"}, {"spramsd", {NULL}, 5770, "tcp"}, {"spramsd", {NULL}, 5770, "udp"}, {"netagent", {NULL}, 5771, "tcp"}, {"netagent", {NULL}, 5771, "udp"}, {"dali-port", {NULL}, 5777, "tcp"}, {"dali-port", {NULL}, 5777, "udp"}, {"vts-rpc", {NULL}, 5780, "tcp"}, {"3par-evts", {NULL}, 5781, "tcp"}, {"3par-evts", {NULL}, 5781, "udp"}, {"3par-mgmt", {NULL}, 5782, "tcp"}, {"3par-mgmt", {NULL}, 5782, "udp"}, {"3par-mgmt-ssl", {NULL}, 5783, "tcp"}, {"3par-mgmt-ssl", {NULL}, 5783, "udp"}, {"ibar", {NULL}, 5784, "udp"}, {"3par-rcopy", {NULL}, 5785, "tcp"}, {"3par-rcopy", {NULL}, 5785, "udp"}, {"cisco-redu", {NULL}, 5786, "udp"}, {"waascluster", {NULL}, 5787, "udp"}, {"xtreamx", {NULL}, 5793, "tcp"}, {"xtreamx", {NULL}, 5793, "udp"}, {"spdp", {NULL}, 5794, "udp"}, {"icmpd", {NULL}, 5813, "tcp"}, {"icmpd", {NULL}, 5813, "udp"}, {"spt-automation", {NULL}, 5814, "tcp"}, {"spt-automation", {NULL}, 5814, "udp"}, {"wherehoo", {NULL}, 5859, "tcp"}, {"wherehoo", {NULL}, 5859, "udp"}, {"ppsuitemsg", {NULL}, 5863, "tcp"}, {"ppsuitemsg", {NULL}, 5863, "udp"}, {"rfb", {NULL}, 5900, "tcp"}, {"rfb", {NULL}, 5900, "udp"}, {"cm", {NULL}, 5910, "tcp"}, {"cm", {NULL}, 5910, "udp"}, {"cpdlc", {NULL}, 5911, "tcp"}, {"cpdlc", {NULL}, 5911, "udp"}, {"fis", {NULL}, 5912, "tcp"}, {"fis", {NULL}, 5912, "udp"}, {"ads-c", {NULL}, 5913, "tcp"}, {"ads-c", {NULL}, 5913, "udp"}, {"indy", {NULL}, 5963, "tcp"}, {"indy", {NULL}, 5963, "udp"}, {"mppolicy-v5", {NULL}, 5968, "tcp"}, {"mppolicy-v5", {NULL}, 5968, "udp"}, {"mppolicy-mgr", {NULL}, 5969, "tcp"}, {"mppolicy-mgr", {NULL}, 5969, "udp"}, {"couchdb", {NULL}, 5984, "tcp"}, {"couchdb", {NULL}, 5984, "udp"}, {"wsman", {NULL}, 5985, "tcp"}, {"wsman", {NULL}, 5985, "udp"}, {"wsmans", {NULL}, 5986, "tcp"}, {"wsmans", {NULL}, 5986, "udp"}, {"wbem-rmi", {NULL}, 5987, "tcp"}, {"wbem-rmi", {NULL}, 5987, "udp"}, {"wbem-http", {NULL}, 5988, "tcp"}, {"wbem-http", {NULL}, 5988, "udp"}, {"wbem-https", {NULL}, 5989, "tcp"}, {"wbem-https", {NULL}, 5989, "udp"}, {"wbem-exp-https", {NULL}, 5990, "tcp"}, {"wbem-exp-https", {NULL}, 5990, "udp"}, {"nuxsl", {NULL}, 5991, "tcp"}, {"nuxsl", {NULL}, 5991, "udp"}, {"consul-insight", {NULL}, 5992, "tcp"}, {"consul-insight", {NULL}, 5992, "udp"}, {"cvsup", {NULL}, 5999, "tcp"}, {"cvsup", {NULL}, 5999, "udp"}, {"ndl-ahp-svc", {NULL}, 6064, "tcp"}, {"ndl-ahp-svc", {NULL}, 6064, "udp"}, {"winpharaoh", {NULL}, 6065, "tcp"}, {"winpharaoh", {NULL}, 6065, "udp"}, {"ewctsp", {NULL}, 6066, "tcp"}, {"ewctsp", {NULL}, 6066, "udp"}, {"gsmp", {NULL}, 6068, "tcp"}, {"gsmp", {NULL}, 6068, "udp"}, {"trip", {NULL}, 6069, "tcp"}, {"trip", {NULL}, 6069, "udp"}, {"messageasap", {NULL}, 6070, "tcp"}, {"messageasap", {NULL}, 6070, "udp"}, {"ssdtp", {NULL}, 6071, "tcp"}, {"ssdtp", {NULL}, 6071, "udp"}, {"diagnose-proc", {NULL}, 6072, "tcp"}, {"diagnose-proc", {NULL}, 6072, "udp"}, {"directplay8", {NULL}, 6073, "tcp"}, {"directplay8", {NULL}, 6073, "udp"}, {"max", {NULL}, 6074, "tcp"}, {"max", {NULL}, 6074, "udp"}, {"dpm-acm", {NULL}, 6075, "tcp"}, {"miami-bcast", {NULL}, 6083, "udp"}, {"p2p-sip", {NULL}, 6084, "tcp"}, {"konspire2b", {NULL}, 6085, "tcp"}, {"konspire2b", {NULL}, 6085, "udp"}, {"pdtp", {NULL}, 6086, "tcp"}, {"pdtp", {NULL}, 6086, "udp"}, {"ldss", {NULL}, 6087, "tcp"}, {"ldss", {NULL}, 6087, "udp"}, {"raxa-mgmt", {NULL}, 6099, "tcp"}, {"synchronet-db", {NULL}, 6100, "tcp"}, {"synchronet-db", {NULL}, 6100, "udp"}, {"synchronet-rtc", {NULL}, 6101, "tcp"}, {"synchronet-rtc", {NULL}, 6101, "udp"}, {"synchronet-upd", {NULL}, 6102, "tcp"}, {"synchronet-upd", {NULL}, 6102, "udp"}, {"rets", {NULL}, 6103, "tcp"}, {"rets", {NULL}, 6103, "udp"}, {"dbdb", {NULL}, 6104, "tcp"}, {"dbdb", {NULL}, 6104, "udp"}, {"primaserver", {NULL}, 6105, "tcp"}, {"primaserver", {NULL}, 6105, "udp"}, {"mpsserver", {NULL}, 6106, "tcp"}, {"mpsserver", {NULL}, 6106, "udp"}, {"etc-control", {NULL}, 6107, "tcp"}, {"etc-control", {NULL}, 6107, "udp"}, {"sercomm-scadmin", {NULL}, 6108, "tcp"}, {"sercomm-scadmin", {NULL}, 6108, "udp"}, {"globecast-id", {NULL}, 6109, "tcp"}, {"globecast-id", {NULL}, 6109, "udp"}, {"softcm", {NULL}, 6110, "tcp"}, {"softcm", {NULL}, 6110, "udp"}, {"spc", {NULL}, 6111, "tcp"}, {"spc", {NULL}, 6111, "udp"}, {"dtspcd", {NULL}, 6112, "tcp"}, {"dtspcd", {NULL}, 6112, "udp"}, {"dayliteserver", {NULL}, 6113, "tcp"}, {"wrspice", {NULL}, 6114, "tcp"}, {"xic", {NULL}, 6115, "tcp"}, {"xtlserv", {NULL}, 6116, "tcp"}, {"daylitetouch", {NULL}, 6117, "tcp"}, {"spdy", {NULL}, 6121, "tcp"}, {"bex-webadmin", {NULL}, 6122, "tcp"}, {"bex-webadmin", {NULL}, 6122, "udp"}, {"backup-express", {NULL}, 6123, "tcp"}, {"backup-express", {NULL}, 6123, "udp"}, {"pnbs", {NULL}, 6124, "tcp"}, {"pnbs", {NULL}, 6124, "udp"}, {"nbt-wol", {NULL}, 6133, "tcp"}, {"nbt-wol", {NULL}, 6133, "udp"}, {"pulsonixnls", {NULL}, 6140, "tcp"}, {"pulsonixnls", {NULL}, 6140, "udp"}, {"meta-corp", {NULL}, 6141, "tcp"}, {"meta-corp", {NULL}, 6141, "udp"}, {"aspentec-lm", {NULL}, 6142, "tcp"}, {"aspentec-lm", {NULL}, 6142, "udp"}, {"watershed-lm", {NULL}, 6143, "tcp"}, {"watershed-lm", {NULL}, 6143, "udp"}, {"statsci1-lm", {NULL}, 6144, "tcp"}, {"statsci1-lm", {NULL}, 6144, "udp"}, {"statsci2-lm", {NULL}, 6145, "tcp"}, {"statsci2-lm", {NULL}, 6145, "udp"}, {"lonewolf-lm", {NULL}, 6146, "tcp"}, {"lonewolf-lm", {NULL}, 6146, "udp"}, {"montage-lm", {NULL}, 6147, "tcp"}, {"montage-lm", {NULL}, 6147, "udp"}, {"ricardo-lm", {NULL}, 6148, "tcp"}, {"ricardo-lm", {NULL}, 6148, "udp"}, {"tal-pod", {NULL}, 6149, "tcp"}, {"tal-pod", {NULL}, 6149, "udp"}, {"efb-aci", {NULL}, 6159, "tcp"}, {"patrol-ism", {NULL}, 6161, "tcp"}, {"patrol-ism", {NULL}, 6161, "udp"}, {"patrol-coll", {NULL}, 6162, "tcp"}, {"patrol-coll", {NULL}, 6162, "udp"}, {"pscribe", {NULL}, 6163, "tcp"}, {"pscribe", {NULL}, 6163, "udp"}, {"lm-x", {NULL}, 6200, "tcp"}, {"lm-x", {NULL}, 6200, "udp"}, {"radmind", {NULL}, 6222, "tcp"}, {"radmind", {NULL}, 6222, "udp"}, {"jeol-nsdtp-1", {NULL}, 6241, "tcp"}, {"jeol-nsddp-1", {NULL}, 6241, "udp"}, {"jeol-nsdtp-2", {NULL}, 6242, "tcp"}, {"jeol-nsddp-2", {NULL}, 6242, "udp"}, {"jeol-nsdtp-3", {NULL}, 6243, "tcp"}, {"jeol-nsddp-3", {NULL}, 6243, "udp"}, {"jeol-nsdtp-4", {NULL}, 6244, "tcp"}, {"jeol-nsddp-4", {NULL}, 6244, "udp"}, {"tl1-raw-ssl", {NULL}, 6251, "tcp"}, {"tl1-raw-ssl", {NULL}, 6251, "udp"}, {"tl1-ssh", {NULL}, 6252, "tcp"}, {"tl1-ssh", {NULL}, 6252, "udp"}, {"crip", {NULL}, 6253, "tcp"}, {"crip", {NULL}, 6253, "udp"}, {"gld", {NULL}, 6267, "tcp"}, {"grid", {NULL}, 6268, "tcp"}, {"grid", {NULL}, 6268, "udp"}, {"grid-alt", {NULL}, 6269, "tcp"}, {"grid-alt", {NULL}, 6269, "udp"}, {"bmc-grx", {NULL}, 6300, "tcp"}, {"bmc-grx", {NULL}, 6300, "udp"}, {"bmc_ctd_ldap", {NULL}, 6301, "tcp"}, {"bmc_ctd_ldap", {NULL}, 6301, "udp"}, {"ufmp", {NULL}, 6306, "tcp"}, {"ufmp", {NULL}, 6306, "udp"}, {"scup", {NULL}, 6315, "tcp"}, {"scup-disc", {NULL}, 6315, "udp"}, {"abb-escp", {NULL}, 6316, "tcp"}, {"abb-escp", {NULL}, 6316, "udp"}, {"repsvc", {NULL}, 6320, "tcp"}, {"repsvc", {NULL}, 6320, "udp"}, {"emp-server1", {NULL}, 6321, "tcp"}, {"emp-server1", {NULL}, 6321, "udp"}, {"emp-server2", {NULL}, 6322, "tcp"}, {"emp-server2", {NULL}, 6322, "udp"}, {"sflow", {NULL}, 6343, "tcp"}, {"sflow", {NULL}, 6343, "udp"}, {"gnutella-svc", {NULL}, 6346, "tcp"}, {"gnutella-svc", {NULL}, 6346, "udp"}, {"gnutella-rtr", {NULL}, 6347, "tcp"}, {"gnutella-rtr", {NULL}, 6347, "udp"}, {"adap", {NULL}, 6350, "tcp"}, {"adap", {NULL}, 6350, "udp"}, {"pmcs", {NULL}, 6355, "tcp"}, {"pmcs", {NULL}, 6355, "udp"}, {"metaedit-mu", {NULL}, 6360, "tcp"}, {"metaedit-mu", {NULL}, 6360, "udp"}, {"metaedit-se", {NULL}, 6370, "tcp"}, {"metaedit-se", {NULL}, 6370, "udp"}, {"metatude-mds", {NULL}, 6382, "tcp"}, {"metatude-mds", {NULL}, 6382, "udp"}, {"clariion-evr01", {NULL}, 6389, "tcp"}, {"clariion-evr01", {NULL}, 6389, "udp"}, {"metaedit-ws", {NULL}, 6390, "tcp"}, {"metaedit-ws", {NULL}, 6390, "udp"}, {"faxcomservice", {NULL}, 6417, "tcp"}, {"faxcomservice", {NULL}, 6417, "udp"}, {"syserverremote", {NULL}, 6418, "tcp"}, {"svdrp", {NULL}, 6419, "tcp"}, {"nim-vdrshell", {NULL}, 6420, "tcp"}, {"nim-vdrshell", {NULL}, 6420, "udp"}, {"nim-wan", {NULL}, 6421, "tcp"}, {"nim-wan", {NULL}, 6421, "udp"}, {"pgbouncer", {NULL}, 6432, "tcp"}, {"sun-sr-https", {NULL}, 6443, "tcp"}, {"sun-sr-https", {NULL}, 6443, "udp"}, {"sge_qmaster", {NULL}, 6444, "tcp"}, {"sge_qmaster", {NULL}, 6444, "udp"}, {"sge_execd", {NULL}, 6445, "tcp"}, {"sge_execd", {NULL}, 6445, "udp"}, {"mysql-proxy", {NULL}, 6446, "tcp"}, {"mysql-proxy", {NULL}, 6446, "udp"}, {"skip-cert-recv", {NULL}, 6455, "tcp"}, {"skip-cert-send", {NULL}, 6456, "udp"}, {"lvision-lm", {NULL}, 6471, "tcp"}, {"lvision-lm", {NULL}, 6471, "udp"}, {"sun-sr-http", {NULL}, 6480, "tcp"}, {"sun-sr-http", {NULL}, 6480, "udp"}, {"servicetags", {NULL}, 6481, "tcp"}, {"servicetags", {NULL}, 6481, "udp"}, {"ldoms-mgmt", {NULL}, 6482, "tcp"}, {"ldoms-mgmt", {NULL}, 6482, "udp"}, {"SunVTS-RMI", {NULL}, 6483, "tcp"}, {"SunVTS-RMI", {NULL}, 6483, "udp"}, {"sun-sr-jms", {NULL}, 6484, "tcp"}, {"sun-sr-jms", {NULL}, 6484, "udp"}, {"sun-sr-iiop", {NULL}, 6485, "tcp"}, {"sun-sr-iiop", {NULL}, 6485, "udp"}, {"sun-sr-iiops", {NULL}, 6486, "tcp"}, {"sun-sr-iiops", {NULL}, 6486, "udp"}, {"sun-sr-iiop-aut", {NULL}, 6487, "tcp"}, {"sun-sr-iiop-aut", {NULL}, 6487, "udp"}, {"sun-sr-jmx", {NULL}, 6488, "tcp"}, {"sun-sr-jmx", {NULL}, 6488, "udp"}, {"sun-sr-admin", {NULL}, 6489, "tcp"}, {"sun-sr-admin", {NULL}, 6489, "udp"}, {"boks", {NULL}, 6500, "tcp"}, {"boks", {NULL}, 6500, "udp"}, {"boks_servc", {NULL}, 6501, "tcp"}, {"boks_servc", {NULL}, 6501, "udp"}, {"boks_servm", {NULL}, 6502, "tcp"}, {"boks_servm", {NULL}, 6502, "udp"}, {"boks_clntd", {NULL}, 6503, "tcp"}, {"boks_clntd", {NULL}, 6503, "udp"}, {"badm_priv", {NULL}, 6505, "tcp"}, {"badm_priv", {NULL}, 6505, "udp"}, {"badm_pub", {NULL}, 6506, "tcp"}, {"badm_pub", {NULL}, 6506, "udp"}, {"bdir_priv", {NULL}, 6507, "tcp"}, {"bdir_priv", {NULL}, 6507, "udp"}, {"bdir_pub", {NULL}, 6508, "tcp"}, {"bdir_pub", {NULL}, 6508, "udp"}, {"mgcs-mfp-port", {NULL}, 6509, "tcp"}, {"mgcs-mfp-port", {NULL}, 6509, "udp"}, {"mcer-port", {NULL}, 6510, "tcp"}, {"mcer-port", {NULL}, 6510, "udp"}, {"netconf-tls", {NULL}, 6513, "tcp"}, {"syslog-tls", {NULL}, 6514, "tcp"}, {"syslog-tls", {NULL}, 6514, "udp"}, {"syslog-tls", {NULL}, 6514, "dccp"}, {"elipse-rec", {NULL}, 6515, "tcp"}, {"elipse-rec", {NULL}, 6515, "udp"}, {"lds-distrib", {NULL}, 6543, "tcp"}, {"lds-distrib", {NULL}, 6543, "udp"}, {"lds-dump", {NULL}, 6544, "tcp"}, {"lds-dump", {NULL}, 6544, "udp"}, {"apc-6547", {NULL}, 6547, "tcp"}, {"apc-6547", {NULL}, 6547, "udp"}, {"apc-6548", {NULL}, 6548, "tcp"}, {"apc-6548", {NULL}, 6548, "udp"}, {"apc-6549", {NULL}, 6549, "tcp"}, {"apc-6549", {NULL}, 6549, "udp"}, {"fg-sysupdate", {NULL}, 6550, "tcp"}, {"fg-sysupdate", {NULL}, 6550, "udp"}, {"sum", {NULL}, 6551, "tcp"}, {"sum", {NULL}, 6551, "udp"}, {"xdsxdm", {NULL}, 6558, "tcp"}, {"xdsxdm", {NULL}, 6558, "udp"}, {"sane-port", {NULL}, 6566, "tcp"}, {"sane-port", {NULL}, 6566, "udp"}, {"esp", {NULL}, 6567, "tcp"}, {"esp", {NULL}, 6567, "udp"}, {"canit_store", {NULL}, 6568, "tcp"}, {"rp-reputation", {NULL}, 6568, "udp"}, {"affiliate", {NULL}, 6579, "tcp"}, {"affiliate", {NULL}, 6579, "udp"}, {"parsec-master", {NULL}, 6580, "tcp"}, {"parsec-master", {NULL}, 6580, "udp"}, {"parsec-peer", {NULL}, 6581, "tcp"}, {"parsec-peer", {NULL}, 6581, "udp"}, {"parsec-game", {NULL}, 6582, "tcp"}, {"parsec-game", {NULL}, 6582, "udp"}, {"joaJewelSuite", {NULL}, 6583, "tcp"}, {"joaJewelSuite", {NULL}, 6583, "udp"}, {"mshvlm", {NULL}, 6600, "tcp"}, {"mstmg-sstp", {NULL}, 6601, "tcp"}, {"wsscomfrmwk", {NULL}, 6602, "tcp"}, {"odette-ftps", {NULL}, 6619, "tcp"}, {"odette-ftps", {NULL}, 6619, "udp"}, {"kftp-data", {NULL}, 6620, "tcp"}, {"kftp-data", {NULL}, 6620, "udp"}, {"kftp", {NULL}, 6621, "tcp"}, {"kftp", {NULL}, 6621, "udp"}, {"mcftp", {NULL}, 6622, "tcp"}, {"mcftp", {NULL}, 6622, "udp"}, {"ktelnet", {NULL}, 6623, "tcp"}, {"ktelnet", {NULL}, 6623, "udp"}, {"datascaler-db", {NULL}, 6624, "tcp"}, {"datascaler-ctl", {NULL}, 6625, "tcp"}, {"wago-service", {NULL}, 6626, "tcp"}, {"wago-service", {NULL}, 6626, "udp"}, {"nexgen", {NULL}, 6627, "tcp"}, {"nexgen", {NULL}, 6627, "udp"}, {"afesc-mc", {NULL}, 6628, "tcp"}, {"afesc-mc", {NULL}, 6628, "udp"}, {"mxodbc-connect", {NULL}, 6632, "tcp"}, {"pcs-sf-ui-man", {NULL}, 6655, "tcp"}, {"emgmsg", {NULL}, 6656, "tcp"}, {"palcom-disc", {NULL}, 6657, "udp"}, {"vocaltec-gold", {NULL}, 6670, "tcp"}, {"vocaltec-gold", {NULL}, 6670, "udp"}, {"p4p-portal", {NULL}, 6671, "tcp"}, {"p4p-portal", {NULL}, 6671, "udp"}, {"vision_server", {NULL}, 6672, "tcp"}, {"vision_server", {NULL}, 6672, "udp"}, {"vision_elmd", {NULL}, 6673, "tcp"}, {"vision_elmd", {NULL}, 6673, "udp"}, {"vfbp", {NULL}, 6678, "tcp"}, {"vfbp-disc", {NULL}, 6678, "udp"}, {"osaut", {NULL}, 6679, "tcp"}, {"osaut", {NULL}, 6679, "udp"}, {"clever-ctrace", {NULL}, 6687, "tcp"}, {"clever-tcpip", {NULL}, 6688, "tcp"}, {"tsa", {NULL}, 6689, "tcp"}, {"tsa", {NULL}, 6689, "udp"}, {"babel", {NULL}, 6697, "udp"}, {"kti-icad-srvr", {NULL}, 6701, "tcp"}, {"kti-icad-srvr", {NULL}, 6701, "udp"}, {"e-design-net", {NULL}, 6702, "tcp"}, {"e-design-net", {NULL}, 6702, "udp"}, {"e-design-web", {NULL}, 6703, "tcp"}, {"e-design-web", {NULL}, 6703, "udp"}, {"frc-hp", {NULL}, 6704, "sctp"}, {"frc-mp", {NULL}, 6705, "sctp"}, {"frc-lp", {NULL}, 6706, "sctp"}, {"ibprotocol", {NULL}, 6714, "tcp"}, {"ibprotocol", {NULL}, 6714, "udp"}, {"fibotrader-com", {NULL}, 6715, "tcp"}, {"fibotrader-com", {NULL}, 6715, "udp"}, {"bmc-perf-agent", {NULL}, 6767, "tcp"}, {"bmc-perf-agent", {NULL}, 6767, "udp"}, {"bmc-perf-mgrd", {NULL}, 6768, "tcp"}, {"bmc-perf-mgrd", {NULL}, 6768, "udp"}, {"adi-gxp-srvprt", {NULL}, 6769, "tcp"}, {"adi-gxp-srvprt", {NULL}, 6769, "udp"}, {"plysrv-http", {NULL}, 6770, "tcp"}, {"plysrv-http", {NULL}, 6770, "udp"}, {"plysrv-https", {NULL}, 6771, "tcp"}, {"plysrv-https", {NULL}, 6771, "udp"}, {"dgpf-exchg", {NULL}, 6785, "tcp"}, {"dgpf-exchg", {NULL}, 6785, "udp"}, {"smc-jmx", {NULL}, 6786, "tcp"}, {"smc-jmx", {NULL}, 6786, "udp"}, {"smc-admin", {NULL}, 6787, "tcp"}, {"smc-admin", {NULL}, 6787, "udp"}, {"smc-http", {NULL}, 6788, "tcp"}, {"smc-http", {NULL}, 6788, "udp"}, {"smc-https", {NULL}, 6789, "tcp"}, {"smc-https", {NULL}, 6789, "udp"}, {"hnmp", {NULL}, 6790, "tcp"}, {"hnmp", {NULL}, 6790, "udp"}, {"hnm", {NULL}, 6791, "tcp"}, {"hnm", {NULL}, 6791, "udp"}, {"acnet", {NULL}, 6801, "tcp"}, {"acnet", {NULL}, 6801, "udp"}, {"pentbox-sim", {NULL}, 6817, "tcp"}, {"ambit-lm", {NULL}, 6831, "tcp"}, {"ambit-lm", {NULL}, 6831, "udp"}, {"netmo-default", {NULL}, 6841, "tcp"}, {"netmo-default", {NULL}, 6841, "udp"}, {"netmo-http", {NULL}, 6842, "tcp"}, {"netmo-http", {NULL}, 6842, "udp"}, {"iccrushmore", {NULL}, 6850, "tcp"}, {"iccrushmore", {NULL}, 6850, "udp"}, {"acctopus-cc", {NULL}, 6868, "tcp"}, {"acctopus-st", {NULL}, 6868, "udp"}, {"muse", {NULL}, 6888, "tcp"}, {"muse", {NULL}, 6888, "udp"}, {"jetstream", {NULL}, 6901, "tcp"}, {"xsmsvc", {NULL}, 6936, "tcp"}, {"xsmsvc", {NULL}, 6936, "udp"}, {"bioserver", {NULL}, 6946, "tcp"}, {"bioserver", {NULL}, 6946, "udp"}, {"otlp", {NULL}, 6951, "tcp"}, {"otlp", {NULL}, 6951, "udp"}, {"jmact3", {NULL}, 6961, "tcp"}, {"jmact3", {NULL}, 6961, "udp"}, {"jmevt2", {NULL}, 6962, "tcp"}, {"jmevt2", {NULL}, 6962, "udp"}, {"swismgr1", {NULL}, 6963, "tcp"}, {"swismgr1", {NULL}, 6963, "udp"}, {"swismgr2", {NULL}, 6964, "tcp"}, {"swismgr2", {NULL}, 6964, "udp"}, {"swistrap", {NULL}, 6965, "tcp"}, {"swistrap", {NULL}, 6965, "udp"}, {"swispol", {NULL}, 6966, "tcp"}, {"swispol", {NULL}, 6966, "udp"}, {"acmsoda", {NULL}, 6969, "tcp"}, {"acmsoda", {NULL}, 6969, "udp"}, {"MobilitySrv", {NULL}, 6997, "tcp"}, {"MobilitySrv", {NULL}, 6997, "udp"}, {"iatp-highpri", {NULL}, 6998, "tcp"}, {"iatp-highpri", {NULL}, 6998, "udp"}, {"iatp-normalpri", {NULL}, 6999, "tcp"}, {"iatp-normalpri", {NULL}, 6999, "udp"}, {"afs3-fileserver", {NULL}, 7000, "tcp"}, {"afs3-fileserver", {NULL}, 7000, "udp"}, {"afs3-callback", {NULL}, 7001, "tcp"}, {"afs3-callback", {NULL}, 7001, "udp"}, {"afs3-prserver", {NULL}, 7002, "tcp"}, {"afs3-prserver", {NULL}, 7002, "udp"}, {"afs3-vlserver", {NULL}, 7003, "tcp"}, {"afs3-vlserver", {NULL}, 7003, "udp"}, {"afs3-kaserver", {NULL}, 7004, "tcp"}, {"afs3-kaserver", {NULL}, 7004, "udp"}, {"afs3-volser", {NULL}, 7005, "tcp"}, {"afs3-volser", {NULL}, 7005, "udp"}, {"afs3-errors", {NULL}, 7006, "tcp"}, {"afs3-errors", {NULL}, 7006, "udp"}, {"afs3-bos", {NULL}, 7007, "tcp"}, {"afs3-bos", {NULL}, 7007, "udp"}, {"afs3-update", {NULL}, 7008, "tcp"}, {"afs3-update", {NULL}, 7008, "udp"}, {"afs3-rmtsys", {NULL}, 7009, "tcp"}, {"afs3-rmtsys", {NULL}, 7009, "udp"}, {"ups-onlinet", {NULL}, 7010, "tcp"}, {"ups-onlinet", {NULL}, 7010, "udp"}, {"talon-disc", {NULL}, 7011, "tcp"}, {"talon-disc", {NULL}, 7011, "udp"}, {"talon-engine", {NULL}, 7012, "tcp"}, {"talon-engine", {NULL}, 7012, "udp"}, {"microtalon-dis", {NULL}, 7013, "tcp"}, {"microtalon-dis", {NULL}, 7013, "udp"}, {"microtalon-com", {NULL}, 7014, "tcp"}, {"microtalon-com", {NULL}, 7014, "udp"}, {"talon-webserver", {NULL}, 7015, "tcp"}, {"talon-webserver", {NULL}, 7015, "udp"}, {"dpserve", {NULL}, 7020, "tcp"}, {"dpserve", {NULL}, 7020, "udp"}, {"dpserveadmin", {NULL}, 7021, "tcp"}, {"dpserveadmin", {NULL}, 7021, "udp"}, {"ctdp", {NULL}, 7022, "tcp"}, {"ctdp", {NULL}, 7022, "udp"}, {"ct2nmcs", {NULL}, 7023, "tcp"}, {"ct2nmcs", {NULL}, 7023, "udp"}, {"vmsvc", {NULL}, 7024, "tcp"}, {"vmsvc", {NULL}, 7024, "udp"}, {"vmsvc-2", {NULL}, 7025, "tcp"}, {"vmsvc-2", {NULL}, 7025, "udp"}, {"op-probe", {NULL}, 7030, "tcp"}, {"op-probe", {NULL}, 7030, "udp"}, {"arcp", {NULL}, 7070, "tcp"}, {"arcp", {NULL}, 7070, "udp"}, {"iwg1", {NULL}, 7071, "tcp"}, {"iwg1", {NULL}, 7071, "udp"}, {"empowerid", {NULL}, 7080, "tcp"}, {"empowerid", {NULL}, 7080, "udp"}, {"lazy-ptop", {NULL}, 7099, "tcp"}, {"lazy-ptop", {NULL}, 7099, "udp"}, {"font-service", {NULL}, 7100, "tcp"}, {"font-service", {NULL}, 7100, "udp"}, {"elcn", {NULL}, 7101, "tcp"}, {"elcn", {NULL}, 7101, "udp"}, {"aes-x170", {NULL}, 7107, "udp"}, {"virprot-lm", {NULL}, 7121, "tcp"}, {"virprot-lm", {NULL}, 7121, "udp"}, {"scenidm", {NULL}, 7128, "tcp"}, {"scenidm", {NULL}, 7128, "udp"}, {"scenccs", {NULL}, 7129, "tcp"}, {"scenccs", {NULL}, 7129, "udp"}, {"cabsm-comm", {NULL}, 7161, "tcp"}, {"cabsm-comm", {NULL}, 7161, "udp"}, {"caistoragemgr", {NULL}, 7162, "tcp"}, {"caistoragemgr", {NULL}, 7162, "udp"}, {"cacsambroker", {NULL}, 7163, "tcp"}, {"cacsambroker", {NULL}, 7163, "udp"}, {"fsr", {NULL}, 7164, "tcp"}, {"fsr", {NULL}, 7164, "udp"}, {"doc-server", {NULL}, 7165, "tcp"}, {"doc-server", {NULL}, 7165, "udp"}, {"aruba-server", {NULL}, 7166, "tcp"}, {"aruba-server", {NULL}, 7166, "udp"}, {"casrmagent", {NULL}, 7167, "tcp"}, {"cnckadserver", {NULL}, 7168, "tcp"}, {"ccag-pib", {NULL}, 7169, "tcp"}, {"ccag-pib", {NULL}, 7169, "udp"}, {"nsrp", {NULL}, 7170, "tcp"}, {"nsrp", {NULL}, 7170, "udp"}, {"drm-production", {NULL}, 7171, "tcp"}, {"drm-production", {NULL}, 7171, "udp"}, {"zsecure", {NULL}, 7173, "tcp"}, {"clutild", {NULL}, 7174, "tcp"}, {"clutild", {NULL}, 7174, "udp"}, {"fodms", {NULL}, 7200, "tcp"}, {"fodms", {NULL}, 7200, "udp"}, {"dlip", {NULL}, 7201, "tcp"}, {"dlip", {NULL}, 7201, "udp"}, {"ramp", {NULL}, 7227, "tcp"}, {"ramp", {NULL}, 7227, "udp"}, {"citrixupp", {NULL}, 7228, "tcp"}, {"citrixuppg", {NULL}, 7229, "tcp"}, {"pads", {NULL}, 7237, "tcp"}, {"cnap", {NULL}, 7262, "tcp"}, {"cnap", {NULL}, 7262, "udp"}, {"watchme-7272", {NULL}, 7272, "tcp"}, {"watchme-7272", {NULL}, 7272, "udp"}, {"oma-rlp", {NULL}, 7273, "tcp"}, {"oma-rlp", {NULL}, 7273, "udp"}, {"oma-rlp-s", {NULL}, 7274, "tcp"}, {"oma-rlp-s", {NULL}, 7274, "udp"}, {"oma-ulp", {NULL}, 7275, "tcp"}, {"oma-ulp", {NULL}, 7275, "udp"}, {"oma-ilp", {NULL}, 7276, "tcp"}, {"oma-ilp", {NULL}, 7276, "udp"}, {"oma-ilp-s", {NULL}, 7277, "tcp"}, {"oma-ilp-s", {NULL}, 7277, "udp"}, {"oma-dcdocbs", {NULL}, 7278, "tcp"}, {"oma-dcdocbs", {NULL}, 7278, "udp"}, {"ctxlic", {NULL}, 7279, "tcp"}, {"ctxlic", {NULL}, 7279, "udp"}, {"itactionserver1", {NULL}, 7280, "tcp"}, {"itactionserver1", {NULL}, 7280, "udp"}, {"itactionserver2", {NULL}, 7281, "tcp"}, {"itactionserver2", {NULL}, 7281, "udp"}, {"mzca-action", {NULL}, 7282, "tcp"}, {"mzca-alert", {NULL}, 7282, "udp"}, {"lcm-server", {NULL}, 7365, "tcp"}, {"lcm-server", {NULL}, 7365, "udp"}, {"mindfilesys", {NULL}, 7391, "tcp"}, {"mindfilesys", {NULL}, 7391, "udp"}, {"mrssrendezvous", {NULL}, 7392, "tcp"}, {"mrssrendezvous", {NULL}, 7392, "udp"}, {"nfoldman", {NULL}, 7393, "tcp"}, {"nfoldman", {NULL}, 7393, "udp"}, {"fse", {NULL}, 7394, "tcp"}, {"fse", {NULL}, 7394, "udp"}, {"winqedit", {NULL}, 7395, "tcp"}, {"winqedit", {NULL}, 7395, "udp"}, {"hexarc", {NULL}, 7397, "tcp"}, {"hexarc", {NULL}, 7397, "udp"}, {"rtps-discovery", {NULL}, 7400, "tcp"}, {"rtps-discovery", {NULL}, 7400, "udp"}, {"rtps-dd-ut", {NULL}, 7401, "tcp"}, {"rtps-dd-ut", {NULL}, 7401, "udp"}, {"rtps-dd-mt", {NULL}, 7402, "tcp"}, {"rtps-dd-mt", {NULL}, 7402, "udp"}, {"ionixnetmon", {NULL}, 7410, "tcp"}, {"ionixnetmon", {NULL}, 7410, "udp"}, {"mtportmon", {NULL}, 7421, "tcp"}, {"mtportmon", {NULL}, 7421, "udp"}, {"pmdmgr", {NULL}, 7426, "tcp"}, {"pmdmgr", {NULL}, 7426, "udp"}, {"oveadmgr", {NULL}, 7427, "tcp"}, {"oveadmgr", {NULL}, 7427, "udp"}, {"ovladmgr", {NULL}, 7428, "tcp"}, {"ovladmgr", {NULL}, 7428, "udp"}, {"opi-sock", {NULL}, 7429, "tcp"}, {"opi-sock", {NULL}, 7429, "udp"}, {"xmpv7", {NULL}, 7430, "tcp"}, {"xmpv7", {NULL}, 7430, "udp"}, {"pmd", {NULL}, 7431, "tcp"}, {"pmd", {NULL}, 7431, "udp"}, {"faximum", {NULL}, 7437, "tcp"}, {"faximum", {NULL}, 7437, "udp"}, {"oracleas-https", {NULL}, 7443, "tcp"}, {"oracleas-https", {NULL}, 7443, "udp"}, {"rise", {NULL}, 7473, "tcp"}, {"rise", {NULL}, 7473, "udp"}, {"telops-lmd", {NULL}, 7491, "tcp"}, {"telops-lmd", {NULL}, 7491, "udp"}, {"silhouette", {NULL}, 7500, "tcp"}, {"silhouette", {NULL}, 7500, "udp"}, {"ovbus", {NULL}, 7501, "tcp"}, {"ovbus", {NULL}, 7501, "udp"}, {"acplt", {NULL}, 7509, "tcp"}, {"ovhpas", {NULL}, 7510, "tcp"}, {"ovhpas", {NULL}, 7510, "udp"}, {"pafec-lm", {NULL}, 7511, "tcp"}, {"pafec-lm", {NULL}, 7511, "udp"}, {"saratoga", {NULL}, 7542, "tcp"}, {"saratoga", {NULL}, 7542, "udp"}, {"atul", {NULL}, 7543, "tcp"}, {"atul", {NULL}, 7543, "udp"}, {"nta-ds", {NULL}, 7544, "tcp"}, {"nta-ds", {NULL}, 7544, "udp"}, {"nta-us", {NULL}, 7545, "tcp"}, {"nta-us", {NULL}, 7545, "udp"}, {"cfs", {NULL}, 7546, "tcp"}, {"cfs", {NULL}, 7546, "udp"}, {"cwmp", {NULL}, 7547, "tcp"}, {"cwmp", {NULL}, 7547, "udp"}, {"tidp", {NULL}, 7548, "tcp"}, {"tidp", {NULL}, 7548, "udp"}, {"nls-tl", {NULL}, 7549, "tcp"}, {"nls-tl", {NULL}, 7549, "udp"}, {"sncp", {NULL}, 7560, "tcp"}, {"sncp", {NULL}, 7560, "udp"}, {"cfw", {NULL}, 7563, "tcp"}, {"vsi-omega", {NULL}, 7566, "tcp"}, {"vsi-omega", {NULL}, 7566, "udp"}, {"dell-eql-asm", {NULL}, 7569, "tcp"}, {"aries-kfinder", {NULL}, 7570, "tcp"}, {"aries-kfinder", {NULL}, 7570, "udp"}, {"sun-lm", {NULL}, 7588, "tcp"}, {"sun-lm", {NULL}, 7588, "udp"}, {"indi", {NULL}, 7624, "tcp"}, {"indi", {NULL}, 7624, "udp"}, {"simco", {NULL}, 7626, "tcp"}, {"simco", {NULL}, 7626, "sctp"}, {"soap-http", {NULL}, 7627, "tcp"}, {"soap-http", {NULL}, 7627, "udp"}, {"zen-pawn", {NULL}, 7628, "tcp"}, {"zen-pawn", {NULL}, 7628, "udp"}, {"xdas", {NULL}, 7629, "tcp"}, {"xdas", {NULL}, 7629, "udp"}, {"hawk", {NULL}, 7630, "tcp"}, {"tesla-sys-msg", {NULL}, 7631, "tcp"}, {"pmdfmgt", {NULL}, 7633, "tcp"}, {"pmdfmgt", {NULL}, 7633, "udp"}, {"cuseeme", {NULL}, 7648, "tcp"}, {"cuseeme", {NULL}, 7648, "udp"}, {"imqstomp", {NULL}, 7672, "tcp"}, {"imqstomps", {NULL}, 7673, "tcp"}, {"imqtunnels", {NULL}, 7674, "tcp"}, {"imqtunnels", {NULL}, 7674, "udp"}, {"imqtunnel", {NULL}, 7675, "tcp"}, {"imqtunnel", {NULL}, 7675, "udp"}, {"imqbrokerd", {NULL}, 7676, "tcp"}, {"imqbrokerd", {NULL}, 7676, "udp"}, {"sun-user-https", {NULL}, 7677, "tcp"}, {"sun-user-https", {NULL}, 7677, "udp"}, {"pando-pub", {NULL}, 7680, "tcp"}, {"pando-pub", {NULL}, 7680, "udp"}, {"collaber", {NULL}, 7689, "tcp"}, {"collaber", {NULL}, 7689, "udp"}, {"klio", {NULL}, 7697, "tcp"}, {"klio", {NULL}, 7697, "udp"}, {"em7-secom", {NULL}, 7700, "tcp"}, {"sync-em7", {NULL}, 7707, "tcp"}, {"sync-em7", {NULL}, 7707, "udp"}, {"scinet", {NULL}, 7708, "tcp"}, {"scinet", {NULL}, 7708, "udp"}, {"medimageportal", {NULL}, 7720, "tcp"}, {"medimageportal", {NULL}, 7720, "udp"}, {"nsdeepfreezectl", {NULL}, 7724, "tcp"}, {"nsdeepfreezectl", {NULL}, 7724, "udp"}, {"nitrogen", {NULL}, 7725, "tcp"}, {"nitrogen", {NULL}, 7725, "udp"}, {"freezexservice", {NULL}, 7726, "tcp"}, {"freezexservice", {NULL}, 7726, "udp"}, {"trident-data", {NULL}, 7727, "tcp"}, {"trident-data", {NULL}, 7727, "udp"}, {"smip", {NULL}, 7734, "tcp"}, {"smip", {NULL}, 7734, "udp"}, {"aiagent", {NULL}, 7738, "tcp"}, {"aiagent", {NULL}, 7738, "udp"}, {"scriptview", {NULL}, 7741, "tcp"}, {"scriptview", {NULL}, 7741, "udp"}, {"msss", {NULL}, 7742, "tcp"}, {"sstp-1", {NULL}, 7743, "tcp"}, {"sstp-1", {NULL}, 7743, "udp"}, {"raqmon-pdu", {NULL}, 7744, "tcp"}, {"raqmon-pdu", {NULL}, 7744, "udp"}, {"prgp", {NULL}, 7747, "tcp"}, {"prgp", {NULL}, 7747, "udp"}, {"cbt", {NULL}, 7777, "tcp"}, {"cbt", {NULL}, 7777, "udp"}, {"interwise", {NULL}, 7778, "tcp"}, {"interwise", {NULL}, 7778, "udp"}, {"vstat", {NULL}, 7779, "tcp"}, {"vstat", {NULL}, 7779, "udp"}, {"accu-lmgr", {NULL}, 7781, "tcp"}, {"accu-lmgr", {NULL}, 7781, "udp"}, {"minivend", {NULL}, 7786, "tcp"}, {"minivend", {NULL}, 7786, "udp"}, {"popup-reminders", {NULL}, 7787, "tcp"}, {"popup-reminders", {NULL}, 7787, "udp"}, {"office-tools", {NULL}, 7789, "tcp"}, {"office-tools", {NULL}, 7789, "udp"}, {"q3ade", {NULL}, 7794, "tcp"}, {"q3ade", {NULL}, 7794, "udp"}, {"pnet-conn", {NULL}, 7797, "tcp"}, {"pnet-conn", {NULL}, 7797, "udp"}, {"pnet-enc", {NULL}, 7798, "tcp"}, {"pnet-enc", {NULL}, 7798, "udp"}, {"altbsdp", {NULL}, 7799, "tcp"}, {"altbsdp", {NULL}, 7799, "udp"}, {"asr", {NULL}, 7800, "tcp"}, {"asr", {NULL}, 7800, "udp"}, {"ssp-client", {NULL}, 7801, "tcp"}, {"ssp-client", {NULL}, 7801, "udp"}, {"rbt-wanopt", {NULL}, 7810, "tcp"}, {"rbt-wanopt", {NULL}, 7810, "udp"}, {"apc-7845", {NULL}, 7845, "tcp"}, {"apc-7845", {NULL}, 7845, "udp"}, {"apc-7846", {NULL}, 7846, "tcp"}, {"apc-7846", {NULL}, 7846, "udp"}, {"mobileanalyzer", {NULL}, 7869, "tcp"}, {"rbt-smc", {NULL}, 7870, "tcp"}, {"pss", {NULL}, 7880, "tcp"}, {"pss", {NULL}, 7880, "udp"}, {"ubroker", {NULL}, 7887, "tcp"}, {"ubroker", {NULL}, 7887, "udp"}, {"mevent", {NULL}, 7900, "tcp"}, {"mevent", {NULL}, 7900, "udp"}, {"tnos-sp", {NULL}, 7901, "tcp"}, {"tnos-sp", {NULL}, 7901, "udp"}, {"tnos-dp", {NULL}, 7902, "tcp"}, {"tnos-dp", {NULL}, 7902, "udp"}, {"tnos-dps", {NULL}, 7903, "tcp"}, {"tnos-dps", {NULL}, 7903, "udp"}, {"qo-secure", {NULL}, 7913, "tcp"}, {"qo-secure", {NULL}, 7913, "udp"}, {"t2-drm", {NULL}, 7932, "tcp"}, {"t2-drm", {NULL}, 7932, "udp"}, {"t2-brm", {NULL}, 7933, "tcp"}, {"t2-brm", {NULL}, 7933, "udp"}, {"supercell", {NULL}, 7967, "tcp"}, {"supercell", {NULL}, 7967, "udp"}, {"micromuse-ncps", {NULL}, 7979, "tcp"}, {"micromuse-ncps", {NULL}, 7979, "udp"}, {"quest-vista", {NULL}, 7980, "tcp"}, {"quest-vista", {NULL}, 7980, "udp"}, {"sossd-collect", {NULL}, 7981, "tcp"}, {"sossd-agent", {NULL}, 7982, "tcp"}, {"sossd-disc", {NULL}, 7982, "udp"}, {"pushns", {NULL}, 7997, "tcp"}, {"usicontentpush", {NULL}, 7998, "udp"}, {"irdmi2", {NULL}, 7999, "tcp"}, {"irdmi2", {NULL}, 7999, "udp"}, {"irdmi", {NULL}, 8000, "tcp"}, {"irdmi", {NULL}, 8000, "udp"}, {"vcom-tunnel", {NULL}, 8001, "tcp"}, {"vcom-tunnel", {NULL}, 8001, "udp"}, {"teradataordbms", {NULL}, 8002, "tcp"}, {"teradataordbms", {NULL}, 8002, "udp"}, {"mcreport", {NULL}, 8003, "tcp"}, {"mcreport", {NULL}, 8003, "udp"}, {"mxi", {NULL}, 8005, "tcp"}, {"mxi", {NULL}, 8005, "udp"}, {"http-alt", {NULL}, 8008, "tcp"}, {"http-alt", {NULL}, 8008, "udp"}, {"qbdb", {NULL}, 8019, "tcp"}, {"qbdb", {NULL}, 8019, "udp"}, {"intu-ec-svcdisc", {NULL}, 8020, "tcp"}, {"intu-ec-svcdisc", {NULL}, 8020, "udp"}, {"intu-ec-client", {NULL}, 8021, "tcp"}, {"intu-ec-client", {NULL}, 8021, "udp"}, {"oa-system", {NULL}, 8022, "tcp"}, {"oa-system", {NULL}, 8022, "udp"}, {"ca-audit-da", {NULL}, 8025, "tcp"}, {"ca-audit-da", {NULL}, 8025, "udp"}, {"ca-audit-ds", {NULL}, 8026, "tcp"}, {"ca-audit-ds", {NULL}, 8026, "udp"}, {"pro-ed", {NULL}, 8032, "tcp"}, {"pro-ed", {NULL}, 8032, "udp"}, {"mindprint", {NULL}, 8033, "tcp"}, {"mindprint", {NULL}, 8033, "udp"}, {"vantronix-mgmt", {NULL}, 8034, "tcp"}, {"vantronix-mgmt", {NULL}, 8034, "udp"}, {"ampify", {NULL}, 8040, "tcp"}, {"ampify", {NULL}, 8040, "udp"}, {"fs-agent", {NULL}, 8042, "tcp"}, {"fs-server", {NULL}, 8043, "tcp"}, {"fs-mgmt", {NULL}, 8044, "tcp"}, {"senomix01", {NULL}, 8052, "tcp"}, {"senomix01", {NULL}, 8052, "udp"}, {"senomix02", {NULL}, 8053, "tcp"}, {"senomix02", {NULL}, 8053, "udp"}, {"senomix03", {NULL}, 8054, "tcp"}, {"senomix03", {NULL}, 8054, "udp"}, {"senomix04", {NULL}, 8055, "tcp"}, {"senomix04", {NULL}, 8055, "udp"}, {"senomix05", {NULL}, 8056, "tcp"}, {"senomix05", {NULL}, 8056, "udp"}, {"senomix06", {NULL}, 8057, "tcp"}, {"senomix06", {NULL}, 8057, "udp"}, {"senomix07", {NULL}, 8058, "tcp"}, {"senomix07", {NULL}, 8058, "udp"}, {"senomix08", {NULL}, 8059, "tcp"}, {"senomix08", {NULL}, 8059, "udp"}, {"gadugadu", {NULL}, 8074, "tcp"}, {"gadugadu", {NULL}, 8074, "udp"}, {"http-alt", {NULL}, 8080, "tcp"}, {"http-alt", {NULL}, 8080, "udp"}, {"sunproxyadmin", {NULL}, 8081, "tcp"}, {"sunproxyadmin", {NULL}, 8081, "udp"}, {"us-cli", {NULL}, 8082, "tcp"}, {"us-cli", {NULL}, 8082, "udp"}, {"us-srv", {NULL}, 8083, "tcp"}, {"us-srv", {NULL}, 8083, "udp"}, {"d-s-n", {NULL}, 8086, "tcp"}, {"d-s-n", {NULL}, 8086, "udp"}, {"simplifymedia", {NULL}, 8087, "tcp"}, {"simplifymedia", {NULL}, 8087, "udp"}, {"radan-http", {NULL}, 8088, "tcp"}, {"radan-http", {NULL}, 8088, "udp"}, {"jamlink", {NULL}, 8091, "tcp"}, {"sac", {NULL}, 8097, "tcp"}, {"sac", {NULL}, 8097, "udp"}, {"xprint-server", {NULL}, 8100, "tcp"}, {"xprint-server", {NULL}, 8100, "udp"}, {"ldoms-migr", {NULL}, 8101, "tcp"}, {"mtl8000-matrix", {NULL}, 8115, "tcp"}, {"mtl8000-matrix", {NULL}, 8115, "udp"}, {"cp-cluster", {NULL}, 8116, "tcp"}, {"cp-cluster", {NULL}, 8116, "udp"}, {"privoxy", {NULL}, 8118, "tcp"}, {"privoxy", {NULL}, 8118, "udp"}, {"apollo-data", {NULL}, 8121, "tcp"}, {"apollo-data", {NULL}, 8121, "udp"}, {"apollo-admin", {NULL}, 8122, "tcp"}, {"apollo-admin", {NULL}, 8122, "udp"}, {"paycash-online", {NULL}, 8128, "tcp"}, {"paycash-online", {NULL}, 8128, "udp"}, {"paycash-wbp", {NULL}, 8129, "tcp"}, {"paycash-wbp", {NULL}, 8129, "udp"}, {"indigo-vrmi", {NULL}, 8130, "tcp"}, {"indigo-vrmi", {NULL}, 8130, "udp"}, {"indigo-vbcp", {NULL}, 8131, "tcp"}, {"indigo-vbcp", {NULL}, 8131, "udp"}, {"dbabble", {NULL}, 8132, "tcp"}, {"dbabble", {NULL}, 8132, "udp"}, {"isdd", {NULL}, 8148, "tcp"}, {"isdd", {NULL}, 8148, "udp"}, {"patrol", {NULL}, 8160, "tcp"}, {"patrol", {NULL}, 8160, "udp"}, {"patrol-snmp", {NULL}, 8161, "tcp"}, {"patrol-snmp", {NULL}, 8161, "udp"}, {"vmware-fdm", {NULL}, 8182, "tcp"}, {"vmware-fdm", {NULL}, 8182, "udp"}, {"proremote", {NULL}, 8183, "tcp"}, {"itach", {NULL}, 8184, "tcp"}, {"itach", {NULL}, 8184, "udp"}, {"spytechphone", {NULL}, 8192, "tcp"}, {"spytechphone", {NULL}, 8192, "udp"}, {"blp1", {NULL}, 8194, "tcp"}, {"blp1", {NULL}, 8194, "udp"}, {"blp2", {NULL}, 8195, "tcp"}, {"blp2", {NULL}, 8195, "udp"}, {"vvr-data", {NULL}, 8199, "tcp"}, {"vvr-data", {NULL}, 8199, "udp"}, {"trivnet1", {NULL}, 8200, "tcp"}, {"trivnet1", {NULL}, 8200, "udp"}, {"trivnet2", {NULL}, 8201, "tcp"}, {"trivnet2", {NULL}, 8201, "udp"}, {"lm-perfworks", {NULL}, 8204, "tcp"}, {"lm-perfworks", {NULL}, 8204, "udp"}, {"lm-instmgr", {NULL}, 8205, "tcp"}, {"lm-instmgr", {NULL}, 8205, "udp"}, {"lm-dta", {NULL}, 8206, "tcp"}, {"lm-dta", {NULL}, 8206, "udp"}, {"lm-sserver", {NULL}, 8207, "tcp"}, {"lm-sserver", {NULL}, 8207, "udp"}, {"lm-webwatcher", {NULL}, 8208, "tcp"}, {"lm-webwatcher", {NULL}, 8208, "udp"}, {"rexecj", {NULL}, 8230, "tcp"}, {"rexecj", {NULL}, 8230, "udp"}, {"synapse-nhttps", {NULL}, 8243, "tcp"}, {"synapse-nhttps", {NULL}, 8243, "udp"}, {"pando-sec", {NULL}, 8276, "tcp"}, {"pando-sec", {NULL}, 8276, "udp"}, {"synapse-nhttp", {NULL}, 8280, "tcp"}, {"synapse-nhttp", {NULL}, 8280, "udp"}, {"blp3", {NULL}, 8292, "tcp"}, {"blp3", {NULL}, 8292, "udp"}, {"hiperscan-id", {NULL}, 8293, "tcp"}, {"blp4", {NULL}, 8294, "tcp"}, {"blp4", {NULL}, 8294, "udp"}, {"tmi", {NULL}, 8300, "tcp"}, {"tmi", {NULL}, 8300, "udp"}, {"amberon", {NULL}, 8301, "tcp"}, {"amberon", {NULL}, 8301, "udp"}, {"tnp-discover", {NULL}, 8320, "tcp"}, {"tnp-discover", {NULL}, 8320, "udp"}, {"tnp", {NULL}, 8321, "tcp"}, {"tnp", {NULL}, 8321, "udp"}, {"server-find", {NULL}, 8351, "tcp"}, {"server-find", {NULL}, 8351, "udp"}, {"cruise-enum", {NULL}, 8376, "tcp"}, {"cruise-enum", {NULL}, 8376, "udp"}, {"cruise-swroute", {NULL}, 8377, "tcp"}, {"cruise-swroute", {NULL}, 8377, "udp"}, {"cruise-config", {NULL}, 8378, "tcp"}, {"cruise-config", {NULL}, 8378, "udp"}, {"cruise-diags", {NULL}, 8379, "tcp"}, {"cruise-diags", {NULL}, 8379, "udp"}, {"cruise-update", {NULL}, 8380, "tcp"}, {"cruise-update", {NULL}, 8380, "udp"}, {"m2mservices", {NULL}, 8383, "tcp"}, {"m2mservices", {NULL}, 8383, "udp"}, {"cvd", {NULL}, 8400, "tcp"}, {"cvd", {NULL}, 8400, "udp"}, {"sabarsd", {NULL}, 8401, "tcp"}, {"sabarsd", {NULL}, 8401, "udp"}, {"abarsd", {NULL}, 8402, "tcp"}, {"abarsd", {NULL}, 8402, "udp"}, {"admind", {NULL}, 8403, "tcp"}, {"admind", {NULL}, 8403, "udp"}, {"svcloud", {NULL}, 8404, "tcp"}, {"svbackup", {NULL}, 8405, "tcp"}, {"espeech", {NULL}, 8416, "tcp"}, {"espeech", {NULL}, 8416, "udp"}, {"espeech-rtp", {NULL}, 8417, "tcp"}, {"espeech-rtp", {NULL}, 8417, "udp"}, {"cybro-a-bus", {NULL}, 8442, "tcp"}, {"cybro-a-bus", {NULL}, 8442, "udp"}, {"pcsync-https", {NULL}, 8443, "tcp"}, {"pcsync-https", {NULL}, 8443, "udp"}, {"pcsync-http", {NULL}, 8444, "tcp"}, {"pcsync-http", {NULL}, 8444, "udp"}, {"npmp", {NULL}, 8450, "tcp"}, {"npmp", {NULL}, 8450, "udp"}, {"cisco-avp", {NULL}, 8470, "tcp"}, {"pim-port", {NULL}, 8471, "tcp"}, {"pim-port", {NULL}, 8471, "sctp"}, {"otv", {NULL}, 8472, "tcp"}, {"otv", {NULL}, 8472, "udp"}, {"vp2p", {NULL}, 8473, "tcp"}, {"vp2p", {NULL}, 8473, "udp"}, {"noteshare", {NULL}, 8474, "tcp"}, {"noteshare", {NULL}, 8474, "udp"}, {"fmtp", {NULL}, 8500, "tcp"}, {"fmtp", {NULL}, 8500, "udp"}, {"rtsp-alt", {NULL}, 8554, "tcp"}, {"rtsp-alt", {NULL}, 8554, "udp"}, {"d-fence", {NULL}, 8555, "tcp"}, {"d-fence", {NULL}, 8555, "udp"}, {"oap-admin", {NULL}, 8567, "tcp"}, {"oap-admin", {NULL}, 8567, "udp"}, {"asterix", {NULL}, 8600, "tcp"}, {"asterix", {NULL}, 8600, "udp"}, {"canon-mfnp", {NULL}, 8610, "tcp"}, {"canon-mfnp", {NULL}, 8610, "udp"}, {"canon-bjnp1", {NULL}, 8611, "tcp"}, {"canon-bjnp1", {NULL}, 8611, "udp"}, {"canon-bjnp2", {NULL}, 8612, "tcp"}, {"canon-bjnp2", {NULL}, 8612, "udp"}, {"canon-bjnp3", {NULL}, 8613, "tcp"}, {"canon-bjnp3", {NULL}, 8613, "udp"}, {"canon-bjnp4", {NULL}, 8614, "tcp"}, {"canon-bjnp4", {NULL}, 8614, "udp"}, {"sun-as-jmxrmi", {NULL}, 8686, "tcp"}, {"sun-as-jmxrmi", {NULL}, 8686, "udp"}, {"vnyx", {NULL}, 8699, "tcp"}, {"vnyx", {NULL}, 8699, "udp"}, {"dtp-net", {NULL}, 8732, "udp"}, {"ibus", {NULL}, 8733, "tcp"}, {"ibus", {NULL}, 8733, "udp"}, {"mc-appserver", {NULL}, 8763, "tcp"}, {"mc-appserver", {NULL}, 8763, "udp"}, {"openqueue", {NULL}, 8764, "tcp"}, {"openqueue", {NULL}, 8764, "udp"}, {"ultraseek-http", {NULL}, 8765, "tcp"}, {"ultraseek-http", {NULL}, 8765, "udp"}, {"dpap", {NULL}, 8770, "tcp"}, {"dpap", {NULL}, 8770, "udp"}, {"msgclnt", {NULL}, 8786, "tcp"}, {"msgclnt", {NULL}, 8786, "udp"}, {"msgsrvr", {NULL}, 8787, "tcp"}, {"msgsrvr", {NULL}, 8787, "udp"}, {"sunwebadmin", {NULL}, 8800, "tcp"}, {"sunwebadmin", {NULL}, 8800, "udp"}, {"truecm", {NULL}, 8804, "tcp"}, {"truecm", {NULL}, 8804, "udp"}, {"dxspider", {NULL}, 8873, "tcp"}, {"dxspider", {NULL}, 8873, "udp"}, {"cddbp-alt", {NULL}, 8880, "tcp"}, {"cddbp-alt", {NULL}, 8880, "udp"}, {"secure-mqtt", {NULL}, 8883, "tcp"}, {"secure-mqtt", {NULL}, 8883, "udp"}, {"ddi-tcp-1", {NULL}, 8888, "tcp"}, {"ddi-udp-1", {NULL}, 8888, "udp"}, {"ddi-tcp-2", {NULL}, 8889, "tcp"}, {"ddi-udp-2", {NULL}, 8889, "udp"}, {"ddi-tcp-3", {NULL}, 8890, "tcp"}, {"ddi-udp-3", {NULL}, 8890, "udp"}, {"ddi-tcp-4", {NULL}, 8891, "tcp"}, {"ddi-udp-4", {NULL}, 8891, "udp"}, {"ddi-tcp-5", {NULL}, 8892, "tcp"}, {"ddi-udp-5", {NULL}, 8892, "udp"}, {"ddi-tcp-6", {NULL}, 8893, "tcp"}, {"ddi-udp-6", {NULL}, 8893, "udp"}, {"ddi-tcp-7", {NULL}, 8894, "tcp"}, {"ddi-udp-7", {NULL}, 8894, "udp"}, {"ospf-lite", {NULL}, 8899, "tcp"}, {"ospf-lite", {NULL}, 8899, "udp"}, {"jmb-cds1", {NULL}, 8900, "tcp"}, {"jmb-cds1", {NULL}, 8900, "udp"}, {"jmb-cds2", {NULL}, 8901, "tcp"}, {"jmb-cds2", {NULL}, 8901, "udp"}, {"manyone-http", {NULL}, 8910, "tcp"}, {"manyone-http", {NULL}, 8910, "udp"}, {"manyone-xml", {NULL}, 8911, "tcp"}, {"manyone-xml", {NULL}, 8911, "udp"}, {"wcbackup", {NULL}, 8912, "tcp"}, {"wcbackup", {NULL}, 8912, "udp"}, {"dragonfly", {NULL}, 8913, "tcp"}, {"dragonfly", {NULL}, 8913, "udp"}, {"twds", {NULL}, 8937, "tcp"}, {"cumulus-admin", {NULL}, 8954, "tcp"}, {"cumulus-admin", {NULL}, 8954, "udp"}, {"sunwebadmins", {NULL}, 8989, "tcp"}, {"sunwebadmins", {NULL}, 8989, "udp"}, {"http-wmap", {NULL}, 8990, "tcp"}, {"http-wmap", {NULL}, 8990, "udp"}, {"https-wmap", {NULL}, 8991, "tcp"}, {"https-wmap", {NULL}, 8991, "udp"}, {"bctp", {NULL}, 8999, "tcp"}, {"bctp", {NULL}, 8999, "udp"}, {"cslistener", {NULL}, 9000, "tcp"}, {"cslistener", {NULL}, 9000, "udp"}, {"etlservicemgr", {NULL}, 9001, "tcp"}, {"etlservicemgr", {NULL}, 9001, "udp"}, {"dynamid", {NULL}, 9002, "tcp"}, {"dynamid", {NULL}, 9002, "udp"}, {"ogs-client", {NULL}, 9007, "udp"}, {"ogs-server", {NULL}, 9008, "tcp"}, {"pichat", {NULL}, 9009, "tcp"}, {"pichat", {NULL}, 9009, "udp"}, {"sdr", {NULL}, 9010, "tcp"}, {"tambora", {NULL}, 9020, "tcp"}, {"tambora", {NULL}, 9020, "udp"}, {"panagolin-ident", {NULL}, 9021, "tcp"}, {"panagolin-ident", {NULL}, 9021, "udp"}, {"paragent", {NULL}, 9022, "tcp"}, {"paragent", {NULL}, 9022, "udp"}, {"swa-1", {NULL}, 9023, "tcp"}, {"swa-1", {NULL}, 9023, "udp"}, {"swa-2", {NULL}, 9024, "tcp"}, {"swa-2", {NULL}, 9024, "udp"}, {"swa-3", {NULL}, 9025, "tcp"}, {"swa-3", {NULL}, 9025, "udp"}, {"swa-4", {NULL}, 9026, "tcp"}, {"swa-4", {NULL}, 9026, "udp"}, {"versiera", {NULL}, 9050, "tcp"}, {"fio-cmgmt", {NULL}, 9051, "tcp"}, {"glrpc", {NULL}, 9080, "tcp"}, {"glrpc", {NULL}, 9080, "udp"}, {"lcs-ap", {NULL}, 9082, "sctp"}, {"emc-pp-mgmtsvc", {NULL}, 9083, "tcp"}, {"aurora", {NULL}, 9084, "tcp"}, {"aurora", {NULL}, 9084, "udp"}, {"aurora", {NULL}, 9084, "sctp"}, {"ibm-rsyscon", {NULL}, 9085, "tcp"}, {"ibm-rsyscon", {NULL}, 9085, "udp"}, {"net2display", {NULL}, 9086, "tcp"}, {"net2display", {NULL}, 9086, "udp"}, {"classic", {NULL}, 9087, "tcp"}, {"classic", {NULL}, 9087, "udp"}, {"sqlexec", {NULL}, 9088, "tcp"}, {"sqlexec", {NULL}, 9088, "udp"}, {"sqlexec-ssl", {NULL}, 9089, "tcp"}, {"sqlexec-ssl", {NULL}, 9089, "udp"}, {"websm", {NULL}, 9090, "tcp"}, {"websm", {NULL}, 9090, "udp"}, {"xmltec-xmlmail", {NULL}, 9091, "tcp"}, {"xmltec-xmlmail", {NULL}, 9091, "udp"}, {"XmlIpcRegSvc", {NULL}, 9092, "tcp"}, {"XmlIpcRegSvc", {NULL}, 9092, "udp"}, {"hp-pdl-datastr", {NULL}, 9100, "tcp"}, {"hp-pdl-datastr", {NULL}, 9100, "udp"}, {"pdl-datastream", {NULL}, 9100, "tcp"}, {"pdl-datastream", {NULL}, 9100, "udp"}, {"bacula-dir", {NULL}, 9101, "tcp"}, {"bacula-dir", {NULL}, 9101, "udp"}, {"bacula-fd", {NULL}, 9102, "tcp"}, {"bacula-fd", {NULL}, 9102, "udp"}, {"bacula-sd", {NULL}, 9103, "tcp"}, {"bacula-sd", {NULL}, 9103, "udp"}, {"peerwire", {NULL}, 9104, "tcp"}, {"peerwire", {NULL}, 9104, "udp"}, {"xadmin", {NULL}, 9105, "tcp"}, {"xadmin", {NULL}, 9105, "udp"}, {"astergate", {NULL}, 9106, "tcp"}, {"astergate-disc", {NULL}, 9106, "udp"}, {"astergatefax", {NULL}, 9107, "tcp"}, {"mxit", {NULL}, 9119, "tcp"}, {"mxit", {NULL}, 9119, "udp"}, {"dddp", {NULL}, 9131, "tcp"}, {"dddp", {NULL}, 9131, "udp"}, {"apani1", {NULL}, 9160, "tcp"}, {"apani1", {NULL}, 9160, "udp"}, {"apani2", {NULL}, 9161, "tcp"}, {"apani2", {NULL}, 9161, "udp"}, {"apani3", {NULL}, 9162, "tcp"}, {"apani3", {NULL}, 9162, "udp"}, {"apani4", {NULL}, 9163, "tcp"}, {"apani4", {NULL}, 9163, "udp"}, {"apani5", {NULL}, 9164, "tcp"}, {"apani5", {NULL}, 9164, "udp"}, {"sun-as-jpda", {NULL}, 9191, "tcp"}, {"sun-as-jpda", {NULL}, 9191, "udp"}, {"wap-wsp", {NULL}, 9200, "tcp"}, {"wap-wsp", {NULL}, 9200, "udp"}, {"wap-wsp-wtp", {NULL}, 9201, "tcp"}, {"wap-wsp-wtp", {NULL}, 9201, "udp"}, {"wap-wsp-s", {NULL}, 9202, "tcp"}, {"wap-wsp-s", {NULL}, 9202, "udp"}, {"wap-wsp-wtp-s", {NULL}, 9203, "tcp"}, {"wap-wsp-wtp-s", {NULL}, 9203, "udp"}, {"wap-vcard", {NULL}, 9204, "tcp"}, {"wap-vcard", {NULL}, 9204, "udp"}, {"wap-vcal", {NULL}, 9205, "tcp"}, {"wap-vcal", {NULL}, 9205, "udp"}, {"wap-vcard-s", {NULL}, 9206, "tcp"}, {"wap-vcard-s", {NULL}, 9206, "udp"}, {"wap-vcal-s", {NULL}, 9207, "tcp"}, {"wap-vcal-s", {NULL}, 9207, "udp"}, {"rjcdb-vcards", {NULL}, 9208, "tcp"}, {"rjcdb-vcards", {NULL}, 9208, "udp"}, {"almobile-system", {NULL}, 9209, "tcp"}, {"almobile-system", {NULL}, 9209, "udp"}, {"oma-mlp", {NULL}, 9210, "tcp"}, {"oma-mlp", {NULL}, 9210, "udp"}, {"oma-mlp-s", {NULL}, 9211, "tcp"}, {"oma-mlp-s", {NULL}, 9211, "udp"}, {"serverviewdbms", {NULL}, 9212, "tcp"}, {"serverviewdbms", {NULL}, 9212, "udp"}, {"serverstart", {NULL}, 9213, "tcp"}, {"serverstart", {NULL}, 9213, "udp"}, {"ipdcesgbs", {NULL}, 9214, "tcp"}, {"ipdcesgbs", {NULL}, 9214, "udp"}, {"insis", {NULL}, 9215, "tcp"}, {"insis", {NULL}, 9215, "udp"}, {"acme", {NULL}, 9216, "tcp"}, {"acme", {NULL}, 9216, "udp"}, {"fsc-port", {NULL}, 9217, "tcp"}, {"fsc-port", {NULL}, 9217, "udp"}, {"teamcoherence", {NULL}, 9222, "tcp"}, {"teamcoherence", {NULL}, 9222, "udp"}, {"mon", {NULL}, 9255, "tcp"}, {"mon", {NULL}, 9255, "udp"}, {"pegasus", {NULL}, 9278, "tcp"}, {"pegasus", {NULL}, 9278, "udp"}, {"pegasus-ctl", {NULL}, 9279, "tcp"}, {"pegasus-ctl", {NULL}, 9279, "udp"}, {"pgps", {NULL}, 9280, "tcp"}, {"pgps", {NULL}, 9280, "udp"}, {"swtp-port1", {NULL}, 9281, "tcp"}, {"swtp-port1", {NULL}, 9281, "udp"}, {"swtp-port2", {NULL}, 9282, "tcp"}, {"swtp-port2", {NULL}, 9282, "udp"}, {"callwaveiam", {NULL}, 9283, "tcp"}, {"callwaveiam", {NULL}, 9283, "udp"}, {"visd", {NULL}, 9284, "tcp"}, {"visd", {NULL}, 9284, "udp"}, {"n2h2server", {NULL}, 9285, "tcp"}, {"n2h2server", {NULL}, 9285, "udp"}, {"n2receive", {NULL}, 9286, "udp"}, {"cumulus", {NULL}, 9287, "tcp"}, {"cumulus", {NULL}, 9287, "udp"}, {"armtechdaemon", {NULL}, 9292, "tcp"}, {"armtechdaemon", {NULL}, 9292, "udp"}, {"storview", {NULL}, 9293, "tcp"}, {"storview", {NULL}, 9293, "udp"}, {"armcenterhttp", {NULL}, 9294, "tcp"}, {"armcenterhttp", {NULL}, 9294, "udp"}, {"armcenterhttps", {NULL}, 9295, "tcp"}, {"armcenterhttps", {NULL}, 9295, "udp"}, {"vrace", {NULL}, 9300, "tcp"}, {"vrace", {NULL}, 9300, "udp"}, {"sphinxql", {NULL}, 9306, "tcp"}, {"sphinxapi", {NULL}, 9312, "tcp"}, {"secure-ts", {NULL}, 9318, "tcp"}, {"secure-ts", {NULL}, 9318, "udp"}, {"guibase", {NULL}, 9321, "tcp"}, {"guibase", {NULL}, 9321, "udp"}, {"mpidcmgr", {NULL}, 9343, "tcp"}, {"mpidcmgr", {NULL}, 9343, "udp"}, {"mphlpdmc", {NULL}, 9344, "tcp"}, {"mphlpdmc", {NULL}, 9344, "udp"}, {"ctechlicensing", {NULL}, 9346, "tcp"}, {"ctechlicensing", {NULL}, 9346, "udp"}, {"fjdmimgr", {NULL}, 9374, "tcp"}, {"fjdmimgr", {NULL}, 9374, "udp"}, {"boxp", {NULL}, 9380, "tcp"}, {"boxp", {NULL}, 9380, "udp"}, {"d2dconfig", {NULL}, 9387, "tcp"}, {"d2ddatatrans", {NULL}, 9388, "tcp"}, {"adws", {NULL}, 9389, "tcp"}, {"otp", {NULL}, 9390, "tcp"}, {"fjinvmgr", {NULL}, 9396, "tcp"}, {"fjinvmgr", {NULL}, 9396, "udp"}, {"mpidcagt", {NULL}, 9397, "tcp"}, {"mpidcagt", {NULL}, 9397, "udp"}, {"sec-t4net-srv", {NULL}, 9400, "tcp"}, {"sec-t4net-srv", {NULL}, 9400, "udp"}, {"sec-t4net-clt", {NULL}, 9401, "tcp"}, {"sec-t4net-clt", {NULL}, 9401, "udp"}, {"sec-pc2fax-srv", {NULL}, 9402, "tcp"}, {"sec-pc2fax-srv", {NULL}, 9402, "udp"}, {"git", {NULL}, 9418, "tcp"}, {"git", {NULL}, 9418, "udp"}, {"tungsten-https", {NULL}, 9443, "tcp"}, {"tungsten-https", {NULL}, 9443, "udp"}, {"wso2esb-console", {NULL}, 9444, "tcp"}, {"wso2esb-console", {NULL}, 9444, "udp"}, {"sntlkeyssrvr", {NULL}, 9450, "tcp"}, {"sntlkeyssrvr", {NULL}, 9450, "udp"}, {"ismserver", {NULL}, 9500, "tcp"}, {"ismserver", {NULL}, 9500, "udp"}, {"sma-spw", {NULL}, 9522, "udp"}, {"mngsuite", {NULL}, 9535, "tcp"}, {"mngsuite", {NULL}, 9535, "udp"}, {"laes-bf", {NULL}, 9536, "tcp"}, {"laes-bf", {NULL}, 9536, "udp"}, {"trispen-sra", {NULL}, 9555, "tcp"}, {"trispen-sra", {NULL}, 9555, "udp"}, {"ldgateway", {NULL}, 9592, "tcp"}, {"ldgateway", {NULL}, 9592, "udp"}, {"cba8", {NULL}, 9593, "tcp"}, {"cba8", {NULL}, 9593, "udp"}, {"msgsys", {NULL}, 9594, "tcp"}, {"msgsys", {NULL}, 9594, "udp"}, {"pds", {NULL}, 9595, "tcp"}, {"pds", {NULL}, 9595, "udp"}, {"mercury-disc", {NULL}, 9596, "tcp"}, {"mercury-disc", {NULL}, 9596, "udp"}, {"pd-admin", {NULL}, 9597, "tcp"}, {"pd-admin", {NULL}, 9597, "udp"}, {"vscp", {NULL}, 9598, "tcp"}, {"vscp", {NULL}, 9598, "udp"}, {"robix", {NULL}, 9599, "tcp"}, {"robix", {NULL}, 9599, "udp"}, {"micromuse-ncpw", {NULL}, 9600, "tcp"}, {"micromuse-ncpw", {NULL}, 9600, "udp"}, {"streamcomm-ds", {NULL}, 9612, "tcp"}, {"streamcomm-ds", {NULL}, 9612, "udp"}, {"iadt-tls", {NULL}, 9614, "tcp"}, {"erunbook_agent", {NULL}, 9616, "tcp"}, {"erunbook_server", {NULL}, 9617, "tcp"}, {"condor", {NULL}, 9618, "tcp"}, {"condor", {NULL}, 9618, "udp"}, {"odbcpathway", {NULL}, 9628, "tcp"}, {"odbcpathway", {NULL}, 9628, "udp"}, {"uniport", {NULL}, 9629, "tcp"}, {"uniport", {NULL}, 9629, "udp"}, {"peoctlr", {NULL}, 9630, "tcp"}, {"peocoll", {NULL}, 9631, "tcp"}, {"mc-comm", {NULL}, 9632, "udp"}, {"pqsflows", {NULL}, 9640, "tcp"}, {"xmms2", {NULL}, 9667, "tcp"}, {"xmms2", {NULL}, 9667, "udp"}, {"tec5-sdctp", {NULL}, 9668, "tcp"}, {"tec5-sdctp", {NULL}, 9668, "udp"}, {"client-wakeup", {NULL}, 9694, "tcp"}, {"client-wakeup", {NULL}, 9694, "udp"}, {"ccnx", {NULL}, 9695, "tcp"}, {"ccnx", {NULL}, 9695, "udp"}, {"board-roar", {NULL}, 9700, "tcp"}, {"board-roar", {NULL}, 9700, "udp"}, {"l5nas-parchan", {NULL}, 9747, "tcp"}, {"l5nas-parchan", {NULL}, 9747, "udp"}, {"board-voip", {NULL}, 9750, "tcp"}, {"board-voip", {NULL}, 9750, "udp"}, {"rasadv", {NULL}, 9753, "tcp"}, {"rasadv", {NULL}, 9753, "udp"}, {"tungsten-http", {NULL}, 9762, "tcp"}, {"tungsten-http", {NULL}, 9762, "udp"}, {"davsrc", {NULL}, 9800, "tcp"}, {"davsrc", {NULL}, 9800, "udp"}, {"sstp-2", {NULL}, 9801, "tcp"}, {"sstp-2", {NULL}, 9801, "udp"}, {"davsrcs", {NULL}, 9802, "tcp"}, {"davsrcs", {NULL}, 9802, "udp"}, {"sapv1", {NULL}, 9875, "tcp"}, {"sapv1", {NULL}, 9875, "udp"}, {"sd", {NULL}, 9876, "tcp"}, {"sd", {NULL}, 9876, "udp"}, {"cyborg-systems", {NULL}, 9888, "tcp"}, {"cyborg-systems", {NULL}, 9888, "udp"}, {"gt-proxy", {NULL}, 9889, "tcp"}, {"gt-proxy", {NULL}, 9889, "udp"}, {"monkeycom", {NULL}, 9898, "tcp"}, {"monkeycom", {NULL}, 9898, "udp"}, {"sctp-tunneling", {NULL}, 9899, "tcp"}, {"sctp-tunneling", {NULL}, 9899, "udp"}, {"iua", {NULL}, 9900, "tcp"}, {"iua", {NULL}, 9900, "udp"}, {"iua", {NULL}, 9900, "sctp"}, {"enrp", {NULL}, 9901, "udp"}, {"enrp-sctp", {NULL}, 9901, "sctp"}, {"enrp-sctp-tls", {NULL}, 9902, "sctp"}, {"domaintime", {NULL}, 9909, "tcp"}, {"domaintime", {NULL}, 9909, "udp"}, {"sype-transport", {NULL}, 9911, "tcp"}, {"sype-transport", {NULL}, 9911, "udp"}, {"apc-9950", {NULL}, 9950, "tcp"}, {"apc-9950", {NULL}, 9950, "udp"}, {"apc-9951", {NULL}, 9951, "tcp"}, {"apc-9951", {NULL}, 9951, "udp"}, {"apc-9952", {NULL}, 9952, "tcp"}, {"apc-9952", {NULL}, 9952, "udp"}, {"acis", {NULL}, 9953, "tcp"}, {"acis", {NULL}, 9953, "udp"}, {"odnsp", {NULL}, 9966, "tcp"}, {"odnsp", {NULL}, 9966, "udp"}, {"dsm-scm-target", {NULL}, 9987, "tcp"}, {"dsm-scm-target", {NULL}, 9987, "udp"}, {"nsesrvr", {NULL}, 9988, "tcp"}, {"osm-appsrvr", {NULL}, 9990, "tcp"}, {"osm-appsrvr", {NULL}, 9990, "udp"}, {"osm-oev", {NULL}, 9991, "tcp"}, {"osm-oev", {NULL}, 9991, "udp"}, {"palace-1", {NULL}, 9992, "tcp"}, {"palace-1", {NULL}, 9992, "udp"}, {"palace-2", {NULL}, 9993, "tcp"}, {"palace-2", {NULL}, 9993, "udp"}, {"palace-3", {NULL}, 9994, "tcp"}, {"palace-3", {NULL}, 9994, "udp"}, {"palace-4", {NULL}, 9995, "tcp"}, {"palace-4", {NULL}, 9995, "udp"}, {"palace-5", {NULL}, 9996, "tcp"}, {"palace-5", {NULL}, 9996, "udp"}, {"palace-6", {NULL}, 9997, "tcp"}, {"palace-6", {NULL}, 9997, "udp"}, {"distinct32", {NULL}, 9998, "tcp"}, {"distinct32", {NULL}, 9998, "udp"}, {"distinct", {NULL}, 9999, "tcp"}, {"distinct", {NULL}, 9999, "udp"}, {"ndmp", {NULL}, 10000, "tcp"}, {"ndmp", {NULL}, 10000, "udp"}, {"scp-config", {NULL}, 10001, "tcp"}, {"scp-config", {NULL}, 10001, "udp"}, {"documentum", {NULL}, 10002, "tcp"}, {"documentum", {NULL}, 10002, "udp"}, {"documentum_s", {NULL}, 10003, "tcp"}, {"documentum_s", {NULL}, 10003, "udp"}, {"emcrmirccd", {NULL}, 10004, "tcp"}, {"emcrmird", {NULL}, 10005, "tcp"}, {"mvs-capacity", {NULL}, 10007, "tcp"}, {"mvs-capacity", {NULL}, 10007, "udp"}, {"octopus", {NULL}, 10008, "tcp"}, {"octopus", {NULL}, 10008, "udp"}, {"swdtp-sv", {NULL}, 10009, "tcp"}, {"swdtp-sv", {NULL}, 10009, "udp"}, {"rxapi", {NULL}, 10010, "tcp"}, {"zabbix-agent", {NULL}, 10050, "tcp"}, {"zabbix-agent", {NULL}, 10050, "udp"}, {"zabbix-trapper", {NULL}, 10051, "tcp"}, {"zabbix-trapper", {NULL}, 10051, "udp"}, {"qptlmd", {NULL}, 10055, "tcp"}, {"amanda", {NULL}, 10080, "tcp"}, {"amanda", {NULL}, 10080, "udp"}, {"famdc", {NULL}, 10081, "tcp"}, {"famdc", {NULL}, 10081, "udp"}, {"itap-ddtp", {NULL}, 10100, "tcp"}, {"itap-ddtp", {NULL}, 10100, "udp"}, {"ezmeeting-2", {NULL}, 10101, "tcp"}, {"ezmeeting-2", {NULL}, 10101, "udp"}, {"ezproxy-2", {NULL}, 10102, "tcp"}, {"ezproxy-2", {NULL}, 10102, "udp"}, {"ezrelay", {NULL}, 10103, "tcp"}, {"ezrelay", {NULL}, 10103, "udp"}, {"swdtp", {NULL}, 10104, "tcp"}, {"swdtp", {NULL}, 10104, "udp"}, {"bctp-server", {NULL}, 10107, "tcp"}, {"bctp-server", {NULL}, 10107, "udp"}, {"nmea-0183", {NULL}, 10110, "tcp"}, {"nmea-0183", {NULL}, 10110, "udp"}, {"netiq-endpoint", {NULL}, 10113, "tcp"}, {"netiq-endpoint", {NULL}, 10113, "udp"}, {"netiq-qcheck", {NULL}, 10114, "tcp"}, {"netiq-qcheck", {NULL}, 10114, "udp"}, {"netiq-endpt", {NULL}, 10115, "tcp"}, {"netiq-endpt", {NULL}, 10115, "udp"}, {"netiq-voipa", {NULL}, 10116, "tcp"}, {"netiq-voipa", {NULL}, 10116, "udp"}, {"iqrm", {NULL}, 10117, "tcp"}, {"iqrm", {NULL}, 10117, "udp"}, {"bmc-perf-sd", {NULL}, 10128, "tcp"}, {"bmc-perf-sd", {NULL}, 10128, "udp"}, {"bmc-gms", {NULL}, 10129, "tcp"}, {"qb-db-server", {NULL}, 10160, "tcp"}, {"qb-db-server", {NULL}, 10160, "udp"}, {"snmptls", {NULL}, 10161, "tcp"}, {"snmpdtls", {NULL}, 10161, "udp"}, {"snmptls-trap", {NULL}, 10162, "tcp"}, {"snmpdtls-trap", {NULL}, 10162, "udp"}, {"trisoap", {NULL}, 10200, "tcp"}, {"trisoap", {NULL}, 10200, "udp"}, {"rsms", {NULL}, 10201, "tcp"}, {"rscs", {NULL}, 10201, "udp"}, {"apollo-relay", {NULL}, 10252, "tcp"}, {"apollo-relay", {NULL}, 10252, "udp"}, {"axis-wimp-port", {NULL}, 10260, "tcp"}, {"axis-wimp-port", {NULL}, 10260, "udp"}, {"blocks", {NULL}, 10288, "tcp"}, {"blocks", {NULL}, 10288, "udp"}, {"cosir", {NULL}, 10321, "tcp"}, {"hip-nat-t", {NULL}, 10500, "udp"}, {"MOS-lower", {NULL}, 10540, "tcp"}, {"MOS-lower", {NULL}, 10540, "udp"}, {"MOS-upper", {NULL}, 10541, "tcp"}, {"MOS-upper", {NULL}, 10541, "udp"}, {"MOS-aux", {NULL}, 10542, "tcp"}, {"MOS-aux", {NULL}, 10542, "udp"}, {"MOS-soap", {NULL}, 10543, "tcp"}, {"MOS-soap", {NULL}, 10543, "udp"}, {"MOS-soap-opt", {NULL}, 10544, "tcp"}, {"MOS-soap-opt", {NULL}, 10544, "udp"}, {"gap", {NULL}, 10800, "tcp"}, {"gap", {NULL}, 10800, "udp"}, {"lpdg", {NULL}, 10805, "tcp"}, {"lpdg", {NULL}, 10805, "udp"}, {"nbd", {NULL}, 10809, "tcp"}, {"nmc-disc", {NULL}, 10810, "udp"}, {"helix", {NULL}, 10860, "tcp"}, {"helix", {NULL}, 10860, "udp"}, {"rmiaux", {NULL}, 10990, "tcp"}, {"rmiaux", {NULL}, 10990, "udp"}, {"irisa", {NULL}, 11000, "tcp"}, {"irisa", {NULL}, 11000, "udp"}, {"metasys", {NULL}, 11001, "tcp"}, {"metasys", {NULL}, 11001, "udp"}, {"netapp-icmgmt", {NULL}, 11104, "tcp"}, {"netapp-icdata", {NULL}, 11105, "tcp"}, {"sgi-lk", {NULL}, 11106, "tcp"}, {"sgi-lk", {NULL}, 11106, "udp"}, {"vce", {NULL}, 11111, "tcp"}, {"vce", {NULL}, 11111, "udp"}, {"dicom", {NULL}, 11112, "tcp"}, {"dicom", {NULL}, 11112, "udp"}, {"suncacao-snmp", {NULL}, 11161, "tcp"}, {"suncacao-snmp", {NULL}, 11161, "udp"}, {"suncacao-jmxmp", {NULL}, 11162, "tcp"}, {"suncacao-jmxmp", {NULL}, 11162, "udp"}, {"suncacao-rmi", {NULL}, 11163, "tcp"}, {"suncacao-rmi", {NULL}, 11163, "udp"}, {"suncacao-csa", {NULL}, 11164, "tcp"}, {"suncacao-csa", {NULL}, 11164, "udp"}, {"suncacao-websvc", {NULL}, 11165, "tcp"}, {"suncacao-websvc", {NULL}, 11165, "udp"}, {"snss", {NULL}, 11171, "udp"}, {"oemcacao-jmxmp", {NULL}, 11172, "tcp"}, {"oemcacao-rmi", {NULL}, 11174, "tcp"}, {"oemcacao-websvc", {NULL}, 11175, "tcp"}, {"smsqp", {NULL}, 11201, "tcp"}, {"smsqp", {NULL}, 11201, "udp"}, {"wifree", {NULL}, 11208, "tcp"}, {"wifree", {NULL}, 11208, "udp"}, {"memcache", {NULL}, 11211, "tcp"}, {"memcache", {NULL}, 11211, "udp"}, {"imip", {NULL}, 11319, "tcp"}, {"imip", {NULL}, 11319, "udp"}, {"imip-channels", {NULL}, 11320, "tcp"}, {"imip-channels", {NULL}, 11320, "udp"}, {"arena-server", {NULL}, 11321, "tcp"}, {"arena-server", {NULL}, 11321, "udp"}, {"atm-uhas", {NULL}, 11367, "tcp"}, {"atm-uhas", {NULL}, 11367, "udp"}, {"hkp", {NULL}, 11371, "tcp"}, {"hkp", {NULL}, 11371, "udp"}, {"asgcypresstcps", {NULL}, 11489, "tcp"}, {"tempest-port", {NULL}, 11600, "tcp"}, {"tempest-port", {NULL}, 11600, "udp"}, {"h323callsigalt", {NULL}, 11720, "tcp"}, {"h323callsigalt", {NULL}, 11720, "udp"}, {"intrepid-ssl", {NULL}, 11751, "tcp"}, {"intrepid-ssl", {NULL}, 11751, "udp"}, {"xoraya", {NULL}, 11876, "tcp"}, {"xoraya", {NULL}, 11876, "udp"}, {"x2e-disc", {NULL}, 11877, "udp"}, {"sysinfo-sp", {NULL}, 11967, "tcp"}, {"sysinfo-sp", {NULL}, 11967, "udp"}, {"wmereceiving", {NULL}, 11997, "sctp"}, {"wmedistribution", {NULL}, 11998, "sctp"}, {"wmereporting", {NULL}, 11999, "sctp"}, {"entextxid", {NULL}, 12000, "tcp"}, {"entextxid", {NULL}, 12000, "udp"}, {"entextnetwk", {NULL}, 12001, "tcp"}, {"entextnetwk", {NULL}, 12001, "udp"}, {"entexthigh", {NULL}, 12002, "tcp"}, {"entexthigh", {NULL}, 12002, "udp"}, {"entextmed", {NULL}, 12003, "tcp"}, {"entextmed", {NULL}, 12003, "udp"}, {"entextlow", {NULL}, 12004, "tcp"}, {"entextlow", {NULL}, 12004, "udp"}, {"dbisamserver1", {NULL}, 12005, "tcp"}, {"dbisamserver1", {NULL}, 12005, "udp"}, {"dbisamserver2", {NULL}, 12006, "tcp"}, {"dbisamserver2", {NULL}, 12006, "udp"}, {"accuracer", {NULL}, 12007, "tcp"}, {"accuracer", {NULL}, 12007, "udp"}, {"accuracer-dbms", {NULL}, 12008, "tcp"}, {"accuracer-dbms", {NULL}, 12008, "udp"}, {"edbsrvr", {NULL}, 12010, "tcp"}, {"vipera", {NULL}, 12012, "tcp"}, {"vipera", {NULL}, 12012, "udp"}, {"vipera-ssl", {NULL}, 12013, "tcp"}, {"vipera-ssl", {NULL}, 12013, "udp"}, {"rets-ssl", {NULL}, 12109, "tcp"}, {"rets-ssl", {NULL}, 12109, "udp"}, {"nupaper-ss", {NULL}, 12121, "tcp"}, {"nupaper-ss", {NULL}, 12121, "udp"}, {"cawas", {NULL}, 12168, "tcp"}, {"cawas", {NULL}, 12168, "udp"}, {"hivep", {NULL}, 12172, "tcp"}, {"hivep", {NULL}, 12172, "udp"}, {"linogridengine", {NULL}, 12300, "tcp"}, {"linogridengine", {NULL}, 12300, "udp"}, {"warehouse-sss", {NULL}, 12321, "tcp"}, {"warehouse-sss", {NULL}, 12321, "udp"}, {"warehouse", {NULL}, 12322, "tcp"}, {"warehouse", {NULL}, 12322, "udp"}, {"italk", {NULL}, 12345, "tcp"}, {"italk", {NULL}, 12345, "udp"}, {"tsaf", {NULL}, 12753, "tcp"}, {"tsaf", {NULL}, 12753, "udp"}, {"i-zipqd", {NULL}, 13160, "tcp"}, {"i-zipqd", {NULL}, 13160, "udp"}, {"bcslogc", {NULL}, 13216, "tcp"}, {"bcslogc", {NULL}, 13216, "udp"}, {"rs-pias", {NULL}, 13217, "tcp"}, {"rs-pias", {NULL}, 13217, "udp"}, {"emc-vcas-tcp", {NULL}, 13218, "tcp"}, {"emc-vcas-udp", {NULL}, 13218, "udp"}, {"powwow-client", {NULL}, 13223, "tcp"}, {"powwow-client", {NULL}, 13223, "udp"}, {"powwow-server", {NULL}, 13224, "tcp"}, {"powwow-server", {NULL}, 13224, "udp"}, {"doip-data", {NULL}, 13400, "tcp"}, {"doip-disc", {NULL}, 13400, "udp"}, {"bprd", {NULL}, 13720, "tcp"}, {"bprd", {NULL}, 13720, "udp"}, {"bpdbm", {NULL}, 13721, "tcp"}, {"bpdbm", {NULL}, 13721, "udp"}, {"bpjava-msvc", {NULL}, 13722, "tcp"}, {"bpjava-msvc", {NULL}, 13722, "udp"}, {"vnetd", {NULL}, 13724, "tcp"}, {"vnetd", {NULL}, 13724, "udp"}, {"bpcd", {NULL}, 13782, "tcp"}, {"bpcd", {NULL}, 13782, "udp"}, {"vopied", {NULL}, 13783, "tcp"}, {"vopied", {NULL}, 13783, "udp"}, {"nbdb", {NULL}, 13785, "tcp"}, {"nbdb", {NULL}, 13785, "udp"}, {"nomdb", {NULL}, 13786, "tcp"}, {"nomdb", {NULL}, 13786, "udp"}, {"dsmcc-config", {NULL}, 13818, "tcp"}, {"dsmcc-config", {NULL}, 13818, "udp"}, {"dsmcc-session", {NULL}, 13819, "tcp"}, {"dsmcc-session", {NULL}, 13819, "udp"}, {"dsmcc-passthru", {NULL}, 13820, "tcp"}, {"dsmcc-passthru", {NULL}, 13820, "udp"}, {"dsmcc-download", {NULL}, 13821, "tcp"}, {"dsmcc-download", {NULL}, 13821, "udp"}, {"dsmcc-ccp", {NULL}, 13822, "tcp"}, {"dsmcc-ccp", {NULL}, 13822, "udp"}, {"bmdss", {NULL}, 13823, "tcp"}, {"dta-systems", {NULL}, 13929, "tcp"}, {"dta-systems", {NULL}, 13929, "udp"}, {"medevolve", {NULL}, 13930, "tcp"}, {"scotty-ft", {NULL}, 14000, "tcp"}, {"scotty-ft", {NULL}, 14000, "udp"}, {"sua", {NULL}, 14001, "tcp"}, {"sua", {NULL}, 14001, "udp"}, {"sua", {NULL}, 14001, "sctp"}, {"sage-best-com1", {NULL}, 14033, "tcp"}, {"sage-best-com1", {NULL}, 14033, "udp"}, {"sage-best-com2", {NULL}, 14034, "tcp"}, {"sage-best-com2", {NULL}, 14034, "udp"}, {"vcs-app", {NULL}, 14141, "tcp"}, {"vcs-app", {NULL}, 14141, "udp"}, {"icpp", {NULL}, 14142, "tcp"}, {"icpp", {NULL}, 14142, "udp"}, {"gcm-app", {NULL}, 14145, "tcp"}, {"gcm-app", {NULL}, 14145, "udp"}, {"vrts-tdd", {NULL}, 14149, "tcp"}, {"vrts-tdd", {NULL}, 14149, "udp"}, {"vcscmd", {NULL}, 14150, "tcp"}, {"vad", {NULL}, 14154, "tcp"}, {"vad", {NULL}, 14154, "udp"}, {"cps", {NULL}, 14250, "tcp"}, {"cps", {NULL}, 14250, "udp"}, {"ca-web-update", {NULL}, 14414, "tcp"}, {"ca-web-update", {NULL}, 14414, "udp"}, {"hde-lcesrvr-1", {NULL}, 14936, "tcp"}, {"hde-lcesrvr-1", {NULL}, 14936, "udp"}, {"hde-lcesrvr-2", {NULL}, 14937, "tcp"}, {"hde-lcesrvr-2", {NULL}, 14937, "udp"}, {"hydap", {NULL}, 15000, "tcp"}, {"hydap", {NULL}, 15000, "udp"}, {"xpilot", {NULL}, 15345, "tcp"}, {"xpilot", {NULL}, 15345, "udp"}, {"3link", {NULL}, 15363, "tcp"}, {"3link", {NULL}, 15363, "udp"}, {"cisco-snat", {NULL}, 15555, "tcp"}, {"cisco-snat", {NULL}, 15555, "udp"}, {"bex-xr", {NULL}, 15660, "tcp"}, {"bex-xr", {NULL}, 15660, "udp"}, {"ptp", {NULL}, 15740, "tcp"}, {"ptp", {NULL}, 15740, "udp"}, {"2ping", {NULL}, 15998, "udp"}, {"programmar", {NULL}, 15999, "tcp"}, {"fmsas", {NULL}, 16000, "tcp"}, {"fmsascon", {NULL}, 16001, "tcp"}, {"gsms", {NULL}, 16002, "tcp"}, {"alfin", {NULL}, 16003, "udp"}, {"jwpc", {NULL}, 16020, "tcp"}, {"jwpc-bin", {NULL}, 16021, "tcp"}, {"sun-sea-port", {NULL}, 16161, "tcp"}, {"sun-sea-port", {NULL}, 16161, "udp"}, {"solaris-audit", {NULL}, 16162, "tcp"}, {"etb4j", {NULL}, 16309, "tcp"}, {"etb4j", {NULL}, 16309, "udp"}, {"pduncs", {NULL}, 16310, "tcp"}, {"pduncs", {NULL}, 16310, "udp"}, {"pdefmns", {NULL}, 16311, "tcp"}, {"pdefmns", {NULL}, 16311, "udp"}, {"netserialext1", {NULL}, 16360, "tcp"}, {"netserialext1", {NULL}, 16360, "udp"}, {"netserialext2", {NULL}, 16361, "tcp"}, {"netserialext2", {NULL}, 16361, "udp"}, {"netserialext3", {NULL}, 16367, "tcp"}, {"netserialext3", {NULL}, 16367, "udp"}, {"netserialext4", {NULL}, 16368, "tcp"}, {"netserialext4", {NULL}, 16368, "udp"}, {"connected", {NULL}, 16384, "tcp"}, {"connected", {NULL}, 16384, "udp"}, {"xoms", {NULL}, 16619, "tcp"}, {"newbay-snc-mc", {NULL}, 16900, "tcp"}, {"newbay-snc-mc", {NULL}, 16900, "udp"}, {"sgcip", {NULL}, 16950, "tcp"}, {"sgcip", {NULL}, 16950, "udp"}, {"intel-rci-mp", {NULL}, 16991, "tcp"}, {"intel-rci-mp", {NULL}, 16991, "udp"}, {"amt-soap-http", {NULL}, 16992, "tcp"}, {"amt-soap-http", {NULL}, 16992, "udp"}, {"amt-soap-https", {NULL}, 16993, "tcp"}, {"amt-soap-https", {NULL}, 16993, "udp"}, {"amt-redir-tcp", {NULL}, 16994, "tcp"}, {"amt-redir-tcp", {NULL}, 16994, "udp"}, {"amt-redir-tls", {NULL}, 16995, "tcp"}, {"amt-redir-tls", {NULL}, 16995, "udp"}, {"isode-dua", {NULL}, 17007, "tcp"}, {"isode-dua", {NULL}, 17007, "udp"}, {"soundsvirtual", {NULL}, 17185, "tcp"}, {"soundsvirtual", {NULL}, 17185, "udp"}, {"chipper", {NULL}, 17219, "tcp"}, {"chipper", {NULL}, 17219, "udp"}, {"integrius-stp", {NULL}, 17234, "tcp"}, {"integrius-stp", {NULL}, 17234, "udp"}, {"ssh-mgmt", {NULL}, 17235, "tcp"}, {"ssh-mgmt", {NULL}, 17235, "udp"}, {"db-lsp", {NULL}, 17500, "tcp"}, {"db-lsp-disc", {NULL}, 17500, "udp"}, {"ea", {NULL}, 17729, "tcp"}, {"ea", {NULL}, 17729, "udp"}, {"zep", {NULL}, 17754, "tcp"}, {"zep", {NULL}, 17754, "udp"}, {"zigbee-ip", {NULL}, 17755, "tcp"}, {"zigbee-ip", {NULL}, 17755, "udp"}, {"zigbee-ips", {NULL}, 17756, "tcp"}, {"zigbee-ips", {NULL}, 17756, "udp"}, {"sw-orion", {NULL}, 17777, "tcp"}, {"biimenu", {NULL}, 18000, "tcp"}, {"biimenu", {NULL}, 18000, "udp"}, {"radpdf", {NULL}, 18104, "tcp"}, {"racf", {NULL}, 18136, "tcp"}, {"opsec-cvp", {NULL}, 18181, "tcp"}, {"opsec-cvp", {NULL}, 18181, "udp"}, {"opsec-ufp", {NULL}, 18182, "tcp"}, {"opsec-ufp", {NULL}, 18182, "udp"}, {"opsec-sam", {NULL}, 18183, "tcp"}, {"opsec-sam", {NULL}, 18183, "udp"}, {"opsec-lea", {NULL}, 18184, "tcp"}, {"opsec-lea", {NULL}, 18184, "udp"}, {"opsec-omi", {NULL}, 18185, "tcp"}, {"opsec-omi", {NULL}, 18185, "udp"}, {"ohsc", {NULL}, 18186, "tcp"}, {"ohsc", {NULL}, 18186, "udp"}, {"opsec-ela", {NULL}, 18187, "tcp"}, {"opsec-ela", {NULL}, 18187, "udp"}, {"checkpoint-rtm", {NULL}, 18241, "tcp"}, {"checkpoint-rtm", {NULL}, 18241, "udp"}, {"gv-pf", {NULL}, 18262, "tcp"}, {"gv-pf", {NULL}, 18262, "udp"}, {"ac-cluster", {NULL}, 18463, "tcp"}, {"ac-cluster", {NULL}, 18463, "udp"}, {"rds-ib", {NULL}, 18634, "tcp"}, {"rds-ib", {NULL}, 18634, "udp"}, {"rds-ip", {NULL}, 18635, "tcp"}, {"rds-ip", {NULL}, 18635, "udp"}, {"ique", {NULL}, 18769, "tcp"}, {"ique", {NULL}, 18769, "udp"}, {"infotos", {NULL}, 18881, "tcp"}, {"infotos", {NULL}, 18881, "udp"}, {"apc-necmp", {NULL}, 18888, "tcp"}, {"apc-necmp", {NULL}, 18888, "udp"}, {"igrid", {NULL}, 19000, "tcp"}, {"igrid", {NULL}, 19000, "udp"}, {"j-link", {NULL}, 19020, "tcp"}, {"opsec-uaa", {NULL}, 19191, "tcp"}, {"opsec-uaa", {NULL}, 19191, "udp"}, {"ua-secureagent", {NULL}, 19194, "tcp"}, {"ua-secureagent", {NULL}, 19194, "udp"}, {"keysrvr", {NULL}, 19283, "tcp"}, {"keysrvr", {NULL}, 19283, "udp"}, {"keyshadow", {NULL}, 19315, "tcp"}, {"keyshadow", {NULL}, 19315, "udp"}, {"mtrgtrans", {NULL}, 19398, "tcp"}, {"mtrgtrans", {NULL}, 19398, "udp"}, {"hp-sco", {NULL}, 19410, "tcp"}, {"hp-sco", {NULL}, 19410, "udp"}, {"hp-sca", {NULL}, 19411, "tcp"}, {"hp-sca", {NULL}, 19411, "udp"}, {"hp-sessmon", {NULL}, 19412, "tcp"}, {"hp-sessmon", {NULL}, 19412, "udp"}, {"fxuptp", {NULL}, 19539, "tcp"}, {"fxuptp", {NULL}, 19539, "udp"}, {"sxuptp", {NULL}, 19540, "tcp"}, {"sxuptp", {NULL}, 19540, "udp"}, {"jcp", {NULL}, 19541, "tcp"}, {"jcp", {NULL}, 19541, "udp"}, {"iec-104-sec", {NULL}, 19998, "tcp"}, {"dnp-sec", {NULL}, 19999, "tcp"}, {"dnp-sec", {NULL}, 19999, "udp"}, {"dnp", {NULL}, 20000, "tcp"}, {"dnp", {NULL}, 20000, "udp"}, {"microsan", {NULL}, 20001, "tcp"}, {"microsan", {NULL}, 20001, "udp"}, {"commtact-http", {NULL}, 20002, "tcp"}, {"commtact-http", {NULL}, 20002, "udp"}, {"commtact-https", {NULL}, 20003, "tcp"}, {"commtact-https", {NULL}, 20003, "udp"}, {"openwebnet", {NULL}, 20005, "tcp"}, {"openwebnet", {NULL}, 20005, "udp"}, {"ss-idi-disc", {NULL}, 20012, "udp"}, {"ss-idi", {NULL}, 20013, "tcp"}, {"opendeploy", {NULL}, 20014, "tcp"}, {"opendeploy", {NULL}, 20014, "udp"}, {"nburn_id", {NULL}, 20034, "tcp"}, {"nburn_id", {NULL}, 20034, "udp"}, {"tmophl7mts", {NULL}, 20046, "tcp"}, {"tmophl7mts", {NULL}, 20046, "udp"}, {"mountd", {NULL}, 20048, "tcp"}, {"mountd", {NULL}, 20048, "udp"}, {"nfsrdma", {NULL}, 20049, "tcp"}, {"nfsrdma", {NULL}, 20049, "udp"}, {"nfsrdma", {NULL}, 20049, "sctp"}, {"tolfab", {NULL}, 20167, "tcp"}, {"tolfab", {NULL}, 20167, "udp"}, {"ipdtp-port", {NULL}, 20202, "tcp"}, {"ipdtp-port", {NULL}, 20202, "udp"}, {"ipulse-ics", {NULL}, 20222, "tcp"}, {"ipulse-ics", {NULL}, 20222, "udp"}, {"emwavemsg", {NULL}, 20480, "tcp"}, {"emwavemsg", {NULL}, 20480, "udp"}, {"track", {NULL}, 20670, "tcp"}, {"track", {NULL}, 20670, "udp"}, {"athand-mmp", {NULL}, 20999, "tcp"}, {"athand-mmp", {NULL}, 20999, "udp"}, {"irtrans", {NULL}, 21000, "tcp"}, {"irtrans", {NULL}, 21000, "udp"}, {"dfserver", {NULL}, 21554, "tcp"}, {"dfserver", {NULL}, 21554, "udp"}, {"vofr-gateway", {NULL}, 21590, "tcp"}, {"vofr-gateway", {NULL}, 21590, "udp"}, {"tvpm", {NULL}, 21800, "tcp"}, {"tvpm", {NULL}, 21800, "udp"}, {"webphone", {NULL}, 21845, "tcp"}, {"webphone", {NULL}, 21845, "udp"}, {"netspeak-is", {NULL}, 21846, "tcp"}, {"netspeak-is", {NULL}, 21846, "udp"}, {"netspeak-cs", {NULL}, 21847, "tcp"}, {"netspeak-cs", {NULL}, 21847, "udp"}, {"netspeak-acd", {NULL}, 21848, "tcp"}, {"netspeak-acd", {NULL}, 21848, "udp"}, {"netspeak-cps", {NULL}, 21849, "tcp"}, {"netspeak-cps", {NULL}, 21849, "udp"}, {"snapenetio", {NULL}, 22000, "tcp"}, {"snapenetio", {NULL}, 22000, "udp"}, {"optocontrol", {NULL}, 22001, "tcp"}, {"optocontrol", {NULL}, 22001, "udp"}, {"optohost002", {NULL}, 22002, "tcp"}, {"optohost002", {NULL}, 22002, "udp"}, {"optohost003", {NULL}, 22003, "tcp"}, {"optohost003", {NULL}, 22003, "udp"}, {"optohost004", {NULL}, 22004, "tcp"}, {"optohost004", {NULL}, 22004, "udp"}, {"optohost004", {NULL}, 22005, "tcp"}, {"optohost004", {NULL}, 22005, "udp"}, {"dcap", {NULL}, 22125, "tcp"}, {"gsidcap", {NULL}, 22128, "tcp"}, {"wnn6", {NULL}, 22273, "tcp"}, {"wnn6", {NULL}, 22273, "udp"}, {"cis", {NULL}, 22305, "tcp"}, {"cis", {NULL}, 22305, "udp"}, {"cis-secure", {NULL}, 22343, "tcp"}, {"cis-secure", {NULL}, 22343, "udp"}, {"WibuKey", {NULL}, 22347, "tcp"}, {"WibuKey", {NULL}, 22347, "udp"}, {"CodeMeter", {NULL}, 22350, "tcp"}, {"CodeMeter", {NULL}, 22350, "udp"}, {"vocaltec-wconf", {NULL}, 22555, "tcp"}, {"vocaltec-phone", {NULL}, 22555, "udp"}, {"talikaserver", {NULL}, 22763, "tcp"}, {"talikaserver", {NULL}, 22763, "udp"}, {"aws-brf", {NULL}, 22800, "tcp"}, {"aws-brf", {NULL}, 22800, "udp"}, {"brf-gw", {NULL}, 22951, "tcp"}, {"brf-gw", {NULL}, 22951, "udp"}, {"inovaport1", {NULL}, 23000, "tcp"}, {"inovaport1", {NULL}, 23000, "udp"}, {"inovaport2", {NULL}, 23001, "tcp"}, {"inovaport2", {NULL}, 23001, "udp"}, {"inovaport3", {NULL}, 23002, "tcp"}, {"inovaport3", {NULL}, 23002, "udp"}, {"inovaport4", {NULL}, 23003, "tcp"}, {"inovaport4", {NULL}, 23003, "udp"}, {"inovaport5", {NULL}, 23004, "tcp"}, {"inovaport5", {NULL}, 23004, "udp"}, {"inovaport6", {NULL}, 23005, "tcp"}, {"inovaport6", {NULL}, 23005, "udp"}, {"s102", {NULL}, 23272, "udp"}, {"elxmgmt", {NULL}, 23333, "tcp"}, {"elxmgmt", {NULL}, 23333, "udp"}, {"novar-dbase", {NULL}, 23400, "tcp"}, {"novar-dbase", {NULL}, 23400, "udp"}, {"novar-alarm", {NULL}, 23401, "tcp"}, {"novar-alarm", {NULL}, 23401, "udp"}, {"novar-global", {NULL}, 23402, "tcp"}, {"novar-global", {NULL}, 23402, "udp"}, {"aequus", {NULL}, 23456, "tcp"}, {"aequus-alt", {NULL}, 23457, "tcp"}, {"med-ltp", {NULL}, 24000, "tcp"}, {"med-ltp", {NULL}, 24000, "udp"}, {"med-fsp-rx", {NULL}, 24001, "tcp"}, {"med-fsp-rx", {NULL}, 24001, "udp"}, {"med-fsp-tx", {NULL}, 24002, "tcp"}, {"med-fsp-tx", {NULL}, 24002, "udp"}, {"med-supp", {NULL}, 24003, "tcp"}, {"med-supp", {NULL}, 24003, "udp"}, {"med-ovw", {NULL}, 24004, "tcp"}, {"med-ovw", {NULL}, 24004, "udp"}, {"med-ci", {NULL}, 24005, "tcp"}, {"med-ci", {NULL}, 24005, "udp"}, {"med-net-svc", {NULL}, 24006, "tcp"}, {"med-net-svc", {NULL}, 24006, "udp"}, {"filesphere", {NULL}, 24242, "tcp"}, {"filesphere", {NULL}, 24242, "udp"}, {"vista-4gl", {NULL}, 24249, "tcp"}, {"vista-4gl", {NULL}, 24249, "udp"}, {"ild", {NULL}, 24321, "tcp"}, {"ild", {NULL}, 24321, "udp"}, {"intel_rci", {NULL}, 24386, "tcp"}, {"intel_rci", {NULL}, 24386, "udp"}, {"tonidods", {NULL}, 24465, "tcp"}, {"tonidods", {NULL}, 24465, "udp"}, {"binkp", {NULL}, 24554, "tcp"}, {"binkp", {NULL}, 24554, "udp"}, {"canditv", {NULL}, 24676, "tcp"}, {"canditv", {NULL}, 24676, "udp"}, {"flashfiler", {NULL}, 24677, "tcp"}, {"flashfiler", {NULL}, 24677, "udp"}, {"proactivate", {NULL}, 24678, "tcp"}, {"proactivate", {NULL}, 24678, "udp"}, {"tcc-http", {NULL}, 24680, "tcp"}, {"tcc-http", {NULL}, 24680, "udp"}, {"cslg", {NULL}, 24754, "tcp"}, {"find", {NULL}, 24922, "tcp"}, {"find", {NULL}, 24922, "udp"}, {"icl-twobase1", {NULL}, 25000, "tcp"}, {"icl-twobase1", {NULL}, 25000, "udp"}, {"icl-twobase2", {NULL}, 25001, "tcp"}, {"icl-twobase2", {NULL}, 25001, "udp"}, {"icl-twobase3", {NULL}, 25002, "tcp"}, {"icl-twobase3", {NULL}, 25002, "udp"}, {"icl-twobase4", {NULL}, 25003, "tcp"}, {"icl-twobase4", {NULL}, 25003, "udp"}, {"icl-twobase5", {NULL}, 25004, "tcp"}, {"icl-twobase5", {NULL}, 25004, "udp"}, {"icl-twobase6", {NULL}, 25005, "tcp"}, {"icl-twobase6", {NULL}, 25005, "udp"}, {"icl-twobase7", {NULL}, 25006, "tcp"}, {"icl-twobase7", {NULL}, 25006, "udp"}, {"icl-twobase8", {NULL}, 25007, "tcp"}, {"icl-twobase8", {NULL}, 25007, "udp"}, {"icl-twobase9", {NULL}, 25008, "tcp"}, {"icl-twobase9", {NULL}, 25008, "udp"}, {"icl-twobase10", {NULL}, 25009, "tcp"}, {"icl-twobase10", {NULL}, 25009, "udp"}, {"rna", {NULL}, 25471, "sctp"}, {"sauterdongle", {NULL}, 25576, "tcp"}, {"vocaltec-hos", {NULL}, 25793, "tcp"}, {"vocaltec-hos", {NULL}, 25793, "udp"}, {"tasp-net", {NULL}, 25900, "tcp"}, {"tasp-net", {NULL}, 25900, "udp"}, {"niobserver", {NULL}, 25901, "tcp"}, {"niobserver", {NULL}, 25901, "udp"}, {"nilinkanalyst", {NULL}, 25902, "tcp"}, {"nilinkanalyst", {NULL}, 25902, "udp"}, {"niprobe", {NULL}, 25903, "tcp"}, {"niprobe", {NULL}, 25903, "udp"}, {"quake", {NULL}, 26000, "tcp"}, {"quake", {NULL}, 26000, "udp"}, {"scscp", {NULL}, 26133, "tcp"}, {"scscp", {NULL}, 26133, "udp"}, {"wnn6-ds", {NULL}, 26208, "tcp"}, {"wnn6-ds", {NULL}, 26208, "udp"}, {"ezproxy", {NULL}, 26260, "tcp"}, {"ezproxy", {NULL}, 26260, "udp"}, {"ezmeeting", {NULL}, 26261, "tcp"}, {"ezmeeting", {NULL}, 26261, "udp"}, {"k3software-svr", {NULL}, 26262, "tcp"}, {"k3software-svr", {NULL}, 26262, "udp"}, {"k3software-cli", {NULL}, 26263, "tcp"}, {"k3software-cli", {NULL}, 26263, "udp"}, {"exoline-tcp", {NULL}, 26486, "tcp"}, {"exoline-udp", {NULL}, 26486, "udp"}, {"exoconfig", {NULL}, 26487, "tcp"}, {"exoconfig", {NULL}, 26487, "udp"}, {"exonet", {NULL}, 26489, "tcp"}, {"exonet", {NULL}, 26489, "udp"}, {"imagepump", {NULL}, 27345, "tcp"}, {"imagepump", {NULL}, 27345, "udp"}, {"jesmsjc", {NULL}, 27442, "tcp"}, {"jesmsjc", {NULL}, 27442, "udp"}, {"kopek-httphead", {NULL}, 27504, "tcp"}, {"kopek-httphead", {NULL}, 27504, "udp"}, {"ars-vista", {NULL}, 27782, "tcp"}, {"ars-vista", {NULL}, 27782, "udp"}, {"tw-auth-key", {NULL}, 27999, "tcp"}, {"tw-auth-key", {NULL}, 27999, "udp"}, {"nxlmd", {NULL}, 28000, "tcp"}, {"nxlmd", {NULL}, 28000, "udp"}, {"pqsp", {NULL}, 28001, "tcp"}, {"siemensgsm", {NULL}, 28240, "tcp"}, {"siemensgsm", {NULL}, 28240, "udp"}, {"sgsap", {NULL}, 29118, "sctp"}, {"otmp", {NULL}, 29167, "tcp"}, {"otmp", {NULL}, 29167, "udp"}, {"sbcap", {NULL}, 29168, "sctp"}, {"iuhsctpassoc", {NULL}, 29169, "sctp"}, {"pago-services1", {NULL}, 30001, "tcp"}, {"pago-services1", {NULL}, 30001, "udp"}, {"pago-services2", {NULL}, 30002, "tcp"}, {"pago-services2", {NULL}, 30002, "udp"}, {"kingdomsonline", {NULL}, 30260, "tcp"}, {"kingdomsonline", {NULL}, 30260, "udp"}, {"ovobs", {NULL}, 30999, "tcp"}, {"ovobs", {NULL}, 30999, "udp"}, {"autotrac-acp", {NULL}, 31020, "tcp"}, {"yawn", {NULL}, 31029, "udp"}, {"xqosd", {NULL}, 31416, "tcp"}, {"xqosd", {NULL}, 31416, "udp"}, {"tetrinet", {NULL}, 31457, "tcp"}, {"tetrinet", {NULL}, 31457, "udp"}, {"lm-mon", {NULL}, 31620, "tcp"}, {"lm-mon", {NULL}, 31620, "udp"}, {"dsx_monitor", {NULL}, 31685, "tcp"}, {"gamesmith-port", {NULL}, 31765, "tcp"}, {"gamesmith-port", {NULL}, 31765, "udp"}, {"iceedcp_tx", {NULL}, 31948, "tcp"}, {"iceedcp_tx", {NULL}, 31948, "udp"}, {"iceedcp_rx", {NULL}, 31949, "tcp"}, {"iceedcp_rx", {NULL}, 31949, "udp"}, {"iracinghelper", {NULL}, 32034, "tcp"}, {"iracinghelper", {NULL}, 32034, "udp"}, {"t1distproc60", {NULL}, 32249, "tcp"}, {"t1distproc60", {NULL}, 32249, "udp"}, {"apm-link", {NULL}, 32483, "tcp"}, {"apm-link", {NULL}, 32483, "udp"}, {"sec-ntb-clnt", {NULL}, 32635, "tcp"}, {"sec-ntb-clnt", {NULL}, 32635, "udp"}, {"DMExpress", {NULL}, 32636, "tcp"}, {"DMExpress", {NULL}, 32636, "udp"}, {"filenet-powsrm", {NULL}, 32767, "tcp"}, {"filenet-powsrm", {NULL}, 32767, "udp"}, {"filenet-tms", {NULL}, 32768, "tcp"}, {"filenet-tms", {NULL}, 32768, "udp"}, {"filenet-rpc", {NULL}, 32769, "tcp"}, {"filenet-rpc", {NULL}, 32769, "udp"}, {"filenet-nch", {NULL}, 32770, "tcp"}, {"filenet-nch", {NULL}, 32770, "udp"}, {"filenet-rmi", {NULL}, 32771, "tcp"}, {"filenet-rmi", {NULL}, 32771, "udp"}, {"filenet-pa", {NULL}, 32772, "tcp"}, {"filenet-pa", {NULL}, 32772, "udp"}, {"filenet-cm", {NULL}, 32773, "tcp"}, {"filenet-cm", {NULL}, 32773, "udp"}, {"filenet-re", {NULL}, 32774, "tcp"}, {"filenet-re", {NULL}, 32774, "udp"}, {"filenet-pch", {NULL}, 32775, "tcp"}, {"filenet-pch", {NULL}, 32775, "udp"}, {"filenet-peior", {NULL}, 32776, "tcp"}, {"filenet-peior", {NULL}, 32776, "udp"}, {"filenet-obrok", {NULL}, 32777, "tcp"}, {"filenet-obrok", {NULL}, 32777, "udp"}, {"mlsn", {NULL}, 32801, "tcp"}, {"mlsn", {NULL}, 32801, "udp"}, {"retp", {NULL}, 32811, "tcp"}, {"idmgratm", {NULL}, 32896, "tcp"}, {"idmgratm", {NULL}, 32896, "udp"}, {"aurora-balaena", {NULL}, 33123, "tcp"}, {"aurora-balaena", {NULL}, 33123, "udp"}, {"diamondport", {NULL}, 33331, "tcp"}, {"diamondport", {NULL}, 33331, "udp"}, {"dgi-serv", {NULL}, 33333, "tcp"}, {"traceroute", {NULL}, 33434, "tcp"}, {"traceroute", {NULL}, 33434, "udp"}, {"snip-slave", {NULL}, 33656, "tcp"}, {"snip-slave", {NULL}, 33656, "udp"}, {"turbonote-2", {NULL}, 34249, "tcp"}, {"turbonote-2", {NULL}, 34249, "udp"}, {"p-net-local", {NULL}, 34378, "tcp"}, {"p-net-local", {NULL}, 34378, "udp"}, {"p-net-remote", {NULL}, 34379, "tcp"}, {"p-net-remote", {NULL}, 34379, "udp"}, {"dhanalakshmi", {NULL}, 34567, "tcp"}, {"profinet-rt", {NULL}, 34962, "tcp"}, {"profinet-rt", {NULL}, 34962, "udp"}, {"profinet-rtm", {NULL}, 34963, "tcp"}, {"profinet-rtm", {NULL}, 34963, "udp"}, {"profinet-cm", {NULL}, 34964, "tcp"}, {"profinet-cm", {NULL}, 34964, "udp"}, {"ethercat", {NULL}, 34980, "tcp"}, {"ethercat", {NULL}, 34980, "udp"}, {"allpeers", {NULL}, 36001, "tcp"}, {"allpeers", {NULL}, 36001, "udp"}, {"s1-control", {NULL}, 36412, "sctp"}, {"x2-control", {NULL}, 36422, "sctp"}, {"m2ap", {NULL}, 36443, "sctp"}, {"m3ap", {NULL}, 36444, "sctp"}, {"kastenxpipe", {NULL}, 36865, "tcp"}, {"kastenxpipe", {NULL}, 36865, "udp"}, {"neckar", {NULL}, 37475, "tcp"}, {"neckar", {NULL}, 37475, "udp"}, {"unisys-eportal", {NULL}, 37654, "tcp"}, {"unisys-eportal", {NULL}, 37654, "udp"}, {"galaxy7-data", {NULL}, 38201, "tcp"}, {"galaxy7-data", {NULL}, 38201, "udp"}, {"fairview", {NULL}, 38202, "tcp"}, {"fairview", {NULL}, 38202, "udp"}, {"agpolicy", {NULL}, 38203, "tcp"}, {"agpolicy", {NULL}, 38203, "udp"}, {"turbonote-1", {NULL}, 39681, "tcp"}, {"turbonote-1", {NULL}, 39681, "udp"}, {"safetynetp", {NULL}, 40000, "tcp"}, {"safetynetp", {NULL}, 40000, "udp"}, {"cscp", {NULL}, 40841, "tcp"}, {"cscp", {NULL}, 40841, "udp"}, {"csccredir", {NULL}, 40842, "tcp"}, {"csccredir", {NULL}, 40842, "udp"}, {"csccfirewall", {NULL}, 40843, "tcp"}, {"csccfirewall", {NULL}, 40843, "udp"}, {"ortec-disc", {NULL}, 40853, "udp"}, {"fs-qos", {NULL}, 41111, "tcp"}, {"fs-qos", {NULL}, 41111, "udp"}, {"tentacle", {NULL}, 41121, "tcp"}, {"crestron-cip", {NULL}, 41794, "tcp"}, {"crestron-cip", {NULL}, 41794, "udp"}, {"crestron-ctp", {NULL}, 41795, "tcp"}, {"crestron-ctp", {NULL}, 41795, "udp"}, {"candp", {NULL}, 42508, "tcp"}, {"candp", {NULL}, 42508, "udp"}, {"candrp", {NULL}, 42509, "tcp"}, {"candrp", {NULL}, 42509, "udp"}, {"caerpc", {NULL}, 42510, "tcp"}, {"caerpc", {NULL}, 42510, "udp"}, {"reachout", {NULL}, 43188, "tcp"}, {"reachout", {NULL}, 43188, "udp"}, {"ndm-agent-port", {NULL}, 43189, "tcp"}, {"ndm-agent-port", {NULL}, 43189, "udp"}, {"ip-provision", {NULL}, 43190, "tcp"}, {"ip-provision", {NULL}, 43190, "udp"}, {"noit-transport", {NULL}, 43191, "tcp"}, {"ew-mgmt", {NULL}, 43440, "tcp"}, {"ew-disc-cmd", {NULL}, 43440, "udp"}, {"ciscocsdb", {NULL}, 43441, "tcp"}, {"ciscocsdb", {NULL}, 43441, "udp"}, {"pmcd", {NULL}, 44321, "tcp"}, {"pmcd", {NULL}, 44321, "udp"}, {"pmcdproxy", {NULL}, 44322, "tcp"}, {"pmcdproxy", {NULL}, 44322, "udp"}, {"pcp", {NULL}, 44323, "udp"}, {"rbr-debug", {NULL}, 44553, "tcp"}, {"rbr-debug", {NULL}, 44553, "udp"}, {"EtherNet/IP-2", {NULL}, 44818, "tcp"}, {"EtherNet/IP-2", {NULL}, 44818, "udp"}, {"invision-ag", {NULL}, 45054, "tcp"}, {"invision-ag", {NULL}, 45054, "udp"}, {"eba", {NULL}, 45678, "tcp"}, {"eba", {NULL}, 45678, "udp"}, {"qdb2service", {NULL}, 45825, "tcp"}, {"qdb2service", {NULL}, 45825, "udp"}, {"ssr-servermgr", {NULL}, 45966, "tcp"}, {"ssr-servermgr", {NULL}, 45966, "udp"}, {"mediabox", {NULL}, 46999, "tcp"}, {"mediabox", {NULL}, 46999, "udp"}, {"mbus", {NULL}, 47000, "tcp"}, {"mbus", {NULL}, 47000, "udp"}, {"winrm", {NULL}, 47001, "tcp"}, {"dbbrowse", {NULL}, 47557, "tcp"}, {"dbbrowse", {NULL}, 47557, "udp"}, {"directplaysrvr", {NULL}, 47624, "tcp"}, {"directplaysrvr", {NULL}, 47624, "udp"}, {"ap", {NULL}, 47806, "tcp"}, {"ap", {NULL}, 47806, "udp"}, {"bacnet", {NULL}, 47808, "tcp"}, {"bacnet", {NULL}, 47808, "udp"}, {"nimcontroller", {NULL}, 48000, "tcp"}, {"nimcontroller", {NULL}, 48000, "udp"}, {"nimspooler", {NULL}, 48001, "tcp"}, {"nimspooler", {NULL}, 48001, "udp"}, {"nimhub", {NULL}, 48002, "tcp"}, {"nimhub", {NULL}, 48002, "udp"}, {"nimgtw", {NULL}, 48003, "tcp"}, {"nimgtw", {NULL}, 48003, "udp"}, {"nimbusdb", {NULL}, 48004, "tcp"}, {"nimbusdbctrl", {NULL}, 48005, "tcp"}, {"3gpp-cbsp", {NULL}, 48049, "tcp"}, {"isnetserv", {NULL}, 48128, "tcp"}, {"isnetserv", {NULL}, 48128, "udp"}, {"blp5", {NULL}, 48129, "tcp"}, {"blp5", {NULL}, 48129, "udp"}, {"com-bardac-dw", {NULL}, 48556, "tcp"}, {"com-bardac-dw", {NULL}, 48556, "udp"}, {"iqobject", {NULL}, 48619, "tcp"}, {"iqobject", {NULL}, 48619, "udp"}, #endif /* USE_IANA_REGISTERED_PORTS */ { NULL, {NULL}, 0, NULL } }; struct servent *getservbyport(int port, const char *proto) { unsigned short u_port; const char *protocol = NULL; int i, error = 0; u_port = ntohs((unsigned short)port); if (proto) { switch (strlen(proto)) { case 3: if (!strncasecmp(proto, "tcp", 3)) protocol = "tcp"; else if (!strncasecmp(proto, "udp", 3)) protocol = "udp"; else error = WSAEFAULT; break; case 4: if (!strncasecmp(proto, "sctp", 4)) protocol = "sctp"; else if (!strncasecmp(proto, "dccp", 4)) protocol = "dccp"; else error = WSAEFAULT; break; default: error = WSAEFAULT; } } if (!error) { for (i = 0; i < (sizeof(IANAports) / sizeof(IANAports[0])) - 1; i++) { if (u_port == IANAports[i].s_port) { if (!protocol || !strcasecmp(protocol, IANAports[i].s_proto)) return (struct servent *)&IANAports[i]; } } error = WSANO_DATA; } SET_SOCKERRNO(error); return NULL; } #endif /* _WIN32_WCE */ gevent-1.1.0/c-ares/ares_platform.h0000644000076500000000000000220112666555342017713 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_PLATFORM_H #define HEADER_CARES_PLATFORM_H /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004 - 2011 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #if defined(WIN32) && !defined(MSDOS) typedef enum { WIN_UNKNOWN, WIN_3X, WIN_9X, WIN_NT, WIN_CE } win_platform; win_platform ares__getplatform(void); #endif #if defined(_WIN32_WCE) struct servent *getservbyport(int port, const char *proto); #endif #endif /* HEADER_CARES_PLATFORM_H */ gevent-1.1.0/c-ares/ares_private.h0000644000076500000000000002423212666555342017551 0ustar jmaddenwheel00000000000000#ifndef __ARES_PRIVATE_H #define __ARES_PRIVATE_H /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004-2010 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* * Define WIN32 when build target is Win32 API */ #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) #define WIN32 #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef WATT32 #include #include #define writev(s,v,c) writev_s(s,v,c) #define HAVE_WRITEV 1 #endif #define DEFAULT_TIMEOUT 5000 /* milliseconds */ #define DEFAULT_TRIES 4 #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif #if defined(WIN32) && !defined(WATT32) #define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP" #define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters" #define NAMESERVER "NameServer" #define DHCPNAMESERVER "DhcpNameServer" #define DATABASEPATH "DatabasePath" #define WIN_PATH_HOSTS "\\hosts" #elif defined(WATT32) #define PATH_RESOLV_CONF "/dev/ENV/etc/resolv.conf" #elif defined(NETWARE) #define PATH_RESOLV_CONF "sys:/etc/resolv.cfg" #define PATH_HOSTS "sys:/etc/hosts" #elif defined(__riscos__) #define PATH_HOSTS "InetDBase:Hosts" #else #define PATH_RESOLV_CONF "/etc/resolv.conf" #ifdef ETC_INET #define PATH_HOSTS "/etc/inet/hosts" #else #define PATH_HOSTS "/etc/hosts" #endif #endif #define ARES_ID_KEY_LEN 31 #include "ares_ipv6.h" #include "ares_llist.h" #ifndef HAVE_GETENV # include "ares_getenv.h" # define getenv(ptr) ares_getenv(ptr) #endif #ifndef HAVE_STRDUP # include "ares_strdup.h" # define strdup(ptr) ares_strdup(ptr) #endif #ifndef HAVE_STRCASECMP # include "ares_strcasecmp.h" # define strcasecmp(p1,p2) ares_strcasecmp(p1,p2) #endif #ifndef HAVE_STRNCASECMP # include "ares_strcasecmp.h" # define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n) #endif #ifndef HAVE_WRITEV # include "ares_writev.h" # define writev(s,ptr,cnt) ares_writev(s,ptr,cnt) #endif /********* EDNS defines section ******/ #define EDNSPACKETSZ 1280 /* Reasonable UDP payload size, as suggested in RFC2671 */ #define MAXENDSSZ 4096 /* Maximum (local) limit for edns packet size */ #define EDNSFIXEDSZ 11 /* Size of EDNS header */ /********* EDNS defines section ******/ struct ares_addr { int family; union { struct in_addr addr4; struct ares_in6_addr addr6; } addr; }; #define addrV4 addr.addr4 #define addrV6 addr.addr6 struct query; struct send_request { /* Remaining data to send */ const unsigned char *data; size_t len; /* The query for which we're sending this data */ struct query* owner_query; /* The buffer we're using, if we have our own copy of the packet */ unsigned char *data_storage; /* Next request in queue */ struct send_request *next; }; struct server_state { struct ares_addr addr; ares_socket_t udp_socket; ares_socket_t tcp_socket; /* Mini-buffer for reading the length word */ unsigned char tcp_lenbuf[2]; int tcp_lenbuf_pos; int tcp_length; /* Buffer for reading actual TCP data */ unsigned char *tcp_buffer; int tcp_buffer_pos; /* TCP output queue */ struct send_request *qhead; struct send_request *qtail; /* Which incarnation of this connection is this? We don't want to * retransmit requests into the very same socket, but if the server * closes on us and we re-open the connection, then we do want to * re-send. */ int tcp_connection_generation; /* Circular, doubly-linked list of outstanding queries to this server */ struct list_node queries_to_server; /* Link back to owning channel */ ares_channel channel; /* Is this server broken? We mark connections as broken when a * request that is queued for sending times out. */ int is_broken; }; /* State to represent a DNS query */ struct query { /* Query ID from qbuf, for faster lookup, and current timeout */ unsigned short qid; struct timeval timeout; /* * Links for the doubly-linked lists in which we insert a query. * These circular, doubly-linked lists that are hash-bucketed based * the attributes we care about, help making most important * operations O(1). */ struct list_node queries_by_qid; /* hopefully in same cache line as qid */ struct list_node queries_by_timeout; struct list_node queries_to_server; struct list_node all_queries; /* Query buf with length at beginning, for TCP transmission */ unsigned char *tcpbuf; int tcplen; /* Arguments passed to ares_send() (qbuf points into tcpbuf) */ const unsigned char *qbuf; int qlen; ares_callback callback; void *arg; /* Query status */ int try_count; /* Number of times we tried this query already. */ int server; /* Server this query has last been sent to. */ struct query_server_info *server_info; /* per-server state */ int using_tcp; int error_status; int timeouts; /* number of timeouts we saw for this request */ }; /* Per-server state for a query */ struct query_server_info { int skip_server; /* should we skip server, due to errors, etc? */ int tcp_connection_generation; /* into which TCP connection did we send? */ }; /* An IP address pattern; matches an IP address X if X & mask == addr */ #define PATTERN_MASK 0x1 #define PATTERN_CIDR 0x2 struct apattern { union { struct in_addr addr4; struct ares_in6_addr addr6; } addr; union { struct in_addr addr4; struct ares_in6_addr addr6; unsigned short bits; } mask; int family; unsigned short type; }; typedef struct rc4_key { unsigned char state[256]; unsigned char x; unsigned char y; } rc4_key; struct ares_channeldata { /* Configuration data */ int flags; int timeout; /* in milliseconds */ int tries; int ndots; int rotate; /* if true, all servers specified are used */ int udp_port; int tcp_port; int socket_send_buffer_size; int socket_receive_buffer_size; char **domains; int ndomains; struct apattern *sortlist; int nsort; char *lookups; int ednspsz; /* For binding to local devices and/or IP addresses. Leave * them null/zero for no binding. */ char local_dev_name[32]; unsigned int local_ip4; unsigned char local_ip6[16]; int optmask; /* the option bitfield passed in at init time */ /* Server addresses and communications state */ struct server_state *servers; int nservers; /* ID to use for next query */ unsigned short next_id; /* key to use when generating new ids */ rc4_key id_key; /* Generation number to use for the next TCP socket open/close */ int tcp_connection_generation; /* The time at which we last called process_timeouts(). Uses integer seconds just to draw the line somewhere. */ time_t last_timeout_processed; /* Last server we sent a query to. */ int last_server; /* Circular, doubly-linked list of queries, bucketed various ways.... */ /* All active queries in a single list: */ struct list_node all_queries; /* Queries bucketed by qid, for quickly dispatching DNS responses: */ #define ARES_QID_TABLE_SIZE 2048 struct list_node queries_by_qid[ARES_QID_TABLE_SIZE]; /* Queries bucketed by timeout, for quickly handling timeouts: */ #define ARES_TIMEOUT_TABLE_SIZE 1024 struct list_node queries_by_timeout[ARES_TIMEOUT_TABLE_SIZE]; ares_sock_state_cb sock_state_cb; void *sock_state_cb_data; ares_sock_create_callback sock_create_cb; void *sock_create_cb_data; }; /* return true if now is exactly check time or later */ int ares__timedout(struct timeval *now, struct timeval *check); /* add the specific number of milliseconds to the time in the first argument */ int ares__timeadd(struct timeval *now, int millisecs); /* return time offset between now and (future) check, in milliseconds */ long ares__timeoffset(struct timeval *now, struct timeval *check); /* returns ARES_SUCCESS if library has been initialized */ int ares_library_initialized(void); void ares__send_query(ares_channel channel, struct query *query, struct timeval *now); void ares__close_sockets(ares_channel channel, struct server_state *server); int ares__get_hostent(FILE *fp, int family, struct hostent **host); int ares__read_line(FILE *fp, char **buf, size_t *bufsize); void ares__free_query(struct query *query); unsigned short ares__generate_new_id(rc4_key* key); struct timeval ares__tvnow(void); int ares__expand_name_for_response(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen); void ares__init_servers_state(ares_channel channel); void ares__destroy_servers_state(ares_channel channel); #if 0 /* Not used */ long ares__tvdiff(struct timeval t1, struct timeval t2); #endif #define ARES_SWAP_BYTE(a,b) \ { unsigned char swapByte = *(a); *(a) = *(b); *(b) = swapByte; } #define SOCK_STATE_CALLBACK(c, s, r, w) \ do { \ if ((c)->sock_state_cb) \ (c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \ } WHILE_FALSE #ifdef CURLDEBUG /* This is low-level hard-hacking memory leak tracking and similar. Using the libcurl lowlevel code from within library is ugly and only works when c-ares is built and linked with a similarly curldebug-enabled libcurl, but we do this anyway for convenience. */ #define HEADER_CURL_SETUP_ONCE_H #include "../lib/memdebug.h" #endif #endif /* __ARES_PRIVATE_H */ gevent-1.1.0/c-ares/ares_process.c0000644000076500000000000012205312666555342017550 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright (C) 2004-2013 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_SYS_UIO_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETINET_TCP_H # include #endif #ifdef HAVE_NETDB_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef NETWARE # include #endif #include #include #include "ares.h" #include "ares_dns.h" #include "ares_nowarn.h" #include "ares_private.h" static int try_again(int errnum); static void write_tcp_data(ares_channel channel, fd_set *write_fds, ares_socket_t write_fd, struct timeval *now); static void read_tcp_data(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, struct timeval *now); static void read_udp_packets(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, struct timeval *now); static void advance_tcp_send_queue(ares_channel channel, int whichserver, ssize_t num_bytes); static void process_timeouts(ares_channel channel, struct timeval *now); static void process_broken_connections(ares_channel channel, struct timeval *now); static void process_answer(ares_channel channel, unsigned char *abuf, int alen, int whichserver, int tcp, struct timeval *now); static void handle_error(ares_channel channel, int whichserver, struct timeval *now); static void skip_server(ares_channel channel, struct query *query, int whichserver); static void next_server(ares_channel channel, struct query *query, struct timeval *now); static int open_tcp_socket(ares_channel channel, struct server_state *server); static int open_udp_socket(ares_channel channel, struct server_state *server); static int same_questions(const unsigned char *qbuf, int qlen, const unsigned char *abuf, int alen); static int same_address(struct sockaddr *sa, struct ares_addr *aa); static void end_query(ares_channel channel, struct query *query, int status, unsigned char *abuf, int alen); /* return true if now is exactly check time or later */ int ares__timedout(struct timeval *now, struct timeval *check) { long secs = (now->tv_sec - check->tv_sec); if(secs > 0) return 1; /* yes, timed out */ if(secs < 0) return 0; /* nope, not timed out */ /* if the full seconds were identical, check the sub second parts */ return (now->tv_usec - check->tv_usec >= 0); } /* add the specific number of milliseconds to the time in the first argument */ int ares__timeadd(struct timeval *now, int millisecs) { now->tv_sec += millisecs/1000; now->tv_usec += (millisecs%1000)*1000; if(now->tv_usec >= 1000000) { ++(now->tv_sec); now->tv_usec -= 1000000; } return 0; } /* return time offset between now and (future) check, in milliseconds */ long ares__timeoffset(struct timeval *now, struct timeval *check) { return (check->tv_sec - now->tv_sec)*1000 + (check->tv_usec - now->tv_usec)/1000; } /* * generic process function */ static void processfds(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, fd_set *write_fds, ares_socket_t write_fd) { struct timeval now = ares__tvnow(); write_tcp_data(channel, write_fds, write_fd, &now); read_tcp_data(channel, read_fds, read_fd, &now); read_udp_packets(channel, read_fds, read_fd, &now); process_timeouts(channel, &now); process_broken_connections(channel, &now); } /* Something interesting happened on the wire, or there was a timeout. * See what's up and respond accordingly. */ void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds) { processfds(channel, read_fds, ARES_SOCKET_BAD, write_fds, ARES_SOCKET_BAD); } /* Something interesting happened on the wire, or there was a timeout. * See what's up and respond accordingly. */ void ares_process_fd(ares_channel channel, ares_socket_t read_fd, /* use ARES_SOCKET_BAD or valid file descriptors */ ares_socket_t write_fd) { processfds(channel, NULL, read_fd, NULL, write_fd); } /* Return 1 if the specified error number describes a readiness error, or 0 * otherwise. This is mostly for HP-UX, which could return EAGAIN or * EWOULDBLOCK. See this man page * * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html? * manpage=/usr/share/man/man2.Z/send.2 */ static int try_again(int errnum) { #if !defined EWOULDBLOCK && !defined EAGAIN #error "Neither EWOULDBLOCK nor EAGAIN defined" #endif switch (errnum) { #ifdef EWOULDBLOCK case EWOULDBLOCK: return 1; #endif #if defined EAGAIN && EAGAIN != EWOULDBLOCK case EAGAIN: return 1; #endif } return 0; } /* If any TCP sockets select true for writing, write out queued data * we have for them. */ static void write_tcp_data(ares_channel channel, fd_set *write_fds, ares_socket_t write_fd, struct timeval *now) { struct server_state *server; struct send_request *sendreq; struct iovec *vec; int i; ssize_t scount; ssize_t wcount; size_t n; if(!write_fds && (write_fd == ARES_SOCKET_BAD)) /* no possible action */ return; for (i = 0; i < channel->nservers; i++) { /* Make sure server has data to send and is selected in write_fds or write_fd. */ server = &channel->servers[i]; if (!server->qhead || server->tcp_socket == ARES_SOCKET_BAD || server->is_broken) continue; if(write_fds) { if(!FD_ISSET(server->tcp_socket, write_fds)) continue; } else { if(server->tcp_socket != write_fd) continue; } if(write_fds) /* If there's an error and we close this socket, then open * another with the same fd to talk to another server, then we * don't want to think that it was the new socket that was * ready. This is not disastrous, but is likely to result in * extra system calls and confusion. */ FD_CLR(server->tcp_socket, write_fds); /* Count the number of send queue items. */ n = 0; for (sendreq = server->qhead; sendreq; sendreq = sendreq->next) n++; /* Allocate iovecs so we can send all our data at once. */ vec = malloc(n * sizeof(struct iovec)); if (vec) { /* Fill in the iovecs and send. */ n = 0; for (sendreq = server->qhead; sendreq; sendreq = sendreq->next) { vec[n].iov_base = (char *) sendreq->data; vec[n].iov_len = sendreq->len; n++; } wcount = (ssize_t)writev(server->tcp_socket, vec, (int)n); free(vec); if (wcount < 0) { if (!try_again(SOCKERRNO)) handle_error(channel, i, now); continue; } /* Advance the send queue by as many bytes as we sent. */ advance_tcp_send_queue(channel, i, wcount); } else { /* Can't allocate iovecs; just send the first request. */ sendreq = server->qhead; scount = swrite(server->tcp_socket, sendreq->data, sendreq->len); if (scount < 0) { if (!try_again(SOCKERRNO)) handle_error(channel, i, now); continue; } /* Advance the send queue by as many bytes as we sent. */ advance_tcp_send_queue(channel, i, scount); } } } /* Consume the given number of bytes from the head of the TCP send queue. */ static void advance_tcp_send_queue(ares_channel channel, int whichserver, ssize_t num_bytes) { struct send_request *sendreq; struct server_state *server = &channel->servers[whichserver]; while (num_bytes > 0) { sendreq = server->qhead; if ((size_t)num_bytes >= sendreq->len) { num_bytes -= sendreq->len; server->qhead = sendreq->next; if (sendreq->data_storage) free(sendreq->data_storage); free(sendreq); if (server->qhead == NULL) { SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0); server->qtail = NULL; /* qhead is NULL so we cannot continue this loop */ break; } } else { sendreq->data += num_bytes; sendreq->len -= num_bytes; num_bytes = 0; } } } /* If any TCP socket selects true for reading, read some data, * allocate a buffer if we finish reading the length word, and process * a packet if we finish reading one. */ static void read_tcp_data(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, struct timeval *now) { struct server_state *server; int i; ssize_t count; if(!read_fds && (read_fd == ARES_SOCKET_BAD)) /* no possible action */ return; for (i = 0; i < channel->nservers; i++) { /* Make sure the server has a socket and is selected in read_fds. */ server = &channel->servers[i]; if (server->tcp_socket == ARES_SOCKET_BAD || server->is_broken) continue; if(read_fds) { if(!FD_ISSET(server->tcp_socket, read_fds)) continue; } else { if(server->tcp_socket != read_fd) continue; } if(read_fds) /* If there's an error and we close this socket, then open another * with the same fd to talk to another server, then we don't want to * think that it was the new socket that was ready. This is not * disastrous, but is likely to result in extra system calls and * confusion. */ FD_CLR(server->tcp_socket, read_fds); if (server->tcp_lenbuf_pos != 2) { /* We haven't yet read a length word, so read that (or * what's left to read of it). */ count = sread(server->tcp_socket, server->tcp_lenbuf + server->tcp_lenbuf_pos, 2 - server->tcp_lenbuf_pos); if (count <= 0) { if (!(count == -1 && try_again(SOCKERRNO))) handle_error(channel, i, now); continue; } server->tcp_lenbuf_pos += (int)count; if (server->tcp_lenbuf_pos == 2) { /* We finished reading the length word. Decode the * length and allocate a buffer for the data. */ server->tcp_length = server->tcp_lenbuf[0] << 8 | server->tcp_lenbuf[1]; server->tcp_buffer = malloc(server->tcp_length); if (!server->tcp_buffer) handle_error(channel, i, now); server->tcp_buffer_pos = 0; } } else { /* Read data into the allocated buffer. */ count = sread(server->tcp_socket, server->tcp_buffer + server->tcp_buffer_pos, server->tcp_length - server->tcp_buffer_pos); if (count <= 0) { if (!(count == -1 && try_again(SOCKERRNO))) handle_error(channel, i, now); continue; } server->tcp_buffer_pos += (int)count; if (server->tcp_buffer_pos == server->tcp_length) { /* We finished reading this answer; process it and * prepare to read another length word. */ process_answer(channel, server->tcp_buffer, server->tcp_length, i, 1, now); if (server->tcp_buffer) free(server->tcp_buffer); server->tcp_buffer = NULL; server->tcp_lenbuf_pos = 0; server->tcp_buffer_pos = 0; } } } } /* If any UDP sockets select true for reading, process them. */ static void read_udp_packets(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, struct timeval *now) { struct server_state *server; int i; ssize_t count; unsigned char buf[MAXENDSSZ + 1]; #ifdef HAVE_RECVFROM ares_socklen_t fromlen; union { struct sockaddr sa; struct sockaddr_in sa4; struct sockaddr_in6 sa6; } from; #endif if(!read_fds && (read_fd == ARES_SOCKET_BAD)) /* no possible action */ return; for (i = 0; i < channel->nservers; i++) { /* Make sure the server has a socket and is selected in read_fds. */ server = &channel->servers[i]; if (server->udp_socket == ARES_SOCKET_BAD || server->is_broken) continue; if(read_fds) { if(!FD_ISSET(server->udp_socket, read_fds)) continue; } else { if(server->udp_socket != read_fd) continue; } if(read_fds) /* If there's an error and we close this socket, then open * another with the same fd to talk to another server, then we * don't want to think that it was the new socket that was * ready. This is not disastrous, but is likely to result in * extra system calls and confusion. */ FD_CLR(server->udp_socket, read_fds); /* To reduce event loop overhead, read and process as many * packets as we can. */ do { if (server->udp_socket == ARES_SOCKET_BAD) count = 0; else { #ifdef HAVE_RECVFROM if (server->addr.family == AF_INET) fromlen = sizeof(from.sa4); else fromlen = sizeof(from.sa6); count = (ssize_t)recvfrom(server->udp_socket, (void *)buf, sizeof(buf), 0, &from.sa, &fromlen); #else count = sread(server->udp_socket, buf, sizeof(buf)); #endif } if (count == -1 && try_again(SOCKERRNO)) continue; else if (count <= 0) handle_error(channel, i, now); #ifdef HAVE_RECVFROM else if (!same_address(&from.sa, &server->addr)) /* The address the response comes from does not match the address we * sent the request to. Someone may be attempting to perform a cache * poisoning attack. */ break; #endif else process_answer(channel, buf, (int)count, i, 0, now); } while (count > 0); } } /* If any queries have timed out, note the timeout and move them on. */ static void process_timeouts(ares_channel channel, struct timeval *now) { time_t t; /* the time of the timeouts we're processing */ struct query *query; struct list_node* list_head; struct list_node* list_node; /* Process all the timeouts that have fired since the last time we processed * timeouts. If things are going well, then we'll have hundreds/thousands of * queries that fall into future buckets, and only a handful of requests * that fall into the "now" bucket, so this should be quite quick. */ for (t = channel->last_timeout_processed; t <= now->tv_sec; t++) { list_head = &(channel->queries_by_timeout[t % ARES_TIMEOUT_TABLE_SIZE]); for (list_node = list_head->next; list_node != list_head; ) { query = list_node->data; list_node = list_node->next; /* in case the query gets deleted */ if (query->timeout.tv_sec && ares__timedout(now, &query->timeout)) { query->error_status = ARES_ETIMEOUT; ++query->timeouts; next_server(channel, query, now); } } } channel->last_timeout_processed = now->tv_sec; } /* Handle an answer from a server. */ static void process_answer(ares_channel channel, unsigned char *abuf, int alen, int whichserver, int tcp, struct timeval *now) { int tc, rcode, packetsz; unsigned short id; struct query *query; struct list_node* list_head; struct list_node* list_node; /* If there's no room in the answer for a header, we can't do much * with it. */ if (alen < HFIXEDSZ) return; /* Grab the query ID, truncate bit, and response code from the packet. */ id = DNS_HEADER_QID(abuf); tc = DNS_HEADER_TC(abuf); rcode = DNS_HEADER_RCODE(abuf); /* Find the query corresponding to this packet. The queries are * hashed/bucketed by query id, so this lookup should be quick. Note that * both the query id and the questions must be the same; when the query id * wraps around we can have multiple outstanding queries with the same query * id, so we need to check both the id and question. */ query = NULL; list_head = &(channel->queries_by_qid[id % ARES_QID_TABLE_SIZE]); for (list_node = list_head->next; list_node != list_head; list_node = list_node->next) { struct query *q = list_node->data; if ((q->qid == id) && same_questions(q->qbuf, q->qlen, abuf, alen)) { query = q; break; } } if (!query) return; packetsz = PACKETSZ; /* If we use EDNS and server answers with one of these RCODES, the protocol * extension is not understood by the responder. We must retry the query * without EDNS enabled. */ if (channel->flags & ARES_FLAG_EDNS) { packetsz = channel->ednspsz; if (rcode == NOTIMP || rcode == FORMERR || rcode == SERVFAIL) { int qlen = alen - EDNSFIXEDSZ; channel->flags ^= ARES_FLAG_EDNS; query->tcplen -= EDNSFIXEDSZ; query->qlen -= EDNSFIXEDSZ; query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff); query->tcpbuf[1] = (unsigned char)(qlen & 0xff); DNS_HEADER_SET_ARCOUNT(query->tcpbuf + 2, 0); query->tcpbuf = realloc(query->tcpbuf, query->tcplen); ares__send_query(channel, query, now); return; } } /* If we got a truncated UDP packet and are not ignoring truncation, * don't accept the packet, and switch the query to TCP if we hadn't * done so already. */ if ((tc || alen > packetsz) && !tcp && !(channel->flags & ARES_FLAG_IGNTC)) { if (!query->using_tcp) { query->using_tcp = 1; ares__send_query(channel, query, now); } return; } /* Limit alen to PACKETSZ if we aren't using TCP (only relevant if we * are ignoring truncation. */ if (alen > packetsz && !tcp) alen = packetsz; /* If we aren't passing through all error packets, discard packets * with SERVFAIL, NOTIMP, or REFUSED response codes. */ if (!(channel->flags & ARES_FLAG_NOCHECKRESP)) { if (rcode == SERVFAIL || rcode == NOTIMP || rcode == REFUSED) { skip_server(channel, query, whichserver); if (query->server == whichserver) next_server(channel, query, now); return; } } end_query(channel, query, ARES_SUCCESS, abuf, alen); } /* Close all the connections that are no longer usable. */ static void process_broken_connections(ares_channel channel, struct timeval *now) { int i; for (i = 0; i < channel->nservers; i++) { struct server_state *server = &channel->servers[i]; if (server->is_broken) { handle_error(channel, i, now); } } } /* Swap the contents of two lists */ static void swap_lists(struct list_node* head_a, struct list_node* head_b) { int is_a_empty = ares__is_list_empty(head_a); int is_b_empty = ares__is_list_empty(head_b); struct list_node old_a = *head_a; struct list_node old_b = *head_b; if (is_a_empty) { ares__init_list_head(head_b); } else { *head_b = old_a; old_a.next->prev = head_b; old_a.prev->next = head_b; } if (is_b_empty) { ares__init_list_head(head_a); } else { *head_a = old_b; old_b.next->prev = head_a; old_b.prev->next = head_a; } } static void handle_error(ares_channel channel, int whichserver, struct timeval *now) { struct server_state *server; struct query *query; struct list_node list_head; struct list_node* list_node; server = &channel->servers[whichserver]; /* Reset communications with this server. */ ares__close_sockets(channel, server); /* Tell all queries talking to this server to move on and not try this * server again. We steal the current list of queries that were in-flight to * this server, since when we call next_server this can cause the queries to * be re-sent to this server, which will re-insert these queries in that * same server->queries_to_server list. */ ares__init_list_head(&list_head); swap_lists(&list_head, &(server->queries_to_server)); for (list_node = list_head.next; list_node != &list_head; ) { query = list_node->data; list_node = list_node->next; /* in case the query gets deleted */ assert(query->server == whichserver); skip_server(channel, query, whichserver); next_server(channel, query, now); } /* Each query should have removed itself from our temporary list as * it re-sent itself or finished up... */ assert(ares__is_list_empty(&list_head)); } static void skip_server(ares_channel channel, struct query *query, int whichserver) { /* The given server gave us problems with this query, so if we have the * luxury of using other servers, then let's skip the potentially broken * server and just use the others. If we only have one server and we need to * retry then we should just go ahead and re-use that server, since it's our * only hope; perhaps we just got unlucky, and retrying will work (eg, the * server timed out our TCP connection just as we were sending another * request). */ if (channel->nservers > 1) { query->server_info[whichserver].skip_server = 1; } } static void next_server(ares_channel channel, struct query *query, struct timeval *now) { /* We need to try each server channel->tries times. We have channel->nservers * servers to try. In total, we need to do channel->nservers * channel->tries * attempts. Use query->try to remember how many times we already attempted * this query. Use modular arithmetic to find the next server to try. */ while (++(query->try_count) < (channel->nservers * channel->tries)) { struct server_state *server; /* Move on to the next server. */ query->server = (query->server + 1) % channel->nservers; server = &channel->servers[query->server]; /* We don't want to use this server if (1) we decided this connection is * broken, and thus about to be closed, (2) we've decided to skip this * server because of earlier errors we encountered, or (3) we already * sent this query over this exact connection. */ if (!server->is_broken && !query->server_info[query->server].skip_server && !(query->using_tcp && (query->server_info[query->server].tcp_connection_generation == server->tcp_connection_generation))) { ares__send_query(channel, query, now); return; } /* You might think that with TCP we only need one try. However, even * when using TCP, servers can time-out our connection just as we're * sending a request, or close our connection because they die, or never * send us a reply because they get wedged or tickle a bug that drops * our request. */ } /* If we are here, all attempts to perform query failed. */ end_query(channel, query, query->error_status, NULL, 0); } void ares__send_query(ares_channel channel, struct query *query, struct timeval *now) { struct send_request *sendreq; struct server_state *server; int timeplus; server = &channel->servers[query->server]; if (query->using_tcp) { /* Make sure the TCP socket for this server is set up and queue * a send request. */ if (server->tcp_socket == ARES_SOCKET_BAD) { if (open_tcp_socket(channel, server) == -1) { skip_server(channel, query, query->server); next_server(channel, query, now); return; } } sendreq = calloc(1, sizeof(struct send_request)); if (!sendreq) { end_query(channel, query, ARES_ENOMEM, NULL, 0); return; } /* To make the common case fast, we avoid copies by using the query's * tcpbuf for as long as the query is alive. In the rare case where the * query ends while it's queued for transmission, then we give the * sendreq its own copy of the request packet and put it in * sendreq->data_storage. */ sendreq->data_storage = NULL; sendreq->data = query->tcpbuf; sendreq->len = query->tcplen; sendreq->owner_query = query; sendreq->next = NULL; if (server->qtail) server->qtail->next = sendreq; else { SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 1); server->qhead = sendreq; } server->qtail = sendreq; query->server_info[query->server].tcp_connection_generation = server->tcp_connection_generation; } else { if (server->udp_socket == ARES_SOCKET_BAD) { if (open_udp_socket(channel, server) == -1) { skip_server(channel, query, query->server); next_server(channel, query, now); return; } } if (swrite(server->udp_socket, query->qbuf, query->qlen) == -1) { /* FIXME: Handle EAGAIN here since it likely can happen. */ skip_server(channel, query, query->server); next_server(channel, query, now); return; } } timeplus = channel->timeout << (query->try_count / channel->nservers); timeplus = (timeplus * (9 + (rand () & 7))) / 16; query->timeout = *now; ares__timeadd(&query->timeout, timeplus); /* Keep track of queries bucketed by timeout, so we can process * timeout events quickly. */ ares__remove_from_list(&(query->queries_by_timeout)); ares__insert_in_list( &(query->queries_by_timeout), &(channel->queries_by_timeout[query->timeout.tv_sec % ARES_TIMEOUT_TABLE_SIZE])); /* Keep track of queries bucketed by server, so we can process server * errors quickly. */ ares__remove_from_list(&(query->queries_to_server)); ares__insert_in_list(&(query->queries_to_server), &(server->queries_to_server)); } /* * setsocknonblock sets the given socket to either blocking or non-blocking * mode based on the 'nonblock' boolean argument. This function is highly * portable. */ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ int nonblock /* TRUE or FALSE */) { #if defined(USE_BLOCKING_SOCKETS) return 0; /* returns success */ #elif defined(HAVE_FCNTL_O_NONBLOCK) /* most recent unix versions */ int flags; flags = fcntl(sockfd, F_GETFL, 0); if (FALSE != nonblock) return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); else return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); #elif defined(HAVE_IOCTL_FIONBIO) /* older unix versions */ int flags = nonblock ? 1 : 0; return ioctl(sockfd, FIONBIO, &flags); #elif defined(HAVE_IOCTLSOCKET_FIONBIO) #ifdef WATT32 char flags = nonblock ? 1 : 0; #else /* Windows */ unsigned long flags = nonblock ? 1UL : 0UL; #endif return ioctlsocket(sockfd, FIONBIO, &flags); #elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) /* Amiga */ long flags = nonblock ? 1L : 0L; return IoctlSocket(sockfd, FIONBIO, flags); #elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) /* BeOS */ long b = nonblock ? 1L : 0L; return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); #else # error "no non-blocking method was found/used/set" #endif } static int configure_socket(ares_socket_t s, int family, ares_channel channel) { union { struct sockaddr sa; struct sockaddr_in sa4; struct sockaddr_in6 sa6; } local; setsocknonblock(s, TRUE); #if defined(FD_CLOEXEC) && !defined(MSDOS) /* Configure the socket fd as close-on-exec. */ if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) return -1; #endif /* Set the socket's send and receive buffer sizes. */ if ((channel->socket_send_buffer_size > 0) && setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *)&channel->socket_send_buffer_size, sizeof(channel->socket_send_buffer_size)) == -1) return -1; if ((channel->socket_receive_buffer_size > 0) && setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *)&channel->socket_receive_buffer_size, sizeof(channel->socket_receive_buffer_size)) == -1) return -1; #ifdef SO_BINDTODEVICE if (channel->local_dev_name[0]) { if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, channel->local_dev_name, sizeof(channel->local_dev_name))) { /* Only root can do this, and usually not fatal if it doesn't work, so */ /* just continue on. */ } } #endif if (family == AF_INET) { if (channel->local_ip4) { memset(&local.sa4, 0, sizeof(local.sa4)); local.sa4.sin_family = AF_INET; local.sa4.sin_addr.s_addr = htonl(channel->local_ip4); if (bind(s, &local.sa, sizeof(local.sa4)) < 0) return -1; } } else if (family == AF_INET6) { if (memcmp(channel->local_ip6, &ares_in6addr_any, sizeof(channel->local_ip6)) != 0) { memset(&local.sa6, 0, sizeof(local.sa6)); local.sa6.sin6_family = AF_INET6; memcpy(&local.sa6.sin6_addr, channel->local_ip6, sizeof(channel->local_ip6)); if (bind(s, &local.sa, sizeof(local.sa6)) < 0) return -1; } } return 0; } static int open_tcp_socket(ares_channel channel, struct server_state *server) { ares_socket_t s; int opt; ares_socklen_t salen; union { struct sockaddr_in sa4; struct sockaddr_in6 sa6; } saddr; struct sockaddr *sa; switch (server->addr.family) { case AF_INET: sa = (void *)&saddr.sa4; salen = sizeof(saddr.sa4); memset(sa, 0, salen); saddr.sa4.sin_family = AF_INET; saddr.sa4.sin_port = aresx_sitous(channel->tcp_port); memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4, sizeof(server->addr.addrV4)); break; case AF_INET6: sa = (void *)&saddr.sa6; salen = sizeof(saddr.sa6); memset(sa, 0, salen); saddr.sa6.sin6_family = AF_INET6; saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port); memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6, sizeof(server->addr.addrV6)); break; default: return -1; } /* Acquire a socket. */ s = socket(server->addr.family, SOCK_STREAM, 0); if (s == ARES_SOCKET_BAD) return -1; /* Configure it. */ if (configure_socket(s, server->addr.family, channel) < 0) { sclose(s); return -1; } #ifdef TCP_NODELAY /* * Disable the Nagle algorithm (only relevant for TCP sockets, and thus not * in configure_socket). In general, in DNS lookups we're pretty much * interested in firing off a single request and then waiting for a reply, * so batching isn't very interesting. */ opt = 1; if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == -1) { sclose(s); return -1; } #endif /* Connect to the server. */ if (connect(s, sa, salen) == -1) { int err = SOCKERRNO; if (err != EINPROGRESS && err != EWOULDBLOCK) { sclose(s); return -1; } } if (channel->sock_create_cb) { int err = channel->sock_create_cb(s, SOCK_STREAM, channel->sock_create_cb_data); if (err < 0) { sclose(s); return err; } } SOCK_STATE_CALLBACK(channel, s, 1, 0); server->tcp_buffer_pos = 0; server->tcp_socket = s; server->tcp_connection_generation = ++channel->tcp_connection_generation; return 0; } static int open_udp_socket(ares_channel channel, struct server_state *server) { ares_socket_t s; ares_socklen_t salen; union { struct sockaddr_in sa4; struct sockaddr_in6 sa6; } saddr; struct sockaddr *sa; switch (server->addr.family) { case AF_INET: sa = (void *)&saddr.sa4; salen = sizeof(saddr.sa4); memset(sa, 0, salen); saddr.sa4.sin_family = AF_INET; saddr.sa4.sin_port = aresx_sitous(channel->udp_port); memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4, sizeof(server->addr.addrV4)); break; case AF_INET6: sa = (void *)&saddr.sa6; salen = sizeof(saddr.sa6); memset(sa, 0, salen); saddr.sa6.sin6_family = AF_INET6; saddr.sa6.sin6_port = aresx_sitous(channel->udp_port); memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6, sizeof(server->addr.addrV6)); break; default: return -1; } /* Acquire a socket. */ s = socket(server->addr.family, SOCK_DGRAM, 0); if (s == ARES_SOCKET_BAD) return -1; /* Set the socket non-blocking. */ if (configure_socket(s, server->addr.family, channel) < 0) { sclose(s); return -1; } /* Connect to the server. */ if (connect(s, sa, salen) == -1) { int err = SOCKERRNO; if (err != EINPROGRESS && err != EWOULDBLOCK) { sclose(s); return -1; } } if (channel->sock_create_cb) { int err = channel->sock_create_cb(s, SOCK_DGRAM, channel->sock_create_cb_data); if (err < 0) { sclose(s); return err; } } SOCK_STATE_CALLBACK(channel, s, 1, 0); server->udp_socket = s; return 0; } static int same_questions(const unsigned char *qbuf, int qlen, const unsigned char *abuf, int alen) { struct { const unsigned char *p; int qdcount; char *name; long namelen; int type; int dnsclass; } q, a; int i, j; if (qlen < HFIXEDSZ || alen < HFIXEDSZ) return 0; /* Extract qdcount from the request and reply buffers and compare them. */ q.qdcount = DNS_HEADER_QDCOUNT(qbuf); a.qdcount = DNS_HEADER_QDCOUNT(abuf); if (q.qdcount != a.qdcount) return 0; /* For each question in qbuf, find it in abuf. */ q.p = qbuf + HFIXEDSZ; for (i = 0; i < q.qdcount; i++) { /* Decode the question in the query. */ if (ares_expand_name(q.p, qbuf, qlen, &q.name, &q.namelen) != ARES_SUCCESS) return 0; q.p += q.namelen; if (q.p + QFIXEDSZ > qbuf + qlen) { free(q.name); return 0; } q.type = DNS_QUESTION_TYPE(q.p); q.dnsclass = DNS_QUESTION_CLASS(q.p); q.p += QFIXEDSZ; /* Search for this question in the answer. */ a.p = abuf + HFIXEDSZ; for (j = 0; j < a.qdcount; j++) { /* Decode the question in the answer. */ if (ares_expand_name(a.p, abuf, alen, &a.name, &a.namelen) != ARES_SUCCESS) { free(q.name); return 0; } a.p += a.namelen; if (a.p + QFIXEDSZ > abuf + alen) { free(q.name); free(a.name); return 0; } a.type = DNS_QUESTION_TYPE(a.p); a.dnsclass = DNS_QUESTION_CLASS(a.p); a.p += QFIXEDSZ; /* Compare the decoded questions. */ if (strcasecmp(q.name, a.name) == 0 && q.type == a.type && q.dnsclass == a.dnsclass) { free(a.name); break; } free(a.name); } free(q.name); if (j == a.qdcount) return 0; } return 1; } static int same_address(struct sockaddr *sa, struct ares_addr *aa) { void *addr1; void *addr2; if (sa->sa_family == aa->family) { switch (aa->family) { case AF_INET: addr1 = &aa->addrV4; addr2 = &((struct sockaddr_in *)sa)->sin_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV4)) == 0) return 1; /* match */ break; case AF_INET6: addr1 = &aa->addrV6; addr2 = &((struct sockaddr_in6 *)sa)->sin6_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV6)) == 0) return 1; /* match */ break; default: break; } } return 0; /* different */ } static void end_query (ares_channel channel, struct query *query, int status, unsigned char *abuf, int alen) { int i; /* First we check to see if this query ended while one of our send * queues still has pointers to it. */ for (i = 0; i < channel->nservers; i++) { struct server_state *server = &channel->servers[i]; struct send_request *sendreq; for (sendreq = server->qhead; sendreq; sendreq = sendreq->next) if (sendreq->owner_query == query) { sendreq->owner_query = NULL; assert(sendreq->data_storage == NULL); if (status == ARES_SUCCESS) { /* We got a reply for this query, but this queued sendreq * points into this soon-to-be-gone query's tcpbuf. Probably * this means we timed out and queued the query for * retransmission, then received a response before actually * retransmitting. This is perfectly fine, so we want to keep * the connection running smoothly if we can. But in the worst * case we may have sent only some prefix of the query, with * some suffix of the query left to send. Also, the buffer may * be queued on multiple queues. To prevent dangling pointers * to the query's tcpbuf and handle these cases, we just give * such sendreqs their own copy of the query packet. */ sendreq->data_storage = malloc(sendreq->len); if (sendreq->data_storage != NULL) { memcpy(sendreq->data_storage, sendreq->data, sendreq->len); sendreq->data = sendreq->data_storage; } } if ((status != ARES_SUCCESS) || (sendreq->data_storage == NULL)) { /* We encountered an error (probably a timeout, suggesting the * DNS server we're talking to is probably unreachable, * wedged, or severely overloaded) or we couldn't copy the * request, so mark the connection as broken. When we get to * process_broken_connections() we'll close the connection and * try to re-send requests to another server. */ server->is_broken = 1; /* Just to be paranoid, zero out this sendreq... */ sendreq->data = NULL; sendreq->len = 0; } } } /* Invoke the callback */ query->callback(query->arg, status, query->timeouts, abuf, alen); ares__free_query(query); /* Simple cleanup policy: if no queries are remaining, close all network * sockets unless STAYOPEN is set. */ if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries))) { for (i = 0; i < channel->nservers; i++) ares__close_sockets(channel, &channel->servers[i]); } } void ares__free_query(struct query *query) { /* Remove the query from all the lists in which it is linked */ ares__remove_from_list(&(query->queries_by_qid)); ares__remove_from_list(&(query->queries_by_timeout)); ares__remove_from_list(&(query->queries_to_server)); ares__remove_from_list(&(query->all_queries)); /* Zero out some important stuff, to help catch bugs */ query->callback = NULL; query->arg = NULL; /* Deallocate the memory associated with the query */ free(query->tcpbuf); free(query->server_info); free(query); } gevent-1.1.0/c-ares/ares_query.c0000644000076500000000000001166012666555342017240 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_private.h" struct qquery { ares_callback callback; void *arg; }; static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); static void rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len) { unsigned char x; unsigned char y; unsigned char* state; unsigned char xorIndex; short counter; x = key->x; y = key->y; state = &key->state[0]; for(counter = 0; counter < buffer_len; counter ++) { x = (unsigned char)((x + 1) % 256); y = (unsigned char)((state[x] + y) % 256); ARES_SWAP_BYTE(&state[x], &state[y]); xorIndex = (unsigned char)((state[x] + state[y]) % 256); buffer_ptr[counter] = (unsigned char)(buffer_ptr[counter]^state[xorIndex]); } key->x = x; key->y = y; } static struct query* find_query_by_id(ares_channel channel, unsigned short id) { unsigned short qid; struct list_node* list_head; struct list_node* list_node; DNS_HEADER_SET_QID(((unsigned char*)&qid), id); /* Find the query corresponding to this packet. */ list_head = &(channel->queries_by_qid[qid % ARES_QID_TABLE_SIZE]); for (list_node = list_head->next; list_node != list_head; list_node = list_node->next) { struct query *q = list_node->data; if (q->qid == qid) return q; } return NULL; } /* a unique query id is generated using an rc4 key. Since the id may already be used by a running query (as infrequent as it may be), a lookup is performed per id generation. In practice this search should happen only once per newly generated id */ static unsigned short generate_unique_id(ares_channel channel) { unsigned short id; do { id = ares__generate_new_id(&channel->id_key); } while (find_query_by_id(channel, id)); return (unsigned short)id; } unsigned short ares__generate_new_id(rc4_key* key) { unsigned short r=0; rc4(key, (unsigned char *)&r, sizeof(r)); return r; } void ares_query(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg) { struct qquery *qquery; unsigned char *qbuf; int qlen, rd, status; /* Compose the query. */ rd = !(channel->flags & ARES_FLAG_NORECURSE); status = ares_create_query(name, dnsclass, type, channel->next_id, rd, &qbuf, &qlen, (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0); if (status != ARES_SUCCESS) { if (qbuf != NULL) free(qbuf); callback(arg, status, 0, NULL, 0); return; } channel->next_id = generate_unique_id(channel); /* Allocate and fill in the query structure. */ qquery = malloc(sizeof(struct qquery)); if (!qquery) { ares_free_string(qbuf); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } qquery->callback = callback; qquery->arg = arg; /* Send it off. qcallback will be called when we get an answer. */ ares_send(channel, qbuf, qlen, qcallback, qquery); ares_free_string(qbuf); } static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct qquery *qquery = (struct qquery *) arg; unsigned int ancount; int rcode; if (status != ARES_SUCCESS) qquery->callback(qquery->arg, status, timeouts, abuf, alen); else { /* Pull the response code and answer count from the packet. */ rcode = DNS_HEADER_RCODE(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); /* Convert errors. */ switch (rcode) { case NOERROR: status = (ancount > 0) ? ARES_SUCCESS : ARES_ENODATA; break; case FORMERR: status = ARES_EFORMERR; break; case SERVFAIL: status = ARES_ESERVFAIL; break; case NXDOMAIN: status = ARES_ENOTFOUND; break; case NOTIMP: status = ARES_ENOTIMP; break; case REFUSED: status = ARES_EREFUSED; break; } qquery->callback(qquery->arg, status, timeouts, abuf, alen); } free(qquery); } gevent-1.1.0/c-ares/ares_rules.h0000644000076500000000000001130412666555342017225 0ustar jmaddenwheel00000000000000#ifndef __CARES_RULES_H #define __CARES_RULES_H /* Copyright (C) 2009 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* ================================================================ */ /* COMPILE TIME SANITY CHECKS */ /* ================================================================ */ /* * NOTE 1: * ------- * * All checks done in this file are intentionally placed in a public * header file which is pulled by ares.h when an application is * being built using an already built c-ares library. Additionally * this file is also included and used when building the library. * * If compilation fails on this file it is certainly sure that the * problem is elsewhere. It could be a problem in the ares_build.h * header file, or simply that you are using different compilation * settings than those used to build the library. * * Nothing in this file is intended to be modified or adjusted by the * c-ares library user nor by the c-ares library builder. * * Do not deactivate any check, these are done to make sure that the * library is properly built and used. * * You can find further help on the c-ares development mailing list: * http://cool.haxx.se/mailman/listinfo/c-ares/ * * NOTE 2 * ------ * * Some of the following compile time checks are based on the fact * that the dimension of a constant array can not be a negative one. * In this way if the compile time verification fails, the compilation * will fail issuing an error. The error description wording is compiler * dependent but it will be quite similar to one of the following: * * "negative subscript or subscript is too large" * "array must have at least one element" * "-1 is an illegal array size" * "size of array is negative" * * If you are building an application which tries to use an already * built c-ares library and you are getting this kind of errors on * this file, it is a clear indication that there is a mismatch between * how the library was built and how you are trying to use it for your * application. Your already compiled or binary library provider is the * only one who can give you the details you need to properly use it. */ /* * Verify that some macros are actually defined. */ #ifndef CARES_SIZEOF_LONG # error "CARES_SIZEOF_LONG definition is missing!" Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing #endif #ifndef CARES_TYPEOF_ARES_SOCKLEN_T # error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!" Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing #endif #ifndef CARES_SIZEOF_ARES_SOCKLEN_T # error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!" Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing #endif /* * Macros private to this header file. */ #define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1 #define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 /* * Verify that the size previously defined and expected for long * is the same as the one reported by sizeof() at compile time. */ typedef char __cares_rule_01__ [CareschkszEQ(long, CARES_SIZEOF_LONG)]; /* * Verify that the size previously defined and expected for * ares_socklen_t is actually the the same as the one reported * by sizeof() at compile time. */ typedef char __cares_rule_02__ [CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)]; /* * Verify at compile time that the size of ares_socklen_t as reported * by sizeof() is greater or equal than the one reported for int for * the current compilation. */ typedef char __cares_rule_03__ [CareschkszGE(ares_socklen_t, int)]; /* ================================================================ */ /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ /* ================================================================ */ /* * Get rid of macros private to this header file. */ #undef CareschkszEQ #undef CareschkszGE /* * Get rid of macros not intended to exist beyond this point. */ #undef CARES_PULL_WS2TCPIP_H #undef CARES_PULL_SYS_TYPES_H #undef CARES_PULL_SYS_SOCKET_H #undef CARES_TYPEOF_ARES_SOCKLEN_T #endif /* __CARES_RULES_H */ gevent-1.1.0/c-ares/ares_search.c0000644000076500000000000002254612666555342017345 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_STRINGS_H # include #endif #include "ares.h" #include "ares_private.h" struct search_query { /* Arguments passed to ares_search */ ares_channel channel; char *name; /* copied into an allocated buffer */ int dnsclass; int type; ares_callback callback; void *arg; int status_as_is; /* error status from trying as-is */ int next_domain; /* next search domain to try */ int trying_as_is; /* current query is for name as-is */ int timeouts; /* number of timeouts we saw for this request */ int ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */ }; static void search_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); static void end_squery(struct search_query *squery, int status, unsigned char *abuf, int alen); static int cat_domain(const char *name, const char *domain, char **s); static int single_domain(ares_channel channel, const char *name, char **s); void ares_search(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg) { struct search_query *squery; char *s; const char *p; int status, ndots; /* If name only yields one domain to search, then we don't have * to keep extra state, so just do an ares_query(). */ status = single_domain(channel, name, &s); if (status != ARES_SUCCESS) { callback(arg, status, 0, NULL, 0); return; } if (s) { ares_query(channel, s, dnsclass, type, callback, arg); free(s); return; } /* Allocate a search_query structure to hold the state necessary for * doing multiple lookups. */ squery = malloc(sizeof(struct search_query)); if (!squery) { callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } squery->channel = channel; squery->name = strdup(name); if (!squery->name) { free(squery); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } squery->dnsclass = dnsclass; squery->type = type; squery->status_as_is = -1; squery->callback = callback; squery->arg = arg; squery->timeouts = 0; squery->ever_got_nodata = 0; /* Count the number of dots in name. */ ndots = 0; for (p = name; *p; p++) { if (*p == '.') ndots++; } /* If ndots is at least the channel ndots threshold (usually 1), * then we try the name as-is first. Otherwise, we try the name * as-is last. */ if (ndots >= channel->ndots) { /* Try the name as-is first. */ squery->next_domain = 0; squery->trying_as_is = 1; ares_query(channel, name, dnsclass, type, search_callback, squery); } else { /* Try the name as-is last; start with the first search domain. */ squery->next_domain = 1; squery->trying_as_is = 0; status = cat_domain(name, channel->domains[0], &s); if (status == ARES_SUCCESS) { ares_query(channel, s, dnsclass, type, search_callback, squery); free(s); } else { /* failed, free the malloc()ed memory */ free(squery->name); free(squery); callback(arg, status, 0, NULL, 0); } } } static void search_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct search_query *squery = (struct search_query *) arg; ares_channel channel = squery->channel; char *s; squery->timeouts += timeouts; /* Stop searching unless we got a non-fatal error. */ if (status != ARES_ENODATA && status != ARES_ESERVFAIL && status != ARES_ENOTFOUND) end_squery(squery, status, abuf, alen); else { /* Save the status if we were trying as-is. */ if (squery->trying_as_is) squery->status_as_is = status; /* * If we ever get ARES_ENODATA along the way, record that; if the search * should run to the very end and we got at least one ARES_ENODATA, * then callers like ares_gethostbyname() may want to try a T_A search * even if the last domain we queried for T_AAAA resource records * returned ARES_ENOTFOUND. */ if (status == ARES_ENODATA) squery->ever_got_nodata = 1; if (squery->next_domain < channel->ndomains) { /* Try the next domain. */ status = cat_domain(squery->name, channel->domains[squery->next_domain], &s); if (status != ARES_SUCCESS) end_squery(squery, status, NULL, 0); else { squery->trying_as_is = 0; squery->next_domain++; ares_query(channel, s, squery->dnsclass, squery->type, search_callback, squery); free(s); } } else if (squery->status_as_is == -1) { /* Try the name as-is at the end. */ squery->trying_as_is = 1; ares_query(channel, squery->name, squery->dnsclass, squery->type, search_callback, squery); } else { if (squery->status_as_is == ARES_ENOTFOUND && squery->ever_got_nodata) { end_squery(squery, ARES_ENODATA, NULL, 0); } else end_squery(squery, squery->status_as_is, NULL, 0); } } } static void end_squery(struct search_query *squery, int status, unsigned char *abuf, int alen) { squery->callback(squery->arg, status, squery->timeouts, abuf, alen); free(squery->name); free(squery); } /* Concatenate two domains. */ static int cat_domain(const char *name, const char *domain, char **s) { size_t nlen = strlen(name); size_t dlen = strlen(domain); *s = malloc(nlen + 1 + dlen + 1); if (!*s) return ARES_ENOMEM; memcpy(*s, name, nlen); (*s)[nlen] = '.'; memcpy(*s + nlen + 1, domain, dlen); (*s)[nlen + 1 + dlen] = 0; return ARES_SUCCESS; } /* Determine if this name only yields one query. If it does, set *s to * the string we should query, in an allocated buffer. If not, set *s * to NULL. */ static int single_domain(ares_channel channel, const char *name, char **s) { size_t len = strlen(name); const char *hostaliases; FILE *fp; char *line = NULL; int status; size_t linesize; const char *p, *q; int error; /* If the name contains a trailing dot, then the single query is the name * sans the trailing dot. */ if (name[len - 1] == '.') { *s = strdup(name); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } if (!(channel->flags & ARES_FLAG_NOALIASES) && !strchr(name, '.')) { /* The name might be a host alias. */ hostaliases = getenv("HOSTALIASES"); if (hostaliases) { fp = fopen(hostaliases, "r"); if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { if (strncasecmp(line, name, len) != 0 || !ISSPACE(line[len])) continue; p = line + len; while (ISSPACE(*p)) p++; if (*p) { q = p + 1; while (*q && !ISSPACE(*q)) q++; *s = malloc(q - p + 1); if (*s) { memcpy(*s, p, q - p); (*s)[q - p] = 0; } free(line); fclose(fp); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } } free(line); fclose(fp); if (status != ARES_SUCCESS && status != ARES_EOF) return status; } else { error = ERRNO; switch(error) { case ENOENT: case ESRCH: break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", hostaliases)); *s = NULL; return ARES_EFILE; } } } } if (channel->flags & ARES_FLAG_NOSEARCH || channel->ndomains == 0) { /* No domain search to do; just try the name as-is. */ *s = strdup(name); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } *s = NULL; return ARES_SUCCESS; } gevent-1.1.0/c-ares/ares_send.c0000644000076500000000000000764412666555342017033 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_dns.h" #include "ares_private.h" void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, ares_callback callback, void *arg) { struct query *query; int i, packetsz; struct timeval now; /* Verify that the query is at least long enough to hold the header. */ if (qlen < HFIXEDSZ || qlen >= (1 << 16)) { callback(arg, ARES_EBADQUERY, 0, NULL, 0); return; } /* Allocate space for query and allocated fields. */ query = malloc(sizeof(struct query)); if (!query) { callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } query->tcpbuf = malloc(qlen + 2); if (!query->tcpbuf) { free(query); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } query->server_info = malloc(channel->nservers * sizeof(query->server_info[0])); if (!query->server_info) { free(query->tcpbuf); free(query); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } /* Compute the query ID. Start with no timeout. */ query->qid = DNS_HEADER_QID(qbuf); query->timeout.tv_sec = 0; query->timeout.tv_usec = 0; /* Form the TCP query buffer by prepending qlen (as two * network-order bytes) to qbuf. */ query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff); query->tcpbuf[1] = (unsigned char)(qlen & 0xff); memcpy(query->tcpbuf + 2, qbuf, qlen); query->tcplen = qlen + 2; /* Fill in query arguments. */ query->qbuf = query->tcpbuf + 2; query->qlen = qlen; query->callback = callback; query->arg = arg; /* Initialize query status. */ query->try_count = 0; /* Choose the server to send the query to. If rotation is enabled, keep track * of the next server we want to use. */ query->server = channel->last_server; if (channel->rotate == 1) channel->last_server = (channel->last_server + 1) % channel->nservers; for (i = 0; i < channel->nservers; i++) { query->server_info[i].skip_server = 0; query->server_info[i].tcp_connection_generation = 0; } packetsz = (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : PACKETSZ; query->using_tcp = (channel->flags & ARES_FLAG_USEVC) || qlen > packetsz; query->error_status = ARES_ECONNREFUSED; query->timeouts = 0; /* Initialize our list nodes. */ ares__init_list_node(&(query->queries_by_qid), query); ares__init_list_node(&(query->queries_by_timeout), query); ares__init_list_node(&(query->queries_to_server), query); ares__init_list_node(&(query->all_queries), query); /* Chain the query into the list of all queries. */ ares__insert_in_list(&(query->all_queries), &(channel->all_queries)); /* Keep track of queries bucketed by qid, so we can process DNS * responses quickly. */ ares__insert_in_list( &(query->queries_by_qid), &(channel->queries_by_qid[query->qid % ARES_QID_TABLE_SIZE])); /* Perform the first query action. */ now = ares__tvnow(); ares__send_query(channel, query, &now); } gevent-1.1.0/c-ares/ares_setup.h0000644000076500000000000001344312666555342017241 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_SETUP_H #define HEADER_CARES_SETUP_H /* Copyright (C) 2004 - 2012 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* * Define WIN32 when build target is Win32 API */ #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) #define WIN32 #endif /* * Include configuration script results or hand-crafted * configuration file for platforms which lack config tool. */ #ifdef HAVE_CONFIG_H #include "ares_config.h" #else #ifdef WIN32 #include "config-win32.h" #endif #endif /* HAVE_CONFIG_H */ /* ================================================================ */ /* Definition of preprocessor macros/symbols which modify compiler */ /* behaviour or generated code characteristics must be done here, */ /* as appropriate, before any system header file is included. It is */ /* also possible to have them defined in the config file included */ /* before this point. As a result of all this we frown inclusion of */ /* system header files in our config files, avoid this at any cost. */ /* ================================================================ */ /* * AIX 4.3 and newer needs _THREAD_SAFE defined to build * proper reentrant code. Others may also need it. */ #ifdef NEED_THREAD_SAFE # ifndef _THREAD_SAFE # define _THREAD_SAFE # endif #endif /* * Tru64 needs _REENTRANT set for a few function prototypes and * things to appear in the system header files. Unixware needs it * to build proper reentrant code. Others may also need it. */ #ifdef NEED_REENTRANT # ifndef _REENTRANT # define _REENTRANT # endif #endif /* ================================================================ */ /* If you need to include a system header file for your platform, */ /* please, do it beyond the point further indicated in this file. */ /* ================================================================ */ /* * c-ares external interface definitions are also used internally, * and might also include required system header files to define them. */ #include /* * Compile time sanity checks must also be done when building the library. */ #include /* ================================================================= */ /* No system header file shall be included in this file before this */ /* point. The only allowed ones are those included from ares_build.h */ /* ================================================================= */ /* * Include header files for windows builds before redefining anything. * Use this preproessor block only to include or exclude windows.h, * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs * to any other further and independent block. Under Cygwin things work * just as under linux (e.g. ) and the winsock headers should * never be included when __CYGWIN__ is defined. configure script takes * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. */ #ifdef HAVE_WINDOWS_H # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # ifdef HAVE_WINSOCK2_H # include # ifdef HAVE_WS2TCPIP_H # include # endif # else # ifdef HAVE_WINSOCK_H # include # endif # endif #endif /* * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else * define USE_WINSOCK to 1 if we have and use WINSOCK API, else * undefine USE_WINSOCK. */ #undef USE_WINSOCK #ifdef HAVE_WINSOCK2_H # define USE_WINSOCK 2 #else # ifdef HAVE_WINSOCK_H # define USE_WINSOCK 1 # endif #endif /* * Work-arounds for systems without configure support */ #ifndef HAVE_CONFIG_H #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__) #define HAVE_SYS_TIME_H #endif #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER) #define HAVE_UNISTD_H 1 #endif #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS) #define HAVE_SYS_UIO_H #endif #endif /* HAVE_CONFIG_H */ /* * Arg 2 type for gethostname in case it hasn't been defined in config file. */ #ifndef GETHOSTNAME_TYPE_ARG2 # ifdef USE_WINSOCK # define GETHOSTNAME_TYPE_ARG2 int # else # define GETHOSTNAME_TYPE_ARG2 size_t # endif #endif #ifdef __POCC__ # include # include # define ESRCH 3 #endif /* * Android does have the arpa/nameser.h header which is detected by configure * but it appears to be empty with recent NDK r7b / r7c, so we undefine here. */ #if (defined(ANDROID) || defined(__ANDROID__)) && defined(HAVE_ARPA_NAMESER_H) # undef HAVE_ARPA_NAMESER_H #endif /* * Recent autoconf versions define these symbols in ares_config.h. We don't * want them (since they collide with the libcurl ones when we build * --enable-debug) so we undef them again here. */ #undef PACKAGE_STRING #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME #undef VERSION #undef PACKAGE /* IPv6 compatibility */ #if !defined(HAVE_AF_INET6) #if defined(HAVE_PF_INET6) #define AF_INET6 PF_INET6 #else #define AF_INET6 AF_MAX+1 #endif #endif /* * Include macros and defines that should only be processed once. */ #ifndef __SETUP_ONCE_H #include "setup_once.h" #endif #endif /* HEADER_CARES_SETUP_H */ gevent-1.1.0/c-ares/ares_strcasecmp.c0000644000076500000000000000315012666555342020232 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares_strcasecmp.h" #ifndef HAVE_STRCASECMP int ares_strcasecmp(const char *a, const char *b) { #if defined(HAVE_STRCMPI) return strcmpi(a, b); #elif defined(HAVE_STRICMP) return stricmp(a, b); #else size_t i; for (i = 0; i < (size_t)-1; i++) { int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; if (c1 != c2) return c1-c2; if (!c1) break; } return 0; #endif } #endif #ifndef HAVE_STRNCASECMP int ares_strncasecmp(const char *a, const char *b, size_t n) { #if defined(HAVE_STRNCMPI) return strncmpi(a, b, n); #elif defined(HAVE_STRNICMP) return strnicmp(a, b, n); #else size_t i; for (i = 0; i < n; i++) { int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; if (c1 != c2) return c1-c2; if (!c1) break; } return 0; #endif } #endif gevent-1.1.0/c-ares/ares_strcasecmp.h0000644000076500000000000000200712666555342020237 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_STRCASECMP_H #define HEADER_CARES_STRCASECMP_H /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifndef HAVE_STRCASECMP extern int ares_strcasecmp(const char *a, const char *b); #endif #ifndef HAVE_STRNCASECMP extern int ares_strncasecmp(const char *a, const char *b, size_t n); #endif #endif /* HEADER_CARES_STRCASECMP_H */ gevent-1.1.0/c-ares/ares_strdup.c0000644000076500000000000000216212666555342017411 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares_strdup.h" #ifndef HAVE_STRDUP char *ares_strdup(const char *s1) { size_t sz; char * s2; if(s1) { sz = strlen(s1); if(sz < (size_t)-1) { sz++; if(sz < ((size_t)-1) / sizeof(char)) { s2 = malloc(sz * sizeof(char)); if(s2) { memcpy(s2, s1, sz * sizeof(char)); return s2; } } } } return (char *)NULL; } #endif gevent-1.1.0/c-ares/ares_strdup.h0000644000076500000000000000160112666555342017413 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_STRDUP_H #define HEADER_CARES_STRDUP_H /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifndef HAVE_STRDUP extern char *ares_strdup(const char *s1); #endif #endif /* HEADER_CARES_STRDUP_H */ gevent-1.1.0/c-ares/ares_strerror.c0000644000076500000000000000355312666555342017757 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include #include "ares.h" const char *ares_strerror(int code) { /* Return a string literal from a table. */ const char *errtext[] = { "Successful completion", "DNS server returned answer with no data", "DNS server claims query was misformatted", "DNS server returned general failure", "Domain name not found", "DNS server does not implement requested operation", "DNS server refused query", "Misformatted DNS query", "Misformatted domain name", "Unsupported address family", "Misformatted DNS reply", "Could not contact DNS servers", "Timeout while contacting DNS servers", "End of file", "Error reading file", "Out of memory", "Channel is being destroyed", "Misformatted string", "Illegal flags specified", "Given hostname is not numeric", "Illegal hints flags specified", "c-ares library initialization not yet performed", "Error loading iphlpapi.dll", "Could not find GetNetworkParams function", "DNS query cancelled" }; if(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext))) return errtext[code]; else return "unknown"; } gevent-1.1.0/c-ares/ares_timeout.c0000644000076500000000000000472012666555342017560 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_LIMITS_H #include #endif #include "ares.h" #include "ares_private.h" /* WARNING: Beware that this is linear in the number of outstanding * requests! You are probably far better off just calling ares_process() * once per second, rather than calling ares_timeout() to figure out * when to next call ares_process(). */ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv, struct timeval *tvbuf) { struct query *query; struct list_node* list_head; struct list_node* list_node; struct timeval now; struct timeval nextstop; long offset, min_offset; /* No queries, no timeout (and no fetch of the current time). */ if (ares__is_list_empty(&(channel->all_queries))) return maxtv; /* Find the minimum timeout for the current set of queries. */ now = ares__tvnow(); min_offset = -1; list_head = &(channel->all_queries); for (list_node = list_head->next; list_node != list_head; list_node = list_node->next) { query = list_node->data; if (query->timeout.tv_sec == 0) continue; offset = ares__timeoffset(&now, &query->timeout); if (offset < 0) offset = 0; if (min_offset == -1 || offset < min_offset) min_offset = offset; } /* If we found a minimum timeout and it's sooner than the one specified in * maxtv (if any), return it. Otherwise go with maxtv. */ if (min_offset != -1) { int ioffset = (min_offset > (long)INT_MAX) ? INT_MAX : (int)min_offset; nextstop.tv_sec = ioffset/1000; nextstop.tv_usec = (ioffset%1000)*1000; if (!maxtv || ares__timedout(maxtv, &nextstop)) { *tvbuf = nextstop; return tvbuf; } } return maxtv; } gevent-1.1.0/c-ares/ares_version.c0000644000076500000000000000023612666555342017555 0ustar jmaddenwheel00000000000000 #include "ares_setup.h" #include "ares.h" const char *ares_version(int *version) { if(version) *version = ARES_VERSION; return ARES_VERSION_STR; } gevent-1.1.0/c-ares/ares_version.h0000644000076500000000000000121012666555342017553 0ustar jmaddenwheel00000000000000 #ifndef ARES__VERSION_H #define ARES__VERSION_H /* This is the global package copyright */ #define ARES_COPYRIGHT "2004 - 2013 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 #define ARES_VERSION_MINOR 10 #define ARES_VERSION_PATCH 0 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ (ARES_VERSION_MINOR<<8)|\ (ARES_VERSION_PATCH)) #define ARES_VERSION_STR "1.10.0" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 # define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 #else # undef CARES_HAVE_ARES_LIBRARY_INIT # undef CARES_HAVE_ARES_LIBRARY_CLEANUP #endif #endif gevent-1.1.0/c-ares/ares_writev.c0000644000076500000000000000336312666555342017414 0ustar jmaddenwheel00000000000000 /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #ifdef HAVE_LIMITS_H # include #endif #include "ares.h" #include "ares_private.h" #ifndef HAVE_WRITEV ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) { char *buffer, *bp; int i; size_t bytes = 0; ssize_t result; /* Validate iovcnt */ if (iovcnt <= 0) { SET_ERRNO(EINVAL); return (-1); } /* Validate and find the sum of the iov_len values in the iov array */ for (i = 0; i < iovcnt; i++) { if (iov[i].iov_len > INT_MAX - bytes) { SET_ERRNO(EINVAL); return (-1); } bytes += iov[i].iov_len; } if (bytes == 0) return (0); /* Allocate a temporary buffer to hold the data */ buffer = malloc(bytes); if (!buffer) { SET_ERRNO(ENOMEM); return (-1); } /* Copy the data into buffer */ for (bp = buffer, i = 0; i < iovcnt; ++i) { memcpy (bp, iov[i].iov_base, iov[i].iov_len); bp += iov[i].iov_len; } /* Send buffer contents */ result = swrite(s, buffer, bytes); free(buffer); return (result); } #endif gevent-1.1.0/c-ares/ares_writev.h0000644000076500000000000000211412666555342017412 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_WRITEV_H #define HEADER_CARES_WRITEV_H /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "ares_setup.h" #include "ares.h" #ifndef HAVE_WRITEV /* Structure for scatter/gather I/O. */ struct iovec { void *iov_base; /* Pointer to data. */ size_t iov_len; /* Length of data. */ }; extern ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); #endif #endif /* HEADER_CARES_WRITEV_H */ gevent-1.1.0/c-ares/AUTHORS0000644000076500000000000000156612666555342015771 0ustar jmaddenwheel00000000000000c-ares is based on ares, and these are the people that have worked on it since the fork was made: Albert Chin Alexander Lazic Alexey Simak Andreas Rieke Andrew C. Morrow Ashish Sharma Ben Greear Ben Noordhuis BogDan Vatra Brad House Brad Spencer Bram Matthys Dan Fandrich Daniel Johnson Daniel Stenberg David Stuart Denis Bilenko Dima Tisnek Dirk Manske Dominick Meglio Doug Goldstein Duncan Wilcox Eino Tuominen Erik Kline George Neill Gisle Vanem Guenter Knauf Guilherme Balena Versiani Gunter Knauf Henrik Stoerner Jakub Hrozek James Bursa Jérémy Lal Marko Kreen Michael Wallner Mike Crowe Nick Alcock Nick Mathewson Patrik Thunstrom Peter Pentchev Phil Blundell Poul Thomas Lomholt Ravi Pratap Robin Cornelius Sebastian at basti79.de Shmulik Regev Stefan Bühler Steinar H. Gunderson Tofu Linden Tom Hughes Tor Arntsen Vlad Dinulescu William Ahern Yang Tse liren at vivisimo.com gevent-1.1.0/c-ares/bitncmp.c0000644000076500000000000000313712666555342016515 0ustar jmaddenwheel00000000000000 /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996,1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef HAVE_BITNCMP #include "ares_setup.h" #include "bitncmp.h" /* * int * bitncmp(l, r, n) * compare bit masks l and r, for n bits. * return: * -1, 1, or 0 in the libc tradition. * note: * network byte order assumed. this means 192.5.5.240/28 has * 0x11110000 in its fourth octet. * author: * Paul Vixie (ISC), June 1996 */ int ares__bitncmp(const void *l, const void *r, int n) { unsigned int lb, rb; int x, b; b = n / 8; x = memcmp(l, r, b); if (x || (n % 8) == 0) return (x); lb = ((const unsigned char *)l)[b]; rb = ((const unsigned char *)r)[b]; for (b = n % 8; b > 0; b--) { if ((lb & 0x80) != (rb & 0x80)) { if (lb & 0x80) return (1); return (-1); } lb <<= 1; rb <<= 1; } return (0); } #endif gevent-1.1.0/c-ares/bitncmp.h0000644000076500000000000000161112666555342016515 0ustar jmaddenwheel00000000000000#ifndef __ARES_BITNCMP_H #define __ARES_BITNCMP_H /* Copyright (C) 2005, 2013 by Dominick Meglio * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifndef HAVE_BITNCMP int ares__bitncmp(const void *l, const void *r, int n); #else #define ares__bitncmp(x,y,z) bitncmp(x,y,z) #endif #endif /* __ARES_BITNCMP_H */ gevent-1.1.0/c-ares/CHANGELOG.git0000644000076500000000000031041312666555342016707 0ustar jmaddenwheel00000000000000 cHangelog for the c-ares project. Generated with git2changes.pl Daniel Stenberg (24 Aug 2012) - [Gisle Vanem brought this change] adig: perror() doesn't work for socket errors on windows ... so print the SOCKERRNO instead - get_DNS_AdaptersAddresses: fix IPv6 parsing Use of the wrong define made the function not parse IPv6 addresses properly. Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-06/0028.shtml Reported by: Saúl Ibarra Corretgé - version: bumped to 1.10.0 Due to the newly added function: ares_create_query() - AUTHORS: synced with 83093ac450 Added 21 authors since this document was last updated - ares_create_query.3: mention when this is added - [hpopescu@ixiacom.com brought this change] Added new feature (rfc2671) - code police: fix indents, < 80 columns, reflowed comments Guenter Knauf (11 Jul 2012) - Cleaned up version awk script. Daniel Stenberg (30 Jun 2012) - [Gisle Vanem brought this change] read_udp_packets: bail out loop on bad sockets I can see that recvfrom() in ares_process.c many times is called with 'udp_socket' == ARES_SOCKET_BAD. The code takes care not to call recv/recvfrom with ARES_SOCKET_BAD in the outer-loop. So should the inner-loop. Yang Tse (29 Jun 2012) - cares-compilers.m4: remove -Wstrict-aliasing=3 from clang Currently it is unknown if there is any version of clang that actually supports -Wstrict-aliasing. What is known is that there are several that don't support it. - cares-compilers.m4: -Wstrict-aliasing=3 for warning enabled gcc and clang builds Daniel Stenberg (18 Jun 2012) - version: work towards 1.9.2 (at least) Version 1.9.1 (18 Jun 2012) Daniel Stenberg (18 Jun 2012) - RELEASE-NOTES: 1.9.1 coming up Version 1.9.0 (16 Jun 2012) Daniel Stenberg (16 Jun 2012) - ares_version.h: next version is 1.9.0 - [Marko Kreen brought this change] ares_data.h: ARES_DATATYPE_SOA_REPLY is added in 1.9.0 - RELEASE-NOTES: synced with 979bf951d Next release deemed to become 1.9.0 due to the new function - [Marko Kreen brought this change] SOA parser added I need to do SOA queries, so here is a parser for them. - ares_soa_reply: new struct - ares_malloc_data/ares_free_soa: ARES_DATATYPE_SOA_REPLY - ares_parse_soa_reply: actual function Yang Tse (14 Jun 2012) - Kill compiler warning - Fix libcares.pc generation for static MingW* cross builds Daniel Stenberg (21 May 2012) - [Nick Alcock brought this change] Fix UDP and TCP port byte order in saved options. The UDP and TCP port are stored in network byte order in the ares_channeldata, but are passed in to ares_init_options() in host byte order. Thus we must return them from ares_save_options() in host byte order too, or a duplicated channel will convert them again, leading to a nonfunctional channel and a mysterious connection refused error from ares_gethostbyname(). This breaks ares_dup(), thus the curl easy API when c-ares is used by curl, and thus all the curl easy API's users. Yang Tse (28 Apr 2012) - version: start working on 1.8.1-DEV Version 1.8.0 (27 Apr 2012) Daniel Stenberg (27 Apr 2012) - RELEASE-NOTES: call next 1.8 instead Since we added a function, let's use a stricter bumping scheme Yang Tse (25 Apr 2012) - INSTALL: some adjustments Daniel Stenberg (25 Apr 2012) - GIT-INFO: mention buildconf Yang Tse (25 Apr 2012) - INSTALL: remove more sections that don't apply to c-ares - ares_timeout.c: fix compiler warning Daniel Stenberg (25 Apr 2012) - [Ben Noordhuis brought this change] Makefile.m32: fix mingw32 build * add . to include path so ares_build.h is picked up * make ar configurable to ease cross-compiling - RELEASE-NOTES: added what's happened since 1.7.5 Guenter Knauf (22 Apr 2012) - Updated copyright year. Yang Tse (21 Apr 2012) - ares_init.c: Further refactoring of Windows system's DNS fetching code Guenter Knauf (20 Apr 2012) - Android: small changes to dns property part. Prefix prop vars; kill var; use DNS_PROP_NAME_PREFIX macro. - Handle CNAME-only in ares_parse_aaaa_reply(). posted to the c-ares list by Peter Griess . - Add support for multiple DNS servers on Android. Before, c-ares always used the first DNS server on Android, causing network problems if this DNS server was not available. Signed-off-by: Geert Uytterhoeven - Added INSTALL so it gets into tarballs. - Added some more ifdefs to silent compiler warnings. Yang Tse (17 Apr 2012) - INSTALL: remove a non c-ares section - cares-compilers.m4: -Wno-pedantic-ms-format for Windows gcc 4.5 builds When building a Windows target with gcc 4.5 or newer and strict compiler warnings enabled use -Wno-pedantic-ms-format in addition to other flags. - setup_once.h: tighten requirements for stdbool.h header inclusion Include stdbool.h only when it is available and configure is capable of detecting a proper 'bool' data type when the header is included. - configure: NATIVE_WINDOWS no longer defined in config file - cares-compilers.m4: double underscore decoration for visibility attribute - build adjustments: CARES_SYMBOL_HIDING no longer defined in config files configure script now provides conditional definitions for Makefile.am that result in CARES_SYMBOL_HIDING being defined by resulting makefiles when appropriate. - configure: Windows cross-compilation fixes CARES_BUILDING_LIBRARY and CARES_STATICLIB no longer defined in ares_config.h, configure will generate appropriate conditionals so that mentioned symbols get defined and used in Makefile derived from Makefile.am at compilation time. Guenter Knauf (17 Apr 2012) - Added INSTALL file adapted from libcurl. Not yet ready, and needs further edits. Yang Tse (16 Apr 2012) - ares_init.c: get_iphlpapi_dns_info() refactoring Guenter Knauf (16 Apr 2012) - Kill some more compiler warnings. - Kill compiler warning about unused var. - Fixed my last commit: wrong preprocessor directive. - Check for __ANDROID__ in addition to ANDROID macro. - Check for __ANDROID__ in addition to ANDROID macro. Posted to c-ares list by Wayne. - Fix for Android to disable useless arpa/nameser.h. - Fix for Android to include sys/select.h for fd_set. Yang Tse (17 Mar 2012) - ares_data.c: some NAPTR related fixes Daniel Stenberg (16 Mar 2012) - port numbers: convert them to network order! When the config options ARES_OPT_UDP_PORT or ARES_OPT_TCP_PORT are used, make sure to convert them to network byte order! Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-02/0004.shtml - white space cleanup - Keep code within 80 columns - Removed funny spaces after open paren and before closing paren - [Poul Thomas Lomholt brought this change] get_iphlpapi_dns_info: fix buffer overrun I experienced a buffer overrun exception in c-ares on Windows and tracked it down to be an error in the calculation of the 'left' variable in get_iphlpapi_dns_info(). I changed the variable type of 'left' to a _signed_ type because of the subtraction arithmetic; not sure if a long is the best choice - Merge pull request #7 from saghul/naptr Added support for parsing NAPTR records saghul (23 Feb 2012) - Added support for parsing NAPTR records Yang Tse (19 Jan 2012) - ares_init.c: fix compiler warning on winsock builds - configure: libtool 1.5 tweaks Daniel Stenberg (19 Dec 2011) - ares_timeout.3: fix the NAME section It was clearly a copy n' paste error Yang Tse (27 Sep 2011) - [Albert Chin brought this change] configure - m4: make CURL_CHECK_DEF ignore leading whitespace on symbol def When using Sun C compiler the preprocessor somehow inserts an extra space in front of replaced symbol, breaking CURL_CHECK_DEF macro. To workaround this, macro CURL_CHECK_DEF now ignores all leading whitespace in front of symbol substitution result. - ares_init.c: fix segfault triggered in ares_init_options() upon previous failure of init_by_defaults() and incomplete cleanup there. - ares_process.c: fix compiler warning - fix MSVC compiler warning 'conditional expression is constant' - setup_once.h cleanup and sync - [Denis Bilenko brought this change] ares_getnameinfo: fix random results with c-ares 1.7.5 In ares_getnameinfo memcpy did not copy enough bytes, causing it to return arbitrary memory contents as a result. - warnings: fix another 'conversion may lose significant bits' compiler warning - ares_dns.h: adjust DNS__16BIT and DNS__32BIT macro definitions Fixing compiler warnings existing definitions triggered on these. - ares_destroy.c: fix segfault in ares_destroy_options() Daniel Stenberg (21 Aug 2011) - ares_parse_srv_reply: silence compiler warnings ... by adding ugly typecasts. - CHANGES: generate from script The CHANGES file is now generated automatically with 'git2changes.pl', invoked by the maketgz script which is used to build release archives. The former human edited CHANGES file was renamed to CHANGES.0 in git. Yang Tse (21 Aug 2011) - Makefile.netware: SIZEOF_SHORT definition - warnings: fix some 'conversion may lose significant bits' compiler warnings - configure: fix symbol hiding usability check A more thorough test is done now in order to determine visibility attribute usability, given that some compilers don't support visibility attribute on all configurations. Daniel Stenberg (16 Aug 2011) - 1.7.6: start working... Version 1.7.5 (16 Aug 2011) Daniel Stenberg (16 Aug 2011) - CHANGES: synced for 1.7.5 release - RELEASE-NOTES: synced with bb4096effef7f000 Jakub Hrozek (15 Aug 2011) - Only fall back to AF_INET searches when looking for AF_UNSPEC addresses Yang Tse (10 Aug 2011) - [Gisle Vanem brought this change] ares_iphlpapi.h: Watcom C fix Added "!defined(_WS2DEF_)" since Watcom doesn't have a per type guard for the typedefs 'CSADDR_INFO' (that MingW has) or 'SOCKET_ADDRESS' (that MSVC has). But we can use the header-guard for instead. - [Gisle Vanem brought this change] Makefile.Watcom: * The 'NTDDI_VERSION' needs to be raised to 0x05010000 in order for SOCKADDR_STORAGE etc. to be typedefed. * Replaced '-dUSE_WATT32' with '-dWATT32'. * Added $(DEMOS) to the 'all' target and removed the 'demos' target to be consistent with e.g. Makefile.msvc etc. * 'ENABLE_IPV6' is no longer used. Hence removed the '%use_ipv6' construct. * object-file order seems to be important (Watcom v.19). Hence 'ares_getopt.obj' must be put after the .obj that references getopt(). - cares-compilers.m4: CARES_CONVERT_INCLUDE_TO_ISYSTEM adjustments Add CARES_CHECK_COMPILER as a requirement. Ensure macro does nothing unless GNU_C or CLANG compiler is used. This should allow usage of this macro in unforeseen placements. - config-win32.h: comments adjustments - followup - config-win32.h: comments adjustments Daniel Stenberg (5 Aug 2011) - [Tom Hughes brought this change] ares_parse_a_reply: fix memleak Yang Tse (29 Jul 2011) - cares-functions.m4 serial # bump - Revert "configure: additional flag checks for fcntl() and socket()" This reverts commit 5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7. - configure: additional flag checks for fcntl() and socket() - xc-translit.m4 fix quoting - configure: avoid direct usage of AS_TR_* macros - xc-translit.m4 provides transliteration macros with well defined behavior. Jakub Hrozek (15 Jun 2011) - Revert "Only fall back to AF_INET searches when looking for AF_UNSPEC addresses" This reverts commit b5823d65706af687c0e5110af8f0cfdcd068997d. This patch was not reviewed properly before pushing - Revert "Do not use sized constants in public headers" This reverts commit 22c01e96f7b2ae9923e1baa50bfe3c0d22297a7d. This is a Red Hat specific patch that does not belong into upstream - Use correct sizeof in ares_getnameinfo() - Do not leak rr_name on failures inside ares_parse_ptr_reply - Do not leak rr_name on failures inside ares_parse_a_reply - Do not leak rr_name on failures inside ares_parse_aaaa_reply - Do not leak rr_name on failures inside ares_parse_ns_reply - Fix incorrect sizeof() in ares_save_options - Fix incorrect allocation in ares_parse_ptr_reply() - Only fall back to AF_INET searches when looking for AF_UNSPEC addresses - Do not use sized constants in public headers Daniel Stenberg (13 Jun 2011) - [Jakub Hrozek brought this change] ares_free_hostent(NULL) should be a noop Yang Tse (8 Jun 2011) - configure: fix recvfrom 5th arg type qualifier detection (followup) - configure: fix recvfrom 5th arg type qualifier detection Additionally remove whitespace from EOL Daniel Stenberg (4 Jun 2011) - strlen: use size_t to receive the return Yang Tse (4 Jun 2011) - xlc: avoid preprocessor definition usage when linking - ares_nowarn: icc 9.1 workaround - ares_nowarn: header inclusion fix - ares_init: make ares_private.h last included header again - compiler warning: fix Fix compiler warning: conversion may lose significant bits - compiler warning: fix Fix compiler warning: variable was set but never used Fix compiler warning: clobber ignored - ares_iphlpapi: fix compiler warnings - winsock: compilation fixes Provide winsock iphlpapi alternative definitions to prevent compilation failures when using a variety of winsock header implementations. Daniel Stenberg (17 May 2011) - [David Stuart brought this change] IPv6-on-windows: find DNS servers correctly - man pages: docs for the c-ares utility programs - ares_parse_ns_reply.c: remove CVSism Yang Tse (27 Mar 2011) - build: fix header inclusion - getservbyport replacement for Win CE - renamed getplatform() to ares__getplatform() to avoid namespace pollution - configure: fix libtool warning Recent versions of libtool are now tracing usage of AC_CONFIG_MACRO_DIR macro and warn heavily when not used in configure script along with ACLOCAL_AMFLAGS in Makefile.am. So in order to make libtool happy while keeping backwards compatibility this is added. - adig: RFC4034 resource record type detection Can be tested with: adig -s 8.8.8.8 -t ANY example.com - nameser.h: RFC4034 resource record type definitions - build: move platform stuff to ares_platform.c and ares_platform.h - build: find out windows platform using GetVersionEx() - build: use getenv() replacement function for systems which lack it - setup_once: system error codes for Windows CE - ares_search: use ERRNO macro for portability sake - System's errno.h inclusion cleanup follow-up. System's errno.h is conditionally included from setup_once.h - Windows CE specific adjustment All versions of Windows CE support Winsock 1.1 - System's errno.h inclusion cleanup. System's errno.h is conditionally included from setup_once.h - ares_init: fix gethostname error detection on winsock platforms - configure: r-enable temporarily disabled detection of system's inet_ntop() Detection was temporarily disabled in commit 674e044ccb21f2f63537da53565fce868f Daniel Stenberg (15 Mar 2011) - configure: stop using the deprecated AM_INIT_AUTOMAKE syntax - [Gisle Vanem brought this change] Watt-32: use errno Make sure Watt-32 programs use 'errno' even on Win32 targets Guenter Knauf (18 Feb 2011) - Removed commented CLFAGS no longer needed. - Fixed CFLAGS for NetWare. Added -m32 to enable compilation with x86_64 compilers; added conditional to set -fpcc-struct-return only for gcc compiler. Daniel Stenberg (18 Feb 2011) - [Gisle Vanem brought this change] Watt32: fix server init Somewhere in the process, programs using the Watt-32 tcp/ip stack stopped working. - [Dima Tisnek brought this change] config_sortlist: (win32) missing else Without an else there, contents of "pat" that could have been successfully set just above, may be clobbered by successive unsuccessful calls to "xxx_pton" or "ip_addr". Yang Tse (17 Jan 2011) - Makefile.msvc: add a couple of VS version strings - Makefile.msvc: add a couple of VS version strings - build: add install target to Makefile.msvc Daniel Stenberg (27 Dec 2010) - ares_set_servers_csv: remove unused variables - init_by_resolv_conf: fix compiler warnings The code received the return codes in the 'status' variable without using it. Instead we just ignore those particular errors. - getv4: Value stored to 'dst' is never read - advance_tcp_send_queue: avoid NULL ptr dereference If given a too large 'num_bytes' value, it would cause a NULL ptr dereference. Instead the code will now break out of the loop at the end of the list. - [Peter Pentchev brought this change] configure: fix a bashism - cleanup: avoid unsafe typecasts Avoid the risk of reading 16bit data from an unaligned address by using a macro that is adapted for this. - [Stefan Bühler brought this change] ares_expand_name: Fix encoded length for indirect root Yang Tse (18 Dec 2010) - build: add some explicit file references to VS project files - config-win32: provide HAVE_ASSERT_H definition - build: include ares_nowarn in sample program VS project files - build: include ares_nowarn among SAMPLESOURCES and SAMPLEHEADERS - configure: temporarily disable detection of system's inet_ntop() This is done to allow compilation of ares_inet_ntop() by some daily builds picky compilers that otherwise do not need this function. - changes: mention last fix - ares_inet_ntop: remove definition and usage of macro SPRINTF Existing definition of SPRINTF always resulted in sprintf() being used, and sprintf() returning 'int' is already used throughout the library. - ares_inet_ntop: reapply changes from previous c-ares version (III) - Replace 'u_char' with 'unsigned char'. - Replace 'u_int' with 'unsigned int'. - use macros ERRNO and SET_ERRNO() for errno handling. - ares_inet_ntop: reapply changes from previous c-ares version (II) - Remove rcsid. - Adjust header file inclusions. - ares_inet_ntop used only on systems without a proper inet_ntop function. - ares_inet_ntop: reapply changes from previous c-ares version (I) - Replace tabs with spaces. - Use ANSI C style for function declarations and definitions. - Use sizeof with parentheses. - ares_inet_ntop: fix off by one error triggering out of bounds write ares_inet_ntop would trigger an out of bounds write when the representation of the address required 15 characters, due to not taking in account null termination character. Full import of inet_ntop.c from bind-9.5.3rc1 to pull additional fixes. - ares_nowarn: add conditional inclusion of assert.h header - fix compiler warning: conversion may lose significant bits - ares_inet_net_pton: fix non-rejection of some malformed literals ares_inet_net_pton would return wrong values when excessively large, and invalid, netmasks are used. Fixes are from bind-9.5.3rc1, issue also described in the WLB-2008080064 advisory. - setup_once: provide ISASCII macro - configure: inet_net_pton function check adjustments Define HAVE_INET_NET_PTON only when system's inet_net_pton function is IPv6 capable and is not affected by the WLB-2008080064 advisory. HAVE_INET_NET_PTON_IPV6 is no longer defined nor used. - ares_init: fix detection of semicolon comments in resolv.conf File resolv.conf may either use a hash '#' or a semicolon ';' character as an indication that the rest of the line is a comment. This fixes not recognizing the semicolon as a valid comment indicator in resolv.conf. - version: start working on 1.7.5 Version 1.7.4 (8 Dec 2010) Daniel Stenberg (8 Dec 2010) - release-preps: CHANGES and RELEASE-NOTES synced - ares_set_local_*: added in 1.7.4, not before Yang Tse (3 Dec 2010) - build: provide SIZEOF_SIZE_T definition for non-configure builds - build: config.dos renamed to config-dos.h - build: provide SIZEOF_SIZE_T netware definition - ares_gethostbyaddr: fix compiler warning: conversion may lose significant bits - configure: undo using autobuilds to temporarily verify strict aliasing warnings. - fix compiler warning: rounding, sign extension, or loss of accuracy may result Daniel Stenberg (2 Dec 2010) - [Ben Noordhuis brought this change] ares_parse_a_reply: fix CNAME response parsing Reply to a CNAME query doesn't contain addresses, causing ares_parse_a_reply() to bail out with ARES_ENODATA Bug: http://groups.google.com/group/nodejs/browse_thread/thread/a1268c9ea5e9ad9b Yang Tse (1 Dec 2010) - fix compiler warning: conversion may lose significant bits - atoi: remove atoi usage - ares_init: fix compiler warning: conversion may lose significant bits - configure: fix autoconf warning - inet_pton: fix compiler warning - configure: use autobuilds to temporarily verify strict aliasing warnings. Temporarily, When cross-compiling with gcc 3.0 or later, enable strict aliasing rules and warnings. Given that cross-compiled targets autobuilds do not run the test-suite, there is no risk of running code that violates strict aliasing rules - ares_getnameinfo: Partially revert commit 85520d66e0ac7ac73411bc25e98769a88b2f Upon socket address family and length validation failure return ARES_ENOTIMP in callback again, this is the error code documented in man page and used mostly all over the library. - ares_getnameinfo: Validate socket address family and length. Validate socket address family and that the socket address length is appropriate for the specified family. Failure is reported with ARES_EBADFAMILY in callback. - ares_getnameinfo: fix two compiler warnings - Added another VS10 version string - Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. - Revert commit 494274e653936335c255a47599970de3df21e7c4 - configure: fix autoconf 2.68 warning: no AC_LANG_SOURCE call detected in body - Fix compiler warning: array subscript has type 'char' - Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. - Revert following commits: 07bc7ea79509bcc9ef6e09151e81766ed00d3392 3392a50ea3f8573ea4b7a9d82b9833dab60cb0e9 9912637d32c9987719a1ea12db591aee2941891c The purpose of the whole patch was to silence a compiler warning triggered with GCC 4 on file ares_process.c The specific compiler warning was 'dereferencing type-punned pointer might break strict-aliasing rules'. A simpler patch will follow to equally silence the warning. - ares_options: reorder header inclusions to make inclusion of ares_private.h the last included one again. Daniel Stenberg (12 Nov 2010) - [Patrik Thunstrom brought this change] adig: fix NAPTR parsing I ran across a small "issue" in your adig example. It is simply the last part of the NAPTR record, the replacement element, which is not a string, as currently handled in adig, but a domain name. - ares_save_options: assignments instead of memcpy - init_by_options: don't copy an empty sortlist If there aren't any sort items to copy, don't bother. Without this little precaution it would do a malloc(0) which causes undefined behaviors and is frowned upon by curl's memdebug-system. Guenter Knauf (3 Oct 2010) - Minor Watcom makefile tweaks. Daniel Stenberg (30 Sep 2010) - [Mike Crowe brought this change] Fix lookup with HOSTALIASES set. ares__read_line returns ARES_EOF when it reaches the end of the file. This will happen every time when reading to the end of the HOSTALIASES file. Unfortunately single_domain treats this error as being fatal. Signed-off-by: Mike Crowe Ben Greear (24 Aug 2010) - Add missing break that caused get_ares_servers to fail. Reported-by: Ning Dong Signed-off-by: Ben Greear Yang Tse (11 Aug 2010) - configure: werror related adjustments Guenter Knauf (8 Aug 2010) - Added copyright string to ares_version.h and make use of it in other files. - Block created ares_build.h for NetWare to avoid usage from other platforms. - Fix to overwrite default libname. - Some more Watcom makefile massage ... - Some more Watcom makefile massage ... Ben Greear (4 Aug 2010) - sock-addr-storage: Detect and deal with lack of .ss_family member. AIX, at least, does not have sockaddr_storage.ss_family member. Detect this in the configure logic and use proper #ifdefs in the ares_process logic. Signed-off-by: Ben Greear Tested-by: Tor Arntsen Guenter Knauf (3 Aug 2010) - Added Watcom makefile based on libcurl's Makefile.Watcom. Ben Greear (31 Jul 2010) - typo: Fix compile bug for platforms that don't have sockaddr_storage. Bug was introduced by me in previous commit. Signed-off-by: Ben Greear - Fix aliasing warning in gcc 4.4.4 (at least). Should be no functional change, though the code gets a bit ugglier. Signed-off-by: Ben Greear Daniel Stenberg (31 Jul 2010) - ares_set_servers_csv: use ISDIGIT The IS*() set of macros are preferred to the regular is*() functions as they help us avoid the most common pitfalls. Ben Greear (30 Jul 2010) - cast arg to isdigit to int Looks like it might silence a warning on Netware build. Signed-off-by: Ben Greear - remove all uses of uint32_t Previous fix forgot a few. Signed-off-by: Ben Greear - fix signed v/s unsigned casts warning in ares_gethostbyaddr.c Signed-off-by: Ben Greear - local-bind-fixup: Fix inet_pton warning. Conditionally include for inet_pton headers. Signed-off-by: Ben Greear - build: Enable compiling with -Werror. This helps find compile warnings because they simply break the build. To use: ./configure --enable-warnings --enable-werror Signed-off-by: Ben Greear - ipv6: Fix some build issues related to the local-bind feature. Signed-off-by: Ben Greear Guenter Knauf (29 Jul 2010) - Replaced uint32_t with unsigned int to fix broken builds on a couple of platforms. Daniel Stenberg (18 Jul 2010) - [Ben Greear brought this change] local-bind: Support binding to local interface/IPs Add 3 new functions to set the local binding for the out-going socket connection, and add ares_set_servers_csv() to set a list of servers at once as a comma-separated string. Signed-off-by: Ben Greear - version: now start on 1.7.4 - [Andrew C. Morrow brought this change] fix memory leak in ares_getnameinfo Version 1.7.3 (11 Jun 2010) Daniel Stenberg (11 Jun 2010) - changelogs: updated for 1.7.3 - [BogDan Vatra brought this change] init: allow c-ares to work on Android OS - changelog: fill in the 1.7.2 changes - added another pdf to ignore Yang Tse (11 Jun 2010) - add ares_parse_mx_reply.c to VS dsp file Daniel Stenberg (10 Jun 2010) - tarball: add $(CSOURCES) $(HHEADERS) to EXTRA_DIST It's not clear to me why we need this, but we apparently may otherwise not get all files bundled in the dist tarball. - version: start working on 1.7.3 Version 1.7.2 (10 Jun 2010) Daniel Stenberg (10 Jun 2010) - RELEASE-NOTES: 1.7.2 details added - [Jakub Hrozek brought this change] ares_init: Last, not first instance of domain or search should win - style: make code less than 80 columns wide Yang Tse (31 May 2010) - [Tor Arntsen brought this change] improve alternative definition of bool to use enum instead of unsigned char - fix VS2010 compiler warnings Daniel Stenberg (18 Apr 2010) - [Jérémy Lal brought this change] added ares_parse_mx_reply - repair the file mode - remove all $Id$ lines - remove all .cvsignore files - spell fix reported by Gregor Jasny on the mailing list - [Peter Pentchev brought this change] Fix a couple of typos and grammar nits. - ignore the GPG signature files too - start the journey towards 1.7.2 - no longer CVS tagging - ignore generated PDFs Version 1.7.1 (23 Mar 2010) Daniel Stenberg (23 Mar 2010) - 1.7.1 - made README the primary readme file ... and did README.cares to contain a historic reason etc. - s/CVS/git - git now, not CVS - ignore lots of generated files - [Daniel Johnson brought this change] Fix warnings for clang Yang Tse (17 Mar 2010) - replaced intel compiler option -no-ansi-alias with -fno-strict-aliasing - update outdated serial number - fix compiler warning - watt32 compilation fix - Added another VS10 version string - fix line break - removed usage of 's6_addr', fixing compilation issue triggered with no longer using 'in6_addr' but only our 'ares_in6_addr' struct Daniel Stenberg (5 Mar 2010) - Daniel Johnson provided fixes for building with the clang compiler Yang Tse (5 Mar 2010) - Added IPv6 name servers support Gisle Vanem (5 Mar 2010) - Ops!. Readded ares_nowarn.h. - Added ares_nowarn.c. Yang Tse (28 Feb 2010) - Added SIZEOF_INT and SIZEOF_SHORT definitions for non-configure systems - Added ares_nowarn.* to VC6 project file - Added SIZEOF_INT definition - fix compiler warning - fix compiler warning - fix compiler warning Daniel Stenberg (17 Feb 2010) - ares_reinit() - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much like the res_init() resolver function offers - - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't check for broken connections like ares_process() did. Based on that, I merged the two functions into a single generic one with two front-ends. Yang Tse (30 Dec 2009) - VMS specific preprocessor symbol checking adjustments - Mention last changes - - Fix configure_socket() to use ares_socket_t instead of int data type. - - Where run-time error checks enabling compiler option /GZ was used it is now replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions. - Compiler option /GX is now replaced with equivalent /EHsc for all versions. - - Ingmar Runge noticed that Windows config-win32.h configuration file did not include a definition for HAVE_CLOSESOCKET which resulted in function close() being inappropriately used to close sockets. Daniel Stenberg (30 Nov 2009) - start working on 1.7.1 Version 1.7.0 (27 Nov 2009) Yang Tse (27 Nov 2009) - Preserve empty line following last target - - Larry Lansing fixed ares_parse_srv_reply to properly parse replies which might contain non-SRV answers, skipping over potential non-SRV ones such as CNAMEs. - When using icc, compile with -fpic and link with intel dynamic libraries. - Added 'currently' in italics to insist on transient situation. - Fix language - Daniel wants upcoming release to be 1.7.0 - Mention last changes - - Removed from external interface preprocessor symbol definition for CARES_HAVE_ARES_FREE_DATA. Current functionality of ares_free_data() makes it unnecessary. - Added README.msvc - Changed c-ares naming conventions when using MSVC as described in README.msvc - - Mention other recent changes - - Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and ares_addr6ttl in order to prevent name space pollution, along with necessary changes to code base and man pages.This change does not break ABI, there is no need to recompile existing applications. But existing applications using these structs with the old name will need source code adjustments when recompiled using c-ares 1.6.1. - - Jakub Hrozek fixed more function prototypes in man pages to sync them with the ones declared in ares.h - Make configure remove the ares_build.h file included in distribution tarballs. - Fix macro redefinition. - Fix name space pollution. - Allow using different extra import libraries for debug and release builds. - Add manifest stuff to msvc makefile - Sync man page with reality - Add missing external API decoration for ares_set_socket_callback() - Add ares_free_data() man page. - - Provide in external interface preprocessor symbol definitions for CARES_HAVE_ARES_FREE_DATA as an indication of function availability. - Remove typecast - Fix comment - Add ares_data.c and ares_data.h - Jakub Hrozek modified ares_parse_srv_reply() and ares_parse_txt_reply() API to return a linked lists of results. These were also modified to internally use the ares_data memory struct and as such its result must be free'ed with ares_free_data(). - Initial support for the generic ares_free_data() function that will allow applications to free memory allocated and returned by some c-ares funtions. - Make usage of calloc()'s arguments consistent with rest of code base - workaround icc 9.1 optimizer issue - Add icc fvisibility bug test - Fix icc 9.0 compiler warning: external definition with no prior declaration - Fix three var names - Add check for assert.h header file - getaddrinfo is fully thread safe on solaris versions which implement the function even when h_errno is not a macro. The h_errno macro test now only done on systems for which there is no hard coded knowledge about getaddrinfo's thread safeness. - Remove files generated on previous buildconf/configure run - Remove enable-thread / disable-thread configure option. These were only placebo options. The library is always built as thread safe as possible on every system. - Refactor how preprocessor symbol _THREAD_SAFE definition is done. - Assume that getaddrinfo is thread safe, unless hard coded knowledge says the contrary or h_errno is not defined. - Related with the threadsafe capability of getaddrinfo: - Constantine Sapuntzakis reported that Darwin 6.0 a.k.a. MAC OS X 10.2 and newer have a threadsafe getaddrinfo. - Fix Dragonfly BSD triplet detection. - In case the hard-coded knowledge says that getaddrinfo is threadsafe, an additional check is done to verify that h_errno is also defined. If h_errno isn't defined, we finally assume that it isn't threadsafe. Jamie Lokier provided the inspiration for this extra check. - AIX 5.2 and newer have threadsafe getaddrinfo. Add some comments to better understand what the regex's pretend to achieve. - HP-UX 11.11 and later have threadsafe getaddrinfo - Check if getaddrinfo is threadsafe when function check allows it to be used - Renamed fpGetNetworkParams and fpSystemFunction036 to avoid namespace pollution with static library - Add kernel32.lib - Mention last changes - Reinstate copyright symbol lost in previous commit - Make some strings different in resource file for debug or release builds - Ignore more subdirs - Fix compiler warning: conditional expression is constant - Sync linker and resource compiler options with Makefile.msvc - Follow Makefile.msvc subdirectory naming scheme, and sync compiler options - Updated MSVC makefile that allows building dynamic and static c-ares libraries in debug and release flavours. Additionally each of the three sample programs is built against each of the four possible c-ares libraries, generating all this a total number of 12 executables and 4 libraries. - Test for USE_WINSOCK since it is more restrictive than WIN32 - Make header inclusion depend on HAVE_*_H definition - Remove unneeded preprocessor directives - Adjust c-ares include paths for memory tracking enabled (--enable-curldebug) builds - source files used by sample programs - Renamed c-ares setup.h to ares_setup.h - Adjust include paths to take in account that currently: c-ares with --enable-curldebug uses memdebug.h from libcurl's lib subdirectory. memdebug.h needs access to libcurl's setup.h from libcurl's lib subdirectory and also needs access to libcurl's generated curl_config.h - Undo old temporary change once used for testing purposes - Mention many changes - Mention --enable-symbol-hiding configure option - Symbol hiding configure options renamed to the hopefully less ambiguous --enable-symbol-hiding and --disable-symbol-hiding as well as related macro names and some internal variables used for them. Related configuration file preprocessor symbols named to CARES_SYMBOL_HIDING and CARES_SYMBOL_SCOPE_EXTERN. - Header inclusion depending on HAVE_* symbol. Fix two typos. - Comparison of the Initial revision of this file with ares_parse_a_reply.c shows that this one is actually a modified copy of ares_parse_a_reply.c. In order to comply with ares_parse_a_reply.c's M.I.T. license, the old 1998 M.I.T. copyright notice is now also preserved in this file the same as it is done in other ares_parse_*.c files. - Add CVS Id tag. Fix identation of some license lines. - Add CVS Id tag. - Fix comment - In no particular order, changed/fixed all of the following in ares_parse_txt_reply() current version: - Fixed a couple of potential double free's. - Fixed memory leaks upon out of memory condition. - Fixed pointer arithmetic. - Setting ntxtreply to zero upon entry for all failure cases. - Changed data type to size_t for variables substr_len, str_len and the length member of ares_txt_reply struct. - Avoided a couple of memcpy() calls. - Changed i data type to unsigned int to prevent compiler warnings. - Adjusted a comment. - Use ARES_SUCCESS literal for successfull completion. - Added CVS Id tag. - Add c-ares DLL resource file to distribution archive - ignore files - Empty subdir - Updated MSVC 6.0 workspace and project files that allows building dynamic and static c-ares libraries in debug and release flavours. Additionally each of the three sample programs is built against each of the four possible c-ares libraries, generating all this a total number of 12 executables and 4 libraries. Daniel Stenberg (29 Oct 2009) - no need to check for NULL pointers before dereferencing, as the pointers MUST be valid and they are dereferenced further down in the function unconditionally! - shorten the descriptions somewhat - update to the new struct name - Jakub Hrozek added ares_parse_txt_reply() for TXT parsing - use 'ares_srv_reply' for proper name-spacing Yang Tse (29 Oct 2009) - Add reference for ares_parse_srv_reply.pdf - Add reference for ares_parse_srv_reply docs - External API function linkage decoration adjustment - External API function linkage decoration adjustment - Initial step towards the ability to reduce c-ares exported symbols based on the 'visibility' attribute for GNUC and __global for Sun compilers, taking also in account __declspec function decoration for Win32 and Symbian DLL's. Introducing configure options --enable-hidden-symbols and --disable-hidden-symbols following libcurl's naming. - Fix comment - Fix spelling - Fix Pelles C Win32 target compilation issues - John Engelhart noticed an unreleased problem relative to a duplicate ARES_ECANCELLED error code value and missing error code description. - Fix compiler warning: local variable may be used without having been initialized - Use *_CHECK_PATH_SEPARATOR_REQUIRED to ensure that *_CHECK_PATH_SEPARATOR is only expanded and included once in the configure script. - Our _AS_PATH_SEPARATOR_PREPARE override is now m4_defun'd instead of m4_define'd due to autoconf 2.64 m4_require'ing it in _AS_SHELL_SANITIZE indirectly through _AS_PATH_WALK. - Fix compiler warning: argument is incompatible with corresponding format string conversion - Fix potential out-of-bounds read - Fix compiler warning: loop without body - Fix compiler warning - Fix compiler warning - Fix compiler warning - Fix compiler warning: addition result could be truncated before cast to bigger sized type - Overhauled ares__get_hostent() - Fixing out of bounds memory overwrite triggered with malformed /etc/hosts file. - Improving parsing of /etc/hosts file. - Validating requested address family. - Ensuring that failures always return a NULL pointer. - Adjusting header inclusions. - Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak - more files to ignore - Check if _REENTRANT definition is required to make errno available as a preprocessor macro. - Attempt to silence bogus compiler warning: "Potential null pointer dereference" - ignore more files Gisle Vanem (7 Sep 2009) - Suppress warnings about unused prototypes in Watt32 and Win32 programs. - Update email address. - Update my email address. Add ares_config.h as dependency for 'make depend'. Yang Tse (6 Sep 2009) - T_SRV portability check Gunter Knauf (5 Sep 2009) - changed includes to match style how we do with all other *.c files. - changed u_int16_t to unsigned short because it is the only place within ares and curl where such a type would be used; also it broke many autobuilds. We should probably introduce an ares_port_t if we want to use a type here. Gisle Vanem (5 Sep 2009) - Replace 'uint16_t' with 'u_int16_t' since the latter is used in ares.h. - Added 'ares_parse_srv_reply.obj'. Added definition of 'u_int16_t'. This is I don't like; we should not depend on such non-universal types in a public header. But this is just a quick fix. Daniel Stenberg (4 Sep 2009) - - Jakub Hrozek added ares_parse_srv_reply() for SRV parsing Steinar H. Gunderson (27 Aug 2009) - Support lookup of IPv4 literals in ares_gethostbyname(), even when the address family is set to AF_INET6. Gisle Vanem (3 Aug 2009) - Remove call to LoadLibrary(). (leftover from debugging). - Fix bad sentence. Daniel Stenberg (3 Aug 2009) - - Timo Teras changed the reason code used in the resolve callback done when ares_cancel() is used, to be ARES_ECANCELLED instead of ARES_ETIMEOUT to better allow the callback to know what's happening. - - Joshua Kwan fixed the init routine to fill in the defaults for stuff that fails to get inited by other means. This fixes a case of when the c-ares init fails when internet access is fone. Gunter Knauf (16 Jul 2009) - test if adding ../lib to includes can fix the current break ... - renamed generated config.h to ares_config.h in order to avoid clashes when libcurl is used with other projects which also have a config.h. Yang Tse (21 Jun 2009) - Refactor how libraries are checked for connect() function, follow-up. - Refactor how libraries are checked for connect() function, and check for connect() as it is done for other functions. Gisle Vanem (20 Jun 2009) - Remove unneeded defines. - Use select_s() and not select(). Yang Tse (19 Jun 2009) - sclose() function-like macro definition used to close a socket, now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions. - add CloseSocket camel case function check - check for socket() and closesocket() as it is done for other functions - Remove HAVE_CONFIG_H definition from here, CFLAGS from common.dj already defines it. - initial step towards decoupling c-ares from libcurl for DOS - don't ignore these subdirs, they must be removed first - Remove DEBUGBUILD symbol definition, is not required for programs using the library. - DEBUGBUILD symbol definition for debug builds - ignore some subdirs - fix comment - Try to make more clear that --enable-curldebug has nothing to do with --enable-debug for this library. - Revert last change, it is inappropriate. Gisle Vanem (12 Jun 2009) - Replace CURLDEBUG with DEBUGBUILD. Yang Tse (11 Jun 2009) - when running automake copy missing files instead of symlinking them - Adjusted to take in account that... With the curl memory tracking feature decoupled from the debug build feature, CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows: CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug) DEBUGBUILD used for debug enabled specific code (--enable-debug) - c-ares' --enable-debug --enable-curldebug decoupling follow-up - mention last changes - Remove buildconf.bat from release and daily snapshot archives. buildconf.bat is only for CVS tree builds. - Ensure that buildconf.bat does nothing unless it is used with a CVS checkout. - CVS-INFO file only present in CVS tree, never in release nor daily snapshot archives. Used as a sentinel file in buildconf.bat to differentiate CVS builds. Gisle Vanem (8 Jun 2009) - Update comment about "ML". Removed "-D_USE_32BIT_TIME_T" (not a requirement). Yang Tse (8 Jun 2009) - just comment it out - For debugging purposes... Disable the '-export-symbols-regex' to discard this as the origin of link failures related with shared libraries and non-GNU linkers. - c-ares Makefile.am back to using $(top_builddir) for *_LDADD - c-ares' -no-undefined and --enable-curldebug adjustments - Use relative path to built c-ares tree libtool library - John E. Malmberg noticed that the configure script was failing to detect the timeval struct on VMS when building with _XOPEN_SOURCE_EXTENDED undefined due to definition taking place in socket.h instead of time.h - Fix compiler warning: out of bound access - fix compilation on AIX - c-ares' --enable-curldebug adjustments - Remove temporarily introduced memory leak. - Temporarily introduce a memory leak to verify curl debug memory tracking works. - Allow curl debug memory tracking when building a shared library on systems which support external, undefined, symbols in shared libraries. Daniel Stenberg (26 May 2009) - language fix Yang Tse (26 May 2009) - Make ares_init(), ares_dup() and ares_init_options() return ARES_ENOTINITIALIZED if library initialization has not been performed calling ares_library_init(). - c-ares's --enable-curldebug configure option decoupled from c-ares's --enable-debug - Prevent copying 'sourced' manpages for build targets that don't use them. Daniel Stenberg (23 May 2009) - minor edits Yang Tse (21 May 2009) - Include .pdf versions of c-ares man pages in distribution tarball. - Allow generation of .html and .pdf versions of c-ares man pages. Gisle Vanem (21 May 2009) - $(OBJ_DIR)/ares_getopt.o must be cleaned explicitly. Yang Tse (20 May 2009) - Mention last changes - Initial ares_library_cleanup(3) man page - Update man page - Update man page - Initial ares_library_init(3) man page attempt - Force revision update, to force CVS to update the $Id date string format - Add same copyright notice as other c-ares files - Fix case - Remove run-time requirement for advapi32.dll since c-ares can work even with no advapi32.dll at all. - Intentionally avoid checking if the address of SystemFunction036, a.k.a. RtlGenRandom, has been located or not. This function is only available on WinXP and later. When unavailable c-ares uses portable rand() function. - - Provide in external interface preprocessor symbol definitions for CARES_HAVE_ARES_LIBRARY_INIT and CARES_HAVE_ARES_LIBRARY_CLEANUP to ease the use of new capabilities. - Move ares_version() prototype to ares.h - Introduction of ares_library_init() and ares_library_cleanup() - Introduction of ares_library_init() and ares_library_cleanup() - remove outdated comment - Fix preprocessor conditional expression - fiX *__SOCKLEN_T definitions for remaining targets - *__SOCKLEN_T definitions for OS400 already fixed - fIX *__SOCKLEN_T definitions for SYMBIAN32 and VMS targets Daniel Stenberg (11 May 2009) - - Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to only expose functions starting with ares_. Yang Tse (11 May 2009) - Remove experimental check. Currently there's no need for it. - Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition attempt in generated config.h - Proper naming for the experimental compiler test and moved to *-compilers.m4 - Moved *_CHECK_COMPILER_HALT_ON_ERROR and *_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE to *-compilers.m4 along with other *_CHECK_COMPILER_* - fIX *__SOCKLEN_T definitions for OS400 and generic GCC targets - fIX *__SOCKLEN_T definitions for MVS and 370 targets - fIX *__SOCKLEN_T definitions for several Windows target tool-chains - HP-UX's X/Open network library requirement check follow-up - HP-UX's X/Open network library requirement check follow-up - Use build-time configured ares_socklen_t instead of socklen_t - David McCreedy's "TPF-platform specific changes to various files" patch follow-up Daniel Stenberg (1 May 2009) - s/libcurl/c-ares - version number typo fix Yang Tse (1 May 2009) - David McCreedy's "TPF-platform specific changes to various files" patch - Check definition of _XOPEN_SOURCE_EXTENDED with the compiler - Check if X/Open network library is required - cope with ares_build.h and ares_rules.h follow-up - Added some notes regarding ares_build.h - fix EOL - fix EOL - cope with ares_build.h and ares_rules.h - buildconf.bat for CVS-tree c-ares - Use 'unsigned int' instead of size_t attempting to avoid header inclusion - NetWare LibC's getpeername() third argument data type is size_t - Remove temporary debug tracing for ares_socklen_t Windows targets - ares_socklen_t follow-up - ares_build.h Windows follow-up - Add temporary debug tracing for ares_socklen_t Windows targets - ares_build.h NetWare follow-up - ares_build.h NetWare attempt - Initial step towards a configure time ares_socklen_t definition - ignore stamp-h* - Added CARES_INCLUDES_SYS_TYPES - Initial step towards a configure time curl_socklen_t definition - avoid use of alloca() - Moved potential inclusion of system's malloc.h and memory.h header files to setup_once.h. Inclusion of each header file is based on the definition of NEED_MALLOC_H and NEED_MEMORY_H respectively. - ignore Gisle Vanem (18 Apr 2009) - Added '-DHAVE_LIMITS_H'. Yang Tse (17 Apr 2009) - remove compiler options used while debugging the icc 9.1 optimizer issue - moved HAVE_LIMITS_H to common defines - Set HP-UX compiler warning level back to the one that exposes the socklen_t issue on this platform. - HAVE_LIMITS_H definition for NetWare CLIB - use HAVE_LIMITS_H symbol to protect limits.h inclusion - fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value - s/u_long/unsigned long/ - Do not halt compilation when using VS2008 to build a Windows 2000 target - ignore Phil Blundell (3 Feb 2009) - * February 3 2009 (Phil Blundell) - If the server returns garbage or nothing at all in response to an AAAA query, go on and ask for A records anyway. Daniel Stenberg (31 Jan 2009) - - ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving either AF_INET6 or AF_INET. It works by accepting any of the looksups in the hosts file, and it resolves the AAAA field with a fallback to A. Gisle Vanem (18 Jan 2009) - fopen() returns error in 'errno' even on Windows. So don't use ERRNO (GetLastError()). Trimmed trailing blanks. - Constified some arguments in local functions. Daniel Stenberg (14 Jan 2009) - - ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it now declares the private struct ares_in6_addr for all systems instead of relying on one possibly not present in the system. Phil Blundell (13 Jan 2009) - - ares__send_query() now varies the retry timeout pseudo-randomly to avoid packet storms when several queries were started at the same time. Daniel Stenberg (11 Jan 2009) - - Phil Blundell added the internal function ares__expand_name_for_response() that is now used by the ares_parse_*_reply() functions instead of the ares_expand_name() simply to easier return ARES_EBADRESP for the cases where the name expansion fails as in responses that really isn't expected. Gunter Knauf (30 Dec 2008) - added HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID to ares Makefile.netware and sync'd with other Makefile.netware. Daniel Stenberg (9 Dec 2008) - use the new URL - start over on the 1.6.1 release... Version 1.6.0 (9 Dec 2008) Daniel Stenberg (9 Dec 2008) - add space Gisle Vanem (9 Dec 2008) - Fix for Win32 targets using Watt-32. Dan Fandrich (9 Dec 2008) - C89 compilers (like Minix' ACK) only need to handle 31 functions arguments so split a long sprintf into two calls to get below that number. Gisle Vanem (8 Dec 2008) - Added needed defines for Watt-32 on Windows. - Undefine 'optarg', 'optind' and 'opterr' when using Watt-32 (to get correct linkage on Windows). - ares_writev() shall not be exported when using Watt-32 (has writev). Added _USE_32BIT_TIME_T to avoid runtime warning. Applies to VC-2008+ only. - Removed unneeded defines HAVE_SIGNAL_H, HAVE_SIG_ATOMIC_T, RETSIGTYPE and HAVE_PROCESS_H. Daniel Stenberg (4 Dec 2008) - the initial version of the ares_set_socket_callback man page - Gregor Jasny provided the patch that introduces ares_set_socket_callback(), and I edited it to also get duped by ares_dup(). Dan Fandrich (4 Dec 2008) - Bring the sys/include.h include test in line with curl's. Daniel Stenberg (3 Dec 2008) - Let's not call ares_save_options() deprecated just yet - Introduce ares_dup(3) and new thoughts about API/ABI and how to move forwards. Also discussed on the ml. Dan Fandrich (2 Dec 2008) - Make sure sys/socket.h is included before netinet/in.h (required by OpenWatcom C, and condoned by SUS) Daniel Stenberg (1 Dec 2008) - minor indent fix - Convert the public config struct to the same binary size/construct as in the latest releases to remain ABI compatible. Gisle Vanem (29 Nov 2008) - Added '-DHAVE_GETHOSTNAME'. Dan Fandrich (29 Nov 2008) - Make sure sys/socket.h is included before netinet/in.h (required by OpenWatcom C) - Netware has gethostname() - Fixed a couple of typos - Don't tweak the HAVE_* macros when using autoconf - Make use of gethostname() conditional on it being available - Only set TCP_NODELAY when it exists Daniel Stenberg (28 Nov 2008) - updated with changes, preparing for a release soon Yang Tse (26 Nov 2008) - Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a buffer to shrink instead of expand if a reply contained 8 or more records. - Brad Spencer provided changes to allow buildconf to work on OS X. - In preparation for the upcomming IPv6 nameservers patch, the internal ares_addr union is now changed into an internal struct which also holds the address family. Dan Fandrich (20 Nov 2008) - Make checking for struct ifreq a prerequisite for setting HAVE_IOCTL_SIOCGIFADDR since it's needed to use SIOCGIFADDR and Watcom C doesn't currently define it. Daniel Stenberg (20 Nov 2008) - use unsigned short better intead of mixing with ints to prevent compiler warnings - please the picky compilers by staying with short as the data we get is short only - - Brad Spencer brought the new function ares_gethostbyname_file() which simply resolves a host name from the given file, using the regular hosts syntax. Yang Tse (19 Nov 2008) - user provided PATH_SEPARATOR always overrides auto-detected one - attempting to keep lines below 80 chars - provide a common PATH_SEPARATOR check method which is required by upcomming work to support the broadest range of Autoconf versions - check for gethostbyaddr and gethostbyname as it is done for other functions - Make configure script check if ioctl with the SIOCGIFADDR command can be used, and define HAVE_IOCTL_SIOCGIFADDR if appropriate. - fix leftover from previous commit - fix inet_pton() runtime configure check - trim down configure script size Daniel Stenberg (15 Nov 2008) - Fixed an OOM condition reported by Jim Meyering Yang Tse (14 Nov 2008) - fix typo affecting inclusion of in configure checks for inet_ntoa_r() inet_ntop() and inet_pton() - #include in the getaddrinfo() runtime check for the memset() prototype - fix symbol definition check for fcntl.h inclusion - Refactor configure script detection of functions used to set sockets into non-blocking mode, and decouple function detection from function capability. Daniel Stenberg (1 Nov 2008) - Added a TODO file to list things we want changed, added or fixed. - - Carlo Contavalli added support for the glibc "rotate" option, as documented in man resolv.conf: causes round robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time. You can enable it with ARES_OPT_ROTATE Yang Tse (1 Nov 2008) - Adjust WIN32 freeaddrinfo, getaddrinfo and getnameinfo availability - WIN32 availability of freeaddrinfo, getaddrinfo and getnameinfo functions is quite convoluted, compiler dependant and in some cases even build target dependat. - check for freeaddrinfo() at configuration phase - update aclocal file serial number - remove verification of the freeability of the addrinfo struct pointer members - fix comment - make CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_ADDR and CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_CANONNAME internal to CHECK_FUNC_GETADDRINFO - fix leftover - Initial attempt to detect at configuration time if the getaddrinfo() function returns an addrinfo with an unfreeable ai_canonname member ptr. - Initial attempt to detect at configuration time if the getaddrinfo() function returns an addrinfo with an unfreeable ai_addr member ptr. - icc adjustments: Select ANSI C89 dialect plus GNU extensions, again. - some more temporary magic for the icc seg-fault issue - icc permanent adjustment: Select precise floating-point model, otherwise doubles are less than 64-bit wide icc test adjustment: Select c89 dialect - icc adjustments: Enable more icc warnings. Optimization disabling options used only for icc 9.1 - #include for exit() prototype - some more temporary magic for the icc seg-fault issue - remove from configure.ac temporary magic for the icc seg-fault issue - some more temporary magic for the icc seg-fault issue - Charles Hardin patch: - handles the EINPROGRESS for UDP connects - uses closesocket instead of close on some paths that were noticed - some more temporary magic for the icc seg-fault issue - messages initially intended only for debug purposes, now become permanent since these are extremely useful when compiler rejects a set of options. - fix compiler warning - fix missing double-quotes Daniel Stenberg (17 Oct 2008) - Charles Hardin made adig support a regular numerical dotted IP address for the -s option as well. Yang Tse (16 Oct 2008) - some more temporary magic for the icc seg-fault issue - Ensure that shell variable contents which have active meaning to the shell echo command are not interpreted when trying to remove extra whitespace from shell variable content. - Adjust Watcom C warnings: Disable warnings on structure members padding. - With this change Solaris target builds will now be done with _REENTRANT defined. - Adjust Tiny C basic options: Remove -b from debug-enabled configuration, as Tiny C might have been built without the memory and bounds checker support. - Adjust GCC warnings: Better disable following warnings when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers: -Wmissing-declarations -Wmissing-prototypes -Wunused -Wshadow - fix syntax error - Initial attempt to detect Watcom C compiler - make naming scheme more consistent across whole file - Adjust GCC warnings: Disable following warnings when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers: -Wmissing-prototypes -Wunused -Wshadow - Adjust GCC --enable-warnings: Do not enable -pedantic when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers. - adjust SGI MIPSpro C detection - LCC compiler adjustments: Highest warning level is double -A, next is single -A. Due to the big number of warnings these trigger on third party header files it is impratical for us to use any of them here. If you want them simply define it in CPPFLAGS. - remove extra space - split SGI compiler check. One for MIPS C and another for MIPSpro C - LCC compiler adjustments: Warning level reduced from double -A to single -A - Initial attempt to detect Tiny C compiler - Initial attempt to detect LCC compiler - 1) fix bug in CONVERT_INCLUDE_TO_ISYSTEM 2) Disable SGI remark: controlling expression is constant - simplify SGI C compiler check - HP C adjustments: Due to the HP-UX socklen_t issue it is insane to use the +w1 warning level. It generates more than 1100 warnings on socklen_t related statements. Until the issue is somehow fixed we will just use the +w2 warning level. - Add debug tracing for COMPILER_WORKS_IFELSE - configure will also warn on 'strict compiler warning' rejected options - convert rejected compiler options messages into a warnings - remove extra whitespace from string in SGI C check - oops - Initial attempt to detect SGI C compiler - HP C adjustments: Disallow run-time dereferencing of null pointers. Disable some remarks: #4227: padding struct with n bytes to align member. #4255: padding size of struct with n bytes to alignment boundary. - improve presentation of accepted/rejected debug/optimizer options - refactoring of COMPILER_BASIC_OPTS - Initial attempt to detect SUN C compiler - Initial attempt to detect HP C compiler - fix compiler warning: 'dot_4' may be used uninitialized in this function - adjust ICC_windows settings - fix VAR_STRIP - Sync up with reality - Initial attempt to support configure's --(dis|en)able-optimize option to specify dis(activation) of compiler optimizations. If option is specified, it will be honored independant of the --(dis|en)able-debug option. - fix comment - Initial attempt to support configure's --(dis|en)able-warnings option to specify dis(activation) of picky compiler warnings. If option is specified, it will be honored independant of the --(dis|en)able-debug option. If option is not specified, it will follow --(dis|en)able-debug setting, whose default is disabled if not specified. - fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules - now compiler warnings are activated for all gcc builds, not only debug ones. - Use CFLAGS for icc linker options instead of LDFLAGS, otherwise gethostbyname() is not detected. - use ac_cv_compiler and ac_cv_compiler_num to keep compiler ID and version number - Temporary icc adjustment: Disable floating point optimizations - HAVE_INET_PTON will only be defined when an IPv6 capable working inet_pton function is available. - HAVE_INET_NTOP will only be defined when an IPv6 capable working inet_ntop function is available. - ntoa() and inet_ntoa_r() no longer used - icc adjustments for icc 9.0 and prior versions: Disable remark #279: controlling expression is constant Remark triggered mostly on va_arg() and FD_ZERO() macros. - attempt to make work the gethostname function check for winsock build target configurations Gisle Vanem (21 Sep 2008) - Added HAVE_NETDB_H, HAVE_ARPA_INET_H, HAVE_STRCASECMP and HAVE_STRNCASECMP. Yang Tse (19 Sep 2008) - icc adjustments: Disable remark #981: operands are evaluated in unspecified order Function calls which are triggering this remark, today, do not depend on the order of evaluation of its arguments. Disable remark #1469: "cc" clobber ignored Remark triggered on htons() and ntohs() due to glibc header files. - icc adjustments - fix netdb.h prerequisite inclusion - improve detection of getservbyport_r() - On Linux Intel's icc uses gcc's header files, so we select ANSI C89 dialect plus GNU extensions. - improve detection of gethostname() - NetWare builds include "nameser.h" from the c-ares subdir - include - Sync up with reality - adjust inclusion of "nameser.h" - reorder some lines in file - code cleanup - NetWare seems to have writev() - rearrange to allow internal/private use of ares_writev to any system that lacks the writev function. - NetWare CLIB target has stricmp() and strnicmp() - include header file only when available - rearrange to allow internal/private use of ares_strcasecmp to any system that lacks the strcasecmp function. - improve detection of: strcasecmp() strcmpi() stricmp() strncasecmp() strncmpi() strnicmp() - *** empty log message *** Gisle Vanem (12 Sep 2008) - djgpp does have strdup(). Yang Tse (12 Sep 2008) - change CRLF into LF line endings - strdup() clone for systems/configurations which lack it - move inclusion of ares_private.h last - icc adjustments - icc adjustments - Select strict ANSI C89 conformance for icc - remove unnecessary typecasting of malloc() - remove unnecessary typecasting of realloc() Daniel Stenberg (29 Aug 2008) - we start over working towards 1.5.4 Version 1.5.3 (29 Aug 2008) Daniel Stenberg (29 Aug 2008) - Version 1.5.3 - added the three people from RELEASE-NOTES and sorted the list alphabetically Yang Tse (27 Aug 2008) - Don't abort configuration if recvfrom() is not available. - Functionality only possible if recvfrom() is available. - George Neill's fix acountry sample application compilation failure. - Brad House's validation that DNS response address matches the request address - fix the output name - Get rid of ENABLE_64BIT symbol definition and usage. Improve HAVE_LONGLONG symbol description. - Export 'ares_process_fd' too. Gisle Vanem (16 Aug 2008) - Ops, remove 'use_vc'. - Support Watt-32 under Win32. Yang Tse (10 Aug 2008) - Fix: Remove now this SIZEOF_CURL_OFF_T symbol definition. This should have been done with the initial 64-bit curl_off_t patch. - Improve CURL_CHECK_DEF - Fix IBM C and DEC/Compaq C compiler detection - Initial support of curlbuild.h and curlrules.h which allows to have a curl_off_t data type no longer gated to off_t. - The minimum autoconf version required for this file is 2.50 Avoid dot notation in aclocal serial file number, use a single number now. Daniel Stenberg (4 Aug 2008) - - Fix by Tofu Linden: The symptom: * Users (usually, but not always) on 2-Wire routers and the Comcast service and a wired connection to their router would find that the second and subsequent DNS lookups from fresh processes using c-ares to resolve the same address would cause the process to never see a reply (it keeps polling for around 1m15s before giving up). The repro: * On such a machine (and yeah, it took us a lot of QA to find the systems that reproduce such a specific problem!), do 'ahost www.secondlife.com', then do it again. The first process's lookup will work, subsequent lookups will time-out and fail. The cause: * init_id_key() was calling randomize_key() *before* it initialized key->state, meaning that the randomness generated by randomize_key() is immediately overwritten with deterministic values. (/dev/urandom was also being read incorrectly in the c-ares version we were using, but this was fixed in a later version.) * This makes the stream of generated query-IDs from any new c-ares process be an identical and predictable sequence of IDs. * This makes the 2-Wire's default built-in DNS server detect these queries as probable-duplicates and (erroneously) not respond at all. Yang Tse (4 Aug 2008) - Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use. Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. But, autoconf 2.62 version of AC_AIX defines _ALL_SOURCE along with other four preprocessor symbols no matter if the system is AIX or not. To keep the traditional behaviour, as well as an uniform one, across autoconf versions AC_AIX is replaced with our own internal macro. - Adjust DEC/Compaq C compiler settings. - Another AC_TRY_LINK conversion to AC_LINK_IFELSE. Proper definition of HAVE_function if function is found deeper. - Sync up with reality - Rename reentrant.m4 to avoid filename clash. - Add file version serial number that might be used by 'aclocal' and others. Keep the '#' character as the first one on the line. - Update copyright year. - Sync comment with reality. - Reinstate the 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4' way of including our local m4/reentrant.m4 file. This even takes care of including the file in the distribution tarball. - Add quoting for the AC_DEFINE arguments. - Also remove the whitespace. - Also remove the extra quoting. - Replace some '@%:@' quadigraphs by its actual representation '#'. This quadigraph used before a C preprocessor 'define' directive could be fooling M4, when processing this file, and make it think that the line contains a pure M4 'define' macro. - Tests done using 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4 in top Makefile.am triggered a problem that prevented aclocal from running successfully on SunOS 5.10 with GNU m4 1.4.5 and GNU Autoconf 2.61 A tarball which reproduces mentioned problem is the one dated July-28-2008 http://cool.haxx.se/curl-daily/curl-7.19.0-20080728.tar.gz We actually don't need all the bells and whistles that the above mechanism provides. We only need to include our m4/reentrant.m4 file in acinclude.m4 so here we go with this simpler mechanism. - for debugging purposes show ACLOCAL_FLAGS - These lines were unintentionally removed in previous commit - Partially undo change that prevented SED, GREP, EGREP and AR from being changed by libtool or autoconf. - Assert that SED and GREP are set - Require autoconf 2.57 or newer - When calling aclocal, user defined ACLOCAL_FLAGS will now precede ours. - move ACLOCAL_AMFLAGS after AUTOMAKE_OPTIONS - setup.h handles definition of _REENTRANT based on NEED_REENTRANT definition which might be defined in config.h or config-*.h files - Remove explicit inclusion of our m4 files first. It was interesting as a test, but it breaks aclocal execution on some systems, with the following error: Can't locate object method "rel2abs" via package "File::Spec" at /usr/local/bin/aclocal line 256. - Another step towards detecting if _REENTRANT is already defined or actually needed, and being able to define it if appropriate for further configure tests as well as for the generated config file. - Explicitly include our m4 files first. This might minimize the impact that other package's underquoted m4 function definitions have on ours. - Add a 3 argument check for getprotobyname_r - move reentrant.m4 to the m4 subdirectory to avoid infinite loop inclusion problem - add checks for strtok_r and getprotobyname_r - Another step towards detecting if _REENTRANT is already defined or actually needed, and being able to define it if appropriate for further configure tests as well as for the generated config file. Introduced reentrant.m4 intended for our reentrant related autotools/m4 macros. - reorder argument number detection for getservbyport_r to actually verify if the test is properly working - Make sure that configure process tests are done with the same _REENTRANT setting as the one actually used when finally building the library. - Change recvfrom's sixth argument data type to the 'historically standard' 'int' data type for systems where this sixth argument is prototyped as a void pointer. Start of thread: http://curl.haxx.se/mail/lib-2008-07/0153.html - use prototypes to improve getservbyport_r detection - Adjust recvfrom's sixth arg data type definition for NetWare (LIBC) - Use the sreadfrom() wrapper to replace recvfrom() in our code. - when recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will now cause the definition of RECVFROM_TYPE_ARG2_IS_VOID, RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID, as appropriate. - Adjust DEC/Compaq C compiler settings - Added "pointer to void" as another data type to check for the sixth argument of function recvfrom as a result of the info additionally logged when running on a Solaris system. The compiler error showed that the prototype being used on Solaris was the one declared in line 427 of "/usr/include/sys/socket.h" as: function(int, pointer to void, unsigned int, int, pointer to struct sockaddr, pointer to void) returning int - Adjust DEC/Compaq C compiler settings - RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined to the data type pointed by its respective argument and not the pointer type. - Configure process now checks availability of recvfrom() socket function and finds out its return type and the types of its arguments. Added definitions for non-configure systems config files, and introduced macro sreadfrom which will be used on udp sockets as a recvfrom() wrapper. - Initial DEC/Compaq C compiler detection and flags - Improved configure detection of number of arguments for getservbyport_r - Allow --enable-largefile and --disable-largefile configurations. Configure process no longer needs nor checks size of curl_off_t. Library will now be built with _REENTRANT symbol defined. - fix compiler warning - since Jun 30 2008 MAXHOSTNAMELEN define is no longer used - fix c-ares version reported in generated libcares.pc file when building from CVS tree. - egrep and ar are also mandatory Daniel Stenberg (3 Jul 2008) - just to clarify that c-ares actually have some ipv6 support - ares_gethostbyname() fallback from AAA to A records with CNAME present - - Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and the target host has only A records, it automatically falls back to an AF_INET lookup and gives you the A results. However, if the target host has a CNAME record, this behaviour is defeated since the original query does return some data even though ares_parse_aaa_reply() doesn't consider it relevant. Here's a small patch to make it behave the same with and without the CNAME. Yang Tse (2 Jul 2008) - The configure process will now halt when sed or grep are unavailable - fallback to gettimeofday when monotonic clock is unavailable at run-time - IBM C/C++ compiler predefined macro check - set earlier in configure process IBM compilers optimization flags - make check message wording more precise Daniel Stenberg (30 Jun 2008) - - As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is not posix or anything and thus c-ares failed to build on hurd (and possibly elsewhere). The define was also somewhat artificially used in the windows port. Now, I instead rewrote the use of gethostbyname to enlarge the host name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN define. I thus also removed the defien from the namser.h file where it was once added for the windows build. I also fixed init_by_defaults() function to not leak memory in case if error. Yang Tse (29 Jun 2008) - fix C style comment - John Lightsey filed bug report #1999181: "CLOCK_MONOTONIC always fails on some systems" (http://curl.haxx.se/bug/view.cgi?id=1999181). The problem was that the configure script did not use the _POSIX_MONOTONIC_CLOCK feature test macro when checking monotonic clock availability. This is now fixed and the monotonic clock will not be used unless the feature test macro is defined with a value greater than zero indicating always supported. - Modified configuration script to actually verify if the compiler is good enough at detecting compilation errors or at least it has been properly configured to do so. Configuration heavily depends on this capability, so if this compiler sanity check fails the configuration process will now fail. - No longer break out of a shell "for" statement from inside AC_FOO_IFELSE macros, otherwise temp files are not removed. Identation adjustment. Gunter Knauf (11 Jun 2008) - enable additional CFLAGS from commandline. Yang Tse (9 Jun 2008) - fix pkg-config reporting of private libraries needed for static linking - MSVC does build Windows native targets - Brad House fixed a missing header file inclusion in adig sample program Daniel Stenberg (29 May 2008) - start working on 1.5.3 Version 1.5.2 (29 May 2008) Daniel Stenberg (29 May 2008) - 1.5.2 Yang Tse (26 May 2008) - fix compiler warning: unreferenced formal parameter Daniel Stenberg (23 May 2008) - list all local sources the (demo) tools need, add a few missing scripts to the dist tarball and remove a two duplicate file names from EXTRA_DIST (most of it pointed out by Yang Tse) - this is not used (anymore) - make sure the configure.ac file with the correct version number is shipped in the tarball Yang Tse (22 May 2008) - MSVC6+ clean-up targets must also remove acountry.exe - sync with reality - fix: [action-if-found] part of AC_CHECK_TYPE macro cannot be quoted when empty - fix: remove need and definition of HAVE_SOCKLEN_T symbol - fix: socklen_t definition comment - update several macros using AC_TRY_LINK with AC_LINK_IFELSE - fix underquoting of AC_LANG_PROGRAM arguments - if'def out private function ares__tvdiff(), it is not in use yet. - update several macros using AC_TRY_LINK with AC_LINK_IFELSE - fix socklen_t equivalent detection when cross compiling Windows target - if WINSOCK2 API is used link with 'ws2_32', else if WINSOCK API is used under WinCE link with 'winsock', else if WINSOCK API is used link with 'wsock32'. - on winsock systems linking is done using library 'ws2_32' when winsock2.h is available, and library 'winsock' is used when only winsock.h is available. - minor change for wince-cegcc and wince-mingw32ce support - millisecond resolution support followup Gisle Vanem (15 May 2008) - Replaced "-DHAVE_FIONBIO" with "-DHAVE_IOCTLSOCKET". Added "-DHAVE_GETTIMEOFDAY". Trimmed lines. Yang Tse (15 May 2008) - sync with reality - remove compilation time generated files - use same time source for timeout initialization and processing - Improve toolchain detection for WinCE cross compilation: When cross compiling WinCE with the arm-wince-cegcc-gcc C compiler symbol __CEGCC__ is defined and the unix-like compatibility layer is used. For our purposes this is not a native Windows build. When cross compiling WinCE with the arm-wince-mingw32ce-gcc C compiler symbol __MINGW32CE__ is defined and the unix-like compatibility layer is not used. For our purposes this _is_ a native Windows build. - skip checks for Windows specific header files when build target is not a native Windows one - WinCE cross compilation adjustments: HAVE_WINSOCK2_H shall not be defined. HAVE_WS2TCPIP_H shall not be defined. Daniel Stenberg (13 May 2008) - - Introducing millisecond resolution support for the timeout option. See ares_init_options()'s ARES_OPT_TIMEOUTMS. Yang Tse (13 May 2008) - also ignore this - also ignore this - ignore this compilation time generated files - don't keep in CVS this compilation time generated file - add MSVC6 project for acountry sample program - update MSVC6 projects to use the multithreaded DLL runtime library - add MSVC6 project for acountry sample program - skip libtool C++ preprocessor compiler and linker checks - ignore libcares.pc - configure script will now define HAVE_CLOCK_GETTIME_MONOTONIC symbol only when function clock_gettime() is available and the monotonic timer is also available. Otherwise, in some cases, librt or libposix4 could be used for linking even when finally not using the clock_gettime() function due to lack of the monotonic clock. - fix syntax error: missing semicolon - Add library checking for clock_gettime() support - Use monotonic time source if available. Daniel Stenberg (9 May 2008) - Removed AC_PROG_CC_STDC again. It enforces C99/gnu99 stdandard which is too liberal for me. Also, autoconf 2.61 and earlier doesn't work with icc 10.1 for this macro. (2.62 confirmed to work though). See discusson on the mailing list starting here: http://daniel.haxx.se/projects/c-ares/mail/c-ares-archive-2008-05/0001.shtml - include strings.h (if available) for the strcasecmp() proto - check for strings.h in configure and use it for the strcasecmp() proto - adjusted to work with the updated configure.ac - - Sebastian made c-ares able to return all PTR-records when doing reverse lookups. It is not common practice to have multiple PTR-Records for a single IP, but its perfectly legal and some sites have those. - - Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to autoconf 2.57 usage (which is the version you have specified as the minimum version). It's a minor change but it does clean up some warnings with newer autoconf (specifically 2.62). Yang Tse (5 May 2008) - Improved parsing of resolver configuration files - make previous compiler warning fix more portable - fix compiler warning: indirection to slightly different base types - fix compiler warning: local variable may be used without having been initialized - fix compiler warning: unreferenced formal parameter - fix compiler warning: assignment within conditional expression Daniel Stenberg (4 Apr 2008) - - Alexey Simak fixed the VC dsp file by adding the missing source file ares_expand_string.c - Alexey Simak made adig support NAPTR records - Eino Tuominen improved the code when a file is used to seed the randomizer Yang Tse (29 Feb 2008) - Force AIX xlc to fail and not generate object code if the source code has compiled with errors. This behaviour is needed for autoconf macros which rely on the ability to compile with or without errors, and is safer than xlc's default of failing only upon severe errors. Gunter Knauf (27 Feb 2008) - added get_ver.awk since c-ares is a standalone project, and should therefore also compile when cURL is absent. - a couple of small fixes to the makefile: fixed comments; fixed INSTDIR define, simplified rules; changed to use get_ver.awk in current dir rather than the curl one. - fixed linker def file for tools when compiled with gcc/nlmconv. - added some files which were missing in release tarballs. - updated copyright for new year. Gisle Vanem (2 Jan 2008) - Added '-d' option for Watt-32 debugging. Yang Tse (18 Dec 2007) - MSVC 9.0 (VS2008) does not support Windows build targets prior to WinXP, and makes wrong asumptions of build target when it isn't specified. So, if no build target has been defined we will target WinXP when building with MSVC 9.0 (VS2008). Daniel Stenberg (11 Dec 2007) - build acountry too Gisle Vanem (11 Dec 2007) - Added acountry.c. - Added build of acountry.nlm. - Added build of acountry.exe. - Build acountry.exe. Added 'socklen_t' define. - Another sample application that returns country-code and name from an IPv4-address or host-name. Using the service of countries.nerd.dk. Daniel Stenberg (10 Dec 2007) - grrr, the previous commit was meant to properly make sure that we don't link any executables when doing debug builds since they kind of assume symbols provided by libcurl, but it also wrongly included acountry.c - when building - build ahost and adig by default but don't install them Gisle Vanem (10 Dec 2007) - Fix for targets that do have 'struct in6_addr', but which doesn't define 's6_addr' as a macro. Yang Tse (3 Dec 2007) - Fix three issues previous cleanup introduces. Daniel Stenberg (3 Dec 2007) - Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat - Brad Spencer fixed the configure script to assume that there's no /dev/urandom when built cross-compiled as then the script cannot check for it. - the gethostbyname fix applied here as well - fix next_lookup() to continue searching even if c-ares failed to load the /etc/hosts file, pointed out by Erik Kline: http://daniel.haxx.se/projects/c-ares/mail/c-ares-archive-2007-11/0027.shtml - Remove the check for libdl since that isn't actually used and it causes warnings. Pointed out by Robin Cornelius. - pkgconfig fix by Andreas Schuldei - spellfix - and we start on 1.5.2! Version 1.5.1 (21 Nov 2007) Daniel Stenberg (21 Nov 2007) - change - oops - start working on 1.5.1 now Version 1.5.0 (21 Nov 2007) Daniel Stenberg (21 Nov 2007) - this is what 1.5.0 is - fill in missing copyrights Gunter Knauf (18 Nov 2007) - removed now obsolete defines; updated external library versions to latest. Steinar H. Gunderson (16 Nov 2007) - Fix a double free. Yang Tse (15 Nov 2007) - Needed now that in6_addr is referenced in ares.h Steinar H. Gunderson (15 Nov 2007) - When looking up in DNS and then in the hosts file, return the error code from DNS if both fail, instead of returning the error code from the hosts file, as today. Patch from the Google tree. - Return TTL data from ares_parse_{a,aaaa}_reply, if the user is so inclined. Patch from the Google tree. Yang Tse (8 Nov 2007) - Define WIN32 when build target is Win32 API. This also defines it for WinCE even though it is a subset of WIN32. - The only libraries actually needed for sample programs adig and ahost are ws2_32.lib and advapi32.lib - MSVC versions prior to VS2005 do not complain about portable C functions - Windows build targets have socklen_t definition in ws2tcpip.h but some versions of ws2tcpip.h do not have the definition. It seems that when the socklen_t definition is missing from ws2tcpip.h the definition for INET_ADDRSTRLEN is also missing, and that when one definition is present the other one also is available. Gunter Knauf (22 Oct 2007) - removed dependency on gettimeofday() since we use only 1 sec resolution here. Yang Tse (20 Oct 2007) - Fix compiler warning: conversion from "int" to "unsigned short" may lose significant bits - Fix message shown when detecting icc version - Avoid shadowing a global declaration - Renamed a variable to avoid shadowing a global declaration - Renamed internal function to avoid a variable shadowing it - Fix compiler warning: feupdateenv is not implemented and will always fail. Specifically for linux x86-64 with Intel's icc. - Sync PLATFORM_AIX_V3 detection and CURL_CC_DEBUG_OPTS() icc warning level with libcurl's - Fix compiler warning: conversion from "int" to "unsigned char" may lose significant bits - actually sync with lib/setup_once.h - sync with lib/setup_once.h Steinar H. Gunderson (16 Oct 2007) - Fix a bug where fallback from AF_INET6 to AF_INET would not work properly together with relative search; if you had a search path of .a.com and .b.com, and foo.a.com would return ARES_ENODATA and foo.b.com would return ARES_ENOTFOUND, the lookup would not properly retry with AF_INET as it forgot the first ARES_ENODATA. Dan Fandrich (15 Oct 2007) - Mention first version with CURLOPT_COPYPOSTFIELDS. Don't confuse NUL with NULL. Gisle Vanem (8 Oct 2007) - Added needed 'HAVE_*' defines. - 'FD_CLOXEC' is meaningless on MSDOS/Watt-32. Steinar H. Gunderson (4 Oct 2007) - Removed a piece of redundant code (process_answer already takes care of it). - Another timeout fix in ares_getnameinfo(). - Send the timeout count in ares_getnameinfo(). - Moved the NULL check for channel upwards in ares_destroy(). - Clarified the comment over ares_cancel. Yang Tse (2 Oct 2007) - Avoid a segfault when generating a DNS "Transaction ID" in internal function init_id_key() under low memory conditions. - Add ares_llist.c and ares_llist.h to MSCV project file. Daniel Stenberg (2 Oct 2007) - Fixed the problem where next_lookup would use 'status' uninitialized. Now it gets passed the initial value as an argument. Yang Tse (2 Oct 2007) - Avoid inline C99ism, and move c-ares routines for managing doubly-linked lists. Daniel Stenberg (1 Oct 2007) - ares_strerror() segfaulted if the input error number was out of the currently supported range. - Prevent ares_strerror() from segfaulting if an invalid error code is passed in as argument! Yang Tse (30 Sep 2007) - Fix compiler warning - check availability of - improve portability, defining MAXDNAME and MAXCDNAME Steinar H. Gunderson (30 Sep 2007) - Fix a memory leak that I recently inadvertedly introduced. - Use ISDIGIT instead of isdigit; fixes a gcc warning. - Port the TCP socket fix made in ares_fds() to ares_getsock() as well. - Previously, processing a large batch of timeouts was O(n^2) in the number of outstanding queries, and processing a DNS response packet was O(n) in the number of outstanding queries. To speed things up in Google, we added a few circular, doubly-linked lists of queries that are hash-bucketed based on the attributes we care about, so most important operations are now O(1). It might be that the number of buckets are higher than most people would need, but on a quick calculation it should only be 100kB or so even on a 64-bit system, so I've let it stay as-is. Gisle Vanem (29 Sep 2007) - We should standarise on C comments. - Fix compiler warning in setsockopt(). Steinar H. Gunderson (29 Sep 2007) - TCP queries can time out too, not just UDP queries. (Patch from the Google tree.) - Read and process as many packets as possible in read_udp_packets, to avoid having to run the entire event loop once per packet. (Patch from the Google tree.) - There are two different places in write_tcp_data() that advance the send_queue; however, they are slightly different and only the first one properly uses a while loop. Consolidate both into a single function that DTTR. (Patch from the Google tree.) - Reject names that are longer than 255 characters, to avoid problems with strict or buggy DNS server implementations. (Patch from the Google tree) - In ares_mkquery, make sure we set buflen and buf to reasonable values if there's an error. (Patch from the Google tree) - Be stricter about what's a valid IP address in fake_hostent. (Patch from the Google tree.) - Handle the root of the DNS tree correctly in ares_expand_name. Daniel Stenberg (28 Sep 2007) - today's modifications by Steinar and me - Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI and API changes in the progress callback (and possibly more coming up from Steinar) Steinar H. Gunderson (28 Sep 2007) - Unrevert previous 'missing' hunks. They were missing since the patch is still in for review :-) - Yet more missing hunks... Nggh. - Always register for TCP events even if there are no outstanding queries, as the other side could always close the connection, which is a valid event which should be responded to. - Forgot to include a few hunks from ares_process.c earlier. Fixing now. - Support a few more socket options, and refactor the option setting a bit. (Patch from the Google tree.) - Make the query callbacks return the number of timeouts that happened during the execution of a query, and update documentation accordingly. (Patch from the Google tree.) - Three fixes in one commit (sorry): a) Take care of the tcpbuf if it ends while queued for transmission, note broken servers and close them in the main loop, and store TCP socket generation number in order not to send the same query twice over the same socket. - Don't skip a server if it's the only one. (Bugfix from the Google tree.) Daniel Stenberg (27 Sep 2007) - wrong, revert the previous "fix" and instead check that the fd_set pointer is non-NULL before we FD_CLR - eek, fix the conditions to return on either problem instead of requiring both to occur - Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that if it fails and the socket is closed the following code doesn't try to use the file descriptor. - Steinar H. Gunderson modified c-ares to now also do to DNS retries even when TCP is used since there are several edge cases where it still makes sense. - Brad House provided a fix for ares_save_options(): Apparently I overlooked something with the ares_save_options() where it would try to do a malloc(0) when no options of that type needed to be saved. On most platforms, this was fine because malloc(0) doesn't actually return NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM. - added initial pkg-config file (attempt) Gunter Knauf (20 Jul 2007) - added curl include for debug builds. Daniel Stenberg (14 Jul 2007) - added another SEE ALSO - Brad House's fix to hish a win32 compiler warning - added Vlad's entire description of his valgrind fix - Vlad Dinulescu fixed two outstanding valgrind reports Gunter Knauf (8 Jul 2007) - added better CodeWarrior detection. - removed some obsolete include paths and defines. - add test for gettimeofday() so that HAVE_GETTIMEOFDAY gets defined. - although the check for HAVE_STRUCT_TIMEVAL solved the redefine it is incorrect; lets see if a check for HAVE_GETTIMEOFDAY also works; if gettimeofday() is present then we can assume we have the timezone struct too. - added check for sys/param.h. - trial to catch problem with Daniels cross-mingw ares builds. - added NetWare CLIB-own header to solve gcc warnings. - few minor changes to make ares compile for NetWare CLIB architecture. - changed to build for CLIB / LIBC. - sync'd with lib makefile changes: use var for awk; fixed RECV* / SEND* defines; debug var can be overwritten; added better compiler path handling. Daniel Stenberg (8 Jun 2007) - start working on 1.4.1 Version 1.4.0 (8 Jun 2007) Daniel Stenberg (8 Jun 2007) - 1.4.0 preps - the revert - Revered Ashish Sharma's multiple entries patch, as it caused memory madness - minor edit since getting an ID seems pointless when failure happens - fix the bad bad bad mess this caused on name resolves returning more than one name... Reported by James Bursa - Brad Spencer found and fixed three flaws in the code, found with the new gcc 4.2.0 warning: -Waddress - Brad House fixed VS2005 compiler warnings due to time_t being 64bit. He also made recent Microsoft compilers use _strdup() instead of strdup(). - Ashish Sharma provided a patch for supporting multiple entries in the /etc/hosts file. Patch edited for coding style and functionality by me (Daniel). - ares_destroy_options() and ares_save_options() man pages by Brad House - make next version 1.4.0 - first take at detecting a random device and seeding the random key using data from it in randomize_key() - Shmulik Regev brought cryptographically secure transaction IDs - Brad House added ares_save_options() and ares_destroy_options() that can be used to keep options for later re-usal when ares_init_options() is used. - added ares_process_fd() to allow applications to ask for processing on specific sockets and thus avoiding select() and associated functions/macros. This function will be used by upcoming libcurl releases for this very reason. It also made me export the ares_socket_t type in the public ares.h header file, since ares_process_fd() uses that type for two of the arguments. - Ravi Pratap fixed a flaw in the init_by_resolv_conf() function for windows that could cause it to return a bad return code. Yang Tse (25 Apr 2007) - Steve Little's fixes to allow compilation on VMS 64-bit mode Gunter Knauf (21 Apr 2007) - fixed ARFLAGS for CodeWarrior build. - added ranlib when library is created with ar. Gisle Vanem (16 Apr 2007) - No need for USE_MANUAL. Use select_s() instead of select(). Added ares_getopt.o to program sample objects. Yang Tse (16 Apr 2007) - move linkage var declarations to ares_getopt.h Gunter Knauf (16 Apr 2007) - use Makefile.inc to determine sources. - ares_getopt() command-line parser function does not belong to actual c-ares library. It is just a convinience source code helper function for use in example programs adig.c and ahost.c Yang Tse (16 Apr 2007) - ares_getopt() command-line parser function does not belong to actual c-ares library. It is just a convinience source code helper function for use in example programs adig.c and ahost.c - ares_getopt() command-line parser function does not belong to actual c-ares library. It is just a convinience source code helper function for use in example programs adig.c and ahost.c - update MSVC project files with ares_getopt() - use ares_getopt for all platforms - add ares_getopt prototype - Rename function as ares_getopt() - Replace tabs with spaces - Add file ares_getopt.c Original file name getopt.c Initial import into the c-ares source tree on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with the modified BSD license, BSD license without the advertising clause. - convenience SIG_ATOMIC_T macro definition - move WinSock definitions of EBADF, EINTR, EINVAL and EAFNOSUPPORT to setup_once.h - update copyright year - Cleanup. Warnings related with FD_SET, FD_ISSET, and FD_ZERO macros are not icc 9.0 specific. Gunter Knauf (27 Mar 2007) - added variadic macro stuff. - added CVS Id tag. - fixed build to use compiler-default lib extension. Yang Tse (22 Mar 2007) - attempt to keep message length below 80 chars Gisle Vanem (17 Mar 2007) - Added a hack to work around the circular dependency when CURL_DEBUG is defined. Yang Tse (15 Mar 2007) - show better description for AMD64-linux static libraries PIC check - remove code superceeded by the new method used to force libtool to skip C++ and Fortran checks in patchset: http://cool.haxx.se/cvs.cgi/curl/ares/configure.ac.diff?r1=1.60&r2=1.64 - fix test leftover in previous commit - force libtool to build static libraries with PIC on AMD64 - Autoconf redefines the M4 builtin macro 'm4_undefine' in such a way that it fails if the macro that is being undefined is not already defined. To make this work under all cases and be sure that at a certain point some specific macro isn't defined we must use the following style in configure: m4_ifdef([macro], [m4_undefine([macro])]) Dan Fandrich (6 Mar 2007) - Autoconf 2.57 didn't like these m4_undefine for some reason (probably a bug). Luckily, they weren't needed. Yang Tse (6 Mar 2007) - skip libtool C++ and Fortran linker checks - skip libtool C++ and Fortran checks Gisle Vanem (27 Feb 2007) - Added TOPDIR variable. Put dependencies in external file. Added -DHAVE_STRUCT_TIMEVAL to CFLAGS. - Removed inclusion of in .c-files since it's already included through "setup.h". Yang Tse (22 Feb 2007) - include when checking availability of the bool type - Check for stdbool.h at configuration stage, and include it if available. Check for lowercase 'bool' type at configuration stage. If not available provide a suitable replacement with a type definition of 'unsigned char' in setup_once.h Move definitions of TRUE and FALSE to setup_once.h - curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h Gisle Vanem (21 Feb 2007) - Cleanup WIN32 target using WSACleanup(). Yang Tse (20 Feb 2007) - Move header file inclusion logic and definition of timeval struct for platforms that don't have it to setup_once.h Gisle Vanem (19 Feb 2007) - Added ares_parse_ns_reply.obj etc. - INADDR_NONE no longer used. - Fixed typo. Daniel Stenberg (19 Feb 2007) - Vlad Dinulescu added ares_parse_ns_reply() Yang Tse (19 Feb 2007) - compiler warning fix - add debug messages for initialization failures - fix ENAMETOOLONG and ENOTEMPTY may already be defined in errno.h - Move portable error number symbolic name definitions to setup_once.h - compiler warning fix - compiler warning fix - add debug messages for fopen() failures - use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling - compiler warning fix - introduce uppercase macros SOCKERRNO, SET_SOCKERRNO(), ERRNO and SET_ERRNO() making them available to any source code file which includes "setup.h". Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno (or equivalent) on this platform to hide platform details to code using it. Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno (or equivalent) on this platform to hide platform details to code using it. - icc 9.0 when compiling its generated code for its own FD_SET, FD_ISSET, and FD_ZERO macros emits warnings #1469 and #593. So for icc 9.0 we also ignore warnings #1469 and #593. * 593 warns on "variable __d0 was set but never used" * 1469 warns on "cc clobber ignored" - compiler warning fix - Oops, missing argument separator comma - in debug messages also show error description - avoid using funtion isblank() and just use our ISBLANK macro to provide this functionality on all platforms - check for isblank() at configuration stage. If not available provide a suitable replacement for use in our ISBLANK macro - use our own ISUPPER and ISLOWER macros - use our own ISBLANK macro - Fix c-ares failing to get the search sequence of /etc/hosts and DNS from /etc/nsswitch.conf, /etc/host.conf or /etc/svc.conf when /etc/resolv.conf did not exist or was unable to read it. - compiler warning fix - use macro AC_AIX to define `_ALL_SOURCE', if on AIX. - use same AIX XLC compiler options as curl's - *) Remove duplicate declaration of TYPE_SOCKADDR_STORAGE *) Update CURL_CC_DEBUG_OPTS from curl's script Gisle Vanem (6 Feb 2007) - INADDR_NONE no longer used. - Added debug option ('-d') for Watt-32 programs. - Added HAVE_PROCESS_H for DOS/Win32. Include for getpid() in ares_init.c. - Fix compiler warning. - Include and inside HAVE_x_H. Added 'optind' and 'optarg' as in adig.c. - Include and inside HAVE_x_H. gevent-1.1.0/c-ares/CHANGES0000644000076500000000000032161012666555342015707 0ustar jmaddenwheel00000000000000 Changelog for the c-ares project. Generated with git2changes.pl Version 1.10.0 (12 May 2013) Daniel Stenberg (12 May 2013) - RELEASE-NOTES: two more bug fixes - [Keith Shaw brought this change] ares_set_servers_csv: fixed IPv6 address parsing Fixed bug that caused the last part of an IPv6 address to be parsed as the port number when the last part is all numeric. - nroff: fix two syntax mistakes ares_parse_a_reply and ares_parse_aaaa_reply both had two \fB instead of \fP Reported-by: Alexander Klauer Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-03/0010.shtml - [Alex Loukissas brought this change] build: fix build on msvc11 - Makefile.am: increment -version-info for 1.10.0 release - README: remove unnecessary comment - ares_version.h: copyright end range year is now 2013 - RELEASE-NOTES: synced with fb0737f3a0a1c37 - [Paul Saab brought this change] ares_parse_aaaa_reply: Plug memory leak This change is similar to ares_parse_a_reply.c in commit bffd67f16a8f42fe6dbf79ab2e39d92eea05c8a6 - [Patrick Valsecchi brought this change] ares_parse_txt_reply: return a ares_txt_reply node for each sub-string Previously, the function would wrongly return all substrings merged into one. - [Alexander Klauer brought this change] library init: documentation update This commit updates the documentation of ares_library_init() and ares_library_cleanup() with regard to the newly introduced reference counting of initializations and deinitializations. - [Alexander Klauer brought this change] library init: be recursive Previously, a single call to ares_library_cleanup() would deinitialise the c-ares library, regardless of how many times ares_library_init() was called. This behaviour may cause problems in programs linking two or more libraries which, in turn, use c-ares. The present commit fixes this problem, deinitializing the library only after a number of calls to ares_library_cleanup() matching the number of calls to ares_library_init(). - [Patrick Valsecchi brought this change] protocol parsing: check input data stricter ... so that bad length fields aren't blindly accepted Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-04/0016.shtml Guenter Knauf (11 Apr 2013) - Create ares_build.h when buidling from Git. - Added -DCARES_STATICLIB to CFLAGS. Currently this static makefile does only support building the static library libcares.a. Daniel Stenberg (8 Apr 2013) - [Alexander Klauer brought this change] .gitignore: ignore patch files This commit adds a line to .gitignore to the effect that patch files generated by 'git format-patch' are excluded from the repository. - [Alexander Klauer brought this change] ares_destroy() documentation: no new requests Clarify that no new requests may be added to a resolver channel that is currently being destroyed. - [Alexander Klauer brought this change] Documentation: properly document ARES_ECANCELLED This commit clarifies the behaviour of ares_cancel() with respect to callbacks and adds missing documentation of ARES_ECANCELLED to the man pages of the affected functions. - [Alexander Klauer brought this change] ares_cancel(): cancel requests safely An invocation of ares_cancel() walks through the request list, calling the callbacks of all pending requests on a channel. Previously, if such a callback added a new request to the channel, the request list might not end up empty, causing an abort by assertion failure. The present commit ensures that precisely all requests present upon entry of ares_cancel() are cancelled, and that adding new requests through callbacks is safe. Yang Tse (10 Mar 2013) - ares.h: stricter CARES_EXTERN linkage decorations logic No API change involved. - ares_build.h.dist: enhance non-configure GCC ABI detection logic GCC specific adjustments: - check __ILP32__ before 32 and 64bit processor architectures in order to detect ILP32 programming model on 64 bit processors which, of course, also support LP64 programming model, when using gcc 4.7 or newer. - keep 32bit processor architecture checks in order to support gcc versions older than 4.7 which don't define __ILP32__ - check __LP64__ for gcc 3.3 and newer, while keeping 64bit processor architecture checks for older versions which don't define __LP64__ Daniel Stenberg (9 Mar 2013) - ares.h: there is no ares_free_soa function Yang Tse (9 Mar 2013) - Makefile.am: empty AM_LDFLAGS definition for automake 1.7 compatibility - ares_inet_ntop.3: s/socklen_t/ares_socklen_t - configure: use XC_LIBTOOL for portability across libtool versions - xc-lt-iface.m4: provide XC_LIBTOOL macro - Makefile.am: use AM_CPPFLAGS instead of INCLUDES - inet_ntop.c: s/socklen_t/ares_socklen_t - inet_ntop.c: s/socklen_t/ares_socklen_t for portability Daniel Stenberg (19 Feb 2013) - ares.h: s/socklen_t/ares_socklen_t for portability - ares_inet_ntop.3: 4th argument is socklen_t! - spell inet correctly! - ares_inet_pton/ntop: cleanup Make sure that the symbols are always exported and present in c-ares. Make the headers prefixed with 'ares'. Removed the inet_ntop.h version as it no longer features any content. - ares_inet_ntop/ares_inet_pton: added man pages Yang Tse (15 Feb 2013) - [Gisle Vanem brought this change] curl_setup_once.h: definition of HAVE_CLOSE_S defines sclose() to close_s() - [Gisle Vanem brought this change] config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32 - [Gisle Vanem brought this change] config-dos.h: define strerror() to strerror_s_() for High-C Daniel Stenberg (13 Feb 2013) - ares_get_datatype: removed unused function it was also wrongly named as internal functions require two underscores - ares__bitncmp: use two underscores for private functions It used a single one previously making it look like a public one - ares__generate_new_id: moved to ares_query.c ... and ares__rc4 is turned into a local static function. - ares__swap_lists: make private and static ... since there's only one user, make it static within ares_process.c Yang Tse (13 Feb 2013) - Makefile.msvc: add four VS version strings Daniel Stenberg (13 Feb 2013) - ares_expand_name.3: clarify how to free the data Yang Tse (30 Jan 2013) - zz40-xc-ovr.m4: fix 'wc' detection - follow-up 2 - Fix a pair of single quotes to double quotes. URL: http://curl.haxx.se/mail/lib-2013-01/0355.html Reported by: Tor Arntsen - zz40-xc-ovr.m4: fix 'wc' detection - follow-up - Take into account that 'wc' may return leading spaces and/or tabs. - Set initial IFS to space, tab and newline. - zz40-xc-ovr.m4: fix 'wc' detection - Take into account that 'wc' may return leading spaces. - Set internationalization behavior variables. Tor Arntsen analyzed and reported the issue. URL: http://curl.haxx.se/mail/lib-2013-01/0351.html - zz40-xc-ovr.m4: check another three basic utilities - zz40-xc-ovr.m4: 1.0 interface stabilization - Stabilization results in 4 public interface m4 macros: XC_CONFIGURE_PREAMBLE XC_CONFIGURE_PREAMBLE_VER_MAJOR XC_CONFIGURE_PREAMBLE_VER_MINOR XC_CHECK_PATH_SEPARATOR - Avoid one level of internal indirection - Update comments - Drop XC_OVR_ZZ40 macro - zz40-xc-ovr.m4: emit witness message in configure BODY This avoids witness message in output when running configure --help, while sending the message to config.log for other configure runs. - zz40-xc-ovr.m4: truly do version conditional overriding - version conditional overriding - catch unexpanded XC macros - fix double words in comments - zz40-xc-ovr.m4: fix variable assignment of subshell output bashism Tor Arntsen analyzed and reported the issue. URL: http://curl.haxx.se/mail/lib-2013-01/0306.html - zz40-xc-ovr.m4: reinstate strict AC_REQUIRE macro dependencies - zz40-xc-ovr.m4: avoid double single-quote usage - zz40-xc-ovr.m4: parentheses balancing of 'case' statements m4 quadrigraph shell comment technique allows proper autoconf parentheses balancing in shell 'case' statements. The presence of unbalanced parentheses may otherwise trigger expansion bugs. - zz40-xc-ovr.m4: internals overhauling - Update comments - Execute commands in subshells - Faster path separator check - Fix missing 'test' command - Rename private macros - Minimize AC_REQUIRE usage - zz40-xc-ovr.m4: redirect errors and warnings to stderr - configure: use XC_CONFIGURE_PREAMBLE early checks Some basic checks we make were placed early enough in generated configure script when using autoconf 2.5X versions. Newer autoconf versions expand these checks much further into the configure script, rendering them useless. Using XC_CONFIGURE_PREAMBLE fixes placement of early intended checks across all our autoconf supported versions. - zz40-xc-ovr.m4: provide XC_CONFIGURE_PREAMBLE macro - configure: autotools compatibility fixes - step I Fix proper macro expansion order across autotools versions for C compiler and preprocessor program checks. - configure: fix automake 1.13 compatibility Tested with: buildconf: autoconf version 2.69 buildconf: autom4te version 2.69 buildconf: autoheader version 2.69 buildconf: automake version 1.13.1 buildconf: aclocal version 1.13.1 buildconf: libtool version 2.4 buildconf: GNU m4 version 1.4.16 - ares_private.h: use again memdebug.h instead of curl_memdebug.h - configure.ac: replace AM_CONFIG_HEADER with AC_CONFIG_HEADERS automake 1.13 errors if AM_CONFIG_HEADER is used in configure script. - cares-override.m4: provide AC_CONFIG_MACRO_DIR definition conditionally Provide a 'traceable' AC_CONFIG_MACRO_DIR definition only when using an autoconf version that does not provide it, instead of what we were doing up to now of providing and overriding AC_CONFIG_MACRO_DIR for all autoconf versions. - ares_private.h: use curl_memdebug.h instead of memdebug.h - vc6cares.dsp: add ares_create_query.c and ares_parse_soa_reply.c - cares-functions.m4: improve gethostname arg 2 data type check - setup_once.h: HP-UX specific 'bool', 'false' and 'true' definitions. Also reverts commit bceb40095a - configure: check if compiler halts on function prototype mismatch - cares-functions.m4: add gethostname arg 2 data type check and definition - cares-functions.m4: update thread-safeness detection of getaddrinfo() Take in account that POSIX standard Issue 7 drops h_errno support. Now, we also consider getaddrinfo() to be thread-safe when (_POSIX_C_SOURCE >= 200809L) or (_XOPEN_SOURCE >= 700) independently of whether h_errno exists or not. Take in account that h_errno might be a modifiable lvalue not defined as a C preprocessor macro. - setup_once.h: HP-UX issue workaround Issue: When building a 32bit target with large file support HP-UX header file may simultaneously provide two different sets of declarations for sendfile and sendpath functions, one with static and another with external linkage. Given that we do not use mentioned functions we really don't care which linkage is the appropriate one, but on the other hand, the double declaration emmits warnings when using the HP-UX compiler and errors when using modern gcc versions resulting in fatal compilation errors. Mentioned issue is now fixed as long as we don't use sendfile nor sendpath functions. - setup_once.h: refactor inclusion of and Inclusion of these two header files now done in setup_once.h - Header inclusion clean-up Remove header inclusions already done in setup_once.h - setup_once.h: HP-UX specific TRUE and FALSE definitions Some HP-UX system headers require TRUE defined to 1 and FALSE to 0. - ares_timeout.c: fix compiler warning - ares_create_query.c: IRIX compilation fix - c-ares/nameser.h: add some T_* defines for ns_t_* values Daniel Stenberg (7 Nov 2012) - Revert "ares_parse_aaaa_reply: fix memory leak" This reverts commit 50f25d8a4b2d16f4c5e0ef620238688b7a315c7a. - ares_parse_aaaa_reply: fix memory leak an allocated buffer was not freed in the successful case. - [Gisle Vanem brought this change] adig: perror() doesn't work for socket errors on windows ... so print the SOCKERRNO instead - get_DNS_AdaptersAddresses: fix IPv6 parsing Use of the wrong define made the function not parse IPv6 addresses properly. Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-06/0028.shtml Reported by: Saúl Ibarra Corretgé - version: bumped to 1.10.0 Due to the newly added function: ares_create_query() - AUTHORS: synced with 83093ac450 Added 21 authors since this document was last updated - ares_create_query.3: mention when this is added - [hpopescu@ixiacom.com brought this change] Added new feature (rfc2671) - code police: fix indents, < 80 columns, reflowed comments Guenter Knauf (11 Jul 2012) - Cleaned up version awk script. Daniel Stenberg (30 Jun 2012) - [Gisle Vanem brought this change] read_udp_packets: bail out loop on bad sockets I can see that recvfrom() in ares_process.c many times is called with 'udp_socket' == ARES_SOCKET_BAD. The code takes care not to call recv/recvfrom with ARES_SOCKET_BAD in the outer-loop. So should the inner-loop. Yang Tse (29 Jun 2012) - cares-compilers.m4: remove -Wstrict-aliasing=3 from clang Currently it is unknown if there is any version of clang that actually supports -Wstrict-aliasing. What is known is that there are several that don't support it. - cares-compilers.m4: -Wstrict-aliasing=3 for warning enabled gcc and clang builds Daniel Stenberg (18 Jun 2012) - version: work towards 1.9.2 (at least) Version 1.9.1 (18 Jun 2012) Daniel Stenberg (18 Jun 2012) - RELEASE-NOTES: 1.9.1 coming up Version 1.9.0 (16 Jun 2012) Daniel Stenberg (16 Jun 2012) - ares_version.h: next version is 1.9.0 - [Marko Kreen brought this change] ares_data.h: ARES_DATATYPE_SOA_REPLY is added in 1.9.0 - RELEASE-NOTES: synced with 979bf951d Next release deemed to become 1.9.0 due to the new function - [Marko Kreen brought this change] SOA parser added I need to do SOA queries, so here is a parser for them. - ares_soa_reply: new struct - ares_malloc_data/ares_free_soa: ARES_DATATYPE_SOA_REPLY - ares_parse_soa_reply: actual function Yang Tse (14 Jun 2012) - Kill compiler warning - Fix libcares.pc generation for static MingW* cross builds Daniel Stenberg (21 May 2012) - [Nick Alcock brought this change] Fix UDP and TCP port byte order in saved options. The UDP and TCP port are stored in network byte order in the ares_channeldata, but are passed in to ares_init_options() in host byte order. Thus we must return them from ares_save_options() in host byte order too, or a duplicated channel will convert them again, leading to a nonfunctional channel and a mysterious connection refused error from ares_gethostbyname(). This breaks ares_dup(), thus the curl easy API when c-ares is used by curl, and thus all the curl easy API's users. Yang Tse (28 Apr 2012) - version: start working on 1.8.1-DEV Version 1.8.0 (27 Apr 2012) Daniel Stenberg (27 Apr 2012) - RELEASE-NOTES: call next 1.8 instead Since we added a function, let's use a stricter bumping scheme Yang Tse (25 Apr 2012) - INSTALL: some adjustments Daniel Stenberg (25 Apr 2012) - GIT-INFO: mention buildconf Yang Tse (25 Apr 2012) - INSTALL: remove more sections that don't apply to c-ares - ares_timeout.c: fix compiler warning Daniel Stenberg (25 Apr 2012) - [Ben Noordhuis brought this change] Makefile.m32: fix mingw32 build * add . to include path so ares_build.h is picked up * make ar configurable to ease cross-compiling - RELEASE-NOTES: added what's happened since 1.7.5 Guenter Knauf (22 Apr 2012) - Updated copyright year. Yang Tse (21 Apr 2012) - ares_init.c: Further refactoring of Windows system's DNS fetching code Guenter Knauf (20 Apr 2012) - Android: small changes to dns property part. Prefix prop vars; kill var; use DNS_PROP_NAME_PREFIX macro. - Handle CNAME-only in ares_parse_aaaa_reply(). posted to the c-ares list by Peter Griess . - Add support for multiple DNS servers on Android. Before, c-ares always used the first DNS server on Android, causing network problems if this DNS server was not available. Signed-off-by: Geert Uytterhoeven - Added INSTALL so it gets into tarballs. - Added some more ifdefs to silent compiler warnings. Yang Tse (17 Apr 2012) - INSTALL: remove a non c-ares section - cares-compilers.m4: -Wno-pedantic-ms-format for Windows gcc 4.5 builds When building a Windows target with gcc 4.5 or newer and strict compiler warnings enabled use -Wno-pedantic-ms-format in addition to other flags. - setup_once.h: tighten requirements for stdbool.h header inclusion Include stdbool.h only when it is available and configure is capable of detecting a proper 'bool' data type when the header is included. - configure: NATIVE_WINDOWS no longer defined in config file - cares-compilers.m4: double underscore decoration for visibility attribute - build adjustments: CARES_SYMBOL_HIDING no longer defined in config files configure script now provides conditional definitions for Makefile.am that result in CARES_SYMBOL_HIDING being defined by resulting makefiles when appropriate. - configure: Windows cross-compilation fixes CARES_BUILDING_LIBRARY and CARES_STATICLIB no longer defined in ares_config.h, configure will generate appropriate conditionals so that mentioned symbols get defined and used in Makefile derived from Makefile.am at compilation time. Guenter Knauf (17 Apr 2012) - Added INSTALL file adapted from libcurl. Not yet ready, and needs further edits. Yang Tse (16 Apr 2012) - ares_init.c: get_iphlpapi_dns_info() refactoring Guenter Knauf (16 Apr 2012) - Kill some more compiler warnings. - Kill compiler warning about unused var. - Fixed my last commit: wrong preprocessor directive. - Check for __ANDROID__ in addition to ANDROID macro. - Check for __ANDROID__ in addition to ANDROID macro. Posted to c-ares list by Wayne. - Fix for Android to disable useless arpa/nameser.h. - Fix for Android to include sys/select.h for fd_set. Yang Tse (17 Mar 2012) - ares_data.c: some NAPTR related fixes Daniel Stenberg (16 Mar 2012) - port numbers: convert them to network order! When the config options ARES_OPT_UDP_PORT or ARES_OPT_TCP_PORT are used, make sure to convert them to network byte order! Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-02/0004.shtml - white space cleanup - Keep code within 80 columns - Removed funny spaces after open paren and before closing paren - [Poul Thomas Lomholt brought this change] get_iphlpapi_dns_info: fix buffer overrun I experienced a buffer overrun exception in c-ares on Windows and tracked it down to be an error in the calculation of the 'left' variable in get_iphlpapi_dns_info(). I changed the variable type of 'left' to a _signed_ type because of the subtraction arithmetic; not sure if a long is the best choice - Merge pull request #7 from saghul/naptr Added support for parsing NAPTR records saghul (23 Feb 2012) - Added support for parsing NAPTR records Yang Tse (19 Jan 2012) - ares_init.c: fix compiler warning on winsock builds - configure: libtool 1.5 tweaks Daniel Stenberg (19 Dec 2011) - ares_timeout.3: fix the NAME section It was clearly a copy n' paste error Yang Tse (27 Sep 2011) - [Albert Chin brought this change] configure - m4: make CURL_CHECK_DEF ignore leading whitespace on symbol def When using Sun C compiler the preprocessor somehow inserts an extra space in front of replaced symbol, breaking CURL_CHECK_DEF macro. To workaround this, macro CURL_CHECK_DEF now ignores all leading whitespace in front of symbol substitution result. - ares_init.c: fix segfault triggered in ares_init_options() upon previous failure of init_by_defaults() and incomplete cleanup there. - ares_process.c: fix compiler warning - fix MSVC compiler warning 'conditional expression is constant' - setup_once.h cleanup and sync - [Denis Bilenko brought this change] ares_getnameinfo: fix random results with c-ares 1.7.5 In ares_getnameinfo memcpy did not copy enough bytes, causing it to return arbitrary memory contents as a result. - warnings: fix another 'conversion may lose significant bits' compiler warning - ares_dns.h: adjust DNS__16BIT and DNS__32BIT macro definitions Fixing compiler warnings existing definitions triggered on these. - ares_destroy.c: fix segfault in ares_destroy_options() Daniel Stenberg (21 Aug 2011) - ares_parse_srv_reply: silence compiler warnings ... by adding ugly typecasts. - CHANGES: generate from script The CHANGES file is now generated automatically with 'git2changes.pl', invoked by the maketgz script which is used to build release archives. The former human edited CHANGES file was renamed to CHANGES.0 in git. Yang Tse (21 Aug 2011) - Makefile.netware: SIZEOF_SHORT definition - warnings: fix some 'conversion may lose significant bits' compiler warnings - configure: fix symbol hiding usability check A more thorough test is done now in order to determine visibility attribute usability, given that some compilers don't support visibility attribute on all configurations. Daniel Stenberg (16 Aug 2011) - 1.7.6: start working... Version 1.7.5 (16 Aug 2011) Daniel Stenberg (16 Aug 2011) - CHANGES: synced for 1.7.5 release - RELEASE-NOTES: synced with bb4096effef7f000 Jakub Hrozek (15 Aug 2011) - Only fall back to AF_INET searches when looking for AF_UNSPEC addresses Yang Tse (10 Aug 2011) - [Gisle Vanem brought this change] ares_iphlpapi.h: Watcom C fix Added "!defined(_WS2DEF_)" since Watcom doesn't have a per type guard for the typedefs 'CSADDR_INFO' (that MingW has) or 'SOCKET_ADDRESS' (that MSVC has). But we can use the header-guard for instead. - [Gisle Vanem brought this change] Makefile.Watcom: * The 'NTDDI_VERSION' needs to be raised to 0x05010000 in order for SOCKADDR_STORAGE etc. to be typedefed. * Replaced '-dUSE_WATT32' with '-dWATT32'. * Added $(DEMOS) to the 'all' target and removed the 'demos' target to be consistent with e.g. Makefile.msvc etc. * 'ENABLE_IPV6' is no longer used. Hence removed the '%use_ipv6' construct. * object-file order seems to be important (Watcom v.19). Hence 'ares_getopt.obj' must be put after the .obj that references getopt(). - cares-compilers.m4: CARES_CONVERT_INCLUDE_TO_ISYSTEM adjustments Add CARES_CHECK_COMPILER as a requirement. Ensure macro does nothing unless GNU_C or CLANG compiler is used. This should allow usage of this macro in unforeseen placements. - config-win32.h: comments adjustments - followup - config-win32.h: comments adjustments Daniel Stenberg (5 Aug 2011) - [Tom Hughes brought this change] ares_parse_a_reply: fix memleak Yang Tse (29 Jul 2011) - cares-functions.m4 serial # bump - Revert "configure: additional flag checks for fcntl() and socket()" This reverts commit 5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7. - configure: additional flag checks for fcntl() and socket() - xc-translit.m4 fix quoting - configure: avoid direct usage of AS_TR_* macros - xc-translit.m4 provides transliteration macros with well defined behavior. Jakub Hrozek (15 Jun 2011) - Revert "Only fall back to AF_INET searches when looking for AF_UNSPEC addresses" This reverts commit b5823d65706af687c0e5110af8f0cfdcd068997d. This patch was not reviewed properly before pushing - Revert "Do not use sized constants in public headers" This reverts commit 22c01e96f7b2ae9923e1baa50bfe3c0d22297a7d. This is a Red Hat specific patch that does not belong into upstream - Use correct sizeof in ares_getnameinfo() - Do not leak rr_name on failures inside ares_parse_ptr_reply - Do not leak rr_name on failures inside ares_parse_a_reply - Do not leak rr_name on failures inside ares_parse_aaaa_reply - Do not leak rr_name on failures inside ares_parse_ns_reply - Fix incorrect sizeof() in ares_save_options - Fix incorrect allocation in ares_parse_ptr_reply() - Only fall back to AF_INET searches when looking for AF_UNSPEC addresses - Do not use sized constants in public headers Daniel Stenberg (13 Jun 2011) - [Jakub Hrozek brought this change] ares_free_hostent(NULL) should be a noop Yang Tse (8 Jun 2011) - configure: fix recvfrom 5th arg type qualifier detection (followup) - configure: fix recvfrom 5th arg type qualifier detection Additionally remove whitespace from EOL Daniel Stenberg (4 Jun 2011) - strlen: use size_t to receive the return Yang Tse (4 Jun 2011) - xlc: avoid preprocessor definition usage when linking - ares_nowarn: icc 9.1 workaround - ares_nowarn: header inclusion fix - ares_init: make ares_private.h last included header again - compiler warning: fix Fix compiler warning: conversion may lose significant bits - compiler warning: fix Fix compiler warning: variable was set but never used Fix compiler warning: clobber ignored - ares_iphlpapi: fix compiler warnings - winsock: compilation fixes Provide winsock iphlpapi alternative definitions to prevent compilation failures when using a variety of winsock header implementations. Daniel Stenberg (17 May 2011) - [David Stuart brought this change] IPv6-on-windows: find DNS servers correctly - man pages: docs for the c-ares utility programs - ares_parse_ns_reply.c: remove CVSism Yang Tse (27 Mar 2011) - build: fix header inclusion - getservbyport replacement for Win CE - renamed getplatform() to ares__getplatform() to avoid namespace pollution - configure: fix libtool warning Recent versions of libtool are now tracing usage of AC_CONFIG_MACRO_DIR macro and warn heavily when not used in configure script along with ACLOCAL_AMFLAGS in Makefile.am. So in order to make libtool happy while keeping backwards compatibility this is added. - adig: RFC4034 resource record type detection Can be tested with: adig -s 8.8.8.8 -t ANY example.com - nameser.h: RFC4034 resource record type definitions - build: move platform stuff to ares_platform.c and ares_platform.h - build: find out windows platform using GetVersionEx() - build: use getenv() replacement function for systems which lack it - setup_once: system error codes for Windows CE - ares_search: use ERRNO macro for portability sake - System's errno.h inclusion cleanup follow-up. System's errno.h is conditionally included from setup_once.h - Windows CE specific adjustment All versions of Windows CE support Winsock 1.1 - System's errno.h inclusion cleanup. System's errno.h is conditionally included from setup_once.h - ares_init: fix gethostname error detection on winsock platforms - configure: r-enable temporarily disabled detection of system's inet_ntop() Detection was temporarily disabled in commit 674e044ccb21f2f63537da53565fce868f Daniel Stenberg (15 Mar 2011) - configure: stop using the deprecated AM_INIT_AUTOMAKE syntax - [Gisle Vanem brought this change] Watt-32: use errno Make sure Watt-32 programs use 'errno' even on Win32 targets Guenter Knauf (18 Feb 2011) - Removed commented CLFAGS no longer needed. - Fixed CFLAGS for NetWare. Added -m32 to enable compilation with x86_64 compilers; added conditional to set -fpcc-struct-return only for gcc compiler. Daniel Stenberg (18 Feb 2011) - [Gisle Vanem brought this change] Watt32: fix server init Somewhere in the process, programs using the Watt-32 tcp/ip stack stopped working. - [Dima Tisnek brought this change] config_sortlist: (win32) missing else Without an else there, contents of "pat" that could have been successfully set just above, may be clobbered by successive unsuccessful calls to "xxx_pton" or "ip_addr". Yang Tse (17 Jan 2011) - Makefile.msvc: add a couple of VS version strings - Makefile.msvc: add a couple of VS version strings - build: add install target to Makefile.msvc Daniel Stenberg (27 Dec 2010) - ares_set_servers_csv: remove unused variables - init_by_resolv_conf: fix compiler warnings The code received the return codes in the 'status' variable without using it. Instead we just ignore those particular errors. - getv4: Value stored to 'dst' is never read - advance_tcp_send_queue: avoid NULL ptr dereference If given a too large 'num_bytes' value, it would cause a NULL ptr dereference. Instead the code will now break out of the loop at the end of the list. - [Peter Pentchev brought this change] configure: fix a bashism - cleanup: avoid unsafe typecasts Avoid the risk of reading 16bit data from an unaligned address by using a macro that is adapted for this. - [Stefan Bühler brought this change] ares_expand_name: Fix encoded length for indirect root Yang Tse (18 Dec 2010) - build: add some explicit file references to VS project files - config-win32: provide HAVE_ASSERT_H definition - build: include ares_nowarn in sample program VS project files - build: include ares_nowarn among SAMPLESOURCES and SAMPLEHEADERS - configure: temporarily disable detection of system's inet_ntop() This is done to allow compilation of ares_inet_ntop() by some daily builds picky compilers that otherwise do not need this function. - changes: mention last fix - ares_inet_ntop: remove definition and usage of macro SPRINTF Existing definition of SPRINTF always resulted in sprintf() being used, and sprintf() returning 'int' is already used throughout the library. - ares_inet_ntop: reapply changes from previous c-ares version (III) - Replace 'u_char' with 'unsigned char'. - Replace 'u_int' with 'unsigned int'. - use macros ERRNO and SET_ERRNO() for errno handling. - ares_inet_ntop: reapply changes from previous c-ares version (II) - Remove rcsid. - Adjust header file inclusions. - ares_inet_ntop used only on systems without a proper inet_ntop function. - ares_inet_ntop: reapply changes from previous c-ares version (I) - Replace tabs with spaces. - Use ANSI C style for function declarations and definitions. - Use sizeof with parentheses. - ares_inet_ntop: fix off by one error triggering out of bounds write ares_inet_ntop would trigger an out of bounds write when the representation of the address required 15 characters, due to not taking in account null termination character. Full import of inet_ntop.c from bind-9.5.3rc1 to pull additional fixes. - ares_nowarn: add conditional inclusion of assert.h header - fix compiler warning: conversion may lose significant bits - ares_inet_net_pton: fix non-rejection of some malformed literals ares_inet_net_pton would return wrong values when excessively large, and invalid, netmasks are used. Fixes are from bind-9.5.3rc1, issue also described in the WLB-2008080064 advisory. - setup_once: provide ISASCII macro - configure: inet_net_pton function check adjustments Define HAVE_INET_NET_PTON only when system's inet_net_pton function is IPv6 capable and is not affected by the WLB-2008080064 advisory. HAVE_INET_NET_PTON_IPV6 is no longer defined nor used. - ares_init: fix detection of semicolon comments in resolv.conf File resolv.conf may either use a hash '#' or a semicolon ';' character as an indication that the rest of the line is a comment. This fixes not recognizing the semicolon as a valid comment indicator in resolv.conf. - version: start working on 1.7.5 Version 1.7.4 (8 Dec 2010) Daniel Stenberg (8 Dec 2010) - release-preps: CHANGES and RELEASE-NOTES synced - ares_set_local_*: added in 1.7.4, not before Yang Tse (3 Dec 2010) - build: provide SIZEOF_SIZE_T definition for non-configure builds - build: config.dos renamed to config-dos.h - build: provide SIZEOF_SIZE_T netware definition - ares_gethostbyaddr: fix compiler warning: conversion may lose significant bits - configure: undo using autobuilds to temporarily verify strict aliasing warnings. - fix compiler warning: rounding, sign extension, or loss of accuracy may result Daniel Stenberg (2 Dec 2010) - [Ben Noordhuis brought this change] ares_parse_a_reply: fix CNAME response parsing Reply to a CNAME query doesn't contain addresses, causing ares_parse_a_reply() to bail out with ARES_ENODATA Bug: http://groups.google.com/group/nodejs/browse_thread/thread/a1268c9ea5e9ad9b Yang Tse (1 Dec 2010) - fix compiler warning: conversion may lose significant bits - atoi: remove atoi usage - ares_init: fix compiler warning: conversion may lose significant bits - configure: fix autoconf warning - inet_pton: fix compiler warning - configure: use autobuilds to temporarily verify strict aliasing warnings. Temporarily, When cross-compiling with gcc 3.0 or later, enable strict aliasing rules and warnings. Given that cross-compiled targets autobuilds do not run the test-suite, there is no risk of running code that violates strict aliasing rules - ares_getnameinfo: Partially revert commit 85520d66e0ac7ac73411bc25e98769a88b2f Upon socket address family and length validation failure return ARES_ENOTIMP in callback again, this is the error code documented in man page and used mostly all over the library. - ares_getnameinfo: Validate socket address family and length. Validate socket address family and that the socket address length is appropriate for the specified family. Failure is reported with ARES_EBADFAMILY in callback. - ares_getnameinfo: fix two compiler warnings - Added another VS10 version string - Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. - Revert commit 494274e653936335c255a47599970de3df21e7c4 - configure: fix autoconf 2.68 warning: no AC_LANG_SOURCE call detected in body - Fix compiler warning: array subscript has type 'char' - Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. - Revert following commits: 07bc7ea79509bcc9ef6e09151e81766ed00d3392 3392a50ea3f8573ea4b7a9d82b9833dab60cb0e9 9912637d32c9987719a1ea12db591aee2941891c The purpose of the whole patch was to silence a compiler warning triggered with GCC 4 on file ares_process.c The specific compiler warning was 'dereferencing type-punned pointer might break strict-aliasing rules'. A simpler patch will follow to equally silence the warning. - ares_options: reorder header inclusions to make inclusion of ares_private.h the last included one again. Daniel Stenberg (12 Nov 2010) - [Patrik Thunstrom brought this change] adig: fix NAPTR parsing I ran across a small "issue" in your adig example. It is simply the last part of the NAPTR record, the replacement element, which is not a string, as currently handled in adig, but a domain name. - ares_save_options: assignments instead of memcpy - init_by_options: don't copy an empty sortlist If there aren't any sort items to copy, don't bother. Without this little precaution it would do a malloc(0) which causes undefined behaviors and is frowned upon by curl's memdebug-system. Guenter Knauf (3 Oct 2010) - Minor Watcom makefile tweaks. Daniel Stenberg (30 Sep 2010) - [Mike Crowe brought this change] Fix lookup with HOSTALIASES set. ares__read_line returns ARES_EOF when it reaches the end of the file. This will happen every time when reading to the end of the HOSTALIASES file. Unfortunately single_domain treats this error as being fatal. Signed-off-by: Mike Crowe Ben Greear (24 Aug 2010) - Add missing break that caused get_ares_servers to fail. Reported-by: Ning Dong Signed-off-by: Ben Greear Yang Tse (11 Aug 2010) - configure: werror related adjustments Guenter Knauf (8 Aug 2010) - Added copyright string to ares_version.h and make use of it in other files. - Block created ares_build.h for NetWare to avoid usage from other platforms. - Fix to overwrite default libname. - Some more Watcom makefile massage ... - Some more Watcom makefile massage ... Ben Greear (4 Aug 2010) - sock-addr-storage: Detect and deal with lack of .ss_family member. AIX, at least, does not have sockaddr_storage.ss_family member. Detect this in the configure logic and use proper #ifdefs in the ares_process logic. Signed-off-by: Ben Greear Tested-by: Tor Arntsen Guenter Knauf (3 Aug 2010) - Added Watcom makefile based on libcurl's Makefile.Watcom. Ben Greear (31 Jul 2010) - typo: Fix compile bug for platforms that don't have sockaddr_storage. Bug was introduced by me in previous commit. Signed-off-by: Ben Greear - Fix aliasing warning in gcc 4.4.4 (at least). Should be no functional change, though the code gets a bit ugglier. Signed-off-by: Ben Greear Daniel Stenberg (31 Jul 2010) - ares_set_servers_csv: use ISDIGIT The IS*() set of macros are preferred to the regular is*() functions as they help us avoid the most common pitfalls. Ben Greear (30 Jul 2010) - cast arg to isdigit to int Looks like it might silence a warning on Netware build. Signed-off-by: Ben Greear - remove all uses of uint32_t Previous fix forgot a few. Signed-off-by: Ben Greear - fix signed v/s unsigned casts warning in ares_gethostbyaddr.c Signed-off-by: Ben Greear - local-bind-fixup: Fix inet_pton warning. Conditionally include for inet_pton headers. Signed-off-by: Ben Greear - build: Enable compiling with -Werror. This helps find compile warnings because they simply break the build. To use: ./configure --enable-warnings --enable-werror Signed-off-by: Ben Greear - ipv6: Fix some build issues related to the local-bind feature. Signed-off-by: Ben Greear Guenter Knauf (29 Jul 2010) - Replaced uint32_t with unsigned int to fix broken builds on a couple of platforms. Daniel Stenberg (18 Jul 2010) - [Ben Greear brought this change] local-bind: Support binding to local interface/IPs Add 3 new functions to set the local binding for the out-going socket connection, and add ares_set_servers_csv() to set a list of servers at once as a comma-separated string. Signed-off-by: Ben Greear - version: now start on 1.7.4 - [Andrew C. Morrow brought this change] fix memory leak in ares_getnameinfo Version 1.7.3 (11 Jun 2010) Daniel Stenberg (11 Jun 2010) - changelogs: updated for 1.7.3 - [BogDan Vatra brought this change] init: allow c-ares to work on Android OS - changelog: fill in the 1.7.2 changes - added another pdf to ignore Yang Tse (11 Jun 2010) - add ares_parse_mx_reply.c to VS dsp file Daniel Stenberg (10 Jun 2010) - tarball: add $(CSOURCES) $(HHEADERS) to EXTRA_DIST It's not clear to me why we need this, but we apparently may otherwise not get all files bundled in the dist tarball. - version: start working on 1.7.3 Version 1.7.2 (10 Jun 2010) Daniel Stenberg (10 Jun 2010) - RELEASE-NOTES: 1.7.2 details added - [Jakub Hrozek brought this change] ares_init: Last, not first instance of domain or search should win - style: make code less than 80 columns wide Yang Tse (31 May 2010) - [Tor Arntsen brought this change] improve alternative definition of bool to use enum instead of unsigned char - fix VS2010 compiler warnings Daniel Stenberg (18 Apr 2010) - [Jérémy Lal brought this change] added ares_parse_mx_reply - repair the file mode - remove all $Id$ lines - remove all .cvsignore files - spell fix reported by Gregor Jasny on the mailing list - [Peter Pentchev brought this change] Fix a couple of typos and grammar nits. - ignore the GPG signature files too - start the journey towards 1.7.2 - no longer CVS tagging - ignore generated PDFs Version 1.7.1 (23 Mar 2010) Daniel Stenberg (23 Mar 2010) - 1.7.1 - made README the primary readme file ... and did README.cares to contain a historic reason etc. - s/CVS/git - git now, not CVS - ignore lots of generated files - [Daniel Johnson brought this change] Fix warnings for clang Yang Tse (17 Mar 2010) - replaced intel compiler option -no-ansi-alias with -fno-strict-aliasing - update outdated serial number - fix compiler warning - watt32 compilation fix - Added another VS10 version string - fix line break - removed usage of 's6_addr', fixing compilation issue triggered with no longer using 'in6_addr' but only our 'ares_in6_addr' struct Daniel Stenberg (5 Mar 2010) - Daniel Johnson provided fixes for building with the clang compiler Yang Tse (5 Mar 2010) - Added IPv6 name servers support Gisle Vanem (5 Mar 2010) - Ops!. Readded ares_nowarn.h. - Added ares_nowarn.c. Yang Tse (28 Feb 2010) - Added SIZEOF_INT and SIZEOF_SHORT definitions for non-configure systems - Added ares_nowarn.* to VC6 project file - Added SIZEOF_INT definition - fix compiler warning - fix compiler warning - fix compiler warning Daniel Stenberg (17 Feb 2010) - ares_reinit() - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much like the res_init() resolver function offers - - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't check for broken connections like ares_process() did. Based on that, I merged the two functions into a single generic one with two front-ends. Yang Tse (30 Dec 2009) - VMS specific preprocessor symbol checking adjustments - Mention last changes - - Fix configure_socket() to use ares_socket_t instead of int data type. - - Where run-time error checks enabling compiler option /GZ was used it is now replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions. - Compiler option /GX is now replaced with equivalent /EHsc for all versions. - - Ingmar Runge noticed that Windows config-win32.h configuration file did not include a definition for HAVE_CLOSESOCKET which resulted in function close() being inappropriately used to close sockets. Daniel Stenberg (30 Nov 2009) - start working on 1.7.1 Version 1.7.0 (27 Nov 2009) Yang Tse (27 Nov 2009) - Preserve empty line following last target - - Larry Lansing fixed ares_parse_srv_reply to properly parse replies which might contain non-SRV answers, skipping over potential non-SRV ones such as CNAMEs. - When using icc, compile with -fpic and link with intel dynamic libraries. - Added 'currently' in italics to insist on transient situation. - Fix language - Daniel wants upcoming release to be 1.7.0 - Mention last changes - - Removed from external interface preprocessor symbol definition for CARES_HAVE_ARES_FREE_DATA. Current functionality of ares_free_data() makes it unnecessary. - Added README.msvc - Changed c-ares naming conventions when using MSVC as described in README.msvc - - Mention other recent changes - - Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and ares_addr6ttl in order to prevent name space pollution, along with necessary changes to code base and man pages.This change does not break ABI, there is no need to recompile existing applications. But existing applications using these structs with the old name will need source code adjustments when recompiled using c-ares 1.6.1. - - Jakub Hrozek fixed more function prototypes in man pages to sync them with the ones declared in ares.h - Make configure remove the ares_build.h file included in distribution tarballs. - Fix macro redefinition. - Fix name space pollution. - Allow using different extra import libraries for debug and release builds. - Add manifest stuff to msvc makefile - Sync man page with reality - Add missing external API decoration for ares_set_socket_callback() - Add ares_free_data() man page. - - Provide in external interface preprocessor symbol definitions for CARES_HAVE_ARES_FREE_DATA as an indication of function availability. - Remove typecast - Fix comment - Add ares_data.c and ares_data.h - Jakub Hrozek modified ares_parse_srv_reply() and ares_parse_txt_reply() API to return a linked lists of results. These were also modified to internally use the ares_data memory struct and as such its result must be free'ed with ares_free_data(). - Initial support for the generic ares_free_data() function that will allow applications to free memory allocated and returned by some c-ares funtions. - Make usage of calloc()'s arguments consistent with rest of code base - workaround icc 9.1 optimizer issue - Add icc fvisibility bug test - Fix icc 9.0 compiler warning: external definition with no prior declaration - Fix three var names - Add check for assert.h header file - getaddrinfo is fully thread safe on solaris versions which implement the function even when h_errno is not a macro. The h_errno macro test now only done on systems for which there is no hard coded knowledge about getaddrinfo's thread safeness. - Remove files generated on previous buildconf/configure run - Remove enable-thread / disable-thread configure option. These were only placebo options. The library is always built as thread safe as possible on every system. - Refactor how preprocessor symbol _THREAD_SAFE definition is done. - Assume that getaddrinfo is thread safe, unless hard coded knowledge says the contrary or h_errno is not defined. - Related with the threadsafe capability of getaddrinfo: - Constantine Sapuntzakis reported that Darwin 6.0 a.k.a. MAC OS X 10.2 and newer have a threadsafe getaddrinfo. - Fix Dragonfly BSD triplet detection. - In case the hard-coded knowledge says that getaddrinfo is threadsafe, an additional check is done to verify that h_errno is also defined. If h_errno isn't defined, we finally assume that it isn't threadsafe. Jamie Lokier provided the inspiration for this extra check. - AIX 5.2 and newer have threadsafe getaddrinfo. Add some comments to better understand what the regex's pretend to achieve. - HP-UX 11.11 and later have threadsafe getaddrinfo - Check if getaddrinfo is threadsafe when function check allows it to be used - Renamed fpGetNetworkParams and fpSystemFunction036 to avoid namespace pollution with static library - Add kernel32.lib - Mention last changes - Reinstate copyright symbol lost in previous commit - Make some strings different in resource file for debug or release builds - Ignore more subdirs - Fix compiler warning: conditional expression is constant - Sync linker and resource compiler options with Makefile.msvc - Follow Makefile.msvc subdirectory naming scheme, and sync compiler options - Updated MSVC makefile that allows building dynamic and static c-ares libraries in debug and release flavours. Additionally each of the three sample programs is built against each of the four possible c-ares libraries, generating all this a total number of 12 executables and 4 libraries. - Test for USE_WINSOCK since it is more restrictive than WIN32 - Make header inclusion depend on HAVE_*_H definition - Remove unneeded preprocessor directives - Adjust c-ares include paths for memory tracking enabled (--enable-curldebug) builds - source files used by sample programs - Renamed c-ares setup.h to ares_setup.h - Adjust include paths to take in account that currently: c-ares with --enable-curldebug uses memdebug.h from libcurl's lib subdirectory. memdebug.h needs access to libcurl's setup.h from libcurl's lib subdirectory and also needs access to libcurl's generated curl_config.h - Undo old temporary change once used for testing purposes - Mention many changes - Mention --enable-symbol-hiding configure option - Symbol hiding configure options renamed to the hopefully less ambiguous --enable-symbol-hiding and --disable-symbol-hiding as well as related macro names and some internal variables used for them. Related configuration file preprocessor symbols named to CARES_SYMBOL_HIDING and CARES_SYMBOL_SCOPE_EXTERN. - Header inclusion depending on HAVE_* symbol. Fix two typos. - Comparison of the Initial revision of this file with ares_parse_a_reply.c shows that this one is actually a modified copy of ares_parse_a_reply.c. In order to comply with ares_parse_a_reply.c's M.I.T. license, the old 1998 M.I.T. copyright notice is now also preserved in this file the same as it is done in other ares_parse_*.c files. - Add CVS Id tag. Fix identation of some license lines. - Add CVS Id tag. - Fix comment - In no particular order, changed/fixed all of the following in ares_parse_txt_reply() current version: - Fixed a couple of potential double free's. - Fixed memory leaks upon out of memory condition. - Fixed pointer arithmetic. - Setting ntxtreply to zero upon entry for all failure cases. - Changed data type to size_t for variables substr_len, str_len and the length member of ares_txt_reply struct. - Avoided a couple of memcpy() calls. - Changed i data type to unsigned int to prevent compiler warnings. - Adjusted a comment. - Use ARES_SUCCESS literal for successfull completion. - Added CVS Id tag. - Add c-ares DLL resource file to distribution archive - ignore files - Empty subdir - Updated MSVC 6.0 workspace and project files that allows building dynamic and static c-ares libraries in debug and release flavours. Additionally each of the three sample programs is built against each of the four possible c-ares libraries, generating all this a total number of 12 executables and 4 libraries. Daniel Stenberg (29 Oct 2009) - no need to check for NULL pointers before dereferencing, as the pointers MUST be valid and they are dereferenced further down in the function unconditionally! - shorten the descriptions somewhat - update to the new struct name - Jakub Hrozek added ares_parse_txt_reply() for TXT parsing - use 'ares_srv_reply' for proper name-spacing Yang Tse (29 Oct 2009) - Add reference for ares_parse_srv_reply.pdf - Add reference for ares_parse_srv_reply docs - External API function linkage decoration adjustment - External API function linkage decoration adjustment - Initial step towards the ability to reduce c-ares exported symbols based on the 'visibility' attribute for GNUC and __global for Sun compilers, taking also in account __declspec function decoration for Win32 and Symbian DLL's. Introducing configure options --enable-hidden-symbols and --disable-hidden-symbols following libcurl's naming. - Fix comment - Fix spelling - Fix Pelles C Win32 target compilation issues - John Engelhart noticed an unreleased problem relative to a duplicate ARES_ECANCELLED error code value and missing error code description. - Fix compiler warning: local variable may be used without having been initialized - Use *_CHECK_PATH_SEPARATOR_REQUIRED to ensure that *_CHECK_PATH_SEPARATOR is only expanded and included once in the configure script. - Our _AS_PATH_SEPARATOR_PREPARE override is now m4_defun'd instead of m4_define'd due to autoconf 2.64 m4_require'ing it in _AS_SHELL_SANITIZE indirectly through _AS_PATH_WALK. - Fix compiler warning: argument is incompatible with corresponding format string conversion - Fix potential out-of-bounds read - Fix compiler warning: loop without body - Fix compiler warning - Fix compiler warning - Fix compiler warning - Fix compiler warning: addition result could be truncated before cast to bigger sized type - Overhauled ares__get_hostent() - Fixing out of bounds memory overwrite triggered with malformed /etc/hosts file. - Improving parsing of /etc/hosts file. - Validating requested address family. - Ensuring that failures always return a NULL pointer. - Adjusting header inclusions. - Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak - more files to ignore - Check if _REENTRANT definition is required to make errno available as a preprocessor macro. - Attempt to silence bogus compiler warning: "Potential null pointer dereference" - ignore more files Gisle Vanem (7 Sep 2009) - Suppress warnings about unused prototypes in Watt32 and Win32 programs. - Update email address. - Update my email address. Add ares_config.h as dependency for 'make depend'. Yang Tse (6 Sep 2009) - T_SRV portability check Gunter Knauf (5 Sep 2009) - changed includes to match style how we do with all other *.c files. - changed u_int16_t to unsigned short because it is the only place within ares and curl where such a type would be used; also it broke many autobuilds. We should probably introduce an ares_port_t if we want to use a type here. Gisle Vanem (5 Sep 2009) - Replace 'uint16_t' with 'u_int16_t' since the latter is used in ares.h. - Added 'ares_parse_srv_reply.obj'. Added definition of 'u_int16_t'. This is I don't like; we should not depend on such non-universal types in a public header. But this is just a quick fix. Daniel Stenberg (4 Sep 2009) - - Jakub Hrozek added ares_parse_srv_reply() for SRV parsing Steinar H. Gunderson (27 Aug 2009) - Support lookup of IPv4 literals in ares_gethostbyname(), even when the address family is set to AF_INET6. Gisle Vanem (3 Aug 2009) - Remove call to LoadLibrary(). (leftover from debugging). - Fix bad sentence. Daniel Stenberg (3 Aug 2009) - - Timo Teras changed the reason code used in the resolve callback done when ares_cancel() is used, to be ARES_ECANCELLED instead of ARES_ETIMEOUT to better allow the callback to know what's happening. - - Joshua Kwan fixed the init routine to fill in the defaults for stuff that fails to get inited by other means. This fixes a case of when the c-ares init fails when internet access is fone. Gunter Knauf (16 Jul 2009) - test if adding ../lib to includes can fix the current break ... - renamed generated config.h to ares_config.h in order to avoid clashes when libcurl is used with other projects which also have a config.h. Yang Tse (21 Jun 2009) - Refactor how libraries are checked for connect() function, follow-up. - Refactor how libraries are checked for connect() function, and check for connect() as it is done for other functions. Gisle Vanem (20 Jun 2009) - Remove unneeded defines. - Use select_s() and not select(). Yang Tse (19 Jun 2009) - sclose() function-like macro definition used to close a socket, now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions. - add CloseSocket camel case function check - check for socket() and closesocket() as it is done for other functions - Remove HAVE_CONFIG_H definition from here, CFLAGS from common.dj already defines it. - initial step towards decoupling c-ares from libcurl for DOS - don't ignore these subdirs, they must be removed first - Remove DEBUGBUILD symbol definition, is not required for programs using the library. - DEBUGBUILD symbol definition for debug builds - ignore some subdirs - fix comment - Try to make more clear that --enable-curldebug has nothing to do with --enable-debug for this library. - Revert last change, it is inappropriate. Gisle Vanem (12 Jun 2009) - Replace CURLDEBUG with DEBUGBUILD. Yang Tse (11 Jun 2009) - when running automake copy missing files instead of symlinking them - Adjusted to take in account that... With the curl memory tracking feature decoupled from the debug build feature, CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows: CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug) DEBUGBUILD used for debug enabled specific code (--enable-debug) - c-ares' --enable-debug --enable-curldebug decoupling follow-up - mention last changes - Remove buildconf.bat from release and daily snapshot archives. buildconf.bat is only for CVS tree builds. - Ensure that buildconf.bat does nothing unless it is used with a CVS checkout. - CVS-INFO file only present in CVS tree, never in release nor daily snapshot archives. Used as a sentinel file in buildconf.bat to differentiate CVS builds. Gisle Vanem (8 Jun 2009) - Update comment about "ML". Removed "-D_USE_32BIT_TIME_T" (not a requirement). Yang Tse (8 Jun 2009) - just comment it out - For debugging purposes... Disable the '-export-symbols-regex' to discard this as the origin of link failures related with shared libraries and non-GNU linkers. - c-ares Makefile.am back to using $(top_builddir) for *_LDADD - c-ares' -no-undefined and --enable-curldebug adjustments - Use relative path to built c-ares tree libtool library - John E. Malmberg noticed that the configure script was failing to detect the timeval struct on VMS when building with _XOPEN_SOURCE_EXTENDED undefined due to definition taking place in socket.h instead of time.h - Fix compiler warning: out of bound access - fix compilation on AIX - c-ares' --enable-curldebug adjustments - Remove temporarily introduced memory leak. - Temporarily introduce a memory leak to verify curl debug memory tracking works. - Allow curl debug memory tracking when building a shared library on systems which support external, undefined, symbols in shared libraries. Daniel Stenberg (26 May 2009) - language fix Yang Tse (26 May 2009) - Make ares_init(), ares_dup() and ares_init_options() return ARES_ENOTINITIALIZED if library initialization has not been performed calling ares_library_init(). - c-ares's --enable-curldebug configure option decoupled from c-ares's --enable-debug - Prevent copying 'sourced' manpages for build targets that don't use them. Daniel Stenberg (23 May 2009) - minor edits Yang Tse (21 May 2009) - Include .pdf versions of c-ares man pages in distribution tarball. - Allow generation of .html and .pdf versions of c-ares man pages. Gisle Vanem (21 May 2009) - $(OBJ_DIR)/ares_getopt.o must be cleaned explicitly. Yang Tse (20 May 2009) - Mention last changes - Initial ares_library_cleanup(3) man page - Update man page - Update man page - Initial ares_library_init(3) man page attempt - Force revision update, to force CVS to update the $Id date string format - Add same copyright notice as other c-ares files - Fix case - Remove run-time requirement for advapi32.dll since c-ares can work even with no advapi32.dll at all. - Intentionally avoid checking if the address of SystemFunction036, a.k.a. RtlGenRandom, has been located or not. This function is only available on WinXP and later. When unavailable c-ares uses portable rand() function. - - Provide in external interface preprocessor symbol definitions for CARES_HAVE_ARES_LIBRARY_INIT and CARES_HAVE_ARES_LIBRARY_CLEANUP to ease the use of new capabilities. - Move ares_version() prototype to ares.h - Introduction of ares_library_init() and ares_library_cleanup() - Introduction of ares_library_init() and ares_library_cleanup() - remove outdated comment - Fix preprocessor conditional expression - fiX *__SOCKLEN_T definitions for remaining targets - *__SOCKLEN_T definitions for OS400 already fixed - fIX *__SOCKLEN_T definitions for SYMBIAN32 and VMS targets Daniel Stenberg (11 May 2009) - - Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to only expose functions starting with ares_. Yang Tse (11 May 2009) - Remove experimental check. Currently there's no need for it. - Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition attempt in generated config.h - Proper naming for the experimental compiler test and moved to *-compilers.m4 - Moved *_CHECK_COMPILER_HALT_ON_ERROR and *_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE to *-compilers.m4 along with other *_CHECK_COMPILER_* - fIX *__SOCKLEN_T definitions for OS400 and generic GCC targets - fIX *__SOCKLEN_T definitions for MVS and 370 targets - fIX *__SOCKLEN_T definitions for several Windows target tool-chains - HP-UX's X/Open network library requirement check follow-up - HP-UX's X/Open network library requirement check follow-up - Use build-time configured ares_socklen_t instead of socklen_t - David McCreedy's "TPF-platform specific changes to various files" patch follow-up Daniel Stenberg (1 May 2009) - s/libcurl/c-ares - version number typo fix Yang Tse (1 May 2009) - David McCreedy's "TPF-platform specific changes to various files" patch - Check definition of _XOPEN_SOURCE_EXTENDED with the compiler - Check if X/Open network library is required - cope with ares_build.h and ares_rules.h follow-up - Added some notes regarding ares_build.h - fix EOL - fix EOL - cope with ares_build.h and ares_rules.h - buildconf.bat for CVS-tree c-ares - Use 'unsigned int' instead of size_t attempting to avoid header inclusion - NetWare LibC's getpeername() third argument data type is size_t - Remove temporary debug tracing for ares_socklen_t Windows targets - ares_socklen_t follow-up - ares_build.h Windows follow-up - Add temporary debug tracing for ares_socklen_t Windows targets - ares_build.h NetWare follow-up - ares_build.h NetWare attempt - Initial step towards a configure time ares_socklen_t definition - ignore stamp-h* - Added CARES_INCLUDES_SYS_TYPES - Initial step towards a configure time curl_socklen_t definition - avoid use of alloca() - Moved potential inclusion of system's malloc.h and memory.h header files to setup_once.h. Inclusion of each header file is based on the definition of NEED_MALLOC_H and NEED_MEMORY_H respectively. - ignore Gisle Vanem (18 Apr 2009) - Added '-DHAVE_LIMITS_H'. Yang Tse (17 Apr 2009) - remove compiler options used while debugging the icc 9.1 optimizer issue - moved HAVE_LIMITS_H to common defines - Set HP-UX compiler warning level back to the one that exposes the socklen_t issue on this platform. - HAVE_LIMITS_H definition for NetWare CLIB - use HAVE_LIMITS_H symbol to protect limits.h inclusion - fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value - s/u_long/unsigned long/ - Do not halt compilation when using VS2008 to build a Windows 2000 target - ignore Phil Blundell (3 Feb 2009) - * February 3 2009 (Phil Blundell) - If the server returns garbage or nothing at all in response to an AAAA query, go on and ask for A records anyway. Daniel Stenberg (31 Jan 2009) - - ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving either AF_INET6 or AF_INET. It works by accepting any of the looksups in the hosts file, and it resolves the AAAA field with a fallback to A. Gisle Vanem (18 Jan 2009) - fopen() returns error in 'errno' even on Windows. So don't use ERRNO (GetLastError()). Trimmed trailing blanks. - Constified some arguments in local functions. Daniel Stenberg (14 Jan 2009) - - ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it now declares the private struct ares_in6_addr for all systems instead of relying on one possibly not present in the system. Phil Blundell (13 Jan 2009) - - ares__send_query() now varies the retry timeout pseudo-randomly to avoid packet storms when several queries were started at the same time. Daniel Stenberg (11 Jan 2009) - - Phil Blundell added the internal function ares__expand_name_for_response() that is now used by the ares_parse_*_reply() functions instead of the ares_expand_name() simply to easier return ARES_EBADRESP for the cases where the name expansion fails as in responses that really isn't expected. Gunter Knauf (30 Dec 2008) - added HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID to ares Makefile.netware and sync'd with other Makefile.netware. Daniel Stenberg (9 Dec 2008) - use the new URL - start over on the 1.6.1 release... Version 1.6.0 (9 Dec 2008) Daniel Stenberg (9 Dec 2008) - add space Gisle Vanem (9 Dec 2008) - Fix for Win32 targets using Watt-32. Dan Fandrich (9 Dec 2008) - C89 compilers (like Minix' ACK) only need to handle 31 functions arguments so split a long sprintf into two calls to get below that number. Gisle Vanem (8 Dec 2008) - Added needed defines for Watt-32 on Windows. - Undefine 'optarg', 'optind' and 'opterr' when using Watt-32 (to get correct linkage on Windows). - ares_writev() shall not be exported when using Watt-32 (has writev). Added _USE_32BIT_TIME_T to avoid runtime warning. Applies to VC-2008+ only. - Removed unneeded defines HAVE_SIGNAL_H, HAVE_SIG_ATOMIC_T, RETSIGTYPE and HAVE_PROCESS_H. Daniel Stenberg (4 Dec 2008) - the initial version of the ares_set_socket_callback man page - Gregor Jasny provided the patch that introduces ares_set_socket_callback(), and I edited it to also get duped by ares_dup(). Dan Fandrich (4 Dec 2008) - Bring the sys/include.h include test in line with curl's. Daniel Stenberg (3 Dec 2008) - Let's not call ares_save_options() deprecated just yet - Introduce ares_dup(3) and new thoughts about API/ABI and how to move forwards. Also discussed on the ml. Dan Fandrich (2 Dec 2008) - Make sure sys/socket.h is included before netinet/in.h (required by OpenWatcom C, and condoned by SUS) Daniel Stenberg (1 Dec 2008) - minor indent fix - Convert the public config struct to the same binary size/construct as in the latest releases to remain ABI compatible. Gisle Vanem (29 Nov 2008) - Added '-DHAVE_GETHOSTNAME'. Dan Fandrich (29 Nov 2008) - Make sure sys/socket.h is included before netinet/in.h (required by OpenWatcom C) - Netware has gethostname() - Fixed a couple of typos - Don't tweak the HAVE_* macros when using autoconf - Make use of gethostname() conditional on it being available - Only set TCP_NODELAY when it exists Daniel Stenberg (28 Nov 2008) - updated with changes, preparing for a release soon Yang Tse (26 Nov 2008) - Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a buffer to shrink instead of expand if a reply contained 8 or more records. - Brad Spencer provided changes to allow buildconf to work on OS X. - In preparation for the upcomming IPv6 nameservers patch, the internal ares_addr union is now changed into an internal struct which also holds the address family. Dan Fandrich (20 Nov 2008) - Make checking for struct ifreq a prerequisite for setting HAVE_IOCTL_SIOCGIFADDR since it's needed to use SIOCGIFADDR and Watcom C doesn't currently define it. Daniel Stenberg (20 Nov 2008) - use unsigned short better intead of mixing with ints to prevent compiler warnings - please the picky compilers by staying with short as the data we get is short only - - Brad Spencer brought the new function ares_gethostbyname_file() which simply resolves a host name from the given file, using the regular hosts syntax. Yang Tse (19 Nov 2008) - user provided PATH_SEPARATOR always overrides auto-detected one - attempting to keep lines below 80 chars - provide a common PATH_SEPARATOR check method which is required by upcomming work to support the broadest range of Autoconf versions - check for gethostbyaddr and gethostbyname as it is done for other functions - Make configure script check if ioctl with the SIOCGIFADDR command can be used, and define HAVE_IOCTL_SIOCGIFADDR if appropriate. - fix leftover from previous commit - fix inet_pton() runtime configure check - trim down configure script size Daniel Stenberg (15 Nov 2008) - Fixed an OOM condition reported by Jim Meyering Yang Tse (14 Nov 2008) - fix typo affecting inclusion of in configure checks for inet_ntoa_r() inet_ntop() and inet_pton() - #include in the getaddrinfo() runtime check for the memset() prototype - fix symbol definition check for fcntl.h inclusion - Refactor configure script detection of functions used to set sockets into non-blocking mode, and decouple function detection from function capability. Daniel Stenberg (1 Nov 2008) - Added a TODO file to list things we want changed, added or fixed. - - Carlo Contavalli added support for the glibc "rotate" option, as documented in man resolv.conf: causes round robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time. You can enable it with ARES_OPT_ROTATE Yang Tse (1 Nov 2008) - Adjust WIN32 freeaddrinfo, getaddrinfo and getnameinfo availability - WIN32 availability of freeaddrinfo, getaddrinfo and getnameinfo functions is quite convoluted, compiler dependant and in some cases even build target dependat. - check for freeaddrinfo() at configuration phase - update aclocal file serial number - remove verification of the freeability of the addrinfo struct pointer members - fix comment - make CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_ADDR and CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_CANONNAME internal to CHECK_FUNC_GETADDRINFO - fix leftover - Initial attempt to detect at configuration time if the getaddrinfo() function returns an addrinfo with an unfreeable ai_canonname member ptr. - Initial attempt to detect at configuration time if the getaddrinfo() function returns an addrinfo with an unfreeable ai_addr member ptr. - icc adjustments: Select ANSI C89 dialect plus GNU extensions, again. - some more temporary magic for the icc seg-fault issue - icc permanent adjustment: Select precise floating-point model, otherwise doubles are less than 64-bit wide icc test adjustment: Select c89 dialect - icc adjustments: Enable more icc warnings. Optimization disabling options used only for icc 9.1 - #include for exit() prototype - some more temporary magic for the icc seg-fault issue - remove from configure.ac temporary magic for the icc seg-fault issue - some more temporary magic for the icc seg-fault issue - Charles Hardin patch: - handles the EINPROGRESS for UDP connects - uses closesocket instead of close on some paths that were noticed - some more temporary magic for the icc seg-fault issue - messages initially intended only for debug purposes, now become permanent since these are extremely useful when compiler rejects a set of options. - fix compiler warning - fix missing double-quotes Daniel Stenberg (17 Oct 2008) - Charles Hardin made adig support a regular numerical dotted IP address for the -s option as well. Yang Tse (16 Oct 2008) - some more temporary magic for the icc seg-fault issue - Ensure that shell variable contents which have active meaning to the shell echo command are not interpreted when trying to remove extra whitespace from shell variable content. - Adjust Watcom C warnings: Disable warnings on structure members padding. - With this change Solaris target builds will now be done with _REENTRANT defined. - Adjust Tiny C basic options: Remove -b from debug-enabled configuration, as Tiny C might have been built without the memory and bounds checker support. - Adjust GCC warnings: Better disable following warnings when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers: -Wmissing-declarations -Wmissing-prototypes -Wunused -Wshadow - fix syntax error - Initial attempt to detect Watcom C compiler - make naming scheme more consistent across whole file - Adjust GCC warnings: Disable following warnings when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers: -Wmissing-prototypes -Wunused -Wshadow - Adjust GCC --enable-warnings: Do not enable -pedantic when cross-compiling with a gcc older than 3.0, to avoid warnings from third party system headers. - adjust SGI MIPSpro C detection - LCC compiler adjustments: Highest warning level is double -A, next is single -A. Due to the big number of warnings these trigger on third party header files it is impratical for us to use any of them here. If you want them simply define it in CPPFLAGS. - remove extra space - split SGI compiler check. One for MIPS C and another for MIPSpro C - LCC compiler adjustments: Warning level reduced from double -A to single -A - Initial attempt to detect Tiny C compiler - Initial attempt to detect LCC compiler - 1) fix bug in CONVERT_INCLUDE_TO_ISYSTEM 2) Disable SGI remark: controlling expression is constant - simplify SGI C compiler check - HP C adjustments: Due to the HP-UX socklen_t issue it is insane to use the +w1 warning level. It generates more than 1100 warnings on socklen_t related statements. Until the issue is somehow fixed we will just use the +w2 warning level. - Add debug tracing for COMPILER_WORKS_IFELSE - configure will also warn on 'strict compiler warning' rejected options - convert rejected compiler options messages into a warnings - remove extra whitespace from string in SGI C check - oops - Initial attempt to detect SGI C compiler - HP C adjustments: Disallow run-time dereferencing of null pointers. Disable some remarks: #4227: padding struct with n bytes to align member. #4255: padding size of struct with n bytes to alignment boundary. - improve presentation of accepted/rejected debug/optimizer options - refactoring of COMPILER_BASIC_OPTS - Initial attempt to detect SUN C compiler - Initial attempt to detect HP C compiler - fix compiler warning: 'dot_4' may be used uninitialized in this function - adjust ICC_windows settings - fix VAR_STRIP - Sync up with reality - Initial attempt to support configure's --(dis|en)able-optimize option to specify dis(activation) of compiler optimizations. If option is specified, it will be honored independant of the --(dis|en)able-debug option. - fix comment - Initial attempt to support configure's --(dis|en)able-warnings option to specify dis(activation) of picky compiler warnings. If option is specified, it will be honored independant of the --(dis|en)able-debug option. If option is not specified, it will follow --(dis|en)able-debug setting, whose default is disabled if not specified. - fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules - now compiler warnings are activated for all gcc builds, not only debug ones. - Use CFLAGS for icc linker options instead of LDFLAGS, otherwise gethostbyname() is not detected. - use ac_cv_compiler and ac_cv_compiler_num to keep compiler ID and version number - Temporary icc adjustment: Disable floating point optimizations - HAVE_INET_PTON will only be defined when an IPv6 capable working inet_pton function is available. - HAVE_INET_NTOP will only be defined when an IPv6 capable working inet_ntop function is available. - ntoa() and inet_ntoa_r() no longer used - icc adjustments for icc 9.0 and prior versions: Disable remark #279: controlling expression is constant Remark triggered mostly on va_arg() and FD_ZERO() macros. - attempt to make work the gethostname function check for winsock build target configurations Gisle Vanem (21 Sep 2008) - Added HAVE_NETDB_H, HAVE_ARPA_INET_H, HAVE_STRCASECMP and HAVE_STRNCASECMP. Yang Tse (19 Sep 2008) - icc adjustments: Disable remark #981: operands are evaluated in unspecified order Function calls which are triggering this remark, today, do not depend on the order of evaluation of its arguments. Disable remark #1469: "cc" clobber ignored Remark triggered on htons() and ntohs() due to glibc header files. - icc adjustments - fix netdb.h prerequisite inclusion - improve detection of getservbyport_r() - On Linux Intel's icc uses gcc's header files, so we select ANSI C89 dialect plus GNU extensions. - improve detection of gethostname() - NetWare builds include "nameser.h" from the c-ares subdir - include - Sync up with reality - adjust inclusion of "nameser.h" - reorder some lines in file - code cleanup - NetWare seems to have writev() - rearrange to allow internal/private use of ares_writev to any system that lacks the writev function. - NetWare CLIB target has stricmp() and strnicmp() - include header file only when available - rearrange to allow internal/private use of ares_strcasecmp to any system that lacks the strcasecmp function. - improve detection of: strcasecmp() strcmpi() stricmp() strncasecmp() strncmpi() strnicmp() - *** empty log message *** Gisle Vanem (12 Sep 2008) - djgpp does have strdup(). Yang Tse (12 Sep 2008) - change CRLF into LF line endings - strdup() clone for systems/configurations which lack it - move inclusion of ares_private.h last - icc adjustments - icc adjustments - Select strict ANSI C89 conformance for icc - remove unnecessary typecasting of malloc() - remove unnecessary typecasting of realloc() Daniel Stenberg (29 Aug 2008) - we start over working towards 1.5.4 Version 1.5.3 (29 Aug 2008) Daniel Stenberg (29 Aug 2008) - Version 1.5.3 - added the three people from RELEASE-NOTES and sorted the list alphabetically Yang Tse (27 Aug 2008) - Don't abort configuration if recvfrom() is not available. - Functionality only possible if recvfrom() is available. - George Neill's fix acountry sample application compilation failure. - Brad House's validation that DNS response address matches the request address - fix the output name - Get rid of ENABLE_64BIT symbol definition and usage. Improve HAVE_LONGLONG symbol description. - Export 'ares_process_fd' too. Gisle Vanem (16 Aug 2008) - Ops, remove 'use_vc'. - Support Watt-32 under Win32. Yang Tse (10 Aug 2008) - Fix: Remove now this SIZEOF_CURL_OFF_T symbol definition. This should have been done with the initial 64-bit curl_off_t patch. - Improve CURL_CHECK_DEF - Fix IBM C and DEC/Compaq C compiler detection - Initial support of curlbuild.h and curlrules.h which allows to have a curl_off_t data type no longer gated to off_t. - The minimum autoconf version required for this file is 2.50 Avoid dot notation in aclocal serial file number, use a single number now. Daniel Stenberg (4 Aug 2008) - - Fix by Tofu Linden: The symptom: * Users (usually, but not always) on 2-Wire routers and the Comcast service and a wired connection to their router would find that the second and subsequent DNS lookups from fresh processes using c-ares to resolve the same address would cause the process to never see a reply (it keeps polling for around 1m15s before giving up). The repro: * On such a machine (and yeah, it took us a lot of QA to find the systems that reproduce such a specific problem!), do 'ahost www.secondlife.com', then do it again. The first process's lookup will work, subsequent lookups will time-out and fail. The cause: * init_id_key() was calling randomize_key() *before* it initialized key->state, meaning that the randomness generated by randomize_key() is immediately overwritten with deterministic values. (/dev/urandom was also being read incorrectly in the c-ares version we were using, but this was fixed in a later version.) * This makes the stream of generated query-IDs from any new c-ares process be an identical and predictable sequence of IDs. * This makes the 2-Wire's default built-in DNS server detect these queries as probable-duplicates and (erroneously) not respond at all. Yang Tse (4 Aug 2008) - Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use. Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. But, autoconf 2.62 version of AC_AIX defines _ALL_SOURCE along with other four preprocessor symbols no matter if the system is AIX or not. To keep the traditional behaviour, as well as an uniform one, across autoconf versions AC_AIX is replaced with our own internal macro. - Adjust DEC/Compaq C compiler settings. - Another AC_TRY_LINK conversion to AC_LINK_IFELSE. Proper definition of HAVE_function if function is found deeper. - Sync up with reality - Rename reentrant.m4 to avoid filename clash. - Add file version serial number that might be used by 'aclocal' and others. Keep the '#' character as the first one on the line. - Update copyright year. - Sync comment with reality. - Reinstate the 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4' way of including our local m4/reentrant.m4 file. This even takes care of including the file in the distribution tarball. - Add quoting for the AC_DEFINE arguments. - Also remove the whitespace. - Also remove the extra quoting. - Replace some '@%:@' quadigraphs by its actual representation '#'. This quadigraph used before a C preprocessor 'define' directive could be fooling M4, when processing this file, and make it think that the line contains a pure M4 'define' macro. - Tests done using 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4 in top Makefile.am triggered a problem that prevented aclocal from running successfully on SunOS 5.10 with GNU m4 1.4.5 and GNU Autoconf 2.61 A tarball which reproduces mentioned problem is the one dated July-28-2008 http://cool.haxx.se/curl-daily/curl-7.19.0-20080728.tar.gz We actually don't need all the bells and whistles that the above mechanism provides. We only need to include our m4/reentrant.m4 file in acinclude.m4 so here we go with this simpler mechanism. - for debugging purposes show ACLOCAL_FLAGS - These lines were unintentionally removed in previous commit - Partially undo change that prevented SED, GREP, EGREP and AR from being changed by libtool or autoconf. - Assert that SED and GREP are set - Require autoconf 2.57 or newer - When calling aclocal, user defined ACLOCAL_FLAGS will now precede ours. - move ACLOCAL_AMFLAGS after AUTOMAKE_OPTIONS - setup.h handles definition of _REENTRANT based on NEED_REENTRANT definition which might be defined in config.h or config-*.h files - Remove explicit inclusion of our m4 files first. It was interesting as a test, but it breaks aclocal execution on some systems, with the following error: Can't locate object method "rel2abs" via package "File::Spec" at /usr/local/bin/aclocal line 256. - Another step towards detecting if _REENTRANT is already defined or actually needed, and being able to define it if appropriate for further configure tests as well as for the generated config file. - Explicitly include our m4 files first. This might minimize the impact that other package's underquoted m4 function definitions have on ours. - Add a 3 argument check for getprotobyname_r - move reentrant.m4 to the m4 subdirectory to avoid infinite loop inclusion problem - add checks for strtok_r and getprotobyname_r - Another step towards detecting if _REENTRANT is already defined or actually needed, and being able to define it if appropriate for further configure tests as well as for the generated config file. Introduced reentrant.m4 intended for our reentrant related autotools/m4 macros. - reorder argument number detection for getservbyport_r to actually verify if the test is properly working - Make sure that configure process tests are done with the same _REENTRANT setting as the one actually used when finally building the library. - Change recvfrom's sixth argument data type to the 'historically standard' 'int' data type for systems where this sixth argument is prototyped as a void pointer. Start of thread: http://curl.haxx.se/mail/lib-2008-07/0153.html - use prototypes to improve getservbyport_r detection - Adjust recvfrom's sixth arg data type definition for NetWare (LIBC) - Use the sreadfrom() wrapper to replace recvfrom() in our code. - when recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will now cause the definition of RECVFROM_TYPE_ARG2_IS_VOID, RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID, as appropriate. - Adjust DEC/Compaq C compiler settings - Added "pointer to void" as another data type to check for the sixth argument of function recvfrom as a result of the info additionally logged when running on a Solaris system. The compiler error showed that the prototype being used on Solaris was the one declared in line 427 of "/usr/include/sys/socket.h" as: function(int, pointer to void, unsigned int, int, pointer to struct sockaddr, pointer to void) returning int - Adjust DEC/Compaq C compiler settings - RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined to the data type pointed by its respective argument and not the pointer type. - Configure process now checks availability of recvfrom() socket function and finds out its return type and the types of its arguments. Added definitions for non-configure systems config files, and introduced macro sreadfrom which will be used on udp sockets as a recvfrom() wrapper. - Initial DEC/Compaq C compiler detection and flags - Improved configure detection of number of arguments for getservbyport_r - Allow --enable-largefile and --disable-largefile configurations. Configure process no longer needs nor checks size of curl_off_t. Library will now be built with _REENTRANT symbol defined. - fix compiler warning - since Jun 30 2008 MAXHOSTNAMELEN define is no longer used - fix c-ares version reported in generated libcares.pc file when building from CVS tree. - egrep and ar are also mandatory Daniel Stenberg (3 Jul 2008) - just to clarify that c-ares actually have some ipv6 support - ares_gethostbyname() fallback from AAA to A records with CNAME present - - Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and the target host has only A records, it automatically falls back to an AF_INET lookup and gives you the A results. However, if the target host has a CNAME record, this behaviour is defeated since the original query does return some data even though ares_parse_aaa_reply() doesn't consider it relevant. Here's a small patch to make it behave the same with and without the CNAME. Yang Tse (2 Jul 2008) - The configure process will now halt when sed or grep are unavailable - fallback to gettimeofday when monotonic clock is unavailable at run-time - IBM C/C++ compiler predefined macro check - set earlier in configure process IBM compilers optimization flags - make check message wording more precise Daniel Stenberg (30 Jun 2008) - - As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is not posix or anything and thus c-ares failed to build on hurd (and possibly elsewhere). The define was also somewhat artificially used in the windows port. Now, I instead rewrote the use of gethostbyname to enlarge the host name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN define. I thus also removed the defien from the namser.h file where it was once added for the windows build. I also fixed init_by_defaults() function to not leak memory in case if error. Yang Tse (29 Jun 2008) - fix C style comment - John Lightsey filed bug report #1999181: "CLOCK_MONOTONIC always fails on some systems" (http://curl.haxx.se/bug/view.cgi?id=1999181). The problem was that the configure script did not use the _POSIX_MONOTONIC_CLOCK feature test macro when checking monotonic clock availability. This is now fixed and the monotonic clock will not be used unless the feature test macro is defined with a value greater than zero indicating always supported. - Modified configuration script to actually verify if the compiler is good enough at detecting compilation errors or at least it has been properly configured to do so. Configuration heavily depends on this capability, so if this compiler sanity check fails the configuration process will now fail. - No longer break out of a shell "for" statement from inside AC_FOO_IFELSE macros, otherwise temp files are not removed. Identation adjustment. Gunter Knauf (11 Jun 2008) - enable additional CFLAGS from commandline. Yang Tse (9 Jun 2008) - fix pkg-config reporting of private libraries needed for static linking - MSVC does build Windows native targets - Brad House fixed a missing header file inclusion in adig sample program Daniel Stenberg (29 May 2008) - start working on 1.5.3 Version 1.5.2 (29 May 2008) Daniel Stenberg (29 May 2008) - 1.5.2 Yang Tse (26 May 2008) - fix compiler warning: unreferenced formal parameter Daniel Stenberg (23 May 2008) - list all local sources the (demo) tools need, add a few missing scripts to the dist tarball and remove a two duplicate file names from EXTRA_DIST (most of it pointed out by Yang Tse) - this is not used (anymore) - make sure the configure.ac file with the correct version number is shipped in the tarball Yang Tse (22 May 2008) - MSVC6+ clean-up targets must also remove acountry.exe - sync with reality - fix: [action-if-found] part of AC_CHECK_TYPE macro cannot be quoted when empty - fix: remove need and definition of HAVE_SOCKLEN_T symbol - fix: socklen_t definition comment - update several macros using AC_TRY_LINK with AC_LINK_IFELSE - fix underquoting of AC_LANG_PROGRAM arguments - if'def out private function ares__tvdiff(), it is not in use yet. - update several macros using AC_TRY_LINK with AC_LINK_IFELSE - fix socklen_t equivalent detection when cross compiling Windows target - if WINSOCK2 API is used link with 'ws2_32', else if WINSOCK API is used under WinCE link with 'winsock', else if WINSOCK API is used link with 'wsock32'. - on winsock systems linking is done using library 'ws2_32' when winsock2.h is available, and library 'winsock' is used when only winsock.h is available. - minor change for wince-cegcc and wince-mingw32ce support - millisecond resolution support followup Gisle Vanem (15 May 2008) - Replaced "-DHAVE_FIONBIO" with "-DHAVE_IOCTLSOCKET". Added "-DHAVE_GETTIMEOFDAY". Trimmed lines. Yang Tse (15 May 2008) - sync with reality - remove compilation time generated files - use same time source for timeout initialization and processing - Improve toolchain detection for WinCE cross compilation: When cross compiling WinCE with the arm-wince-cegcc-gcc C compiler symbol __CEGCC__ is defined and the unix-like compatibility layer is used. For our purposes this is not a native Windows build. When cross compiling WinCE with the arm-wince-mingw32ce-gcc C compiler symbol __MINGW32CE__ is defined and the unix-like compatibility layer is not used. For our purposes this _is_ a native Windows build. - skip checks for Windows specific header files when build target is not a native Windows one - WinCE cross compilation adjustments: HAVE_WINSOCK2_H shall not be defined. HAVE_WS2TCPIP_H shall not be defined. Daniel Stenberg (13 May 2008) - - Introducing millisecond resolution support for the timeout option. See ares_init_options()'s ARES_OPT_TIMEOUTMS. Yang Tse (13 May 2008) - also ignore this - also ignore this - ignore this compilation time generated files - don't keep in CVS this compilation time generated file - add MSVC6 project for acountry sample program - update MSVC6 projects to use the multithreaded DLL runtime library - add MSVC6 project for acountry sample program - skip libtool C++ preprocessor compiler and linker checks - ignore libcares.pc - configure script will now define HAVE_CLOCK_GETTIME_MONOTONIC symbol only when function clock_gettime() is available and the monotonic timer is also available. Otherwise, in some cases, librt or libposix4 could be used for linking even when finally not using the clock_gettime() function due to lack of the monotonic clock. - fix syntax error: missing semicolon - Add library checking for clock_gettime() support - Use monotonic time source if available. Daniel Stenberg (9 May 2008) - Removed AC_PROG_CC_STDC again. It enforces C99/gnu99 stdandard which is too liberal for me. Also, autoconf 2.61 and earlier doesn't work with icc 10.1 for this macro. (2.62 confirmed to work though). See discusson on the mailing list starting here: http://daniel.haxx.se/projects/c-ares/mail/c-ares-archive-2008-05/0001.shtml - include strings.h (if available) for the strcasecmp() proto - check for strings.h in configure and use it for the strcasecmp() proto - adjusted to work with the updated configure.ac - - Sebastian made c-ares able to return all PTR-records when doing reverse lookups. It is not common practice to have multiple PTR-Records for a single IP, but its perfectly legal and some sites have those. - - Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to autoconf 2.57 usage (which is the version you have specified as the minimum version). It's a minor change but it does clean up some warnings with newer autoconf (specifically 2.62). Yang Tse (5 May 2008) - Improved parsing of resolver configuration files - make previous compiler warning fix more portable - fix compiler warning: indirection to slightly different base types - fix compiler warning: local variable may be used without having been initialized - fix compiler warning: unreferenced formal parameter - fix compiler warning: assignment within conditional expression Daniel Stenberg (4 Apr 2008) - - Alexey Simak fixed the VC dsp file by adding the missing source file ares_expand_string.c - Alexey Simak made adig support NAPTR records - Eino Tuominen improved the code when a file is used to seed the randomizer Yang Tse (29 Feb 2008) - Force AIX xlc to fail and not generate object code if the source code has compiled with errors. This behaviour is needed for autoconf macros which rely on the ability to compile with or without errors, and is safer than xlc's default of failing only upon severe errors. Gunter Knauf (27 Feb 2008) - added get_ver.awk since c-ares is a standalone project, and should therefore also compile when cURL is absent. - a couple of small fixes to the makefile: fixed comments; fixed INSTDIR define, simplified rules; changed to use get_ver.awk in current dir rather than the curl one. - fixed linker def file for tools when compiled with gcc/nlmconv. - added some files which were missing in release tarballs. - updated copyright for new year. Gisle Vanem (2 Jan 2008) - Added '-d' option for Watt-32 debugging. Yang Tse (18 Dec 2007) - MSVC 9.0 (VS2008) does not support Windows build targets prior to WinXP, and makes wrong asumptions of build target when it isn't specified. So, if no build target has been defined we will target WinXP when building with MSVC 9.0 (VS2008). Daniel Stenberg (11 Dec 2007) - build acountry too Gisle Vanem (11 Dec 2007) - Added acountry.c. - Added build of acountry.nlm. - Added build of acountry.exe. - Build acountry.exe. Added 'socklen_t' define. - Another sample application that returns country-code and name from an IPv4-address or host-name. Using the service of countries.nerd.dk. Daniel Stenberg (10 Dec 2007) - grrr, the previous commit was meant to properly make sure that we don't link any executables when doing debug builds since they kind of assume symbols provided by libcurl, but it also wrongly included acountry.c - when building - build ahost and adig by default but don't install them Gisle Vanem (10 Dec 2007) - Fix for targets that do have 'struct in6_addr', but which doesn't define 's6_addr' as a macro. Yang Tse (3 Dec 2007) - Fix three issues previous cleanup introduces. Daniel Stenberg (3 Dec 2007) - Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat - Brad Spencer fixed the configure script to assume that there's no /dev/urandom when built cross-compiled as then the script cannot check for it. - the gethostbyname fix applied here as well - fix next_lookup() to continue searching even if c-ares failed to load the /etc/hosts file, pointed out by Erik Kline: http://daniel.haxx.se/projects/c-ares/mail/c-ares-archive-2007-11/0027.shtml - Remove the check for libdl since that isn't actually used and it causes warnings. Pointed out by Robin Cornelius. - pkgconfig fix by Andreas Schuldei - spellfix - and we start on 1.5.2! Version 1.5.1 (21 Nov 2007) Daniel Stenberg (21 Nov 2007) - change - oops - start working on 1.5.1 now Version 1.5.0 (21 Nov 2007) Daniel Stenberg (21 Nov 2007) - this is what 1.5.0 is - fill in missing copyrights Gunter Knauf (18 Nov 2007) - removed now obsolete defines; updated external library versions to latest. Steinar H. Gunderson (16 Nov 2007) - Fix a double free. Yang Tse (15 Nov 2007) - Needed now that in6_addr is referenced in ares.h Steinar H. Gunderson (15 Nov 2007) - When looking up in DNS and then in the hosts file, return the error code from DNS if both fail, instead of returning the error code from the hosts file, as today. Patch from the Google tree. - Return TTL data from ares_parse_{a,aaaa}_reply, if the user is so inclined. Patch from the Google tree. Yang Tse (8 Nov 2007) - Define WIN32 when build target is Win32 API. This also defines it for WinCE even though it is a subset of WIN32. - The only libraries actually needed for sample programs adig and ahost are ws2_32.lib and advapi32.lib - MSVC versions prior to VS2005 do not complain about portable C functions - Windows build targets have socklen_t definition in ws2tcpip.h but some versions of ws2tcpip.h do not have the definition. It seems that when the socklen_t definition is missing from ws2tcpip.h the definition for INET_ADDRSTRLEN is also missing, and that when one definition is present the other one also is available. Gunter Knauf (22 Oct 2007) - removed dependency on gettimeofday() since we use only 1 sec resolution here. Yang Tse (20 Oct 2007) - Fix compiler warning: conversion from "int" to "unsigned short" may lose significant bits - Fix message shown when detecting icc version - Avoid shadowing a global declaration - Renamed a variable to avoid shadowing a global declaration - Renamed internal function to avoid a variable shadowing it - Fix compiler warning: feupdateenv is not implemented and will always fail. Specifically for linux x86-64 with Intel's icc. - Sync PLATFORM_AIX_V3 detection and CURL_CC_DEBUG_OPTS() icc warning level with libcurl's - Fix compiler warning: conversion from "int" to "unsigned char" may lose significant bits - actually sync with lib/setup_once.h - sync with lib/setup_once.h Steinar H. Gunderson (16 Oct 2007) - Fix a bug where fallback from AF_INET6 to AF_INET would not work properly together with relative search; if you had a search path of .a.com and .b.com, and foo.a.com would return ARES_ENODATA and foo.b.com would return ARES_ENOTFOUND, the lookup would not properly retry with AF_INET as it forgot the first ARES_ENODATA. Dan Fandrich (15 Oct 2007) - Mention first version with CURLOPT_COPYPOSTFIELDS. Don't confuse NUL with NULL. Gisle Vanem (8 Oct 2007) - Added needed 'HAVE_*' defines. - 'FD_CLOXEC' is meaningless on MSDOS/Watt-32. Steinar H. Gunderson (4 Oct 2007) - Removed a piece of redundant code (process_answer already takes care of it). - Another timeout fix in ares_getnameinfo(). - Send the timeout count in ares_getnameinfo(). - Moved the NULL check for channel upwards in ares_destroy(). - Clarified the comment over ares_cancel. Yang Tse (2 Oct 2007) - Avoid a segfault when generating a DNS "Transaction ID" in internal function init_id_key() under low memory conditions. - Add ares_llist.c and ares_llist.h to MSCV project file. Daniel Stenberg (2 Oct 2007) - Fixed the problem where next_lookup would use 'status' uninitialized. Now it gets passed the initial value as an argument. Yang Tse (2 Oct 2007) - Avoid inline C99ism, and move c-ares routines for managing doubly-linked lists. Daniel Stenberg (1 Oct 2007) - ares_strerror() segfaulted if the input error number was out of the currently supported range. - Prevent ares_strerror() from segfaulting if an invalid error code is passed in as argument! Yang Tse (30 Sep 2007) - Fix compiler warning - check availability of - improve portability, defining MAXDNAME and MAXCDNAME Steinar H. Gunderson (30 Sep 2007) - Fix a memory leak that I recently inadvertedly introduced. - Use ISDIGIT instead of isdigit; fixes a gcc warning. - Port the TCP socket fix made in ares_fds() to ares_getsock() as well. - Previously, processing a large batch of timeouts was O(n^2) in the number of outstanding queries, and processing a DNS response packet was O(n) in the number of outstanding queries. To speed things up in Google, we added a few circular, doubly-linked lists of queries that are hash-bucketed based on the attributes we care about, so most important operations are now O(1). It might be that the number of buckets are higher than most people would need, but on a quick calculation it should only be 100kB or so even on a 64-bit system, so I've let it stay as-is. Gisle Vanem (29 Sep 2007) - We should standarise on C comments. - Fix compiler warning in setsockopt(). Steinar H. Gunderson (29 Sep 2007) - TCP queries can time out too, not just UDP queries. (Patch from the Google tree.) - Read and process as many packets as possible in read_udp_packets, to avoid having to run the entire event loop once per packet. (Patch from the Google tree.) - There are two different places in write_tcp_data() that advance the send_queue; however, they are slightly different and only the first one properly uses a while loop. Consolidate both into a single function that DTTR. (Patch from the Google tree.) - Reject names that are longer than 255 characters, to avoid problems with strict or buggy DNS server implementations. (Patch from the Google tree) - In ares_mkquery, make sure we set buflen and buf to reasonable values if there's an error. (Patch from the Google tree) - Be stricter about what's a valid IP address in fake_hostent. (Patch from the Google tree.) - Handle the root of the DNS tree correctly in ares_expand_name. Daniel Stenberg (28 Sep 2007) - today's modifications by Steinar and me - Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI and API changes in the progress callback (and possibly more coming up from Steinar) Steinar H. Gunderson (28 Sep 2007) - Unrevert previous 'missing' hunks. They were missing since the patch is still in for review :-) - Yet more missing hunks... Nggh. - Always register for TCP events even if there are no outstanding queries, as the other side could always close the connection, which is a valid event which should be responded to. - Forgot to include a few hunks from ares_process.c earlier. Fixing now. - Support a few more socket options, and refactor the option setting a bit. (Patch from the Google tree.) - Make the query callbacks return the number of timeouts that happened during the execution of a query, and update documentation accordingly. (Patch from the Google tree.) - Three fixes in one commit (sorry): a) Take care of the tcpbuf if it ends while queued for transmission, note broken servers and close them in the main loop, and store TCP socket generation number in order not to send the same query twice over the same socket. - Don't skip a server if it's the only one. (Bugfix from the Google tree.) Daniel Stenberg (27 Sep 2007) - wrong, revert the previous "fix" and instead check that the fd_set pointer is non-NULL before we FD_CLR - eek, fix the conditions to return on either problem instead of requiring both to occur - Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that if it fails and the socket is closed the following code doesn't try to use the file descriptor. - Steinar H. Gunderson modified c-ares to now also do to DNS retries even when TCP is used since there are several edge cases where it still makes sense. - Brad House provided a fix for ares_save_options(): Apparently I overlooked something with the ares_save_options() where it would try to do a malloc(0) when no options of that type needed to be saved. On most platforms, this was fine because malloc(0) doesn't actually return NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM. - added initial pkg-config file (attempt) Gunter Knauf (20 Jul 2007) - added curl include for debug builds. Daniel Stenberg (14 Jul 2007) - added another SEE ALSO - Brad House's fix to hish a win32 compiler warning - added Vlad's entire description of his valgrind fix - Vlad Dinulescu fixed two outstanding valgrind reports Gunter Knauf (8 Jul 2007) - added better CodeWarrior detection. - removed some obsolete include paths and defines. - add test for gettimeofday() so that HAVE_GETTIMEOFDAY gets defined. - although the check for HAVE_STRUCT_TIMEVAL solved the redefine it is incorrect; lets see if a check for HAVE_GETTIMEOFDAY also works; if gettimeofday() is present then we can assume we have the timezone struct too. - added check for sys/param.h. - trial to catch problem with Daniels cross-mingw ares builds. - added NetWare CLIB-own header to solve gcc warnings. - few minor changes to make ares compile for NetWare CLIB architecture. - changed to build for CLIB / LIBC. - sync'd with lib makefile changes: use var for awk; fixed RECV* / SEND* defines; debug var can be overwritten; added better compiler path handling. Daniel Stenberg (8 Jun 2007) - start working on 1.4.1 Version 1.4.0 (8 Jun 2007) Daniel Stenberg (8 Jun 2007) - 1.4.0 preps - the revert - Revered Ashish Sharma's multiple entries patch, as it caused memory madness - minor edit since getting an ID seems pointless when failure happens - fix the bad bad bad mess this caused on name resolves returning more than one name... Reported by James Bursa - Brad Spencer found and fixed three flaws in the code, found with the new gcc 4.2.0 warning: -Waddress - Brad House fixed VS2005 compiler warnings due to time_t being 64bit. He also made recent Microsoft compilers use _strdup() instead of strdup(). - Ashish Sharma provided a patch for supporting multiple entries in the /etc/hosts file. Patch edited for coding style and functionality by me (Daniel). gevent-1.1.0/c-ares/CHANGES.00000644000076500000000000013413012666555342016044 0ustar jmaddenwheel00000000000000 Changelog for the c-ares project Version 1.7.5 (August 16, 2011) Fixed: o detection of semicolon comments in resolv.conf o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory o replacement ares_inet_net_pton affected by the WLB-2008080064 advisory o replacement ares_inet_ntop affected by potential out of bounds write o added install target to Makefile.msvc o only fall back to AF_INET searches when looking for AF_UNSPEC addresses o fixed ares_parse_*_reply memory leaks o Use correct sizeof in ares_getnameinfo() o IPv6-on-windows: find DNS servers correctly o man pages: docs for the c-ares utility programs o getservbyport replacement for Win CE o config_sortlist: (win32) missing else o advance_tcp_send_queue: avoid NULL ptr dereference o configure: fix a bashism o ares_expand_name: Fix encoded length for indirect root Version 1.7.4 (December 9, 2010) Changed: o local-bind: Support binding to local interface/IPs, see ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev Fixed: o memory leak in ares_getnameinfo o add missing break that caused get_ares_servers to fail o ares_parse_a_reply: fix CNAME response parsing o init_by_options: don't copy an empty sortlist o Replaced uint32_t with unsigned int to fix broken builds on a couple of platforms o Fix lookup with HOSTALIASES set o adig: fix NAPTR parsing o compiler warning cleanups Version 1.7.3 (June 11, 2010) Fixed: o builds on Android o now includes all files necessary to build it (1.7.2 lacked a file) Version 1.7.2 (June 10, 2010) Changed: o Added ares_parse_mx_reply() Fixed: o ares_init: Last, not first instance of domain or search should win o improve alternative definition of bool o fix VS2010 compiler warnings Version 1.7.1 (Mar 23, 2010) * May 31, 2010 (Jakub Hrozek) - Use the last instance of domain/search, not the first one * March 23, 2010 (Daniel Stenberg) - We switched from CVS to git. See http://github.com/bagder/c-ares * March 5, 2010 (Daniel Stenberg) - Daniel Johnson provided fixes for building with the clang compiler. * March 5, 2010 (Yang Tse) - Added IPv6 name servers support. Implementation has been based on code, comments and feedback provided November and December of 2008 by Daniel Stenberg, Gregor Jasny, Phil Blundell and myself, December 2009 by Cedric Bail, and February 2010 by Jakub Hrozek on the c-ares mailing list. On March I reviewed all that, selected the best of each, and adjusted or extended parts of it to make the best fit. The external and visible result of all this is that two new functions are added to the external API, ares_get_servers() and ares_set_servers(), which becomes now the preferred way of getting and setting name servers for any ares channel as these support both IPv4 and IPv6 name servers. In order to not break ABI compatibility, ares_init_options() with option mask ARES_OPT_SERVERS and ares_save_options() may still be used in code which is intended to run on IPv4-only stacks. But remember that these functions do not support IPv6 name servers. This implies that if the user is capable of defining or providing an IPv6 name server, and the app is using ares_init_options() or ares_save_options() at some point to handle the name servers, the app will likely lose IPv6 name servers. * January 28, 2010 (Daniel Stenberg) - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't check for broken connections like ares_process() did. Based on that, I merged the two functions into a single generic one with two front-ends. * December 29, 2009 (Yang Tse) - Laszlo Tamas Szabo adjusted Makefile.msvc compiler options so that where run-time error checks enabling compiler option /GZ was used it is replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions. Option /GX is replaced with equivalent /EHsc for all versions. Also fixed socket data type for internal configure_socket function. * December 21, 2009 (Yang Tse) - Ingmar Runge noticed that Windows config-win32.h configuration file did not include a definition for HAVE_CLOSESOCKET which resulted in function close() being inappropriately used to close sockets. Version 1.7.0 (Nov 30, 2009) * November 26, 2009 (Yang Tse) - Larry Lansing fixed ares_parse_srv_reply to properly parse replies which might contain non-SRV answers, skipping over potential non-SRV ones such as CNAMEs. * November 23, 2009 (Yang Tse) - Changed naming convention for c-ares libraries built with MSVC, details and build instructions provided in README.msvc file. * November 22, 2009 (Yang Tse) - Jakub Hrozek fixed more function prototypes in man pages to sync them with the ones declared in ares.h - Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and ares_addr6ttl in order to prevent name space pollution, along with necessary changes to code base and man pages.This change does not break ABI, there is no need to recompile existing applications. But existing applications using these structs with the old name will need source code adjustments when recompiled using c-ares 1.7.0. * November 21, 2009 (Yang Tse) - Added manifest stuff to Makefile.msvc. * November 20, 2009 (Yang Tse) - Fixed several function prototypes in man pages that were out of sync with the ones declared in ares.h. Added ares_free_data() along with man page. Updated ares_parse_srv_reply() and ares_parse_txt_reply() with changes from Jakub Hrozek making these now return linked lists instead of arrays, and merging the ares_free_data() adjustments. * November 10, 2009 (Yang Tse) - Updated MSVC 6.0 project files to match settings from Makefile.msvc. * November 9, 2009 (Yang Tse) - Makefile.msvc is now the reference method to build c-ares and sample programs with any MSVC compiler or MS Visual Studio version. If no option or target are specified it builds dynamic and static c-ares libraries in debug and release flavours and also builds all sample programs using each of the different c-ares libraries. * November 2, 2009 (Yang Tse) - Renamed c-ares setup.h to ares_setup.h * October 31, 2009 (Yang Tse) - Symbol hiding configure options are named now --enable-symbol-hiding and --disable-symbol-hiding in an attempt to make them less ambiguous. * October 30, 2009 (Yang Tse) - Many fixes for ares_parse_txt_reply() * October 29, 2009 (Daniel Stenberg) - Jakub Hrozek added ares_parse_txt_reply() for TXT parsing * October 29, 2009 (Yang Tse) - Updated MSVC 6.0 workspace and project files that allows building dynamic and static c-ares libraries in debug and release flavours. Additionally each of the three sample programs is built against each of the four possible c-ares libraries, generating all this a total number of 12 executables and 4 libraries. * October 28, 2009 (Yang Tse) - Initial step towards the ability to reduce c-ares exported symbols when built as a shared library based on the 'visibility' attribute for GNUC and Intel compilers and based on __global for Sun compilers, taking also in account __declspec function decoration for Win32 and Symbian DLL's. * October 27, 2009 (Yang Tse) - Fixed Pelles C Win32 target compilation issues. * October 23, 2009 (Yang Tse) - John Engelhart noticed an unreleased problem relative to a duplicate ARES_ECANCELLED error code value and missing error code description. * October 7, 2009 (Yang Tse) - Overhauled ares__get_hostent() Fixing out of bounds memory overwrite triggered with malformed /etc/hosts file. Improving parsing of /etc/hosts file. Validating requested address family. Ensuring that failures always return a NULL pointer. Adjusting header inclusions. * October 6, 2009 (Yang Tse) - Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak. * September 29, 2009 (Yang Tse) - Make configure script also check if _REENTRANT definition is required to make errno available as a preprocessor macro. * September 7, 2009 (Yang Tse) - Add T_SRV portability check to ares_parse_srv_reply.c * 4 Sep 2009 (Daniel Stenberg) - Jakub Hrozek added ares_parse_srv_reply() for SRV parsing * 3 Aug 2009 (Daniel Stenberg) - Joshua Kwan fixed the init routine to fill in the defaults for stuff that fails to get inited by other means. This fixes a case of when the c-ares init fails when internet access is fone. - Timo Teras changed the reason code used in the resolve callback done when ares_cancel() is used, to be ARES_ECANCELLED instead of ARES_ETIMEOUT to better allow the callback to know what's happening. * 14 Jul 2009 (Guenter Knauf) - renamed generated config.h to ares_config.h to avoid any future clashes with config.h from other projects. * June 20 2009 (Yang Tse) - Refactor how libraries are checked for connect() function in configure script and check for connect() as it is done for other functions. * June 19 2009 (Yang Tse) - Make sclose() function-like macro definition used to close a socket, now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions * June 18 2009 (Yang Tse) - Add CloseSocket camel case function check for configure script. * June 17 2009 (Yang Tse) - Check for socket() and closesocket() as it is done for other functions in configure script. * June 11 2009 (Yang Tse) - Modified buildconf so that when automake runs it copies missing files instead of symlinking them. * June 8 2009 (Yang Tse) - Removed buildconf.bat from release and daily snapshot archives. This file is only for CVS tree checkout builds. * May 26 2009 (Yang Tse) - Added --enable-curldebug configure option to enable and disable building with the low-level curl debug memory tracking 'feature' to allow decoupled setting from --enable-debug, allowing again to build c-ares independently out of the CVS tree. For the c-ares library option --enable-debug enables debug build features which are _not_ related with memory tracking. For the c-ares library when --enable-debug is given it does not enable the memory tracking feature. If you wish to enable the curl debug memory tracking you must use configure option --enable-curldebug explicitily to do so. Internally, definition of preprocessor symbol DEBUGBUILD restricts code which is only compiled for debug enabled builds. And symbol CURLDEBUG is used to differentiate code which is _only_ used for memory tracking. Make ares_init(), ares_dup() and ares_init_options() fail returning ARES_ENOTINITIALIZED if library initialization has not been performed calling ares_library_init(). * May 20 2009 (Yang Tse) - Added ares_library_init() and ares_library_cleanup() man pages. * May 19 2009 (Yang Tse) - Introduced ares_library_init() and ares_library_cleanup() functions. This is an API and ABI break for Win32/64 systems. Non-Win32/64 build targets using c-ares 1.7.0 can still survive without calling these functions. Read all the details on ares_library_init(3) and ares_library_cleanup(3) man pages that are included. curl/libcurl 7.19.5 is fully compatible with c-ares 1.7.0 on all systems. In order to use c-ares 1.7.0 with curl/libcurl on Win32/64 systems it is required that curl/libcurl is 7.19.5 or newer. In other words, it is not possible on Win32/64 to use c-ares 1.7.0 with a curl/libcurl version less than 7.19.5 * May 11 2009 (Daniel Stenberg) - Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to only expose functions starting with ares_. * May 7 2009 (Yang Tse) - Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition attempt in generated config.h * May 2 2009 (Yang Tse) - Use a build-time configured ares_socklen_t data type instead of socklen_t. * April 21 2009 (Yang Tse) - Moved potential inclusion of system's malloc.h and memory.h header files to setup_once.h. Inclusion of each header file is based on the definition of NEED_MALLOC_H and NEED_MEMORY_H respectively. * March 11 2009 (Yang Tse) - Japheth Cleaver fixed acountry.c replacing u_long with unsigned long. * February 20 2009 (Yang Tse) - Do not halt compilation when using VS2008 to build a Windows 2000 target. * February 3 2009 (Phil Blundell) - If the server returns garbage or nothing at all in response to an AAAA query, go on and ask for A records anyway. * January 31 2009 (Daniel Stenberg) - ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving either AF_INET6 or AF_INET. It works by accepting any of the looksups in the hosts file, and it resolves the AAAA field with a fallback to A. * January 14 2009 (Daniel Stenberg) - ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it now declares the private struct ares_in6_addr for all systems instead of relying on one possibly not present in the system. * January 13 2009 (Phil Blundell) - ares__send_query() now varies the retry timeout pseudo-randomly to avoid packet storms when several queries were started at the same time. * January 11 2009 (Daniel Stenberg) - Phil Blundell added the internal function ares__expand_name_for_response() that is now used by the ares_parse_*_reply() functions instead of the ares_expand_name() simply to easier return ARES_EBADRESP for the cases where the name expansion fails as in responses that really isn't expected. Version 1.6.0 (Dec 9, 2008) * December 9 2008 (Gisle Vanem) Fixes for Win32 targets using the Watt-32 tcp/ip stack. * Dec 4 2008 (Daniel Stenberg) Gregor Jasny provided the patch that introduces ares_set_socket_callback(), and I edited it to also get duped by ares_dup(). * Dec 3 2008 (Daniel Stenberg) API changes: I made sure the public ares_config struct looks like before and yet it supports the ROTATE option thanks to c-ares now storing the "optmask" internally. Thus we should be ABI compatible with the past release(s) now. My efforts mentioned below should not break backwards ABI compliance. Here's how I suggest we proceed with the API: ares_init() will be primary "channel creator" function. ares_init_options() will continue to work exactly like now and before. For starters, it will be the (only) way to set the existing options. ares_save_options() will continue to work like today, but will ONLY save options that you can set today (including ARES_OPT_ROTATE actually) but new options that we add may not be saved with this. Instead we introduce: ares_dup() that instead can make a new channel and clone the config used from an existing channel. It will then clone all config options, including future new things we add. ares_set_*() style functions that set (new) config options. As a start we simply add these for new functionality, but over time we can also introduce them for existing "struct ares_options" so that we can eventually deprecate the two ares_*_options() functions. ares_get_*() style functions for extracting info from a channel handle that should be used instead of ares_save_options(). * Nov 26 2008 (Yang Tse) - Brad Spencer provided changes to allow buildconf to work on OS X. - Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a buffer to shrink instead of expand if a reply contained 8 or more records. * Nov 25 2008 (Yang Tse) - In preparation for the upcomming IPv6 nameservers patch, the internal ares_addr union is now changed into an internal struct which also holds the address family. * Nov 19 2008 (Daniel Stenberg) - Brad Spencer brought the new function ares_gethostbyname_file() which simply resolves a host name from the given file, using the regular hosts syntax. * Nov 1 2008 (Daniel Stenberg) - Carlo Contavalli added support for the glibc "rotate" option, as documented in man resolv.conf: causes round robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time. You can enable it with ARES_OPT_ROTATE * Oct 21 2008 (Yang Tse) Charles Hardin added handling of EINPROGRESS for UDP connects. * Oct 18 2008 (Daniel Stenberg) Charles Hardin made adig support a regular numerical dotted IP address for the -s option as well. * Oct 7 2008 (Yang Tse) - Added --enable-optimize configure option to enable and disable compiler optimizations to allow decoupled setting from --enable-debug. * Oct 2 2008 (Yang Tse) - Added --enable-warnings configure option to enable and disable strict compiler warnings to allow decoupled setting from --enable-debug. * Sep 17 2008 (Yang Tse) - Code reorganization to allow internal/private use of "nameser.h" to any system that lacks arpa/nameser.h or arpa/nameser_compat.h header files. * Sep 16 2008 (Yang Tse) - Code reorganization to allow internal/private use of ares_writev to any system that lacks the writev function. * Sep 15 2008 (Yang Tse) - Code reorganization to allow internal/private use of ares_strcasecmp to any system that lacks the strcasecmp function. - Improve configure detection of some string functions. * Sep 11 2008 (Yang Tse) - Code reorganization to allow internal/private use of ares_strdup to any system that lacks the strdup function. Version 1.5.3 (Aug 29, 2008) * Aug 25 2008 (Yang Tse) - Improvement by Brad House: This patch addresses an issue in which a response could be sent back to the source port of a client from a different address than the request was made to. This is one form of a DNS cache poisoning attack. The patch simply uses recvfrom() rather than recv() and validates that the address returned from recvfrom() matches the address of the server we have connected to. Only necessary on UDP sockets as they are connection-less, TCP is unaffected. - Fix by George Neill: Fixed compilation of acountry sample application failure on some systems. * Aug 4 2008 (Daniel Stenberg) - Fix by Tofu Linden: The symptom: * Users (usually, but not always) on 2-Wire routers and the Comcast service and a wired connection to their router would find that the second and subsequent DNS lookups from fresh processes using c-ares to resolve the same address would cause the process to never see a reply (it keeps polling for around 1m15s before giving up). The repro: * On such a machine (and yeah, it took us a lot of QA to find the systems that reproduce such a specific problem!), do 'ahost www.secondlife.com', then do it again. The first process's lookup will work, subsequent lookups will time-out and fail. The cause: * init_id_key() was calling randomize_key() *before* it initialized key->state, meaning that the randomness generated by randomize_key() is immediately overwritten with deterministic values. (/dev/urandom was also being read incorrectly in the c-ares version we were using, but this was fixed in a later version.) * This makes the stream of generated query-IDs from any new c-ares process be an identical and predictable sequence of IDs. * This makes the 2-Wire's default built-in DNS server detect these queries as probable-duplicates and (erroneously) not respond at all. * Aug 4 2008 (Yang Tse) - Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use. Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. 2.62 version of AC_AIX defines _ALL_SOURCE and other four preprocessor symbols no matter if the system is AIX or not. To keep the traditional behaviour, and an uniform one across autoconf versions AC_AIX is replaced with our own internal macro CARES_CHECK_AIX_ALL_SOURCE. * Aug 1 2008 (Yang Tse) - Configure process now checks if the preprocessor _REENTRANT symbol is already defined. If it isn't currently defined a set of checks are performed to test if its definition is required to make visible to the compiler a set of *_r functions. Finally, if _REENTRANT is already defined or needed it takes care of making adjustments necessary to ensure that it is defined equally for the configure process tests and generated config file. * Jul 20 2008 (Yang Tse) - When recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will now cause the definition, as appropriate, of RECVFROM_TYPE_ARG2_IS_VOID, RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID. * Jul 17 2008 (Yang Tse) - RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined to the data type pointed by its respective argument and not the pointer type. * Jul 16 2008 (Yang Tse) - Improved configure detection of number of arguments for getservbyport_r. Detection is now based on compilation checks instead of linker ones. - Configure process now checks availability of recvfrom() socket function and finds out its return type and the types of its arguments. Added definitions for non-configure systems config files, and introduced macro sreadfrom which will be used on udp sockets as a recvfrom() wrapper in the future. * Jul 15 2008 (Yang Tse) - Introduce definition of _REENTRANT symbol in setup.h to improve library usability. Previously the configure process only used the AC_SYS_LARGEFILE macro for debug builds, now it is also used for non-debug ones enabling the use of configure options --enable-largefile and --disable-largefile which might be needed for library compatibility. Remove checking the size of curl_off_t, it is no longer needed. * Jul 3 2008 (Daniel Stenberg) - Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and the target host has only A records, it automatically falls back to an AF_INET lookup and gives you the A results. However, if the target host has a CNAME record, this behaviour is defeated since the original query does return some data even though ares_parse_aaa_reply() doesn't consider it relevant. Here's a small patch to make it behave the same with and without the CNAME. * Jul 2 2008 (Yang Tse) - Fallback to gettimeofday when monotonic clock is unavailable at run-time. * Jun 30 2008 (Daniel Stenberg) - As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is not posix or anything and thus c-ares failed to build on hurd (and possibly elsewhere). The define was also somewhat artificially used in the windows port. Now, I instead rewrote the use of gethostbyname to enlarge the host name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN define. I thus also removed the defien from the namser.h file where it was once added for the windows build. I also fixed init_by_defaults() function to not leak memory in case if error. * Jun 9 2008 (Yang Tse) - Make libcares.pc generated file for pkg-config include information relative to the libraries needed for the static linking of c-ares. * May 30 2008 (Yang Tse) - Brad House fixed a missing header file inclusion in adig sample program. Version 1.5.2 (May 29, 2008) * May 13 2008 (Daniel Stenberg) - Introducing millisecond resolution support for the timeout option. See ares_init_options()'s ARES_OPT_TIMEOUTMS. * May 9 2008 (Yang Tse) - Use monotonic time source if available, for private function ares__tvnow() * May 7 2008 (Daniel Stenberg) - Sebastian made c-ares able to return all PTR-records when doing reverse lookups. It is not common practice to have multiple PTR-Records for a single IP, but its perfectly legal and some sites have those. - Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to autoconf 2.57 usage (which is the version you have specified as the minimum version). It's a minor change but it does clean up some warnings with newer autoconf (specifically 2.62). * May 5 2008 (Yang Tse) - Improved parsing of resolver configuration files. * April 4 2008 (Daniel Stenberg) - Eino Tuominen improved the code when a file is used to seed the randomizer. - Alexey Simak made adig support NAPTR records - Alexey Simak fixed the VC dsp file by adding the missing source file ares_expand_string.c * December 11 2007 (Gisle Vanem) - Added another sample application; acountry.c which converts an IPv4-address(es) and/or host-name(s) to country-name and country-code. This uses the service of the DNSBL at countries.nerd.dk. * December 3 2007 (Daniel Stenberg) - Brad Spencer fixed the configure script to assume that there's no /dev/urandom when built cross-compiled as then the script cannot check for it. - Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat Version 1.5.1 (Nov 21, 2007) * November 21 2007 (Daniel Stenberg) - Robin Cornelius pointed out that ares_llist.h was missing in the release archive for 1.5.0 Version 1.5.0 (Nov 21, 2007) * October 2 2007 (Daniel Stenberg) - ares_strerror() segfaulted if the input error number was out of the currently supported range. - Yang Tse: Avoid a segfault when generating a DNS "Transaction ID" in internal function init_id_key() under low memory conditions. * September 28 2007 (Daniel Stenberg) - Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI and API changes in the progress callback (and possibly more coming up from Steinar) * September 28 2007 (Steinar H. Gunderson) - Don't skip a server if it's the only one. (Bugfix from the Google tree.) - Made the query callbacks receive the number of timeouts that happened during the execution of a query, and updated documentation accordingly. (Patch from the Google tree.) - Support a few more socket options: ARES_OPT_SOCK_SNDBUF and ARES_OPT_SOCK_RCVBUF - Always register for TCP events even if there are no outstanding queries, as the other side could always close the connection, which is a valid event which should be responded to. * September 22 2007 (Daniel Stenberg) - Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that if it fails and the socket is closed the following code doesn't try to use the file descriptor. - Steinar H. Gunderson modified c-ares to now also do to DNS retries even when TCP is used since there are several edge cases where it still makes sense. - Brad House provided a fix for ares_save_options(): Apparently I overlooked something with the ares_save_options() where it would try to do a malloc(0) when no options of that type needed to be saved. On most platforms, this was fine because malloc(0) doesn't actually return NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM. * July 14 2007 (Daniel Stenberg) - Vlad Dinulescu fixed two outstanding valgrind reports: 1. In ares_query.c , in find_query_by_id we compare q->qid (which is a short int variable) with qid, which is declared as an int variable. Moreover, DNS_HEADER_SET_QID is used to set the value of qid, but DNS_HEADER_SET_QID sets only the first two bytes of qid. I think that qid should be declared as "unsigned short" in this function. 2. The same problem occurs in ares_process.c, process_answer() . query->qid (an unsigned short integer variable) is compared with id, which is an integer variable. Moreover, id is initialized from DNS_HEADER_QID which sets only the first two bytes of id. I think that the id variable should be declared as "unsigned short" in this function. Even after declaring these variables as "unsigned short", the valgrind errors are still there. Which brings us to the third problem. 3. The third problem is that Valgrind assumes that query->qid is not initialised correctly. And it does that because query->qid is set from DNS_HEADER_QID(qbuf); Valgrind says that qbuf has unitialised bytes. And qbuf has uninitialised bytes because of channel->next_id . And next_id is set by ares_init.c:ares__generate_new_id() . I found that putting short r=0 in this function (instead of short r) makes all Valgrind warnings go away. I have studied ares__rc4() too, and this is the offending line: buffer_ptr[counter] ^= state[xorIndex]; (ares_query.c:62) This is what triggers Valgrind.. buffer_ptr is unitialised in this function, and by applying ^= on it, it remains unitialised. Version 1.4.0 (June 8, 2007) * June 4 2007 (Daniel Stenberg) - James Bursa reported a major memory problem when resolving multi-IP names and I found and fixed the problem. It was added by Ashish Sharma's patch two days ago. When I then tried to verify multiple entries in /etc/hosts after my fix, I got another segfault and decided this code was not ripe for inclusion and I reverted the patch. * June 2 2007 - Brad Spencer found and fixed three flaws in the code, found with the new gcc 4.2.0 warning: -Waddress - Brad House fixed VS2005 compiler warnings due to time_t being 64bit. He also made recent Microsoft compilers use _strdup() instead of strdup(). - Brad House's man pages for ares_save_options() and ares_destroy_options() were added. - Ashish Sharma provided a patch for supporting multiple entries in the /etc/hosts file. Patch edited for coding style and functionality by me (Daniel). * May 30 2007 - Shmulik Regev brought cryptographically secure transaction IDs: The c-ares library implementation uses a DNS "Transaction ID" field that is seeded with a pseudo random number (based on gettimeofday) which is incremented (++) between consecutive calls and is therefore rather predictable. In general, predictability of DNS Transaction ID is a well known security problem (e.g. http://bak.spc.org/dms/archive/dns_id_attack.txt) and makes a c-ares based implementation vulnerable to DNS poisoning. Credit goes to Amit Klein (Trusteer) for identifying this problem. The patch I wrote changes the implementation to use a more secure way of generating unique IDs. It starts by obtaining a key with reasonable entropy which is used with an RC4 stream to generate the cryptographically secure transaction IDs. Note that the key generation code (in ares_init:randomize_key) has two versions, the Windows specific one uses a cryptographically safe function provided (but undocumented :) by the operating system (described at http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx). The default implementation is a bit naive and uses the standard 'rand' function. Surely a better way to generate random keys exists for other platforms. The patch can be tested by using the adig utility and using the '-s' option. - Brad House added ares_save_options() and ares_destroy_options() that can be used to keep options for later re-usal when ares_init_options() is used. Problem: Calling ares_init() for each lookup can be unnecessarily resource intensive. On windows, it must LoadLibrary() or search the registry on each call to ares_init(). On unix, it must read and parse multiple files to obtain the necessary configuration information. In a single-threaded environment, it would make sense to only ares_init() once, but in a heavily multi-threaded environment, it is undesirable to ares_init() and ares_destroy() for each thread created and track that. Solution: Create ares_save_options() and ares_destroy_options() functions to retrieve and free options obtained from an initialized channel. The options populated can be used to pass back into ares_init_options(), it should populate all needed fields and not retrieve any information from the system. Probably wise to destroy the cache every minute or so to prevent the data from becoming stale. - Daniel S added ares_process_fd() to allow applications to ask for processing on specific sockets and thus avoiding select() and associated functions/macros. This function will be used by upcoming libcurl releases for this very reason. It also made me export the ares_socket_t type in the public ares.h header file, since ares_process_fd() uses that type for two of the arguments. * May 25 2007 - Ravi Pratap fixed a flaw in the init_by_resolv_conf() function for windows that could cause it to return a bad return code. * April 16 2007 - Yang Tse: Provide ares_getopt() command-line parser function as a source code helper function, not belonging to the actual c-ares library. * February 19 2007 - Vlad Dinulescu added ares_parse_ns_reply(). * February 13 2007 - Yang Tse: Fix failure to get the search sequence of /etc/hosts and DNS from /etc/nsswitch.conf, /etc/host.conf or /etc/svc.conf when /etc/resolv.conf did not exist or was unable to read it. * November 22 2006 - Install ares_dns.h too - Michael Wallner fixed this problem: When I set domains in the options struct, and there are domain/search entries in /etc/resolv.conf, the domains of the options struct will be overridden. * November 6 2006 - Yang Tse removed a couple of potential zero size memory allocations. - Andreas Rieke fixed the line endings in the areslib.dsp file that I (Daniel) broke in the 1.3.2 release. We should switch to a system where that file is auto-generated. We could rip some code for that from curl... Version 1.3.2 (November 3, 2006) * October 12 2006 - Prevent ares_getsock() to overflow if more than 16 sockets are used. * September 11 2006 - Guilherme Balena Versiani: I noted a strange BUG in Win32 port (ares_init.c/get_iphlpapi_dns_info() function): when I disable the network by hand or disconnect the network cable in Windows 2000 or Windows XP, my application gets 127.0.0.1 as the only name server. The problem comes from 'GetNetworkParams' function, that returns the empty string "" as the only name server in that case. Moreover, the Windows implementation of inet_addr() returns INADDR_LOOPBACK instead of INADDR_NONE. * August 29 2006 - Brad Spencer did o made ares_version.h use extern "C" for c++ compilers o fixed compiler warnings in ares_getnameinfo.c o fixed a buffer position init for TCP reads * August 3 2006 - Ravi Pratap fixed ares_getsock() to actually return the proper bitmap and not always zero! Version 1.3.1 (June 24, 2006) * July 23, 2006 - Gisle Vanem added getopt() to the ahost program. Currently accepts only [-t {a|aaaa}] to specify address family in ares_gethostbyname(). * June 19, 2006 - (wahern) Removed "big endian" DNS section and RR data integer parser macros from ares_dns.h, which break c-ares on my Sparc64. Bit-wise operations in C operate on logical values. And in any event the octets are already in big-endian (aka network) byte order so they're being reversed (thus the source of the breakage). * June 18, 2006 - William Ahern handles EAGAIN/EWOULDBLOCK errors in most of the I/O calls from area_process.c. TODO: Handle one last EAGAIN for a UDP socket send(2) in ares__send_query(). * May 10, 2006 - Bram Matthys brought my attention to a libtool peculiarity where detecting things such as C++ compiler actually is a bad thing and since we don't need that detection I added a work-around, much inspired by a previous patch by Paolo Bonzini. This also shortens the configure script quite a lot. * May 3, 2006 - Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set makes c-ares call a callback on socket state changes. A better way than the ares_getsock() to get full control over the socket state. * January 9, 2006 - Alexander Lazic improved the getservbyport_r() configure check. * January 6, 2006 - Alexander Lazic pointed out that the buildconf should use the ACLOCAL_FLAGS variable for easier controlling what it does and how it runs. * January 5, 2006 - James Bursa fixed c-ares to find the hosts file on RISC OS, and made it build with newer gcc versions that no longer defines "riscos". * December 22 - Daniel Stenberg added ares_getsock() that extracts the set of sockets to wait for action on. Similar to ares_fds() but not restricted to using select() for the waiting. * November 25 - Yang Tse fixed some send() / recv() compiler warnings * September 18 - Added constants that will be used by ares_getaddrinfo - Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it is available to ensure it works properly in a threaded environment. * September 10 - configure fix for detecting a member in the sockaddr_in6 struct which failed on ipv6-enabled HP-UX 11.00 Version 1.3.0 (August 29, 2005) * August 21 - Alfredo Tupone provided a fix for the Windows code in get_iphlpapi_dns_info() when getting the DNS server etc. * June 19 - Added some checks for the addrinfo structure. * June 2 - William Ahern: Make UDP sockets non-blocking. I've confirmed that at least on Linux 2.4 a read event can come back from poll() on a valid SOCK_DGRAM socket but recv(2) will still block. This patch doesn't ignore EAGAIN in read_udp_packets(), though maybe it should. (This patch was edited by Daniel Stenberg and a new configure test was added (imported from curl's configure) to properly detect what non-blocking socket approach to use.) I'm not quite sure how this was happening, but I've been seeing PTR queries which seem to return empty responses. At least, they were empty when calling ares_expand_name() on the record. Here's a patch which guarantees to NUL-terminate the expanded name. The old behavior failed to NUL-terminate if len was 0, and this was causing strlen() to run past the end of the buffer after calling ares_expand_name() and getting ARES_SUCCESS as the return value. If q is not greater than *s then it's equal and *s is always allocated with at least one byte. * May 16 - Added ares_getnameinfo which mimics the getnameinfo API (another feature that could use testing). * May 14 - Added an inet_ntop function from BIND for systems that do not have it. * April 9 - Made sortlist support IPv6 (this can probably use some testing). - Made sortlist support CIDR matching for IPv4. * April 8 - Added preliminary IPv6 support to ares_gethostbyname. Currently, sortlist does not work with IPv6. Also provided an implementation of bitncmp from BIND for systems that do not supply this function. This will be used to add IPv6 support to sortlist. - Made ares_gethostbyaddr support IPv6 by specifying AF_INET6 as the family. The function can lookup IPv6 addresses both from files (/etc/hosts) and DNS lookups. * April 7 - Tupone Alfredo fixed includes of arpa/nameser_compat.h to build fine on Mac OS X. * April 5 - Dominick Meglio: Provided implementations of inet_net_pton and inet_pton from BIND for systems that do not include these functions. * March 11, 2005 - Dominick Meglio added ares_parse_aaaa_reply.c and did various adjustments. The first little steps towards IPv6 support! * November 7 - Fixed the VC project and makefile to use ares_cancel and ares_version * October 24 - The released ares_version.h from 1.2.1 says 1.2.0 due to a maketgz flaw. This is now fixed. Version 1.2.1 (October 20, 2004) * September 29 - Henrik Stoerner fix: got a report that Tru64 Unix (the unix from Digital when they made Alpha's) uses /etc/svc.conf for the purpose fixed below for other OSes. He made c-ares check for and understand it if present. - Now c-ares will use local host name lookup _before_ DNS resolving by default if nothing else is told. * September 26 - Henrik Stoerner: found out that c-ares does not look at the /etc/host.conf file to determine the sequence in which to search /etc/hosts and DNS. So on systems where this order is defined by /etc/host.conf instead of a "lookup" entry in /etc/resolv.conf, c-ares will always default to looking in DNS first, and /etc/hosts second. c-ares now looks at 1) resolv.conf (for the "lookup" line); 2) nsswitch.fon (for the "hosts:" line); 3) host.conf (for the "order" line). First match wins. - Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is located in a static location. It assumed C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact, the location of the HOSTS file can be changed via a registry setting. There is a key called DatabasePath which specifies the path to the HOSTS file: http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx The patch will make c-ares correctly consult the registry for the location of this file. * August 29 - Gisle Vanem fixed the MSVC build files. * August 20 - Gisle Vanem made c-ares build and work with his Watt-32 TCP/IP stack. * August 13 - Harshal Pradhan made a minor syntax change in ares_init.c to make it build fine with MSVC 7.1 * July 24 - Made the lib get built static only if --enable-debug is used. - Gisle Vanem fixed: Basically in loops like handle_errors(), 'query->next' was assigned a local variable and then query was referenced after the memory was freed by next_server(). I've changed that so next_server() and end_query() returns the next query. So callers should use this ret-value. The next problem was that 'server->tcp_buffer_pos' had a random value at entry to 1st recv() (luckily causing Winsock to return ENOBUFS). I've also added a ares_writev() for Windows to streamline the code a bit more. * July 20 - Fixed a few variable return types for some system calls. Made configure check for ssize_t to make it possible to use that when receiving the send() error code. This is necessary to prevent compiler warnings on some systems. - Made configure create config.h, and all source files now include setup.h that might include the proper config.h (or a handicrafted alternative). - Switched to 'ares_socket_t' type for sockets in ares, since Windows don't use 'int' for that. - automake-ified and libool-ified c-ares. Now it builds libcares as a shared lib on most platforms if wanted. (This bloated the size of the release archive with another 200K!) - Makefile.am now uses Makefile.inc for the c sources, h headers and man pages, to make it easier for other makefiles to use the exact same set of files. - Adjusted 'maketgz' to use the new automake magic when building distribution archives. - Anyone desires HTML and/or PDF versions of the man pages in the release archives? * July 3 - Gnter Knauf made c-ares build and run on Novell Netware. * July 1 - Gisle Vanem provided Makefile.dj to build with djgpp, added a few more djgpp fixes and made ares not use 'errno' to provide further info on Windows. * June 30 - Gisle Vanem made it build with djgpp and run fine with the Watt-32 stack. * June 10 - Gisle Vanem's init patch for Windows: The init_by_resolv_conf() function fetches the DNS-server(s) from a series of registry branches. This can be wrong in the case where DHCP has assigned nameservers, but the user has overridden these servers with other prefered settings. Then it's wrong to use the DHCPNAMESERVER setting in registry. In the case of no global DHCP-assigned or fixed servers, but DNS server(s) per adapter, one has to query the adapter branches. But how can c-ares know which adapter is valid for use? AFAICS it can't. There could be one adapter that is down (e.g. a VPN adapter). So it's better to leave this to the IP Helper API (iphlapi) available in Win-98/2000 and later. My patch falls-back to the old way if not available. * June 8 - James Bursa fixed an init issue for RISC OS. * May 11 - Nico Stappenbelt reported that when processing domain and search lines in the resolv.conf file, the first entry encountered is processed and used as the search list. According to the manual pages for both Linux, Solaris and Tru64, the last entry of either a domain or a search field is used. This is now adjusted in the code Version 1.2.0 (April 13, 2004) * April 2, 2004 - Updated various man pages to look nicer when converted to HTML on the web site. * April 1, 2004 - Dirk Manske provided a new function that is now named ares_cancel(). It is used to cancel/cleanup a resolve/request made using ares functions on the given ares channel. It does not destroy/kill the ares channel itself. - Dominick Meglio cleaned up the formatting in several man pages. * March 30, 2004 - Dominick Meglio's new ares_expand_string. A helper function when decoding incoming DNS packages. - Daniel Stenberg modified the Makefile.in to use a for loop for the man page installation to improve overview and make it easier to add man pages. Version 1.1.0 (March 11, 2004) * March 9, 2004 - Gisle Vanem improved build on Windows. * February 25, 2004 - Dan Fandrich found a flaw in the Feb 22 fix. - Added better configure --enable-debug logic (taken from the curl configure script). Added acinclude.m4 to the tarball. * February 23, 2004 - Removed ares_free_errmem(), the function, the file and the man page. It was not used and it did nothing. - Fixed a lot of code that wasn't "64bit clean" and thus caused a lot of compiler warnings on picky compilers. * February 22, 2004 - Dominick Meglio made ares init support multiple name servers in the NameServer key on Windows. * February 16, 2004 - Modified ares_private.h to include libcurl's memory debug header if CURLDEBUG is set. This makes all the ares-functions supervised properly by the curl test suite. This also forced me to add inclusion of the ares_private.h header in a few more files that are using some kind of memory-related resources. - Made the makefile only build ahost and adig if 'make demos' is used. * February 10, 2004 - Dirk Manske made ares_version.h installed with 'make install' * February 4, 2004 - ares_free_errmem() is subject for removal, it is simply present for future purposes, and since we removed the extra parameter in strerror() it won't be used by c-ares! - configure --enable-debug now enables picky compiler options if gcc is used - fixed several compiler warnings --enable-debug showed and Joerg Mueller-Tolk reported Version 1.0.0 (February 3, 2004) * February 3, 2004 - now we produce the libcares.a library instead of the previous libares.a since we are no longer compatible * February 2, 2004 - ares_strerror() has one argument less. This is the first official modification of the existing provided ares API. * January 29, 2004 - Dirk Manske fixed how the socket is set non-blocking. * January 4, 2004 - Dominick Meglio made the private gettimeofday() become ares_gettimeofday() instead in order to not pollute the name space and risk colliding with other libraries' versions of this function. * October 24, 2003. Daniel Stenberg Added ares_version(). Version 1.0-pre1 (8 October 2003) - James Bursa made it run on RISC OS - Dominick Meglio made it run fine on NT4 - Duncan Wilcox made it work fine on Mac OS X - Daniel Stenberg adjusted the windows port - liren at vivisimo.com made the initial windows port * Imported the sources from ares 1.1.1 gevent-1.1.0/c-ares/config-dos.h0000644000076500000000000000644512666555342017123 0ustar jmaddenwheel00000000000000#ifndef HEADER_CONFIG_DOS_H #define HEADER_CONFIG_DOS_H /* ================================================================ */ /* ares/config-dos.h - Hand crafted config file for DOS */ /* ================================================================ */ #define PACKAGE "c-ares" #define HAVE_ERRNO_H 1 #define HAVE_GETENV 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_IOCTLSOCKET 1 #define HAVE_IOCTLSOCKET_FIONBIO 1 #define HAVE_LIMITS_H 1 #define HAVE_NET_IF_H 1 #define HAVE_RECV 1 #define HAVE_RECVFROM 1 #define HAVE_SEND 1 #define HAVE_STRDUP 1 #define HAVE_STRICMP 1 #define HAVE_STRUCT_IN6_ADDR 1 #define HAVE_STRUCT_TIMEVAL 1 #define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_SOCKET_H 1 #define HAVE_SYS_STAT_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_TIME_H 1 #define HAVE_UNISTD_H 1 #define NEED_MALLOC_H 1 #define RETSIGTYPE void #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 #define SIZEOF_SIZE_T 4 #define TIME_WITH_SYS_TIME 1 /* Qualifiers for send(), recv(), recvfrom() and getnameinfo(). */ #define SEND_TYPE_ARG1 int #define SEND_QUAL_ARG2 const #define SEND_TYPE_ARG2 void * #define SEND_TYPE_ARG3 int #define SEND_TYPE_ARG4 int #define SEND_TYPE_RETV int #define RECV_TYPE_ARG1 int #define RECV_TYPE_ARG2 void * #define RECV_TYPE_ARG3 int #define RECV_TYPE_ARG4 int #define RECV_TYPE_RETV int #define RECVFROM_TYPE_ARG1 int #define RECVFROM_TYPE_ARG2 void #define RECVFROM_TYPE_ARG3 int #define RECVFROM_TYPE_ARG4 int #define RECVFROM_TYPE_ARG5 struct sockaddr #define RECVFROM_TYPE_ARG6 int #define RECVFROM_TYPE_RETV int #define RECVFROM_TYPE_ARG2_IS_VOID 1 #define BSD #if defined(__HIGHC__) || \ (defined(__GNUC__) && (__GNUC__ < 4)) #define ssize_t int #endif /* Target HAVE_x section */ #if defined(DJGPP) #define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 #define HAVE_SYS_TIME_H 1 #define HAVE_VARIADIC_MACROS_GCC 1 /* Because djgpp <= 2.03 doesn't have snprintf() etc. */ #if (DJGPP_MINOR < 4) #define _MPRINTF_REPLACE #endif #elif defined(__WATCOMC__) #define HAVE_STRCASECMP 1 #elif defined(__HIGHC__) #define HAVE_SYS_TIME_H 1 #define strerror(e) strerror_s_((e)) #endif #ifdef WATT32 #define HAVE_AF_INET6 1 #define HAVE_ARPA_INET_H 1 #define HAVE_ARPA_NAMESER_H 1 #define HAVE_CLOSE_S 1 #define HAVE_GETHOSTNAME 1 #define HAVE_NETDB_H 1 #define HAVE_NETINET_IN_H 1 #define HAVE_NETINET_TCP_H 1 #define HAVE_PF_INET6 1 #define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 #define HAVE_STRUCT_ADDRINFO 1 #define HAVE_STRUCT_IN6_ADDR 1 #define HAVE_STRUCT_SOCKADDR_IN6 1 #define HAVE_SYS_SOCKET_H 1 #define HAVE_SYS_UIO_H 1 #define NS_INADDRSZ 4 #define HAVE_STRUCT_SOCKADDR_IN6 1 #endif #undef word #undef byte #endif /* HEADER_CONFIG_DOS_H */ gevent-1.1.0/c-ares/config-win32.h0000644000076500000000000002752212666555342017277 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_CONFIG_WIN32_H #define HEADER_CARES_CONFIG_WIN32_H /* Copyright (C) 2004 - 2011 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /* ================================================================ */ /* c-ares/config-win32.h - Hand crafted config file for Windows */ /* ================================================================ */ /* ---------------------------------------------------------------- */ /* HEADER FILES */ /* ---------------------------------------------------------------- */ /* Define if you have the header file. */ #define HAVE_ASSERT_H 1 /* Define if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define if you have the header file. */ #if defined(__MINGW32__) || defined(__POCC__) #define HAVE_GETOPT_H 1 #endif /* Define if you have the header file. */ #define HAVE_LIMITS_H 1 /* Define if you have the header file. */ #ifndef __SALFORDC__ #define HAVE_PROCESS_H 1 #endif /* Define if you have the header file. */ #define HAVE_SIGNAL_H 1 /* Define if you have the header file */ /* #define HAVE_SYS_TIME_H 1 */ /* Define if you have the header file. */ #define HAVE_TIME_H 1 /* Define if you have the header file. */ #if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__LCC__) || \ defined(__POCC__) #define HAVE_UNISTD_H 1 #endif /* Define if you have the header file. */ #define HAVE_WINDOWS_H 1 /* Define if you have the header file. */ #define HAVE_WINSOCK_H 1 /* Define if you have the header file. */ #ifndef __SALFORDC__ #define HAVE_WINSOCK2_H 1 #endif /* Define if you have the header file. */ #ifndef __SALFORDC__ #define HAVE_WS2TCPIP_H 1 #endif /* ---------------------------------------------------------------- */ /* OTHER HEADER INFO */ /* ---------------------------------------------------------------- */ /* Define if sig_atomic_t is an available typedef. */ #define HAVE_SIG_ATOMIC_T 1 /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if you can safely include both and . */ /* #define TIME_WITH_SYS_TIME 1 */ /* ---------------------------------------------------------------- */ /* FUNCTIONS */ /* ---------------------------------------------------------------- */ /* Define if you have the closesocket function. */ #define HAVE_CLOSESOCKET 1 /* Define if you have the getenv function. */ #define HAVE_GETENV 1 /* Define if you have the gethostname function. */ #define HAVE_GETHOSTNAME 1 /* Define if you have the ioctlsocket function. */ #define HAVE_IOCTLSOCKET 1 /* Define if you have a working ioctlsocket FIONBIO function. */ #define HAVE_IOCTLSOCKET_FIONBIO 1 /* Define if you have the strcasecmp function. */ /* #define HAVE_STRCASECMP 1 */ /* Define if you have the strdup function. */ #define HAVE_STRDUP 1 /* Define if you have the stricmp function. */ #define HAVE_STRICMP 1 /* Define if you have the strncasecmp function. */ /* #define HAVE_STRNCASECMP 1 */ /* Define if you have the strnicmp function. */ #define HAVE_STRNICMP 1 /* Define if you have the recv function. */ #define HAVE_RECV 1 /* Define to the type of arg 1 for recv. */ #define RECV_TYPE_ARG1 SOCKET /* Define to the type of arg 2 for recv. */ #define RECV_TYPE_ARG2 char * /* Define to the type of arg 3 for recv. */ #define RECV_TYPE_ARG3 int /* Define to the type of arg 4 for recv. */ #define RECV_TYPE_ARG4 int /* Define to the function return type for recv. */ #define RECV_TYPE_RETV int /* Define if you have the recvfrom function. */ #define HAVE_RECVFROM 1 /* Define to the type of arg 1 for recvfrom. */ #define RECVFROM_TYPE_ARG1 SOCKET /* Define to the type pointed by arg 2 for recvfrom. */ #define RECVFROM_TYPE_ARG2 char /* Define to the type of arg 3 for recvfrom. */ #define RECVFROM_TYPE_ARG3 int /* Define to the type of arg 4 for recvfrom. */ #define RECVFROM_TYPE_ARG4 int /* Define to the type pointed by arg 5 for recvfrom. */ #define RECVFROM_TYPE_ARG5 struct sockaddr /* Define to the type pointed by arg 6 for recvfrom. */ #define RECVFROM_TYPE_ARG6 int /* Define to the function return type for recvfrom. */ #define RECVFROM_TYPE_RETV int /* Define if you have the send function. */ #define HAVE_SEND 1 /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 SOCKET /* Define to the type qualifier of arg 2 for send. */ #define SEND_QUAL_ARG2 const /* Define to the type of arg 2 for send. */ #define SEND_TYPE_ARG2 char * /* Define to the type of arg 3 for send. */ #define SEND_TYPE_ARG3 int /* Define to the type of arg 4 for send. */ #define SEND_TYPE_ARG4 int /* Define to the function return type for send. */ #define SEND_TYPE_RETV int /* Specifics for the Watt-32 tcp/ip stack. */ #ifdef WATT32 #define SOCKET int #define NS_INADDRSZ 4 #define HAVE_ARPA_NAMESER_H 1 #define HAVE_ARPA_INET_H 1 #define HAVE_NETDB_H 1 #define HAVE_NETINET_IN_H 1 #define HAVE_SYS_SOCKET_H 1 #define HAVE_NETINET_TCP_H 1 #define HAVE_AF_INET6 1 #define HAVE_PF_INET6 1 #define HAVE_STRUCT_IN6_ADDR 1 #define HAVE_STRUCT_SOCKADDR_IN6 1 #undef HAVE_WINSOCK_H #undef HAVE_WINSOCK2_H #undef HAVE_WS2TCPIP_H #endif /* ---------------------------------------------------------------- */ /* TYPEDEF REPLACEMENTS */ /* ---------------------------------------------------------------- */ /* Define if in_addr_t is not an available 'typedefed' type. */ #define in_addr_t unsigned long /* Define to the return type of signal handlers (int or void). */ #define RETSIGTYPE void /* Define if ssize_t is not an available 'typedefed' type. */ #ifndef _SSIZE_T_DEFINED # if (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \ defined(__POCC__) || \ defined(__MINGW32__) # elif defined(_WIN64) # define _SSIZE_T_DEFINED # define ssize_t __int64 # else # define _SSIZE_T_DEFINED # define ssize_t int # endif #endif /* ---------------------------------------------------------------- */ /* TYPE SIZES */ /* ---------------------------------------------------------------- */ /* Define to the size of `int', as computed by sizeof. */ #define SIZEOF_INT 4 /* Define to the size of `short', as computed by sizeof. */ #define SIZEOF_SHORT 2 /* Define to the size of `size_t', as computed by sizeof. */ #if defined(_WIN64) # define SIZEOF_SIZE_T 8 #else # define SIZEOF_SIZE_T 4 #endif /* ---------------------------------------------------------------- */ /* STRUCT RELATED */ /* ---------------------------------------------------------------- */ /* Define if you have struct addrinfo. */ #define HAVE_STRUCT_ADDRINFO 1 /* Define if you have struct sockaddr_storage. */ #if !defined(__SALFORDC__) && !defined(__BORLANDC__) #define HAVE_STRUCT_SOCKADDR_STORAGE 1 #endif /* Define if you have struct timeval. */ #define HAVE_STRUCT_TIMEVAL 1 /* ---------------------------------------------------------------- */ /* COMPILER SPECIFIC */ /* ---------------------------------------------------------------- */ /* Define to avoid VS2005 complaining about portable C functions. */ #if defined(_MSC_VER) && (_MSC_VER >= 1400) # define _CRT_SECURE_NO_DEPRECATE 1 # define _CRT_NONSTDC_NO_DEPRECATE 1 #endif /* Officially, Microsoft's Windows SDK versions 6.X do not support Windows 2000 as a supported build target. VS2008 default installations provide an embedded Windows SDK v6.0A along with the claim that Windows 2000 is a valid build target for VS2008. Popular belief is that binaries built with VS2008 using Windows SDK versions 6.X and Windows 2000 as a build target are functional. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) # define VS2008_MIN_TARGET 0x0500 #endif /* When no build target is specified VS2008 default build target is Windows Vista, which leaves out even Winsows XP. If no build target has been given for VS2008 we will target the minimum Officially supported build target, which happens to be Windows XP. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) # define VS2008_DEF_TARGET 0x0501 #endif /* VS2008 default target settings and minimum build target check. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) # ifndef _WIN32_WINNT # define _WIN32_WINNT VS2008_DEF_TARGET # endif # ifndef WINVER # define WINVER VS2008_DEF_TARGET # endif # if (_WIN32_WINNT < VS2008_MIN_TARGET) || (WINVER < VS2008_MIN_TARGET) # error VS2008 does not support Windows build targets prior to Windows 2000 # endif #endif /* When no build target is specified Pelles C 5.00 and later default build target is Windows Vista. We override default target to be Windows 2000. */ #if defined(__POCC__) && (__POCC__ >= 500) # ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0500 # endif # ifndef WINVER # define WINVER 0x0500 # endif #endif /* Availability of freeaddrinfo, getaddrinfo and getnameinfo functions is quite convoluted, compiler dependent and even build target dependent. */ #if defined(HAVE_WS2TCPIP_H) # if defined(__POCC__) # define HAVE_FREEADDRINFO 1 # define HAVE_GETADDRINFO 1 # define HAVE_GETNAMEINFO 1 # elif defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) # define HAVE_FREEADDRINFO 1 # define HAVE_GETADDRINFO 1 # define HAVE_GETNAMEINFO 1 # elif defined(_MSC_VER) && (_MSC_VER >= 1200) # define HAVE_FREEADDRINFO 1 # define HAVE_GETADDRINFO 1 # define HAVE_GETNAMEINFO 1 # endif #endif #if defined(__POCC__) # ifndef _MSC_VER # error Microsoft extensions /Ze compiler option is required # endif # ifndef __POCC__OLDNAMES # error Compatibility names /Go compiler option is required # endif #endif /* ---------------------------------------------------------------- */ /* IPV6 COMPATIBILITY */ /* ---------------------------------------------------------------- */ /* Define if you have address family AF_INET6. */ #ifdef HAVE_WINSOCK2_H #define HAVE_AF_INET6 1 #endif /* Define if you have protocol family PF_INET6. */ #ifdef HAVE_WINSOCK2_H #define HAVE_PF_INET6 1 #endif /* Define if you have struct in6_addr. */ #ifdef HAVE_WS2TCPIP_H #define HAVE_STRUCT_IN6_ADDR 1 #endif /* Define if you have struct sockaddr_in6. */ #ifdef HAVE_WS2TCPIP_H #define HAVE_STRUCT_SOCKADDR_IN6 1 #endif /* Define if you have sockaddr_in6 with scopeid. */ #ifdef HAVE_WS2TCPIP_H #define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 #endif /* ---------------------------------------------------------------- */ /* Win CE */ /* ---------------------------------------------------------------- */ /* FIXME: A proper config-win32ce.h should be created to hold these */ /* * System error codes for Windows CE */ #if defined(_WIN32_WCE) && !defined(HAVE_ERRNO_H) # define ENOENT ERROR_FILE_NOT_FOUND # define ESRCH ERROR_PATH_NOT_FOUND # define ENOMEM ERROR_NOT_ENOUGH_MEMORY # define ENOSPC ERROR_INVALID_PARAMETER #endif #endif /* HEADER_CARES_CONFIG_WIN32_H */ gevent-1.1.0/c-ares/config.guess0000755000076500000000000012463712666555342017246 0ustar jmaddenwheel00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-03-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gevent-1.1.0/c-ares/config.sub0000755000076500000000000010636712666555342016711 0ustar jmaddenwheel00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-03-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gevent-1.1.0/c-ares/configure0000755000076500000000000302101212666555342016617 0ustar jmaddenwheel00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for c-ares 1.10.0. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------------------- ## ## XC_CONFIGURE_PREAMBLE ver: 1.0 ## ## -------------------------------- ## xc_configure_preamble_ver_major='1' xc_configure_preamble_ver_minor='0' # # Set IFS to space, tab and newline. # xc_space=' ' xc_tab=' ' xc_newline=' ' IFS="$xc_space$xc_tab$xc_newline" # # Set internationalization behavior variables. # LANG='C' LC_ALL='C' LANGUAGE='C' export LANG export LC_ALL export LANGUAGE # # Some useful variables. # xc_msg_warn='configure: WARNING:' xc_msg_abrt='Can not continue.' xc_msg_err='configure: error:' # # Verify that 'echo' command is available, otherwise abort. # xc_tst_str='unknown' (`echo "$xc_tst_str" >/dev/null 2>&1`) && xc_tst_str='success' case "x$xc_tst_str" in # (( xsuccess) : ;; *) # Try built-in echo, and fail. echo "$xc_msg_err 'echo' command not found. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'test' command is available, otherwise abort. # xc_tst_str='unknown' (`test -n "$xc_tst_str" >/dev/null 2>&1`) && xc_tst_str='success' case "x$xc_tst_str" in # (( xsuccess) : ;; *) echo "$xc_msg_err 'test' command not found. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'PATH' variable is set, otherwise abort. # xc_tst_str='unknown' (`test -n "$PATH" >/dev/null 2>&1`) && xc_tst_str='success' case "x$xc_tst_str" in # (( xsuccess) : ;; *) echo "$xc_msg_err 'PATH' variable not set. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'expr' command is available, otherwise abort. # xc_tst_str='unknown' xc_tst_str=`expr "$xc_tst_str" : '.*' 2>/dev/null` case "x$xc_tst_str" in # (( x7) : ;; *) echo "$xc_msg_err 'expr' command not found. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'sed' utility is found within 'PATH', otherwise abort. # xc_tst_str='unknown' xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \ | sed -e 's:unknown:success:' 2>/dev/null` case "x$xc_tst_str" in # (( xsuccess) : ;; *) echo "$xc_msg_err 'sed' utility not found in 'PATH'. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'grep' utility is found within 'PATH', otherwise abort. # xc_tst_str='unknown' (`echo "$xc_tst_str" 2>/dev/null \ | grep 'unknown' >/dev/null 2>&1`) && xc_tst_str='success' case "x$xc_tst_str" in # (( xsuccess) : ;; *) echo "$xc_msg_err 'grep' utility not found in 'PATH'. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'tr' utility is found within 'PATH', otherwise abort. # xc_tst_str="${xc_tab}98s7u6c5c4e3s2s10" xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \ | tr -d "0123456789$xc_tab" 2>/dev/null` case "x$xc_tst_str" in # (( xsuccess) : ;; *) echo "$xc_msg_err 'tr' utility not found in 'PATH'. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'wc' utility is found within 'PATH', otherwise abort. # xc_tst_str='unknown unknown unknown unknown' xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \ | wc -w 2>/dev/null | tr -d "$xc_space$xc_tab" 2>/dev/null` case "x$xc_tst_str" in # (( x4) : ;; *) echo "$xc_msg_err 'wc' utility not found in 'PATH'. $xc_msg_abrt" >&2 exit 1 ;; esac # # Verify that 'cat' utility is found within 'PATH', otherwise abort. # xc_tst_str='unknown' xc_tst_str=`cat <<_EOT 2>/dev/null \ | wc -l 2>/dev/null | tr -d "$xc_space$xc_tab" 2>/dev/null unknown unknown unknown _EOT` case "x$xc_tst_str" in # (( x3) : ;; *) echo "$xc_msg_err 'cat' utility not found in 'PATH'. $xc_msg_abrt" >&2 exit 1 ;; esac # # Auto-detect and set 'PATH_SEPARATOR', unless it is already non-empty set. # # Directory count in 'PATH' when using a colon separator. xc_tst_dirs_col='x' xc_tst_prev_IFS=$IFS; IFS=':' for xc_tst_dir in $PATH; do IFS=$xc_tst_prev_IFS xc_tst_dirs_col="x$xc_tst_dirs_col" done IFS=$xc_tst_prev_IFS xc_tst_dirs_col=`expr "$xc_tst_dirs_col" : '.*'` # Directory count in 'PATH' when using a semicolon separator. xc_tst_dirs_sem='x' xc_tst_prev_IFS=$IFS; IFS=';' for xc_tst_dir in $PATH; do IFS=$xc_tst_prev_IFS xc_tst_dirs_sem="x$xc_tst_dirs_sem" done IFS=$xc_tst_prev_IFS xc_tst_dirs_sem=`expr "$xc_tst_dirs_sem" : '.*'` if test $xc_tst_dirs_sem -eq $xc_tst_dirs_col; then # When both counting methods give the same result we do not want to # chose one over the other, and consider auto-detection not possible. if test -z "$PATH_SEPARATOR"; then # Stop dead until user provides 'PATH_SEPARATOR' definition. echo "$xc_msg_err 'PATH_SEPARATOR' variable not set. $xc_msg_abrt" >&2 exit 1 fi else # Separator with the greater directory count is the auto-detected one. if test $xc_tst_dirs_sem -gt $xc_tst_dirs_col; then xc_tst_auto_separator=';' else xc_tst_auto_separator=':' fi if test -z "$PATH_SEPARATOR"; then # Simply use the auto-detected one when not already set. PATH_SEPARATOR=$xc_tst_auto_separator elif test "x$PATH_SEPARATOR" != "x$xc_tst_auto_separator"; then echo "$xc_msg_warn 'PATH_SEPARATOR' does not match auto-detected one." >&2 fi fi xc_PATH_SEPARATOR=$PATH_SEPARATOR xc_configure_preamble_result='yes' ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and c-ares mailing $0: list: http://cool.haxx.se/mailman/listinfo/c-ares about $0: your system, including any error possibly output before $0: this message. Then install a modern shell, or manually $0: run the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='c-ares' PACKAGE_TARNAME='c-ares' PACKAGE_VERSION='1.10.0' PACKAGE_STRING='c-ares 1.10.0' PACKAGE_BUGREPORT='c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares' PACKAGE_URL='' ac_unique_file="ares_ipv6.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CARES_CFLAG_EXTRAS CARES_PRIVATE_LIBS CFLAG_CARES_SYMBOL_HIDING DOING_CARES_SYMBOL_HIDING_FALSE DOING_CARES_SYMBOL_HIDING_TRUE RANDOM_FILE DOING_NATIVE_WINDOWS_FALSE DOING_NATIVE_WINDOWS_TRUE CURLDEBUG_FALSE CURLDEBUG_TRUE CPPFLAG_CARES_STATICLIB USE_CPPFLAG_CARES_STATICLIB_FALSE USE_CPPFLAG_CARES_STATICLIB_TRUE CARES_LT_SHLIB_USE_MIMPURE_TEXT_FALSE CARES_LT_SHLIB_USE_MIMPURE_TEXT_TRUE CARES_LT_SHLIB_USE_NO_UNDEFINED_FALSE CARES_LT_SHLIB_USE_NO_UNDEFINED_TRUE CARES_LT_SHLIB_USE_VERSION_INFO_FALSE CARES_LT_SHLIB_USE_VERSION_INFO_TRUE OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP LIBTOOL OBJDUMP DLLTOOL AS am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM host_os host_vendor host_cpu host build_os build_vendor build_cpu build AR EGREP GREP SED MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME SHELL PATH_SEPARATOR' ac_subst_files='' ac_user_opts=' enable_option_checking enable_maintainer_mode enable_debug enable_optimize enable_warnings enable_werror enable_curldebug enable_symbol_hiding enable_dependency_tracking enable_largefile enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock enable_libgcc with_random enable_nonblocking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures c-ares 1.10.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/c-ares] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of c-ares 1.10.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-debug Enable debug build options --disable-debug Disable debug build options --enable-optimize(=OPT) Enable compiler optimizations (default=-O2) --disable-optimize Disable compiler optimizations --enable-warnings Enable strict compiler warnings --disable-warnings Disable strict compiler warnings --enable-werror Enable compiler warnings as errors --disable-werror Disable compiler warnings as errors --enable-curldebug Enable curl debug memory tracking --disable-curldebug Disable curl debug memory tracking --enable-symbol-hiding Enable hiding of library internal symbols --disable-symbol-hiding Disable hiding of library internal symbols --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-largefile omit support for large files --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-libgcc use libgcc when linking --enable-nonblocking Enable non-blocking communications --disable-nonblocking Disable non-blocking communications Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-random=FILE read randomness from FILE (default=/dev/urandom) Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF c-ares configure 1.10.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define $2 innocuous_$2 #ifdef __STDC__ # include #else # include #endif #undef $2 #ifdef __cplusplus extern "C" #endif char $2 (); #if defined __stub_$2 || defined __stub___$2 choke me #endif int main (void) { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------------------------------------------- ## ## Report this to c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares ## ## ------------------------------------------------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main (void) { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2.$3... " >&6; } if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by c-ares $as_me 1.10.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # using cares-override.m4 ac_config_headers="$ac_config_headers ares_config.h ares_build.h" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable debug build options" >&5 $as_echo_n "checking whether to enable debug build options... " >&6; } OPT_DEBUG_BUILD="default" # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; OPT_DEBUG_BUILD=$enableval fi case "$OPT_DEBUG_BUILD" in no) want_debug="no" ;; default) want_debug="no" ;; *) want_debug="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $want_debug" >&5 $as_echo "$want_debug" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable compiler optimizer" >&5 $as_echo_n "checking whether to enable compiler optimizer... " >&6; } OPT_COMPILER_OPTIMIZE="default" # Check whether --enable-optimize was given. if test "${enable_optimize+set}" = set; then : enableval=$enable_optimize; OPT_COMPILER_OPTIMIZE=$enableval fi case "$OPT_COMPILER_OPTIMIZE" in no) want_optimize="no" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; default) if test "$want_debug" = "yes"; then want_optimize="assume_no" { $as_echo "$as_me:${as_lineno-$LINENO}: result: not specified (assuming no)" >&5 $as_echo "not specified (assuming no)" >&6; } else want_optimize="assume_yes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: not specified (assuming yes)" >&5 $as_echo "not specified (assuming yes)" >&6; } fi ;; *) want_optimize="yes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable strict compiler warnings" >&5 $as_echo_n "checking whether to enable strict compiler warnings... " >&6; } OPT_COMPILER_WARNINGS="default" # Check whether --enable-warnings was given. if test "${enable_warnings+set}" = set; then : enableval=$enable_warnings; OPT_COMPILER_WARNINGS=$enableval fi case "$OPT_COMPILER_WARNINGS" in no) want_warnings="no" ;; default) want_warnings="$want_debug" ;; *) want_warnings="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $want_warnings" >&5 $as_echo "$want_warnings" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable compiler warnings as errors" >&5 $as_echo_n "checking whether to enable compiler warnings as errors... " >&6; } OPT_COMPILER_WERROR="default" # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; OPT_COMPILER_WERROR=$enableval fi case "$OPT_COMPILER_WERROR" in no) want_werror="no" ;; default) want_werror="no" ;; *) want_werror="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $want_werror" >&5 $as_echo "$want_werror" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable curl debug memory tracking" >&5 $as_echo_n "checking whether to enable curl debug memory tracking... " >&6; } OPT_CURLDEBUG_BUILD="default" # Check whether --enable-curldebug was given. if test "${enable_curldebug+set}" = set; then : enableval=$enable_curldebug; OPT_CURLDEBUG_BUILD=$enableval fi case "$OPT_CURLDEBUG_BUILD" in no) want_curldebug="no" ;; default) want_curldebug="no" ;; *) want_curldebug="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $want_curldebug" >&5 $as_echo "$want_curldebug" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable hiding of library internal symbols" >&5 $as_echo_n "checking whether to enable hiding of library internal symbols... " >&6; } OPT_SYMBOL_HIDING="default" # Check whether --enable-symbol-hiding was given. if test "${enable_symbol_hiding+set}" = set; then : enableval=$enable_symbol_hiding; OPT_SYMBOL_HIDING=$enableval fi case "$OPT_SYMBOL_HIDING" in no) want_symbol_hiding="no" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; default) want_symbol_hiding="yes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; *) want_symbol_hiding="yes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; esac # # Check that 'XC_CONFIGURE_PREAMBLE' has already run. # if test -z "$xc_configure_preamble_result"; then as_fn_error $? "xc_configure_preamble_result not set (internal problem)" "$LINENO" 5 fi # # Check that 'PATH_SEPARATOR' has already been set. # if test -z "$xc_PATH_SEPARATOR"; then as_fn_error $? "xc_PATH_SEPARATOR not set (internal problem)" "$LINENO" 5 fi if test -z "$PATH_SEPARATOR"; then as_fn_error $? "PATH_SEPARATOR not set (internal or config.site problem)" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for path separator" >&5 $as_echo_n "checking for path separator... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_SEPARATOR" >&5 $as_echo "$PATH_SEPARATOR" >&6; } if test "x$PATH_SEPARATOR" != "x$xc_PATH_SEPARATOR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initial path separator" >&5 $as_echo_n "checking for initial path separator... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_PATH_SEPARATOR" >&5 $as_echo "$xc_PATH_SEPARATOR" >&6; } as_fn_error $? "path separator mismatch (internal or config.site problem)" "$LINENO" 5 fi # Extract the first word of "sed", so it can be a program name with args. set dummy sed; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else case $SED in [\\/]* | ?:[\\/]*) ac_cv_path_SED="$SED" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/bin:/usr/local/bin" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SED" && ac_cv_path_SED="not_found" ;; esac fi SED=$ac_cv_path_SED if test -n "$SED"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5 $as_echo "$SED" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$SED" || test "$SED" = "not_found"; then as_fn_error $? "sed not found in PATH. Cannot continue without sed." "$LINENO" 5 fi # Extract the first word of "grep", so it can be a program name with args. set dummy grep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else case $GREP in [\\/]* | ?:[\\/]*) ac_cv_path_GREP="$GREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/bin:/usr/local/bin" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GREP" && ac_cv_path_GREP="not_found" ;; esac fi GREP=$ac_cv_path_GREP if test -n "$GREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5 $as_echo "$GREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$GREP" || test "$GREP" = "not_found"; then as_fn_error $? "grep not found in PATH. Cannot continue without grep." "$LINENO" 5 fi if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } EGREP="$GREP -E" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EGREP" >&5 $as_echo "$EGREP" >&6; } else # Extract the first word of "egrep", so it can be a program name with args. set dummy egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/bin:/usr/local/bin" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_EGREP" && ac_cv_path_EGREP="not_found" ;; esac fi EGREP=$ac_cv_path_EGREP if test -n "$EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EGREP" >&5 $as_echo "$EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$EGREP" || test "$EGREP" = "not_found"; then as_fn_error $? "egrep not found in PATH. Cannot continue without egrep." "$LINENO" 5 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_AR+:} false; then : $as_echo_n "(cached) " >&6 else case $AR in [\\/]* | ?:[\\/]*) ac_cv_path_AR="$AR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/bin:/usr/local/bin" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi AR=$ac_cv_path_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_AR"; then ac_pt_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_AR+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_AR in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_AR="$ac_pt_AR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/bin:/usr/local/bin" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_AR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_AR=$ac_cv_path_ac_pt_AR if test -n "$ac_pt_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_AR" >&5 $as_echo "$ac_pt_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_AR" = x; then AR="not_found" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_pt_AR fi else AR="$ac_cv_path_AR" fi if test -z "$AR" || test "$AR" = "not_found"; then as_fn_error $? "ar not found in PATH. Cannot continue without ar." "$LINENO" 5 fi if test -f ${srcdir}/ares_build.h; then rm -f ${srcdir}/ares_build.h fi ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac cat >>confdefs.h <<_ACEOF #define OS "${host}" _ACEOF xc_prog_cc_prev_IFS=$IFS xc_prog_cc_prev_LIBS=$LIBS xc_prog_cc_prev_CFLAGS=$CFLAGS xc_prog_cc_prev_LDFLAGS=$LDFLAGS xc_prog_cc_prev_CPPFLAGS=$CPPFLAGS xc_bad_var_libs=no for xc_word in $LIBS; do case "$xc_word" in -l* | --library=*) : ;; *) xc_bad_var_libs=yes ;; esac done if test $xc_bad_var_libs = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using LIBS: $LIBS" >&5 $as_echo "$as_me: using LIBS: $LIBS" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: LIBS error: LIBS may only be used to specify libraries (-lname)." >&5 $as_echo "$as_me: LIBS error: LIBS may only be used to specify libraries (-lname)." >&6;} fi xc_bad_var_ldflags=no for xc_word in $LDFLAGS; do case "$xc_word" in -D*) xc_bad_var_ldflags=yes ;; -U*) xc_bad_var_ldflags=yes ;; -I*) xc_bad_var_ldflags=yes ;; -l* | --library=*) xc_bad_var_ldflags=yes ;; esac done if test $xc_bad_var_ldflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using LDFLAGS: $LDFLAGS" >&5 $as_echo "$as_me: using LDFLAGS: $LDFLAGS" >&6;} xc_bad_var_msg="LDFLAGS error: LDFLAGS may only be used to specify linker flags, not" for xc_word in $LDFLAGS; do case "$xc_word" in -D*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&6;} ;; -U*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&6;} ;; -I*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi xc_bad_var_cppflags=no for xc_word in $CPPFLAGS; do case "$xc_word" in -rpath*) xc_bad_var_cppflags=yes ;; -L* | --library-path=*) xc_bad_var_cppflags=yes ;; -l* | --library=*) xc_bad_var_cppflags=yes ;; esac done if test $xc_bad_var_cppflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using CPPFLAGS: $CPPFLAGS" >&5 $as_echo "$as_me: using CPPFLAGS: $CPPFLAGS" >&6;} xc_bad_var_msg="CPPFLAGS error: CPPFLAGS may only be used to specify C preprocessor flags, not" for xc_word in $CPPFLAGS; do case "$xc_word" in -rpath*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&6;} ;; -L* | --library-path=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi xc_bad_var_cflags=no for xc_word in $CFLAGS; do case "$xc_word" in -D*) xc_bad_var_cflags=yes ;; -U*) xc_bad_var_cflags=yes ;; -I*) xc_bad_var_cflags=yes ;; -rpath*) xc_bad_var_cflags=yes ;; -L* | --library-path=*) xc_bad_var_cflags=yes ;; -l* | --library=*) xc_bad_var_cflags=yes ;; esac done if test $xc_bad_var_cflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using CFLAGS: $CFLAGS" >&5 $as_echo "$as_me: using CFLAGS: $CFLAGS" >&6;} xc_bad_var_msg="CFLAGS error: CFLAGS may only be used to specify C compiler flags, not" for xc_word in $CFLAGS; do case "$xc_word" in -D*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&6;} ;; -U*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&6;} ;; -I*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&6;} ;; -rpath*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&6;} ;; -L* | --library-path=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi if test $xc_bad_var_libs = yes || test $xc_bad_var_cflags = yes || test $xc_bad_var_ldflags = yes || test $xc_bad_var_cppflags = yes; then as_fn_error $? "Can not continue. Fix errors mentioned immediately above this line." "$LINENO" 5 fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main (void) { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu IFS=$xc_prog_cc_prev_IFS LIBS=$xc_prog_cc_prev_LIBS CFLAGS=$xc_prog_cc_prev_CFLAGS LDFLAGS=$xc_prog_cc_prev_LDFLAGS CPPFLAGS=$xc_prog_cc_prev_CPPFLAGS am__api_version='1.11' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='c-ares' VERSION='1.10.0' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if OS is AIX (to define _ALL_SOURCE)" >&5 $as_echo_n "checking if OS is AIX (to define _ALL_SOURCE)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _AIX yes_this_is_aix #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes_this_is_aix" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define _ALL_SOURCE 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _THREAD_SAFE is already defined" >&5 $as_echo_n "checking if _THREAD_SAFE is already defined... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifdef _THREAD_SAFE int dummy=1; #else force compilation error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tmp_thread_safe_initially_defined="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tmp_thread_safe_initially_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # if test "$tmp_thread_safe_initially_defined" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _THREAD_SAFE is actually needed" >&5 $as_echo_n "checking if _THREAD_SAFE is actually needed... " >&6; } case $host_os in aix[123].* | aix4.[012].*) tmp_need_thread_safe="no" ;; aix*) tmp_need_thread_safe="yes" ;; *) tmp_need_thread_safe="no" ;; esac if test "$tmp_need_thread_safe" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _THREAD_SAFE is onwards defined" >&5 $as_echo_n "checking if _THREAD_SAFE is onwards defined... " >&6; } if test "$tmp_thread_safe_initially_defined" = "yes" || test "$tmp_need_thread_safe" = "yes"; then $as_echo "#define NEED_THREAD_SAFE 1" >>confdefs.h cat >>confdefs.h <<_EOF #ifndef _THREAD_SAFE # define _THREAD_SAFE #endif _EOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _REENTRANT is already defined" >&5 $as_echo_n "checking if _REENTRANT is already defined... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifdef _REENTRANT int dummy=1; #else force compilation error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tmp_reentrant_initially_defined="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tmp_reentrant_initially_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # if test "$tmp_reentrant_initially_defined" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _REENTRANT is actually needed" >&5 $as_echo_n "checking if _REENTRANT is actually needed... " >&6; } case $host_os in solaris*) tmp_need_reentrant="yes" ;; *) tmp_need_reentrant="no" ;; esac if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { if(0 != errno) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_errno="yes" else tmp_errno="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tmp_errno" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #ifdef errno int dummy=1; #else force compilation error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_errno="errno_macro_defined" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include int main (void) { #ifdef errno int dummy=1; #else force compilation error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_errno="errno_macro_needs_reentrant" tmp_need_reentrant="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi if test "$tmp_need_reentrant" = "no"; then if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define gmtime_r innocuous_gmtime_r #ifdef __STDC__ # include #else # include #endif #undef gmtime_r #ifdef __cplusplus extern "C" #endif char gmtime_r (); #if defined __stub_gmtime_r || defined __stub___gmtime_r choke me #endif int main (void) { return gmtime_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_gmtime_r="yes" else tmp_gmtime_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_gmtime_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gmtime_r" >/dev/null 2>&1; then : tmp_gmtime_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gmtime_r" >/dev/null 2>&1; then : tmp_gmtime_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define localtime_r innocuous_localtime_r #ifdef __STDC__ # include #else # include #endif #undef localtime_r #ifdef __cplusplus extern "C" #endif char localtime_r (); #if defined __stub_localtime_r || defined __stub___localtime_r choke me #endif int main (void) { return localtime_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_localtime_r="yes" else tmp_localtime_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_localtime_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "localtime_r" >/dev/null 2>&1; then : tmp_localtime_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "localtime_r" >/dev/null 2>&1; then : tmp_localtime_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strerror_r innocuous_strerror_r #ifdef __STDC__ # include #else # include #endif #undef strerror_r #ifdef __cplusplus extern "C" #endif char strerror_r (); #if defined __stub_strerror_r || defined __stub___strerror_r choke me #endif int main (void) { return strerror_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_strerror_r="yes" else tmp_strerror_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_strerror_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strerror_r" >/dev/null 2>&1; then : tmp_strerror_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strerror_r" >/dev/null 2>&1; then : tmp_strerror_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strtok_r innocuous_strtok_r #ifdef __STDC__ # include #else # include #endif #undef strtok_r #ifdef __cplusplus extern "C" #endif char strtok_r (); #if defined __stub_strtok_r || defined __stub___strtok_r choke me #endif int main (void) { return strtok_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_strtok_r="yes" else tmp_strtok_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_strtok_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strtok_r" >/dev/null 2>&1; then : tmp_strtok_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strtok_r" >/dev/null 2>&1; then : tmp_strtok_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inet_ntoa_r innocuous_inet_ntoa_r #ifdef __STDC__ # include #else # include #endif #undef inet_ntoa_r #ifdef __cplusplus extern "C" #endif char inet_ntoa_r (); #if defined __stub_inet_ntoa_r || defined __stub___inet_ntoa_r choke me #endif int main (void) { return inet_ntoa_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_inet_ntoa_r="yes" else tmp_inet_ntoa_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_inet_ntoa_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "inet_ntoa_r" >/dev/null 2>&1; then : tmp_inet_ntoa_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "inet_ntoa_r" >/dev/null 2>&1; then : tmp_inet_ntoa_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define gethostbyaddr_r innocuous_gethostbyaddr_r #ifdef __STDC__ # include #else # include #endif #undef gethostbyaddr_r #ifdef __cplusplus extern "C" #endif char gethostbyaddr_r (); #if defined __stub_gethostbyaddr_r || defined __stub___gethostbyaddr_r choke me #endif int main (void) { return gethostbyaddr_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_gethostbyaddr_r="yes" else tmp_gethostbyaddr_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_gethostbyaddr_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyaddr_r" >/dev/null 2>&1; then : tmp_gethostbyaddr_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyaddr_r" >/dev/null 2>&1; then : tmp_gethostbyaddr_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define gethostbyname_r innocuous_gethostbyname_r #ifdef __STDC__ # include #else # include #endif #undef gethostbyname_r #ifdef __cplusplus extern "C" #endif char gethostbyname_r (); #if defined __stub_gethostbyname_r || defined __stub___gethostbyname_r choke me #endif int main (void) { return gethostbyname_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_gethostbyname_r="yes" else tmp_gethostbyname_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_gethostbyname_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyname_r" >/dev/null 2>&1; then : tmp_gethostbyname_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyname_r" >/dev/null 2>&1; then : tmp_gethostbyname_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define getprotobyname_r innocuous_getprotobyname_r #ifdef __STDC__ # include #else # include #endif #undef getprotobyname_r #ifdef __cplusplus extern "C" #endif char getprotobyname_r (); #if defined __stub_getprotobyname_r || defined __stub___getprotobyname_r choke me #endif int main (void) { return getprotobyname_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_getprotobyname_r="yes" else tmp_getprotobyname_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_getprotobyname_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getprotobyname_r" >/dev/null 2>&1; then : tmp_getprotobyname_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getprotobyname_r" >/dev/null 2>&1; then : tmp_getprotobyname_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi if test "$tmp_need_reentrant" = "no"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define getservbyport_r innocuous_getservbyport_r #ifdef __STDC__ # include #else # include #endif #undef getservbyport_r #ifdef __cplusplus extern "C" #endif char getservbyport_r (); #if defined __stub_getservbyport_r || defined __stub___getservbyport_r choke me #endif int main (void) { return getservbyport_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_getservbyport_r="yes" else tmp_getservbyport_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$tmp_getservbyport_r" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getservbyport_r" >/dev/null 2>&1; then : tmp_getservbyport_r="proto_declared" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _REENTRANT #include #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getservbyport_r" >/dev/null 2>&1; then : tmp_getservbyport_r="proto_needs_reentrant" tmp_need_reentrant="yes" fi rm -f conftest* fi rm -f conftest* fi fi fi if test "$tmp_need_reentrant" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if _REENTRANT is onwards defined" >&5 $as_echo_n "checking if _REENTRANT is onwards defined... " >&6; } if test "$tmp_reentrant_initially_defined" = "yes" || test "$tmp_need_reentrant" = "yes"; then $as_echo "#define NEED_REENTRANT 1" >>confdefs.h cat >>confdefs.h <<_EOF #ifndef _REENTRANT # define _REENTRANT #endif _EOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi case $host_os in solaris*) $as_echo "#define ETC_INET 1" >>confdefs.h ;; esac case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv -f conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # ------------------------------------ # # Determine libtool default behavior # # ------------------------------------ # # # Default behavior is to enable shared and static libraries on systems # where libtool knows how to build both library versions, and does not # require separate configuration and build runs for each flavor. # xc_lt_want_enable_shared='yes' xc_lt_want_enable_static='yes' # # User may have disabled shared or static libraries. # case "x$enable_shared" in # ( xno) xc_lt_want_enable_shared='no' ;; esac case "x$enable_static" in # ( xno) xc_lt_want_enable_static='no' ;; esac if test "x$xc_lt_want_enable_shared" = 'xno' && test "x$xc_lt_want_enable_static" = 'xno'; then as_fn_error $? "can not disable shared and static libraries simultaneously" "$LINENO" 5 fi # # Default behavior on systems that require independent configuration # and build runs for shared and static is to enable shared libraries # and disable static ones. On these systems option '--disable-shared' # must be used in order to build a proper static library. # if test "x$xc_lt_want_enable_shared" = 'xyes' && test "x$xc_lt_want_enable_static" = 'xyes'; then case $host_os in # ( mingw* | pw32* | cegcc* | os2* | aix*) xc_lt_want_enable_static='no' ;; esac fi # # Make libtool aware of current shared and static library preferences # taking in account that, depending on host characteristics, libtool # may modify these option preferences later in this configure script. # enable_shared=$xc_lt_want_enable_shared enable_static=$xc_lt_want_enable_static # # Default behavior is to build PIC objects for shared libraries and # non-PIC objects for static libraries. # xc_lt_want_with_pic='default' # # User may have specified PIC preference. # case "x$with_pic" in # (( xno) xc_lt_want_with_pic='no' ;; xyes) xc_lt_want_with_pic='yes' ;; esac # # Default behavior on some systems where building a shared library out # of non-PIC compiled objects will fail with following linker error # "relocation R_X86_64_32 can not be used when making a shared object" # is to build PIC objects even for static libraries. This behavior may # be overriden using 'configure --disable-shared --without-pic'. # if test "x$xc_lt_want_with_pic" = 'xdefault'; then case $host_cpu in # ( x86_64 | amd64 | ia64) case $host_os in # ( linux* | freebsd*) xc_lt_want_with_pic='yes' ;; esac ;; esac fi # # Make libtool aware of current PIC preference taking in account that, # depending on host characteristics, libtool may modify PIC default # behavior to fit host system idiosyncrasies later in this script. # with_pic=$xc_lt_want_with_pic ## ----------------------- ## ## Start of libtool code ## ## ----------------------- ## # Set options enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 $as_echo "$ac_ct_AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump enable_dlopen=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv -f $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv -f $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main (void) { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main (void) { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: ## --------------------- ## ## End of libtool code ## ## --------------------- ## # # Verify if finally libtool shared libraries will be built # case "x$enable_shared" in # (( xyes | xno) xc_lt_build_shared=$enable_shared ;; *) as_fn_error $? "unexpected libtool enable_shared value: $enable_shared" "$LINENO" 5 ;; esac # # Verify if finally libtool static libraries will be built # case "x$enable_static" in # (( xyes | xno) xc_lt_build_static=$enable_static ;; *) as_fn_error $? "unexpected libtool enable_static value: $enable_static" "$LINENO" 5 ;; esac # # Verify if libtool shared libraries should be linked using flag -version-info # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries with -version-info" >&5 $as_echo_n "checking whether to build shared libraries with -version-info... " >&6; } xc_lt_shlib_use_version_info='yes' if test "x$version_type" = 'xnone'; then xc_lt_shlib_use_version_info='no' fi case $host_os in # ( amigaos*) xc_lt_shlib_use_version_info='yes' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_shlib_use_version_info" >&5 $as_echo "$xc_lt_shlib_use_version_info" >&6; } # # Verify if libtool shared libraries should be linked using flag -no-undefined # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries with -no-undefined" >&5 $as_echo_n "checking whether to build shared libraries with -no-undefined... " >&6; } xc_lt_shlib_use_no_undefined='no' if test "x$allow_undefined" = 'xno'; then xc_lt_shlib_use_no_undefined='yes' elif test "x$allow_undefined_flag" = 'xunsupported'; then xc_lt_shlib_use_no_undefined='yes' fi case $host_os in # ( cygwin* | mingw* | pw32* | cegcc* | os2* | aix*) xc_lt_shlib_use_no_undefined='yes' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_shlib_use_no_undefined" >&5 $as_echo "$xc_lt_shlib_use_no_undefined" >&6; } # # Verify if libtool shared libraries should be linked using flag -mimpure-text # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries with -mimpure-text" >&5 $as_echo_n "checking whether to build shared libraries with -mimpure-text... " >&6; } xc_lt_shlib_use_mimpure_text='no' case $host_os in # ( solaris2*) if test "x$GCC" = 'xyes'; then xc_lt_shlib_use_mimpure_text='yes' fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_shlib_use_mimpure_text" >&5 $as_echo "$xc_lt_shlib_use_mimpure_text" >&6; } # # Find out wether libtool libraries would be built wit PIC # case "x$pic_mode" in # (((( xdefault) xc_lt_build_shared_with_pic='yes' xc_lt_build_static_with_pic='no' ;; xyes) xc_lt_build_shared_with_pic='yes' xc_lt_build_static_with_pic='yes' ;; xno) xc_lt_build_shared_with_pic='no' xc_lt_build_static_with_pic='no' ;; *) xc_lt_build_shared_with_pic='unknown' xc_lt_build_static_with_pic='unknown' { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unexpected libtool pic_mode value: $pic_mode" >&5 $as_echo "$as_me: WARNING: unexpected libtool pic_mode value: $pic_mode" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries with PIC" >&5 $as_echo_n "checking whether to build shared libraries with PIC... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_build_shared_with_pic" >&5 $as_echo "$xc_lt_build_shared_with_pic" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries with PIC" >&5 $as_echo_n "checking whether to build static libraries with PIC... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_build_static_with_pic" >&5 $as_echo "$xc_lt_build_static_with_pic" >&6; } # # Verify if libtool shared libraries will be built while static not built # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries only" >&5 $as_echo_n "checking whether to build shared libraries only... " >&6; } if test "$xc_lt_build_shared" = 'yes' && test "$xc_lt_build_static" = 'no'; then xc_lt_build_shared_only='yes' else xc_lt_build_shared_only='no' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_build_shared_only" >&5 $as_echo "$xc_lt_build_shared_only" >&6; } # # Verify if libtool static libraries will be built while shared not built # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries only" >&5 $as_echo_n "checking whether to build static libraries only... " >&6; } if test "$xc_lt_build_static" = 'yes' && test "$xc_lt_build_shared" = 'no'; then xc_lt_build_static_only='yes' else xc_lt_build_static_only='no' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xc_lt_build_static_only" >&5 $as_echo "$xc_lt_build_static_only" >&6; } # # Automake conditionals based on libtool related checks # if test "x$xc_lt_shlib_use_version_info" = 'xyes'; then CARES_LT_SHLIB_USE_VERSION_INFO_TRUE= CARES_LT_SHLIB_USE_VERSION_INFO_FALSE='#' else CARES_LT_SHLIB_USE_VERSION_INFO_TRUE='#' CARES_LT_SHLIB_USE_VERSION_INFO_FALSE= fi if test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then CARES_LT_SHLIB_USE_NO_UNDEFINED_TRUE= CARES_LT_SHLIB_USE_NO_UNDEFINED_FALSE='#' else CARES_LT_SHLIB_USE_NO_UNDEFINED_TRUE='#' CARES_LT_SHLIB_USE_NO_UNDEFINED_FALSE= fi if test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'; then CARES_LT_SHLIB_USE_MIMPURE_TEXT_TRUE= CARES_LT_SHLIB_USE_MIMPURE_TEXT_FALSE='#' else CARES_LT_SHLIB_USE_MIMPURE_TEXT_TRUE='#' CARES_LT_SHLIB_USE_MIMPURE_TEXT_FALSE= fi # # Due to libtool and automake machinery limitations of not allowing # specifying separate CPPFLAGS or CFLAGS when compiling objects for # inclusion of these in shared or static libraries, we are forced to # build using separate configure runs for shared and static libraries # on systems where different CPPFLAGS or CFLAGS are mandatory in order # to compile objects for each kind of library. Notice that relying on # the '-DPIC' CFLAG that libtool provides is not valid given that the # user might for example choose to build static libraries with PIC. # # # Make our Makefile.am files use the staticlib CPPFLAG only when strictly # targeting a static library and not building its shared counterpart. # if test "x$xc_lt_build_static_only" = 'xyes'; then USE_CPPFLAG_CARES_STATICLIB_TRUE= USE_CPPFLAG_CARES_STATICLIB_FALSE='#' else USE_CPPFLAG_CARES_STATICLIB_TRUE='#' USE_CPPFLAG_CARES_STATICLIB_FALSE= fi # # Make staticlib CPPFLAG variable and its definition visible in output # files unconditionally, providing an empty definition unless strictly # targeting a static library and not building its shared counterpart. # CPPFLAG_CARES_STATICLIB= if test "x$xc_lt_build_static_only" = 'xyes'; then CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB' fi # compiler_id="unknown" compiler_num="0" # flags_dbg_all="unknown" flags_dbg_yes="unknown" flags_dbg_off="unknown" flags_opt_all="unknown" flags_opt_yes="unknown" flags_opt_off="unknown" # flags_prefer_cppflags="no" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is DEC/Compaq/HP C" >&5 $as_echo_n "checking if compiler is DEC/Compaq/HP C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __DECC CURL_DEF_TOKEN __DECC #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__DECC"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___DECC=no else curl_cv_have_def___DECC=yes curl_cv_def___DECC=$tmp_exp fi if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __DECC_VER CURL_DEF_TOKEN __DECC_VER #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__DECC_VER"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___DECC_VER=no else curl_cv_have_def___DECC_VER=yes curl_cv_def___DECC_VER=$tmp_exp fi if test "$curl_cv_have_def___DECC" = "yes" && test "$curl_cv_have_def___DECC_VER" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="DEC_C" flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_yes="-g2" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -O3 -O4" flags_opt_yes="-O1" flags_opt_off="-O0" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is HP-UX C" >&5 $as_echo_n "checking if compiler is HP-UX C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __HP_cc CURL_DEF_TOKEN __HP_cc #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__HP_cc"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___HP_cc=no else curl_cv_have_def___HP_cc=yes curl_cv_def___HP_cc=$tmp_exp fi if test "$curl_cv_have_def___HP_cc" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="HP_UX_C" flags_dbg_all="-g -s" flags_dbg_yes="-g" flags_dbg_off="-s" flags_opt_all="-O +O0 +O1 +O2 +O3 +O4" flags_opt_yes="+O2" flags_opt_off="+O0" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is IBM C" >&5 $as_echo_n "checking if compiler is IBM C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __IBMC__ CURL_DEF_TOKEN __IBMC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__IBMC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___IBMC__=no else curl_cv_have_def___IBMC__=yes curl_cv_def___IBMC__=$tmp_exp fi if test "$curl_cv_have_def___IBMC__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="IBM_C" flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_yes="-g" flags_dbg_off="" flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5" flags_opt_all="$flags_opt_all -qnooptimize" flags_opt_all="$flags_opt_all -qoptimize=0" flags_opt_all="$flags_opt_all -qoptimize=1" flags_opt_all="$flags_opt_all -qoptimize=2" flags_opt_all="$flags_opt_all -qoptimize=3" flags_opt_all="$flags_opt_all -qoptimize=4" flags_opt_all="$flags_opt_all -qoptimize=5" flags_opt_yes="-O2" flags_opt_off="-qnooptimize" flags_prefer_cppflags="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is Intel C" >&5 $as_echo_n "checking if compiler is Intel C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __INTEL_COMPILER CURL_DEF_TOKEN __INTEL_COMPILER #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__INTEL_COMPILER"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___INTEL_COMPILER=no else curl_cv_have_def___INTEL_COMPILER=yes curl_cv_def___INTEL_COMPILER=$tmp_exp fi if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_num="$curl_cv_def___INTEL_COMPILER" if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __unix__ CURL_DEF_TOKEN __unix__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = ""; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___unix__=no else curl_cv_have_def___unix__=yes curl_cv_def___unix__=$tmp_exp fi if test "$curl_cv_have_def___unix__" = "yes"; then compiler_id="INTEL_UNIX_C" flags_dbg_all="-g -g0" flags_dbg_yes="-g" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" flags_opt_yes="-O2" flags_opt_off="-O0" else compiler_id="INTEL_WINDOWS_C" flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-" flags_dbg_all="$flags_dbg_all /debug" flags_dbg_all="$flags_dbg_all /debug:none" flags_dbg_all="$flags_dbg_all /debug:minimal" flags_dbg_all="$flags_dbg_all /debug:partial" flags_dbg_all="$flags_dbg_all /debug:full" flags_dbg_all="$flags_dbg_all /debug:semantic_stepping" flags_dbg_all="$flags_dbg_all /debug:extended" flags_dbg_yes="/Zi /Oy-" flags_dbg_off="/debug:none /Oy-" flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-" flags_opt_yes="/O2" flags_opt_off="/Od" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is clang" >&5 $as_echo_n "checking if compiler is clang... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __clang__ CURL_DEF_TOKEN __clang__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__clang__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___clang__=no else curl_cv_have_def___clang__=yes curl_cv_def___clang__=$tmp_exp fi if test "$curl_cv_have_def___clang__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="CLANG" clangver=`$CC -dumpversion` clangvhi=`echo $clangver | cut -d . -f1` clangvlo=`echo $clangver | cut -d . -f2` compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null` flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_all="$flags_dbg_all -ggdb" flags_dbg_all="$flags_dbg_all -gstabs" flags_dbg_all="$flags_dbg_all -gstabs+" flags_dbg_all="$flags_dbg_all -gcoff" flags_dbg_all="$flags_dbg_all -gxcoff" flags_dbg_all="$flags_dbg_all -gdwarf-2" flags_dbg_all="$flags_dbg_all -gvms" flags_dbg_yes="-g" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4" flags_opt_yes="-Os" flags_opt_off="-O0" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is GNU C" >&5 $as_echo_n "checking if compiler is GNU C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ CURL_DEF_TOKEN __GNUC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__GNUC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___GNUC__=no else curl_cv_have_def___GNUC__=yes curl_cv_def___GNUC__=$tmp_exp fi if test "$curl_cv_have_def___GNUC__" = "yes" && test "$compiler_id" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="GNU_C" gccver=`$CC -dumpversion` gccvhi=`echo $gccver | cut -d . -f1` gccvlo=`echo $gccver | cut -d . -f2` compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null` flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_all="$flags_dbg_all -ggdb" flags_dbg_all="$flags_dbg_all -gstabs" flags_dbg_all="$flags_dbg_all -gstabs+" flags_dbg_all="$flags_dbg_all -gcoff" flags_dbg_all="$flags_dbg_all -gxcoff" flags_dbg_all="$flags_dbg_all -gdwarf-2" flags_dbg_all="$flags_dbg_all -gvms" flags_dbg_yes="-g" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" flags_opt_yes="-O2" flags_opt_off="-O0" if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _WIN32 CURL_DEF_TOKEN _WIN32 #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "_WIN32"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def__WIN32=no else curl_cv_have_def__WIN32=yes curl_cv_def__WIN32=$tmp_exp fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is LCC" >&5 $as_echo_n "checking if compiler is LCC... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __LCC__ CURL_DEF_TOKEN __LCC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__LCC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___LCC__=no else curl_cv_have_def___LCC__=yes curl_cv_def___LCC__=$tmp_exp fi if test "$curl_cv_have_def___LCC__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="LCC" flags_dbg_all="-g" flags_dbg_yes="-g" flags_dbg_off="" flags_opt_all="" flags_opt_yes="" flags_opt_off="" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is SGI MIPSpro C" >&5 $as_echo_n "checking if compiler is SGI MIPSpro C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ CURL_DEF_TOKEN __GNUC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__GNUC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___GNUC__=no else curl_cv_have_def___GNUC__=yes curl_cv_def___GNUC__=$tmp_exp fi if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _COMPILER_VERSION CURL_DEF_TOKEN _COMPILER_VERSION #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "_COMPILER_VERSION"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def__COMPILER_VERSION=no else curl_cv_have_def__COMPILER_VERSION=yes curl_cv_def__COMPILER_VERSION=$tmp_exp fi if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _SGI_COMPILER_VERSION CURL_DEF_TOKEN _SGI_COMPILER_VERSION #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "_SGI_COMPILER_VERSION"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def__SGI_COMPILER_VERSION=no else curl_cv_have_def__SGI_COMPILER_VERSION=yes curl_cv_def__SGI_COMPILER_VERSION=$tmp_exp fi if test "$curl_cv_have_def___GNUC__" = "no" && (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" || test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="SGI_MIPSPRO_C" flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_yes="-g" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" flags_opt_yes="-O2" flags_opt_off="-O0" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is SGI MIPS C" >&5 $as_echo_n "checking if compiler is SGI MIPS C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ CURL_DEF_TOKEN __GNUC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__GNUC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___GNUC__=no else curl_cv_have_def___GNUC__=yes curl_cv_def___GNUC__=$tmp_exp fi if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __sgi CURL_DEF_TOKEN __sgi #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__sgi"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___sgi=no else curl_cv_have_def___sgi=yes curl_cv_def___sgi=$tmp_exp fi if test "$curl_cv_have_def___GNUC__" = "no" && test "$curl_cv_have_def___sgi" = "yes" && test "$compiler_id" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="SGI_MIPS_C" flags_dbg_all="-g -g0 -g1 -g2 -g3" flags_dbg_yes="-g" flags_dbg_off="-g0" flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" flags_opt_yes="-O2" flags_opt_off="-O0" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is SunPro C" >&5 $as_echo_n "checking if compiler is SunPro C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __SUNPRO_C CURL_DEF_TOKEN __SUNPRO_C #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__SUNPRO_C"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___SUNPRO_C=no else curl_cv_have_def___SUNPRO_C=yes curl_cv_def___SUNPRO_C=$tmp_exp fi if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="SUNPRO_C" flags_dbg_all="-g -s" flags_dbg_yes="-g" flags_dbg_off="-s" flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5" flags_opt_yes="-xO2" flags_opt_off="" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is Tiny C" >&5 $as_echo_n "checking if compiler is Tiny C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __TINYC__ CURL_DEF_TOKEN __TINYC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__TINYC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___TINYC__=no else curl_cv_have_def___TINYC__=yes curl_cv_def___TINYC__=$tmp_exp fi if test "$curl_cv_have_def___TINYC__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } compiler_id="TINY_C" flags_dbg_all="-g -b" flags_dbg_yes="-g" flags_dbg_off="" flags_opt_all="" flags_opt_yes="" flags_opt_off="" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler is Watcom C" >&5 $as_echo_n "checking if compiler is Watcom C... " >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __WATCOMC__ CURL_DEF_TOKEN __WATCOMC__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__WATCOMC__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___WATCOMC__=no else curl_cv_have_def___WATCOMC__=yes curl_cv_def___WATCOMC__=$tmp_exp fi if test "$curl_cv_have_def___WATCOMC__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test -z "$SED"; then as_fn_error $? "SED not set. Cannot continue without SED being set." "$LINENO" 5 fi if test -z "$GREP"; then as_fn_error $? "GREP not set. Cannot continue without GREP being set." "$LINENO" 5 fi tmp_exp="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __UNIX__ CURL_DEF_TOKEN __UNIX__ #endif _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ "$SED" 's/.*CURL_DEF_TOKEN[ ][ ]*//' 2>/dev/null | \ "$SED" 's/["][ ]*["]//g' 2>/dev/null` if test -z "$tmp_exp" || test "$tmp_exp" = "__UNIX__"; then tmp_exp="" fi fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$tmp_exp"; then curl_cv_have_def___UNIX__=no else curl_cv_have_def___UNIX__=yes curl_cv_def___UNIX__=$tmp_exp fi if test "$curl_cv_have_def___UNIX__" = "yes"; then compiler_id="WATCOM_UNIX_C" flags_dbg_all="-g1 -g1+ -g2 -g3" flags_dbg_yes="-g2" flags_dbg_off="" flags_opt_all="-O0 -O1 -O2 -O3" flags_opt_yes="-O2" flags_opt_off="-O0" else compiler_id="WATCOM_WINDOWS_C" flags_dbg_all="" flags_dbg_yes="" flags_dbg_off="" flags_opt_all="" flags_opt_yes="" flags_opt_off="" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # if test "$compiler_id" = "unknown"; then cat <<_EOF 1>&2 *** *** Warning: This configure script does not have information about the *** compiler you are using, relative to the flags required to enable or *** disable generation of debug info, optimization options or warnings. *** *** Whatever settings are present in CFLAGS will be used for this run. *** *** If you wish to help the c-ares project to better support your compiler *** you can report this and the required info on the c-ares development *** mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ *** _EOF fi squeeze() { _sqz_result="" eval _sqz_input=\$$1 for _sqz_token in $_sqz_input; do if test -z "$_sqz_result"; then _sqz_result="$_sqz_token" else _sqz_result="$_sqz_result $_sqz_token" fi done eval $1=\$_sqz_result return 0 } # if test "$compiler_id" != "unknown"; then # if test "$compiler_id" = "GNU_C" || test "$compiler_id" = "CLANG"; then if test "$compiler_id" = "GNU_C" || test "$compiler_id" = "CLANG"; then tmp_has_include="no" tmp_chg_FLAGS="$CFLAGS" for word1 in $tmp_chg_FLAGS; do case "$word1" in -I*) tmp_has_include="yes" ;; esac done if test "$tmp_has_include" = "yes"; then tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` CFLAGS="$tmp_chg_FLAGS" squeeze CFLAGS fi tmp_has_include="no" tmp_chg_FLAGS="$CPPFLAGS" for word1 in $tmp_chg_FLAGS; do case "$word1" in -I*) tmp_has_include="yes" ;; esac done if test "$tmp_has_include" = "yes"; then tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` CPPFLAGS="$tmp_chg_FLAGS" squeeze CPPFLAGS fi fi fi # tmp_save_CPPFLAGS="$CPPFLAGS" tmp_save_CFLAGS="$CFLAGS" tmp_CPPFLAGS="" tmp_CFLAGS="" # case "$compiler_id" in # CLANG) # tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments" ;; # DEC_C) # tmp_CFLAGS="$tmp_CFLAGS -std1" tmp_CFLAGS="$tmp_CFLAGS -noansi_alias" tmp_CFLAGS="$tmp_CFLAGS -warnprotos" tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs" ;; # GNU_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # HP_UX_C) # tmp_CFLAGS="$tmp_CFLAGS -z" tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255" ;; # IBM_C) # tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded" tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias" tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e" ;; # INTEL_UNIX_C) # tmp_CFLAGS="$tmp_CFLAGS -std=gnu89" tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266" tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469" ;; # INTEL_WINDOWS_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # LCC) # tmp_CFLAGS="$tmp_CFLAGS -n" ;; # SGI_MIPS_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # SGI_MIPSPRO_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # SUNPRO_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # TINY_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # WATCOM_UNIX_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # WATCOM_WINDOWS_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # esac # squeeze tmp_CPPFLAGS squeeze tmp_CFLAGS # if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts some basic options" >&5 $as_echo_n "checking if compiler accepts some basic options... " >&6; } CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" squeeze CPPFLAGS squeeze CFLAGS tmp_compiler_works="unknown" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/cc-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tmp_compiler_works" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/link-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "x$cross_compiling" != "xyes" && test "$tmp_compiler_works" = "yes"; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef __STDC__ # include # endif int main (void) { int i = 0; exit(i); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 echo "run-fail: test program exited with status $ac_status" >&6 echo " " >&6 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test "$tmp_compiler_works" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS" >&5 $as_echo "$as_me: compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS" >&5 $as_echo "$as_me: WARNING: compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS" >&2;} CPPFLAGS="$tmp_save_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS" fi fi # fi # if test "$compiler_id" != "unknown"; then # tmp_save_CFLAGS="$CFLAGS" tmp_save_CPPFLAGS="$CPPFLAGS" # tmp_options="" tmp_CFLAGS="$CFLAGS" tmp_CPPFLAGS="$CPPFLAGS" ac_var_stripped="" for word1 in $tmp_CFLAGS; do ac_var_strip_word="no" for word2 in $flags_dbg_all; do if test "$word1" = "$word2"; then ac_var_strip_word="yes" fi done if test "$ac_var_strip_word" = "no"; then ac_var_stripped="$ac_var_stripped $word1" fi done tmp_CFLAGS="$ac_var_stripped" squeeze tmp_CFLAGS ac_var_stripped="" for word1 in $tmp_CPPFLAGS; do ac_var_strip_word="no" for word2 in $flags_dbg_all; do if test "$word1" = "$word2"; then ac_var_strip_word="yes" fi done if test "$ac_var_strip_word" = "no"; then ac_var_stripped="$ac_var_stripped $word1" fi done tmp_CPPFLAGS="$ac_var_stripped" squeeze tmp_CPPFLAGS # if test "$want_debug" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts debug enabling options" >&5 $as_echo_n "checking if compiler accepts debug enabling options... " >&6; } tmp_options="$flags_dbg_yes" fi if test "$want_debug" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts debug disabling options" >&5 $as_echo_n "checking if compiler accepts debug disabling options... " >&6; } tmp_options="$flags_dbg_off" fi # if test "$flags_prefer_cppflags" = "yes"; then CPPFLAGS="$tmp_CPPFLAGS $tmp_options" CFLAGS="$tmp_CFLAGS" else CPPFLAGS="$tmp_CPPFLAGS" CFLAGS="$tmp_CFLAGS $tmp_options" fi squeeze CPPFLAGS squeeze CFLAGS tmp_compiler_works="unknown" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/cc-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tmp_compiler_works" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/link-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "x$cross_compiling" != "xyes" && test "$tmp_compiler_works" = "yes"; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef __STDC__ # include # endif int main (void) { int i = 0; exit(i); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 echo "run-fail: test program exited with status $ac_status" >&6 echo " " >&6 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test "$tmp_compiler_works" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: compiler options added: $tmp_options" >&5 $as_echo "$as_me: compiler options added: $tmp_options" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler options rejected: $tmp_options" >&5 $as_echo "$as_me: WARNING: compiler options rejected: $tmp_options" >&2;} CPPFLAGS="$tmp_save_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS" fi # fi # if test "$compiler_id" != "unknown"; then # tmp_save_CFLAGS="$CFLAGS" tmp_save_CPPFLAGS="$CPPFLAGS" # tmp_options="" tmp_CFLAGS="$CFLAGS" tmp_CPPFLAGS="$CPPFLAGS" honor_optimize_option="yes" # # if test "$want_optimize" = "assume_no" || test "$want_optimize" = "assume_yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler optimizer assumed setting might be used" >&5 $as_echo_n "checking if compiler optimizer assumed setting might be used... " >&6; } ac_var_match_word="no" for word1 in $tmp_CFLAGS; do for word2 in $flags_opt_all; do if test "$word1" = "$word2"; then ac_var_match_word="yes" fi done done if test "$ac_var_match_word" = "yes"; then honor_optimize_option="no" fi ac_var_match_word="no" for word1 in $tmp_CPPFLAGS; do for word2 in $flags_opt_all; do if test "$word1" = "$word2"; then ac_var_match_word="yes" fi done done if test "$ac_var_match_word" = "yes"; then honor_optimize_option="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $honor_optimize_option" >&5 $as_echo "$honor_optimize_option" >&6; } if test "$honor_optimize_option" = "yes"; then if test "$want_optimize" = "assume_yes"; then want_optimize="yes" fi if test "$want_optimize" = "assume_no"; then want_optimize="no" fi fi fi # if test "$honor_optimize_option" = "yes"; then ac_var_stripped="" for word1 in $tmp_CFLAGS; do ac_var_strip_word="no" for word2 in $flags_opt_all; do if test "$word1" = "$word2"; then ac_var_strip_word="yes" fi done if test "$ac_var_strip_word" = "no"; then ac_var_stripped="$ac_var_stripped $word1" fi done tmp_CFLAGS="$ac_var_stripped" squeeze tmp_CFLAGS ac_var_stripped="" for word1 in $tmp_CPPFLAGS; do ac_var_strip_word="no" for word2 in $flags_opt_all; do if test "$word1" = "$word2"; then ac_var_strip_word="yes" fi done if test "$ac_var_strip_word" = "no"; then ac_var_stripped="$ac_var_stripped $word1" fi done tmp_CPPFLAGS="$ac_var_stripped" squeeze tmp_CPPFLAGS if test "$want_optimize" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts optimizer enabling options" >&5 $as_echo_n "checking if compiler accepts optimizer enabling options... " >&6; } tmp_options="$flags_opt_yes" fi if test "$want_optimize" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts optimizer disabling options" >&5 $as_echo_n "checking if compiler accepts optimizer disabling options... " >&6; } tmp_options="$flags_opt_off" fi if test "$flags_prefer_cppflags" = "yes"; then CPPFLAGS="$tmp_CPPFLAGS $tmp_options" CFLAGS="$tmp_CFLAGS" else CPPFLAGS="$tmp_CPPFLAGS" CFLAGS="$tmp_CFLAGS $tmp_options" fi squeeze CPPFLAGS squeeze CFLAGS tmp_compiler_works="unknown" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/cc-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tmp_compiler_works" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/link-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "x$cross_compiling" != "xyes" && test "$tmp_compiler_works" = "yes"; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef __STDC__ # include # endif int main (void) { int i = 0; exit(i); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 echo "run-fail: test program exited with status $ac_status" >&6 echo " " >&6 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test "$tmp_compiler_works" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: compiler options added: $tmp_options" >&5 $as_echo "$as_me: compiler options added: $tmp_options" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler options rejected: $tmp_options" >&5 $as_echo "$as_me: WARNING: compiler options rejected: $tmp_options" >&2;} CPPFLAGS="$tmp_save_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS" fi fi # fi # if test "$compiler_id" != "unknown"; then # tmp_save_CPPFLAGS="$CPPFLAGS" tmp_save_CFLAGS="$CFLAGS" tmp_CPPFLAGS="" tmp_CFLAGS="" # case "$compiler_id" in # CLANG) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -pedantic" tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra" tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" tmp_CFLAGS="$tmp_CFLAGS -Wshadow" tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare" tmp_CFLAGS="$tmp_CFLAGS -Wundef" tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" tmp_CFLAGS="$tmp_CFLAGS -Wcast-align" tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32" # if test "$compiler_num" -ge "101"; then tmp_CFLAGS="$tmp_CFLAGS -Wunused" fi fi ;; # DEC_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3" fi ;; # GNU_C) # if test "$want_warnings" = "yes"; then # if test "x$cross_compiling" != "xyes" || test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS -pedantic" fi # tmp_CFLAGS="$tmp_CFLAGS -Wall -W" # if test "$compiler_num" -ge "104"; then tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" if test "x$cross_compiling" != "xyes" || test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow" fi fi # if test "$compiler_num" -ge "207"; then tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs" if test "x$cross_compiling" != "xyes" || test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" fi fi # if test "$compiler_num" -ge "295"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" fi # if test "$compiler_num" -ge "296"; then tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare" tmp_CFLAGS="$tmp_CFLAGS -Wundef" fi # if test "$compiler_num" -ge "297"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" fi # if test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS" fi # if test "$compiler_num" -ge "303"; then tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" fi # if test "$compiler_num" -ge "304"; then tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" fi # if test "$compiler_num" -ge "400"; then tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3" fi # if test "$compiler_num" -ge "402"; then tmp_CFLAGS="$tmp_CFLAGS -Wcast-align" fi # if test "$compiler_num" -ge "403"; then tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration" tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body" tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers" tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla" fi # if test "$compiler_num" -ge "405"; then if test "$curl_cv_have_def__WIN32" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format" fi fi # fi # if test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" else if test "x$cross_compiling" = "xyes"; then if test "$compiler_num" -ge "104"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" fi if test "$compiler_num" -ge "207"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations" tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes" fi fi fi ;; # HP_UX_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS +w1" fi ;; # IBM_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # INTEL_UNIX_C) # if test "$want_warnings" = "yes"; then if test "$compiler_num" -gt "600"; then tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized" tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function" fi fi tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer" tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing" tmp_CFLAGS="$tmp_CFLAGS -fp-model precise" if test "$compiler_num" -ge "1000"; then tmp_CFLAGS="$tmp_CFLAGS -vec-report0" fi ;; # INTEL_WINDOWS_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # LCC) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS" fi ;; # SGI_MIPS_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -fullwarn" fi ;; # SGI_MIPSPRO_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -fullwarn" tmp_CFLAGS="$tmp_CFLAGS -woff 1209" fi ;; # SUNPRO_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -v" fi ;; # TINY_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -Wall" tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings" tmp_CFLAGS="$tmp_CFLAGS -Wunsupported" fi ;; # WATCOM_UNIX_C) # if test "$want_warnings" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra" fi ;; # WATCOM_WINDOWS_C) # tmp_CFLAGS="$tmp_CFLAGS" ;; # esac # squeeze tmp_CPPFLAGS squeeze tmp_CFLAGS # if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts strict warning options" >&5 $as_echo_n "checking if compiler accepts strict warning options... " >&6; } CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" squeeze CPPFLAGS squeeze CFLAGS tmp_compiler_works="unknown" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/cc-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tmp_compiler_works" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int i = 1; return i; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 sed 's/^/link-fail: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "x$cross_compiling" != "xyes" && test "$tmp_compiler_works" = "yes"; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef __STDC__ # include # endif int main (void) { int i = 0; exit(i); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tmp_compiler_works="yes" else tmp_compiler_works="no" echo " " >&6 echo "run-fail: test program exited with status $ac_status" >&6 echo " " >&6 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test "$tmp_compiler_works" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS" >&5 $as_echo "$as_me: compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS" >&6;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS" >&5 $as_echo "$as_me: WARNING: compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS" >&2;} CPPFLAGS="$tmp_save_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS" fi fi # fi if test "$compiler_id" = "INTEL_UNIX_C"; then # if test "$compiler_num" -ge "1000"; then CFLAGS="$CFLAGS -shared-intel" elif test "$compiler_num" -ge "900"; then CFLAGS="$CFLAGS -i-dynamic" fi # fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler halts on compilation errors" >&5 $as_echo_n "checking if compiler halts on compilation errors... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { force compilation error ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "compiler does not halt on compilation errors." "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler halts on negative sized arrays" >&5 $as_echo_n "checking if compiler halts on negative sized arrays... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ]; int main (void) { bad_t dummy; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "compiler does not halt on negative sized arrays." "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler halts on function prototype mismatch" >&5 $as_echo_n "checking if compiler halts on function prototype mismatch... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int rand(int n); int rand(int n) { if(n) return ++n; else return n; } int main (void) { int i[2]; int j = rand(i[0]); if(j) return j; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "compiler does not halt on function prototype mismatch." "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports hiding library internal symbols" >&5 $as_echo_n "checking if compiler supports hiding library internal symbols... " >&6; } supports_symbol_hiding="no" symbol_hiding_CFLAGS="" symbol_hiding_EXTERN="" tmp_CFLAGS="" tmp_EXTERN="" case "$compiler_id" in CLANG) tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" ;; GNU_C) if test "$compiler_num" -ge "304"; then if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" fi fi ;; INTEL_UNIX_C) if test "$compiler_num" -ge "900"; then if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then tmp_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main (void) { printf("icc fvisibility bug test"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$tmp_save_CFLAGS" fi fi ;; SUNPRO_C) if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then tmp_EXTERN="__global" tmp_CFLAGS="-xldscope=hidden" supports_symbol_hiding="yes" fi ;; esac if test "$supports_symbol_hiding" = "yes"; then tmp_save_CFLAGS="$CFLAGS" CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" squeeze CFLAGS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $tmp_EXTERN char *dummy(char *buff); char *dummy(char *buff) { if(buff) return ++buff; else return buff; } int main (void) { char b[16]; char *r = dummy(&b[0]); if(r) return (int)*r; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : supports_symbol_hiding="yes" if test -f conftest.err; then grep 'visibility' conftest.err >/dev/null if test "$?" -eq "0"; then supports_symbol_hiding="no" fi fi else supports_symbol_hiding="no" echo " " >&6 sed 's/^/cc-src: /' conftest.$ac_ext >&6 sed 's/^/cc-err: /' conftest.err >&6 echo " " >&6 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$tmp_save_CFLAGS" fi if test "$supports_symbol_hiding" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } symbol_hiding_CFLAGS="$tmp_CFLAGS" symbol_hiding_EXTERN="$tmp_EXTERN" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cares_builddir=`pwd` supports_curldebug="unknown" if test "$want_curldebug" = "yes"; then if test "x$enable_shared" != "xno" && test "x$enable_shared" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unknown enable_shared setting." >&5 $as_echo "$as_me: WARNING: unknown enable_shared setting." >&2;} supports_curldebug="no" fi if test "x$enable_static" != "xno" && test "x$enable_static" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unknown enable_static setting." >&5 $as_echo "$as_me: WARNING: unknown enable_static setting." >&2;} supports_curldebug="no" fi if test "$supports_curldebug" != "no"; then if test "$enable_shared" = "yes" && test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then supports_curldebug="no" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: shared library does not support undefined symbols." >&5 $as_echo "$as_me: WARNING: shared library does not support undefined symbols." >&2;} fi if test ! -f "$srcdir/../include/curl/curlbuild.h.dist"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: c-ares source not embedded in curl's CVS tree." >&5 $as_echo "$as_me: WARNING: c-ares source not embedded in curl's CVS tree." >&2;} supports_curldebug="no" elif test ! -f "$srcdir/../include/curl/Makefile.in"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: curl's buildconf has not been run." >&5 $as_echo "$as_me: WARNING: curl's buildconf has not been run." >&2;} supports_curldebug="no" elif test ! -f "$cares_builddir/../libcurl.pc" || test ! -f "$cares_builddir/../include/curl/curlbuild.h"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: curl's configure has not been run." >&5 $as_echo "$as_me: WARNING: curl's configure has not been run." >&2;} supports_curldebug="no" elif test ! -f "$cares_builddir/../lib/curl_config.h"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcurl's curl_config.h is missing." >&5 $as_echo "$as_me: WARNING: libcurl's curl_config.h is missing." >&2;} supports_curldebug="no" elif test ! -f "$cares_builddir/../config.status"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: curl's config.status is missing." >&5 $as_echo "$as_me: WARNING: curl's config.status is missing." >&2;} supports_curldebug="no" fi if test "$supports_curldebug" != "no"; then grep '^#define USE_ARES' "$cares_builddir/../lib/curl_config.h" >/dev/null if test "$?" -ne "0"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcurl configured without c-ares support." >&5 $as_echo "$as_me: WARNING: libcurl configured without c-ares support." >&2;} supports_curldebug="no" fi fi if test "$supports_curldebug" != "no"; then grep 'CPPFLAGS.*CURLDEBUG' "$cares_builddir/../config.status" >/dev/null if test "$?" -ne "0"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcurl configured without curldebug support." >&5 $as_echo "$as_me: WARNING: libcurl configured without curldebug support." >&2;} supports_curldebug="no" fi fi fi fi # if test "$want_curldebug" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if curl debug memory tracking can be enabled" >&5 $as_echo_n "checking if curl debug memory tracking can be enabled... " >&6; } test "$supports_curldebug" = "no" || supports_curldebug="yes" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports_curldebug" >&5 $as_echo "$supports_curldebug" >&6; } if test "$supports_curldebug" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable curl debug memory tracking." >&5 $as_echo "$as_me: WARNING: cannot enable curl debug memory tracking." >&2;} want_curldebug="no" fi fi # if test "$want_curldebug" = "yes"; then $as_echo "#define BUILDING_LIBCURL 1" >>confdefs.h CPPFLAGS="-DCURLDEBUG $CPPFLAGS" squeeze CPPFLAGS fi # if test "$want_debug" = "yes"; then CPPFLAGS="-DDEBUGBUILD $CPPFLAGS" squeeze CPPFLAGS fi if test x$want_curldebug = xyes; then CURLDEBUG_TRUE= CURLDEBUG_FALSE='#' else CURLDEBUG_TRUE='#' CURLDEBUG_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows.h" >&5 $as_echo_n "checking for windows.h... " >&6; } if ${ac_cv_header_windows_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) HAVE_WINDOWS_H shall not be defined. #else int dummy=2*WINVER; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_windows_h="yes" else ac_cv_header_windows_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_windows_h" >&5 $as_echo "$ac_cv_header_windows_h" >&6; } case "$ac_cv_header_windows_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF cat >>confdefs.h <<_ACEOF #define WIN32_LEAN_AND_MEAN 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build target is a native Windows one" >&5 $as_echo_n "checking whether build target is a native Windows one... " >&6; } if ${ac_cv_native_windows+:} false; then : $as_echo_n "(cached) " >&6 else if test "$ac_cv_header_windows_h" = "no"; then ac_cv_native_windows="no" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #if defined(__MINGW32__) || defined(__MINGW32CE__) || \ (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))) int dummy=1; #else Not a native Windows build target. #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_native_windows="yes" else ac_cv_native_windows="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_native_windows" >&5 $as_echo "$ac_cv_native_windows" >&6; } if test "x$ac_cv_native_windows" = xyes; then DOING_NATIVE_WINDOWS_TRUE= DOING_NATIVE_WINDOWS_FALSE='#' else DOING_NATIVE_WINDOWS_TRUE='#' DOING_NATIVE_WINDOWS_FALSE= fi case X-"$ac_cv_native_windows" in X-yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock.h" >&5 $as_echo_n "checking for winsock.h... " >&6; } if ${ac_cv_header_winsock_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) HAVE_WINSOCK_H shall not be defined. #else int dummy=WSACleanup(); #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_winsock_h="yes" else ac_cv_header_winsock_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_winsock_h" >&5 $as_echo "$ac_cv_header_winsock_h" >&6; } case "$ac_cv_header_winsock_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK_H 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock2.h" >&5 $as_echo_n "checking for winsock2.h... " >&6; } if ${ac_cv_header_winsock2_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) HAVE_WINSOCK2_H shall not be defined. #else int dummy=2*IPPROTO_ESP; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_winsock2_h="yes" else ac_cv_header_winsock2_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_winsock2_h" >&5 $as_echo "$ac_cv_header_winsock2_h" >&6; } case "$ac_cv_header_winsock2_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ws2tcpip.h" >&5 $as_echo_n "checking for ws2tcpip.h... " >&6; } if ${ac_cv_header_ws2tcpip_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) HAVE_WS2TCPIP_H shall not be defined. #else int dummy=2*IP_PKTINFO; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_ws2tcpip_h="yes" else ac_cv_header_ws2tcpip_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_ws2tcpip_h" >&5 $as_echo "$ac_cv_header_ws2tcpip_h" >&6; } case "$ac_cv_header_ws2tcpip_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WS2TCPIP_H 1 _ACEOF ;; esac ;; *) ac_cv_header_winsock_h="no" ac_cv_header_winsock2_h="no" ac_cv_header_ws2tcpip_h="no" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if X/Open network library is required" >&5 $as_echo_n "checking if X/Open network library is required... " >&6; } tst_lib_xnet_required="no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600) return 0; #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED) return 0; #else force compilation error #endif } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tst_lib_xnet_required="yes" LIBS="$LIBS -lxnet" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tst_lib_xnet_required" >&5 $as_echo "$tst_lib_xnet_required" >&6; } ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" if test "x$ac_cv_func_gethostbyname" = xyes; then : HAVE_GETHOSTBYNAME="1" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } if ${ac_cv_lib_nsl_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main (void) { return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostbyname=yes else ac_cv_lib_nsl_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : HAVE_GETHOSTBYNAME="1" LIBS="$LIBS -lnsl" fi fi if test "$HAVE_GETHOSTBYNAME" != "1" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5 $as_echo_n "checking for gethostbyname in -lsocket... " >&6; } if ${ac_cv_lib_socket_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main (void) { return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_gethostbyname=yes else ac_cv_lib_socket_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5 $as_echo "$ac_cv_lib_socket_gethostbyname" >&6; } if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then : HAVE_GETHOSTBYNAME="1" LIBS="$LIBS -lsocket" fi fi if test "$HAVE_GETHOSTBYNAME" != "1" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname with both nsl and socket libs" >&5 $as_echo_n "checking for gethostbyname with both nsl and socket libs... " >&6; } my_ac_save_LIBS=$LIBS LIBS="-lnsl -lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { gethostbyname(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_GETHOSTBYNAME="1" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } LIBS=$my_ac_save_LIBS fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$HAVE_GETHOSTBYNAME" != "1" then if test "$ac_cv_header_windows_h" = "yes"; then if test "$ac_cv_header_winsock_h" = "yes"; then case $host in *-*-mingw32ce*) winsock_LIB="-lwinsock" ;; *) winsock_LIB="-lwsock32" ;; esac fi if test "$ac_cv_header_winsock2_h" = "yes"; then winsock_LIB="-lws2_32" fi if test ! -z "$winsock_LIB"; then my_ac_save_LIBS=$LIBS LIBS="$winsock_LIB $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in $winsock_LIB" >&5 $as_echo_n "checking for gethostbyname in $winsock_LIB... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #endif int main (void) { gethostbyname("www.dummysite.com"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_GETHOSTBYNAME="1" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } winsock_LIB="" LIBS=$my_ac_save_LIBS fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi fi fi if test "$HAVE_GETHOSTBYNAME" != "1" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname for Minix 3" >&5 $as_echo_n "checking for gethostbyname for Minix 3... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Older Minix versions may need here instead */ #include int main (void) { gethostbyname("www.dummysite.com"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_GETHOSTBYNAME="1" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$HAVE_GETHOSTBYNAME" != "1" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname for eCos" >&5 $as_echo_n "checking for gethostbyname for eCos... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { gethostbyname("www.dummysite.com"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_GETHOSTBYNAME="1" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$HAVE_GETHOSTBYNAME" != "1" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnet" >&5 $as_echo_n "checking for gethostbyname in -lnet... " >&6; } if ${ac_cv_lib_net_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main (void) { return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_net_gethostbyname=yes else ac_cv_lib_net_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_net_gethostbyname" >&5 $as_echo "$ac_cv_lib_net_gethostbyname" >&6; } if test "x$ac_cv_lib_net_gethostbyname" = xyes; then : HAVE_GETHOSTBYNAME="1" LIBS="$LIBS -lnet" fi fi if test "$HAVE_GETHOSTBYNAME" != "1"; then as_fn_error $? "couldn't find libraries for gethostbyname()" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" if test "x$ac_cv_func_strcasecmp" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strcasecmp in -lresolve" >&5 $as_echo_n "checking for strcasecmp in -lresolve... " >&6; } if ${ac_cv_lib_resolve_strcasecmp+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolve $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char strcasecmp (); int main (void) { return strcasecmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resolve_strcasecmp=yes else ac_cv_lib_resolve_strcasecmp=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolve_strcasecmp" >&5 $as_echo "$ac_cv_lib_resolve_strcasecmp" >&6; } if test "x$ac_cv_lib_resolve_strcasecmp" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRESOLVE 1 _ACEOF LIBS="-lresolve $LIBS" fi fi if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strcasecmp in -lresolve" >&5 $as_echo_n "checking for strcasecmp in -lresolve... " >&6; } if ${ac_cv_lib_resolve_strcasecmp+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolve -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" #endif char strcasecmp (); int main (void) { return strcasecmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resolve_strcasecmp=yes else ac_cv_lib_resolve_strcasecmp=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolve_strcasecmp" >&5 $as_echo "$ac_cv_lib_resolve_strcasecmp" >&6; } if test "x$ac_cv_lib_resolve_strcasecmp" = xyes; then : LIBS="-lresolve $LIBS" fi fi ac_cv_func_strcasecmp="no" cares_includes_winsock2="\ /* includes start */ #ifdef HAVE_WINDOWS_H # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # ifdef HAVE_WINSOCK2_H # include # else # ifdef HAVE_WINSOCK_H # include # endif # endif #endif /* includes end */" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows.h" >&5 $as_echo_n "checking for windows.h... " >&6; } if ${ac_cv_header_windows_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) HAVE_WINDOWS_H shall not be defined. #else int dummy=2*WINVER; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_windows_h="yes" else ac_cv_header_windows_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_windows_h" >&5 $as_echo "$ac_cv_header_windows_h" >&6; } case "$ac_cv_header_windows_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF cat >>confdefs.h <<_ACEOF #define WIN32_LEAN_AND_MEAN 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock.h" >&5 $as_echo_n "checking for winsock.h... " >&6; } if ${ac_cv_header_winsock_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) HAVE_WINSOCK_H shall not be defined. #else int dummy=WSACleanup(); #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_winsock_h="yes" else ac_cv_header_winsock_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_winsock_h" >&5 $as_echo "$ac_cv_header_winsock_h" >&6; } case "$ac_cv_header_winsock_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK_H 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock2.h" >&5 $as_echo_n "checking for winsock2.h... " >&6; } if ${ac_cv_header_winsock2_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) HAVE_WINSOCK2_H shall not be defined. #else int dummy=2*IPPROTO_ESP; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_winsock2_h="yes" else ac_cv_header_winsock2_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_winsock2_h" >&5 $as_echo "$ac_cv_header_winsock2_h" >&6; } case "$ac_cv_header_winsock2_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in libraries" >&5 $as_echo_n "checking for connect in libraries... " >&6; } tst_connect_save_LIBS="$LIBS" tst_connect_need_LIBS="unknown" for tst_lib in '' '-lsocket' ; do if test "$tst_connect_need_LIBS" = "unknown"; then LIBS="$tst_lib $tst_connect_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 #ifndef HAVE_WINDOWS_H int connect(int, void*, int); #endif int main (void) { if(0 != connect(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tst_connect_need_LIBS="$tst_lib" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi done LIBS="$tst_connect_save_LIBS" # case X-"$tst_connect_need_LIBS" in X-unknown) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot find connect" >&5 $as_echo "cannot find connect" >&6; } as_fn_error $? "cannot find connect function in libraries." "$LINENO" 5 ;; X-) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tst_connect_need_LIBS" >&5 $as_echo "$tst_connect_need_LIBS" >&6; } LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main (void) { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi for ac_header in sys/types.h sys/time.h time.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for monotonic clock_gettime" >&5 $as_echo_n "checking for monotonic clock_gettime... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME #include #endif #else #ifdef HAVE_TIME_H #include #endif #endif int main (void) { struct timespec ts; (void)clock_gettime(CLOCK_MONOTONIC, &ts); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ac_cv_func_clock_gettime="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_clock_gettime="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # if test "$ac_cv_func_clock_gettime" = "yes"; then # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in libraries" >&5 $as_echo_n "checking for clock_gettime in libraries... " >&6; } # curl_cv_save_LIBS="$LIBS" curl_cv_gclk_LIBS="unknown" # for x_xlibs in '' '-lrt' '-lposix4' ; do if test "$curl_cv_gclk_LIBS" = "unknown"; then if test -z "$x_xlibs"; then LIBS="$curl_cv_save_LIBS" else LIBS="$x_xlibs $curl_cv_save_LIBS" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME #include #endif #else #ifdef HAVE_TIME_H #include #endif #endif int main (void) { struct timespec ts; (void)clock_gettime(CLOCK_MONOTONIC, &ts); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : curl_cv_gclk_LIBS="$x_xlibs" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi done # LIBS="$curl_cv_save_LIBS" # case X-"$curl_cv_gclk_LIBS" in X-unknown) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot find clock_gettime" >&5 $as_echo "cannot find clock_gettime" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: HAVE_CLOCK_GETTIME_MONOTONIC will not be defined" >&5 $as_echo "$as_me: WARNING: HAVE_CLOCK_GETTIME_MONOTONIC will not be defined" >&2;} ac_cv_func_clock_gettime="no" ;; X-) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no additional lib required" >&5 $as_echo "no additional lib required" >&6; } ac_cv_func_clock_gettime="yes" ;; *) if test -z "$curl_cv_save_LIBS"; then LIBS="$curl_cv_gclk_LIBS" else LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_gclk_LIBS" >&5 $as_echo "$curl_cv_gclk_LIBS" >&6; } ac_cv_func_clock_gettime="yes" ;; esac # if test "x$cross_compiling" != "xyes" && test "$ac_cv_func_clock_gettime" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if monotonic clock_gettime works" >&5 $as_echo_n "checking if monotonic clock_gettime works... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME #include #endif #else #ifdef HAVE_TIME_H #include #endif #endif int main (void) { struct timespec ts; if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) exit(0); else exit(1); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: HAVE_CLOCK_GETTIME_MONOTONIC will not be defined" >&5 $as_echo "$as_me: WARNING: HAVE_CLOCK_GETTIME_MONOTONIC will not be defined" >&2;} ac_cv_func_clock_gettime="no" LIBS="$curl_cv_save_LIBS" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # case "$ac_cv_func_clock_gettime" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_CLOCK_GETTIME_MONOTONIC 1 _ACEOF ;; esac # fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libgcc" >&5 $as_echo_n "checking whether to use libgcc... " >&6; } # Check whether --enable-libgcc was given. if test "${enable_libgcc+set}" = set; then : enableval=$enable_libgcc; case "$enableval" in yes) LIBS="$LIBS -lgcc" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc.h" >&5 $as_echo_n "checking for malloc.h... " >&6; } if ${ac_cv_header_malloc_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { void *p = malloc(10); void *q = calloc(10,10); free(p); free(q); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_malloc_h="yes" else ac_cv_header_malloc_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_malloc_h" >&5 $as_echo "$ac_cv_header_malloc_h" >&6; } if test "$ac_cv_header_malloc_h" = "yes"; then cat >>confdefs.h <<_ACEOF #define HAVE_MALLOC_H 1 _ACEOF # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { void *p = malloc(10); void *q = calloc(10,10); free(p); free(q); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_need_header_malloc_h="no" else curl_cv_need_header_malloc_h="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # case "$curl_cv_need_header_malloc_h" in yes) cat >>confdefs.h <<_ACEOF #define NEED_MALLOC_H 1 _ACEOF ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for memory.h" >&5 $as_echo_n "checking for memory.h... " >&6; } if ${ac_cv_header_memory_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { void *p = malloc(10); void *q = calloc(10,10); free(p); free(q); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_memory_h="yes" else ac_cv_header_memory_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_memory_h" >&5 $as_echo "$ac_cv_header_memory_h" >&6; } if test "$ac_cv_header_memory_h" = "yes"; then cat >>confdefs.h <<_ACEOF #define HAVE_MEMORY_H 1 _ACEOF # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { void *p = malloc(10); void *q = calloc(10,10); free(p); free(q); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_need_header_memory_h="no" else curl_cv_need_header_memory_h="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # case "$curl_cv_need_header_memory_h" in yes) cat >>confdefs.h <<_ACEOF #define NEED_MEMORY_H 1 _ACEOF ;; esac fi for ac_header in sys/types.h \ sys/time.h \ sys/select.h \ sys/socket.h \ sys/ioctl.h \ sys/param.h \ sys/uio.h \ assert.h \ netdb.h \ netinet/in.h \ netinet/tcp.h \ net/if.h \ errno.h \ socket.h \ strings.h \ stdbool.h \ time.h \ limits.h \ arpa/nameser.h \ arpa/nameser_compat.h \ arpa/inet.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_ARPA_NAMESER_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main (void) { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi for ac_header in sys/types.h sys/time.h time.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timeval" >&5 $as_echo_n "checking for struct timeval... " >&6; } if ${ac_cv_struct_timeval+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME #include #endif #else #ifdef HAVE_TIME_H #include #endif #endif #ifdef HAVE_SYS_SOCKET_H #include #endif int main (void) { struct timeval ts; ts.tv_sec = 0; ts.tv_usec = 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_timeval="yes" else ac_cv_struct_timeval="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_timeval" >&5 $as_echo "$ac_cv_struct_timeval" >&6; } case "$ac_cv_struct_timeval" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TIMEVAL 1 _ACEOF ;; esac # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 $as_echo_n "checking size of size_t... " >&6; } if ${ac_cv_sizeof_size_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : else if test "$ac_cv_type_size_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_size_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 $as_echo "$ac_cv_sizeof_size_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } if ${ac_cv_sizeof_short+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : else if test "$ac_cv_type_short" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 $as_echo "$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF if test -z "$ac_cv_sizeof_long" || test "$ac_cv_sizeof_long" -eq "0"; then as_fn_error $? "cannot find out size of long." "$LINENO" 5 fi cat >>confdefs.h <<_EOF #define CARES_SIZEOF_LONG $ac_cv_sizeof_long _EOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 $as_echo_n "checking size of time_t... " >&6; } if ${ac_cv_sizeof_time_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "$ac_includes_default"; then : else if test "$ac_cv_type_time_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (time_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_time_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5 $as_echo "$ac_cv_sizeof_time_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_TIME_T $ac_cv_sizeof_time_t _ACEOF ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default" if test "x$ac_cv_type_long_long" = xyes; then : $as_echo "#define HAVE_LONGLONG 1" >>confdefs.h longlong="yes" fi if test "xyes" = "x$longlong"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if numberLL works" >&5 $as_echo_n "checking if numberLL works... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { long long val = 1000LL; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LL 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # check for ssize_t ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else $as_echo "#define ssize_t int" >>confdefs.h fi # check for bool type ac_fn_c_check_type "$LINENO" "bool" "ac_cv_type_bool" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_STDBOOL_H #include #endif " if test "x$ac_cv_type_bool" = xyes; then : $as_echo "#define HAVE_BOOL_T 1" >>confdefs.h fi cares_includes_ws2tcpip="\ /* includes start */ #ifdef HAVE_WINDOWS_H # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include # ifdef HAVE_WINSOCK2_H # include # ifdef HAVE_WS2TCPIP_H # include # endif # endif #endif /* includes end */" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows.h" >&5 $as_echo_n "checking for windows.h... " >&6; } if ${ac_cv_header_windows_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) HAVE_WINDOWS_H shall not be defined. #else int dummy=2*WINVER; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_windows_h="yes" else ac_cv_header_windows_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_windows_h" >&5 $as_echo "$ac_cv_header_windows_h" >&6; } case "$ac_cv_header_windows_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF cat >>confdefs.h <<_ACEOF #define WIN32_LEAN_AND_MEAN 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock2.h" >&5 $as_echo_n "checking for winsock2.h... " >&6; } if ${ac_cv_header_winsock2_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) HAVE_WINSOCK2_H shall not be defined. #else int dummy=2*IPPROTO_ESP; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_winsock2_h="yes" else ac_cv_header_winsock2_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_winsock2_h" >&5 $as_echo "$ac_cv_header_winsock2_h" >&6; } case "$ac_cv_header_winsock2_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ws2tcpip.h" >&5 $as_echo_n "checking for ws2tcpip.h... " >&6; } if ${ac_cv_header_ws2tcpip_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #include int main (void) { #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) HAVE_WS2TCPIP_H shall not be defined. #else int dummy=2*IP_PKTINFO; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_ws2tcpip_h="yes" else ac_cv_header_ws2tcpip_h="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_ws2tcpip_h" >&5 $as_echo "$ac_cv_header_ws2tcpip_h" >&6; } case "$ac_cv_header_ws2tcpip_h" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_WS2TCPIP_H 1 _ACEOF ;; esac cares_includes_sys_socket="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif /* includes end */" for ac_header in sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_sys_socket " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done cares_preprocess_callconv="\ /* preprocess start */ #ifdef HAVE_WINDOWS_H # define FUNCALLCONV __stdcall #else # define FUNCALLCONV #endif /* preprocess end */" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ares_socklen_t data type" >&5 $as_echo_n "checking for ares_socklen_t data type... " >&6; } cares_typeof_ares_socklen_t="unknown" for arg1 in int SOCKET; do for arg2 in 'struct sockaddr' void; do for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do if test "$cares_typeof_ares_socklen_t" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_preprocess_callconv extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *); int main (void) { $t *lenptr = 0; if(0 != getpeername(0, 0, lenptr)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cares_typeof_ares_socklen_t="$t" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done done for t in socklen_t int; do if test "$cares_typeof_ares_socklen_t" = "void"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket typedef $t ares_socklen_t; int main (void) { ares_socklen_t dummy; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cares_typeof_ares_socklen_t="$t" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cares_typeof_ares_socklen_t" >&5 $as_echo "$cares_typeof_ares_socklen_t" >&6; } if test "$cares_typeof_ares_socklen_t" = "void" || test "$cares_typeof_ares_socklen_t" = "unknown"; then as_fn_error $? "cannot find data type for ares_socklen_t." "$LINENO" 5 fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ares_socklen_t" >&5 $as_echo_n "checking size of ares_socklen_t... " >&6; } cares_sizeof_ares_socklen_t="unknown" cares_pull_headers_socklen_t="unknown" if test "$ac_cv_header_ws2tcpip_h" = "yes"; then tst_pull_header_checks='none ws2tcpip' tst_size_checks='4' else tst_pull_header_checks='none systypes syssocket' tst_size_checks='4 8 2' fi for tst_size in $tst_size_checks; do for tst_pull_headers in $tst_pull_header_checks; do if test "$cares_sizeof_ares_socklen_t" = "unknown"; then case $tst_pull_headers in ws2tcpip) tmp_includes="$cares_includes_ws2tcpip" ;; systypes) tmp_includes="$cares_includes_sys_types" ;; syssocket) tmp_includes="$cares_includes_sys_socket" ;; *) tmp_includes="" ;; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $tmp_includes typedef $cares_typeof_ares_socklen_t ares_socklen_t; typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1]; int main (void) { ares_socklen_t dummy; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cares_sizeof_ares_socklen_t="$tst_size" cares_pull_headers_socklen_t="$tst_pull_headers" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cares_sizeof_ares_socklen_t" >&5 $as_echo "$cares_sizeof_ares_socklen_t" >&6; } if test "$cares_sizeof_ares_socklen_t" = "unknown"; then as_fn_error $? "cannot find out size of ares_socklen_t." "$LINENO" 5 fi # case $cares_pull_headers_socklen_t in ws2tcpip) cat >>confdefs.h <<_EOF #define CARES_PULL_WS2TCPIP_H 1 _EOF ;; systypes) cat >>confdefs.h <<_EOF #define CARES_PULL_SYS_TYPES_H 1 _EOF ;; syssocket) cat >>confdefs.h <<_EOF #define CARES_PULL_SYS_TYPES_H 1 _EOF cat >>confdefs.h <<_EOF #define CARES_PULL_SYS_SOCKET_H 1 _EOF ;; esac cat >>confdefs.h <<_EOF #define CARES_TYPEOF_ARES_SOCKLEN_T $cares_typeof_ares_socklen_t _EOF cat >>confdefs.h <<_EOF #define CARES_SIZEOF_ARES_SOCKLEN_T $cares_sizeof_ares_socklen_t _EOF ac_fn_c_check_type "$LINENO" "in_addr_t" "ac_cv_type_in_addr_t" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #endif " if test "x$ac_cv_type_in_addr_t" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for in_addr_t equivalent" >&5 $as_echo_n "checking for in_addr_t equivalent... " >&6; } if ${curl_cv_in_addr_t_equiv+:} false; then : $as_echo_n "(cached) " >&6 else curl_cv_in_addr_t_equiv="unknown" for t in "unsigned long" int size_t unsigned long; do if test "$curl_cv_in_addr_t_equiv" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #endif int main (void) { $t data = inet_addr ("1.2.3.4"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : curl_cv_in_addr_t_equiv="$t" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_in_addr_t_equiv" >&5 $as_echo "$curl_cv_in_addr_t_equiv" >&6; } case "$curl_cv_in_addr_t_equiv" in unknown) as_fn_error $? "Cannot find a type to use in place of in_addr_t" "$LINENO" 5 ;; *) cat >>confdefs.h <<_ACEOF #define in_addr_t $curl_cv_in_addr_t_equiv _ACEOF ;; esac fi ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #endif " if test "x$ac_cv_type_struct_sockaddr_storage" = xyes; then : $as_echo "#define HAVE_STRUCT_SOCKADDR_STORAGE 1" >>confdefs.h fi for ac_header in signal.h do : ac_fn_c_check_header_mongrel "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default" if test "x$ac_cv_header_signal_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGNAL_H 1 _ACEOF fi done ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" " #ifdef HAVE_SIGNAL_H #include #endif " if test "x$ac_cv_type_sig_atomic_t" = xyes; then : $as_echo "#define HAVE_SIG_ATOMIC_T 1" >>confdefs.h fi case "$ac_cv_type_sig_atomic_t" in yes) # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sig_atomic_t is already defined as volatile" >&5 $as_echo_n "checking if sig_atomic_t is already defined as volatile... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SIGNAL_H #include #endif int main (void) { static volatile sig_atomic_t dummy = 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_sig_atomic_t_volatile="no" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ac_cv_sig_atomic_t_volatile="yes" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then $as_echo "#define HAVE_SIG_ATOMIC_T_VOLATILE 1" >>confdefs.h fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_header in sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recv" >&5 $as_echo_n "checking for recv... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif int main (void) { recv(0, 0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_recv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } curl_cv_recv="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$curl_cv_recv" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of args and return type for recv" >&5 $as_echo_n "checking types of args and return type for recv... " >&6; } if ${curl_cv_func_recv_args+:} false; then : $as_echo_n "(cached) " >&6 else curl_cv_func_recv_args="unknown" for recv_retv in 'int' 'ssize_t'; do for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do for recv_arg2 in 'char *' 'void *'; do for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do for recv_arg4 in 'int' 'unsigned int'; do if test "$curl_cv_func_recv_args" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #define RECVCALLCONV PASCAL #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #define RECVCALLCONV #endif extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4); int main (void) { $recv_arg1 s=0; $recv_arg2 buf=0; $recv_arg3 len=0; $recv_arg4 flags=0; $recv_retv res = recv(s, buf, len, flags); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done done done done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_func_recv_args" >&5 $as_echo "$curl_cv_func_recv_args" >&6; } # AC-CACHE-CHECK if test "$curl_cv_func_recv_args" = "unknown"; then as_fn_error $? "Cannot find proper types to use for recv args" "$LINENO" 5 else recv_prev_IFS=$IFS; IFS=',' set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'` IFS=$recv_prev_IFS shift # cat >>confdefs.h <<_ACEOF #define RECV_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define RECV_TYPE_ARG2 $2 _ACEOF cat >>confdefs.h <<_ACEOF #define RECV_TYPE_ARG3 $3 _ACEOF cat >>confdefs.h <<_ACEOF #define RECV_TYPE_ARG4 $4 _ACEOF cat >>confdefs.h <<_ACEOF #define RECV_TYPE_RETV $5 _ACEOF # cat >>confdefs.h <<_ACEOF #define HAVE_RECV 1 _ACEOF ac_cv_func_recv="yes" fi else as_fn_error $? "Unable to link function recv" "$LINENO" 5 fi for ac_header in sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recvfrom" >&5 $as_echo_n "checking for recvfrom... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif int main (void) { recvfrom(0, 0, 0, 0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_recvfrom="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } curl_cv_recvfrom="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$curl_cv_recvfrom" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of args and return type for recvfrom" >&5 $as_echo_n "checking types of args and return type for recvfrom... " >&6; } if ${curl_cv_func_recvfrom_args+:} false; then : $as_echo_n "(cached) " >&6 else curl_cv_func_recvfrom_args="unknown" for recvfrom_retv in 'int' 'ssize_t'; do for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do for recvfrom_arg2 in 'char *' 'void *'; do for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do for recvfrom_arg4 in 'int' 'unsigned int'; do for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do if test "$curl_cv_func_recvfrom_args" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #define RECVFROMCALLCONV PASCAL #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #define RECVFROMCALLCONV #endif extern $recvfrom_retv RECVFROMCALLCONV recvfrom($recvfrom_arg1, $recvfrom_arg2, $recvfrom_arg3, $recvfrom_arg4, $recvfrom_arg5, $recvfrom_arg6); int main (void) { $recvfrom_arg1 s=0; $recvfrom_arg2 buf=0; $recvfrom_arg3 len=0; $recvfrom_arg4 flags=0; $recvfrom_arg5 addr=0; $recvfrom_arg6 addrlen=0; $recvfrom_retv res=0; res = recvfrom(s, buf, len, flags, addr, addrlen); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done done done done done done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_func_recvfrom_args" >&5 $as_echo "$curl_cv_func_recvfrom_args" >&6; } # AC-CACHE-CHECK # Nearly last minute change for this release starts here cat >>confdefs.h <<_ACEOF #define HAVE_RECVFROM 1 _ACEOF ac_cv_func_recvfrom="yes" # Nearly last minute change for this release ends here if test "$curl_cv_func_recvfrom_args" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find proper types to use for recvfrom args" >&5 $as_echo "$as_me: WARNING: Cannot find proper types to use for recvfrom args" >&2;} else recvfrom_prev_IFS=$IFS; IFS=',' set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'` IFS=$recvfrom_prev_IFS shift # recvfrom_ptrt_arg2=$2 recvfrom_qual_ptrt_arg5=$5 recvfrom_ptrt_arg6=$6 # cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG3 $3 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG4 $4 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_RETV $7 _ACEOF # prev_sh_opts=$- # case $prev_sh_opts in *f*) ;; *) set -f ;; esac # case "$recvfrom_qual_ptrt_arg5" in const*) recvfrom_qual_arg5=const recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'` ;; *) recvfrom_qual_arg5= recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5 ;; esac # recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'` recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'` recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'` # cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG2 $recvfrom_type_arg2 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_QUAL_ARG5 $recvfrom_qual_arg5 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG5 $recvfrom_type_arg5 _ACEOF cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG6 $recvfrom_type_arg6 _ACEOF # if test "$recvfrom_type_arg2" = "void"; then cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG2_IS_VOID 1 _ACEOF fi if test "$recvfrom_type_arg5" = "void"; then cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG5_IS_VOID 1 _ACEOF fi if test "$recvfrom_type_arg6" = "void"; then cat >>confdefs.h <<_ACEOF #define RECVFROM_TYPE_ARG6_IS_VOID 1 _ACEOF fi # case $prev_sh_opts in *f*) ;; *) set +f ;; esac # cat >>confdefs.h <<_ACEOF #define HAVE_RECVFROM 1 _ACEOF ac_cv_func_recvfrom="yes" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to link function recvfrom" >&5 $as_echo "$as_me: WARNING: Unable to link function recvfrom" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your system will be vulnerable to some forms of DNS cache poisoning" >&5 $as_echo "$as_me: WARNING: Your system will be vulnerable to some forms of DNS cache poisoning" >&2;} fi for ac_header in sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for send" >&5 $as_echo_n "checking for send... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif int main (void) { send(0, 0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_send="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } curl_cv_send="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$curl_cv_send" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of args and return type for send" >&5 $as_echo_n "checking types of args and return type for send... " >&6; } if ${curl_cv_func_send_args+:} false; then : $as_echo_n "(cached) " >&6 else curl_cv_func_send_args="unknown" for send_retv in 'int' 'ssize_t'; do for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do for send_arg4 in 'int' 'unsigned int'; do if test "$curl_cv_func_send_args" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #define SENDCALLCONV PASCAL #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #define SENDCALLCONV #endif extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4); int main (void) { $send_arg1 s=0; $send_arg3 len=0; $send_arg4 flags=0; $send_retv res = send(s, 0, len, flags); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done done done done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_func_send_args" >&5 $as_echo "$curl_cv_func_send_args" >&6; } # AC-CACHE-CHECK if test "$curl_cv_func_send_args" = "unknown"; then as_fn_error $? "Cannot find proper types to use for send args" "$LINENO" 5 else send_prev_IFS=$IFS; IFS=',' set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'` IFS=$send_prev_IFS shift # send_qual_type_arg2=$2 # cat >>confdefs.h <<_ACEOF #define SEND_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define SEND_TYPE_ARG3 $3 _ACEOF cat >>confdefs.h <<_ACEOF #define SEND_TYPE_ARG4 $4 _ACEOF cat >>confdefs.h <<_ACEOF #define SEND_TYPE_RETV $5 _ACEOF # prev_sh_opts=$- # case $prev_sh_opts in *f*) ;; *) set -f ;; esac # case "$send_qual_type_arg2" in const*) send_qual_arg2=const send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'` ;; *) send_qual_arg2= send_type_arg2=$send_qual_type_arg2 ;; esac # cat >>confdefs.h <<_ACEOF #define SEND_QUAL_ARG2 $send_qual_arg2 _ACEOF cat >>confdefs.h <<_ACEOF #define SEND_TYPE_ARG2 $send_type_arg2 _ACEOF # case $prev_sh_opts in *f*) ;; *) set +f ;; esac # cat >>confdefs.h <<_ACEOF #define HAVE_SEND 1 _ACEOF ac_cv_func_send="yes" fi else as_fn_error $? "Unable to link function send" "$LINENO" 5 fi for ac_header in sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MSG_NOSIGNAL" >&5 $as_echo_n "checking for MSG_NOSIGNAL... " >&6; } if ${ac_cv_msg_nosignal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #else #ifdef HAVE_WINSOCK_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif int main (void) { int flag=MSG_NOSIGNAL; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_msg_nosignal="yes" else ac_cv_msg_nosignal="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_msg_nosignal" >&5 $as_echo "$ac_cv_msg_nosignal" >&6; } case "$ac_cv_msg_nosignal" in yes) cat >>confdefs.h <<_ACEOF #define HAVE_MSG_NOSIGNAL 1 _ACEOF ;; esac cares_includes_socket="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SOCKET_H # include #endif /* includes end */" for ac_header in sys/types.h socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_socket " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_closesocket="unknown" tst_proto_closesocket="unknown" tst_compi_closesocket="unknown" tst_allow_closesocket="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if closesocket can be linked" >&5 $as_echo_n "checking if closesocket can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_socket int main (void) { if(0 != closesocket(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_closesocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_closesocket="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_closesocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if closesocket is prototyped" >&5 $as_echo_n "checking if closesocket is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_socket _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "closesocket" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_closesocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_closesocket="no" fi rm -f conftest* fi # if test "$tst_proto_closesocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if closesocket is compilable" >&5 $as_echo_n "checking if closesocket is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_socket int main (void) { if(0 != closesocket(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_closesocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_closesocket="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_closesocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if closesocket usage allowed" >&5 $as_echo_n "checking if closesocket usage allowed... " >&6; } if test "x$cares_disallow_closesocket" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_closesocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_closesocket="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if closesocket might be used" >&5 $as_echo_n "checking if closesocket might be used... " >&6; } if test "$tst_links_closesocket" = "yes" && test "$tst_proto_closesocket" = "yes" && test "$tst_compi_closesocket" = "yes" && test "$tst_allow_closesocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_CLOSESOCKET 1 _ACEOF ac_cv_func_closesocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_closesocket="no" fi # tst_links_closesocket_camel="unknown" tst_proto_closesocket_camel="unknown" tst_compi_closesocket_camel="unknown" tst_allow_closesocket_camel="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CloseSocket can be linked" >&5 $as_echo_n "checking if CloseSocket can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket int main (void) { if(0 != CloseSocket(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_closesocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_closesocket_camel="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_closesocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CloseSocket is prototyped" >&5 $as_echo_n "checking if CloseSocket is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "CloseSocket" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_closesocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_closesocket_camel="no" fi rm -f conftest* fi # if test "$tst_proto_closesocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CloseSocket is compilable" >&5 $as_echo_n "checking if CloseSocket is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket int main (void) { if(0 != CloseSocket(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_closesocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_closesocket_camel="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_closesocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CloseSocket usage allowed" >&5 $as_echo_n "checking if CloseSocket usage allowed... " >&6; } if test "x$cares_disallow_closesocket_camel" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_closesocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_closesocket_camel="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CloseSocket might be used" >&5 $as_echo_n "checking if CloseSocket might be used... " >&6; } if test "$tst_links_closesocket_camel" = "yes" && test "$tst_proto_closesocket_camel" = "yes" && test "$tst_compi_closesocket_camel" = "yes" && test "$tst_allow_closesocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_CLOSESOCKET_CAMEL 1 _ACEOF ac_cv_func_closesocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_closesocket_camel="no" fi # tst_links_connect="unknown" tst_proto_connect="unknown" tst_compi_connect="unknown" tst_allow_connect="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if connect can be linked" >&5 $as_echo_n "checking if connect can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket int main (void) { if(0 != connect(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_connect="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_connect="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_connect" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if connect is prototyped" >&5 $as_echo_n "checking if connect is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "connect" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_connect="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_connect="no" fi rm -f conftest* fi # if test "$tst_proto_connect" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if connect is compilable" >&5 $as_echo_n "checking if connect is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket int main (void) { if(0 != connect(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_connect="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_connect="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_connect" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if connect usage allowed" >&5 $as_echo_n "checking if connect usage allowed... " >&6; } if test "x$cares_disallow_connect" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_connect="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_connect="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if connect might be used" >&5 $as_echo_n "checking if connect might be used... " >&6; } if test "$tst_links_connect" = "yes" && test "$tst_proto_connect" = "yes" && test "$tst_compi_connect" = "yes" && test "$tst_allow_connect" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_CONNECT 1 _ACEOF ac_cv_func_connect="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_connect="no" fi cares_includes_fcntl="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_FCNTL_H # include #endif /* includes end */" for ac_header in sys/types.h unistd.h fcntl.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_fcntl " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_fcntl="unknown" tst_proto_fcntl="unknown" tst_compi_fcntl="unknown" tst_allow_fcntl="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl can be linked" >&5 $as_echo_n "checking if fcntl can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define fcntl innocuous_fcntl #ifdef __STDC__ # include #else # include #endif #undef fcntl #ifdef __cplusplus extern "C" #endif char fcntl (); #if defined __stub_fcntl || defined __stub___fcntl choke me #endif int main (void) { return fcntl (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_fcntl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_fcntl="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_fcntl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl is prototyped" >&5 $as_echo_n "checking if fcntl is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_fcntl _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "fcntl" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_fcntl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_fcntl="no" fi rm -f conftest* fi # if test "$tst_proto_fcntl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl is compilable" >&5 $as_echo_n "checking if fcntl is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_fcntl int main (void) { if(0 != fcntl(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_fcntl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_fcntl="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_fcntl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl usage allowed" >&5 $as_echo_n "checking if fcntl usage allowed... " >&6; } if test "x$cares_disallow_fcntl" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_fcntl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_fcntl="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl might be used" >&5 $as_echo_n "checking if fcntl might be used... " >&6; } if test "$tst_links_fcntl" = "yes" && test "$tst_proto_fcntl" = "yes" && test "$tst_compi_fcntl" = "yes" && test "$tst_allow_fcntl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL 1 _ACEOF ac_cv_func_fcntl="yes" # tst_compi_fcntl_o_nonblock="unknown" tst_allow_fcntl_o_nonblock="unknown" # case $host_os in sunos4* | aix3* | beos*) cares_disallow_fcntl_o_nonblock="yes" ;; esac # if test "$ac_cv_func_fcntl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl O_NONBLOCK is compilable" >&5 $as_echo_n "checking if fcntl O_NONBLOCK is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_fcntl int main (void) { int flags = 0; if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_fcntl_o_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_fcntl_o_nonblock="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_fcntl_o_nonblock" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl O_NONBLOCK usage allowed" >&5 $as_echo_n "checking if fcntl O_NONBLOCK usage allowed... " >&6; } if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_fcntl_o_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_fcntl_o_nonblock="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fcntl O_NONBLOCK might be used" >&5 $as_echo_n "checking if fcntl O_NONBLOCK might be used... " >&6; } if test "$tst_compi_fcntl_o_nonblock" = "yes" && test "$tst_allow_fcntl_o_nonblock" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL_O_NONBLOCK 1 _ACEOF ac_cv_func_fcntl_o_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_fcntl_o_nonblock="no" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_fcntl="no" fi cares_includes_netdb="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_NETDB_H # include #endif /* includes end */" for ac_header in sys/types.h netdb.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_netdb " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_freeaddrinfo="unknown" tst_proto_freeaddrinfo="unknown" tst_compi_freeaddrinfo="unknown" tst_allow_freeaddrinfo="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if freeaddrinfo can be linked" >&5 $as_echo_n "checking if freeaddrinfo can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb int main (void) { freeaddrinfo(0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_freeaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_freeaddrinfo="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_freeaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if freeaddrinfo is prototyped" >&5 $as_echo_n "checking if freeaddrinfo is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "freeaddrinfo" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_freeaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_freeaddrinfo="no" fi rm -f conftest* fi # if test "$tst_proto_freeaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if freeaddrinfo is compilable" >&5 $as_echo_n "checking if freeaddrinfo is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb int main (void) { freeaddrinfo(0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_freeaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_freeaddrinfo="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_freeaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if freeaddrinfo usage allowed" >&5 $as_echo_n "checking if freeaddrinfo usage allowed... " >&6; } if test "x$cares_disallow_freeaddrinfo" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_freeaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_freeaddrinfo="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if freeaddrinfo might be used" >&5 $as_echo_n "checking if freeaddrinfo might be used... " >&6; } if test "$tst_links_freeaddrinfo" = "yes" && test "$tst_proto_freeaddrinfo" = "yes" && test "$tst_compi_freeaddrinfo" = "yes" && test "$tst_allow_freeaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_FREEADDRINFO 1 _ACEOF ac_cv_func_freeaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_freeaddrinfo="no" fi cares_includes_stdlib="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_STDLIB_H # include #endif /* includes end */" for ac_header in sys/types.h stdlib.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_stdlib " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done cares_includes_string="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_STRINGS_H # include #endif /* includes end */" for ac_header in sys/types.h string.h strings.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_string " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_getaddrinfo="unknown" tst_proto_getaddrinfo="unknown" tst_compi_getaddrinfo="unknown" tst_works_getaddrinfo="unknown" tst_allow_getaddrinfo="unknown" tst_tsafe_getaddrinfo="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo can be linked" >&5 $as_echo_n "checking if getaddrinfo can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb int main (void) { if(0 != getaddrinfo(0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_getaddrinfo="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_getaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo is prototyped" >&5 $as_echo_n "checking if getaddrinfo is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getaddrinfo" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_getaddrinfo="no" fi rm -f conftest* fi # if test "$tst_proto_getaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo is compilable" >&5 $as_echo_n "checking if getaddrinfo is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_sys_socket $cares_includes_netdb int main (void) { if(0 != getaddrinfo(0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_getaddrinfo="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "x$cross_compiling" != "xyes" && test "$tst_compi_getaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo seems to work" >&5 $as_echo_n "checking if getaddrinfo seems to work... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_ws2tcpip $cares_includes_stdlib $cares_includes_string $cares_includes_sys_socket $cares_includes_netdb int main (void) { struct addrinfo hints; struct addrinfo *ai = 0; int error; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; error = getaddrinfo("127.0.0.1", 0, &hints, &ai); if(error || !ai) exit(1); /* fail */ else exit(0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_works_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_works_getaddrinfo="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # if test "$tst_compi_getaddrinfo" = "yes" && test "$tst_works_getaddrinfo" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo usage allowed" >&5 $as_echo_n "checking if getaddrinfo usage allowed... " >&6; } if test "x$cares_disallow_getaddrinfo" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_getaddrinfo="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo might be used" >&5 $as_echo_n "checking if getaddrinfo might be used... " >&6; } if test "$tst_links_getaddrinfo" = "yes" && test "$tst_proto_getaddrinfo" = "yes" && test "$tst_compi_getaddrinfo" = "yes" && test "$tst_allow_getaddrinfo" = "yes" && test "$tst_works_getaddrinfo" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETADDRINFO 1 _ACEOF ac_cv_func_getaddrinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_getaddrinfo="no" ac_cv_func_getaddrinfo_threadsafe="no" fi # if test "$ac_cv_func_getaddrinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getaddrinfo is threadsafe" >&5 $as_echo_n "checking if getaddrinfo is threadsafe... " >&6; } case $host_os in aix[1234].* | aix5.[01].*) tst_tsafe_getaddrinfo="no" ;; aix*) tst_tsafe_getaddrinfo="yes" ;; darwin[12345].*) tst_tsafe_getaddrinfo="no" ;; darwin*) tst_tsafe_getaddrinfo="yes" ;; freebsd[1234].* | freebsd5.[1234]*) tst_tsafe_getaddrinfo="no" ;; freebsd*) tst_tsafe_getaddrinfo="yes" ;; hpux[123456789].* | hpux10.* | hpux11.0* | hpux11.10*) tst_tsafe_getaddrinfo="no" ;; hpux*) tst_tsafe_getaddrinfo="yes" ;; netbsd[123].*) tst_tsafe_getaddrinfo="no" ;; netbsd*) tst_tsafe_getaddrinfo="yes" ;; *bsd*) tst_tsafe_getaddrinfo="no" ;; solaris2*) tst_tsafe_getaddrinfo="yes" ;; esac if test "$tst_tsafe_getaddrinfo" = "unknown" && test "$ac_cv_native_windows" = "yes"; then tst_tsafe_getaddrinfo="yes" fi if test "$tst_tsafe_getaddrinfo" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket $cares_includes_netdb int main (void) { #ifdef h_errno return 0; #else force compilation error #endif } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tst_symbol_defined="yes" else tst_symbol_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tst_symbol_defined" = "yes"; then curl_cv_have_def_h_errno=yes else curl_cv_have_def_h_errno=no fi if test "$curl_cv_have_def_h_errno" = "yes"; then tst_h_errno_macro="yes" else tst_h_errno_macro="no" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_socket $cares_includes_netdb int main (void) { h_errno = 2; if(0 != h_errno) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tst_h_errno_modifiable_lvalue="yes" else tst_h_errno_modifiable_lvalue="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) return 0; #elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700) return 0; #else force compilation error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tst_h_errno_sbs_issue_7="yes" else tst_h_errno_sbs_issue_7="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$tst_h_errno_macro" = "no" && test "$tst_h_errno_modifiable_lvalue" = "no" && test "$tst_h_errno_sbs_issue_7" = "no"; then tst_tsafe_getaddrinfo="no" else tst_tsafe_getaddrinfo="yes" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tst_tsafe_getaddrinfo" >&5 $as_echo "$tst_tsafe_getaddrinfo" >&6; } if test "$tst_tsafe_getaddrinfo" = "yes"; then cat >>confdefs.h <<_ACEOF #define HAVE_GETADDRINFO_THREADSAFE 1 _ACEOF ac_cv_func_getaddrinfo_threadsafe="yes" else ac_cv_func_getaddrinfo_threadsafe="no" fi fi # tst_links_getenv="unknown" tst_proto_getenv="unknown" tst_compi_getenv="unknown" tst_allow_getenv="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getenv can be linked" >&5 $as_echo_n "checking if getenv can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define getenv innocuous_getenv #ifdef __STDC__ # include #else # include #endif #undef getenv #ifdef __cplusplus extern "C" #endif char getenv (); #if defined __stub_getenv || defined __stub___getenv choke me #endif int main (void) { return getenv (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_getenv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_getenv="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_getenv" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getenv is prototyped" >&5 $as_echo_n "checking if getenv is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stdlib _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getenv" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_getenv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_getenv="no" fi rm -f conftest* fi # if test "$tst_proto_getenv" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getenv is compilable" >&5 $as_echo_n "checking if getenv is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stdlib int main (void) { if(0 != getenv(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_getenv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_getenv="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_getenv" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getenv usage allowed" >&5 $as_echo_n "checking if getenv usage allowed... " >&6; } if test "x$cares_disallow_getenv" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_getenv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_getenv="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getenv might be used" >&5 $as_echo_n "checking if getenv might be used... " >&6; } if test "$tst_links_getenv" = "yes" && test "$tst_proto_getenv" = "yes" && test "$tst_compi_getenv" = "yes" && test "$tst_allow_getenv" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETENV 1 _ACEOF ac_cv_func_getenv="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_getenv="no" fi # tst_links_gethostbyaddr="unknown" tst_proto_gethostbyaddr="unknown" tst_compi_gethostbyaddr="unknown" tst_allow_gethostbyaddr="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyaddr can be linked" >&5 $as_echo_n "checking if gethostbyaddr can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb int main (void) { if(0 != gethostbyaddr(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_gethostbyaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_gethostbyaddr="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_gethostbyaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyaddr is prototyped" >&5 $as_echo_n "checking if gethostbyaddr is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyaddr" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_gethostbyaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_gethostbyaddr="no" fi rm -f conftest* fi # if test "$tst_proto_gethostbyaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyaddr is compilable" >&5 $as_echo_n "checking if gethostbyaddr is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb int main (void) { if(0 != gethostbyaddr(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_gethostbyaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_gethostbyaddr="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_gethostbyaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyaddr usage allowed" >&5 $as_echo_n "checking if gethostbyaddr usage allowed... " >&6; } if test "x$cares_disallow_gethostbyaddr" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_gethostbyaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_gethostbyaddr="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyaddr might be used" >&5 $as_echo_n "checking if gethostbyaddr might be used... " >&6; } if test "$tst_links_gethostbyaddr" = "yes" && test "$tst_proto_gethostbyaddr" = "yes" && test "$tst_compi_gethostbyaddr" = "yes" && test "$tst_allow_gethostbyaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETHOSTBYADDR 1 _ACEOF ac_cv_func_gethostbyaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_gethostbyaddr="no" fi # tst_links_gethostbyname="unknown" tst_proto_gethostbyname="unknown" tst_compi_gethostbyname="unknown" tst_allow_gethostbyname="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyname can be linked" >&5 $as_echo_n "checking if gethostbyname can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb int main (void) { if(0 != gethostbyname(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_gethostbyname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_gethostbyname="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_gethostbyname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyname is prototyped" >&5 $as_echo_n "checking if gethostbyname is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostbyname" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_gethostbyname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_gethostbyname="no" fi rm -f conftest* fi # if test "$tst_proto_gethostbyname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyname is compilable" >&5 $as_echo_n "checking if gethostbyname is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_netdb int main (void) { if(0 != gethostbyname(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_gethostbyname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_gethostbyname="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_gethostbyname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyname usage allowed" >&5 $as_echo_n "checking if gethostbyname usage allowed... " >&6; } if test "x$cares_disallow_gethostbyname" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_gethostbyname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_gethostbyname="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostbyname might be used" >&5 $as_echo_n "checking if gethostbyname might be used... " >&6; } if test "$tst_links_gethostbyname" = "yes" && test "$tst_proto_gethostbyname" = "yes" && test "$tst_compi_gethostbyname" = "yes" && test "$tst_allow_gethostbyname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETHOSTBYNAME 1 _ACEOF ac_cv_func_gethostbyname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_gethostbyname="no" fi cares_includes_unistd="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_UNISTD_H # include #endif /* includes end */" for ac_header in sys/types.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_unistd " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_gethostname="unknown" tst_proto_gethostname="unknown" tst_compi_gethostname="unknown" tst_allow_gethostname="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostname can be linked" >&5 $as_echo_n "checking if gethostname can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_unistd int main (void) { if(0 != gethostname(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_gethostname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_gethostname="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_gethostname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostname is prototyped" >&5 $as_echo_n "checking if gethostname is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_unistd _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gethostname" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_gethostname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_gethostname="no" fi rm -f conftest* fi # if test "$tst_proto_gethostname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostname is compilable" >&5 $as_echo_n "checking if gethostname is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_unistd int main (void) { if(0 != gethostname(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_gethostname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_gethostname="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_gethostname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostname arg 2 data type" >&5 $as_echo_n "checking for gethostname arg 2 data type... " >&6; } tst_gethostname_type_arg2="unknown" for tst_arg1 in 'char *' 'unsigned char *' 'void *'; do for tst_arg2 in 'int' 'unsigned int' 'size_t'; do if test "$tst_gethostname_type_arg2" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_unistd $cares_preprocess_callconv extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2); int main (void) { if(0 != gethostname(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tst_gethostname_type_arg2="$tst_arg2" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tst_gethostname_type_arg2" >&5 $as_echo "$tst_gethostname_type_arg2" >&6; } if test "$tst_gethostname_type_arg2" != "unknown"; then cat >>confdefs.h <<_ACEOF #define GETHOSTNAME_TYPE_ARG2 $tst_gethostname_type_arg2 _ACEOF fi fi # if test "$tst_compi_gethostname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostname usage allowed" >&5 $as_echo_n "checking if gethostname usage allowed... " >&6; } if test "x$cares_disallow_gethostname" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_gethostname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_gethostname="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gethostname might be used" >&5 $as_echo_n "checking if gethostname might be used... " >&6; } if test "$tst_links_gethostname" = "yes" && test "$tst_proto_gethostname" = "yes" && test "$tst_compi_gethostname" = "yes" && test "$tst_allow_gethostname" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETHOSTNAME 1 _ACEOF ac_cv_func_gethostname="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_gethostname="no" fi # tst_links_getservbyport_r="unknown" tst_proto_getservbyport_r="unknown" tst_compi_getservbyport_r="unknown" tst_allow_getservbyport_r="unknown" tst_nargs_getservbyport_r="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r can be linked" >&5 $as_echo_n "checking if getservbyport_r can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define getservbyport_r innocuous_getservbyport_r #ifdef __STDC__ # include #else # include #endif #undef getservbyport_r #ifdef __cplusplus extern "C" #endif char getservbyport_r (); #if defined __stub_getservbyport_r || defined __stub___getservbyport_r choke me #endif int main (void) { return getservbyport_r (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_getservbyport_r="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_getservbyport_r="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_getservbyport_r" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r is prototyped" >&5 $as_echo_n "checking if getservbyport_r is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_netdb _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "getservbyport_r" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_getservbyport_r="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_getservbyport_r="no" fi rm -f conftest* fi # if test "$tst_proto_getservbyport_r" = "yes"; then if test "$tst_nargs_getservbyport_r" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r takes 4 args." >&5 $as_echo_n "checking if getservbyport_r takes 4 args.... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_netdb int main (void) { if(0 != getservbyport_r(0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_getservbyport_r="yes" tst_nargs_getservbyport_r="4" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_getservbyport_r="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$tst_nargs_getservbyport_r" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r takes 5 args." >&5 $as_echo_n "checking if getservbyport_r takes 5 args.... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_netdb int main (void) { if(0 != getservbyport_r(0, 0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_getservbyport_r="yes" tst_nargs_getservbyport_r="5" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_getservbyport_r="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$tst_nargs_getservbyport_r" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r takes 6 args." >&5 $as_echo_n "checking if getservbyport_r takes 6 args.... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_netdb int main (void) { if(0 != getservbyport_r(0, 0, 0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_getservbyport_r="yes" tst_nargs_getservbyport_r="6" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_getservbyport_r="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r is compilable" >&5 $as_echo_n "checking if getservbyport_r is compilable... " >&6; } if test "$tst_compi_getservbyport_r" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # if test "$tst_compi_getservbyport_r" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r usage allowed" >&5 $as_echo_n "checking if getservbyport_r usage allowed... " >&6; } if test "x$cares_disallow_getservbyport_r" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_getservbyport_r="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_getservbyport_r="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if getservbyport_r might be used" >&5 $as_echo_n "checking if getservbyport_r might be used... " >&6; } if test "$tst_links_getservbyport_r" = "yes" && test "$tst_proto_getservbyport_r" = "yes" && test "$tst_compi_getservbyport_r" = "yes" && test "$tst_allow_getservbyport_r" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_GETSERVBYPORT_R 1 _ACEOF cat >>confdefs.h <<_ACEOF #define GETSERVBYPORT_R_ARGS $tst_nargs_getservbyport_r _ACEOF if test "$tst_nargs_getservbyport_r" -eq "4"; then $as_echo "#define GETSERVBYPORT_R_BUFSIZE sizeof(struct servent_data)" >>confdefs.h else $as_echo "#define GETSERVBYPORT_R_BUFSIZE 4096" >>confdefs.h fi ac_cv_func_getservbyport_r="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_getservbyport_r="no" fi cares_includes_arpa_inet="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif /* includes end */" for ac_header in sys/types.h sys/socket.h netinet/in.h arpa/inet.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_arpa_inet " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_inet_net_pton="unknown" tst_proto_inet_net_pton="unknown" tst_compi_inet_net_pton="unknown" tst_works_inet_net_pton="unknown" tst_allow_inet_net_pton="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton can be linked" >&5 $as_echo_n "checking if inet_net_pton can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inet_net_pton innocuous_inet_net_pton #ifdef __STDC__ # include #else # include #endif #undef inet_net_pton #ifdef __cplusplus extern "C" #endif char inet_net_pton (); #if defined __stub_inet_net_pton || defined __stub___inet_net_pton choke me #endif int main (void) { return inet_net_pton (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_inet_net_pton="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_inet_net_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton is prototyped" >&5 $as_echo_n "checking if inet_net_pton is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "inet_net_pton" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_inet_net_pton="no" fi rm -f conftest* fi # if test "$tst_proto_inet_net_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton is compilable" >&5 $as_echo_n "checking if inet_net_pton is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet int main (void) { if(0 != inet_net_pton(0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_inet_net_pton="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "x$cross_compiling" != "xyes" && test "$tst_compi_inet_net_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton seems to work" >&5 $as_echo_n "checking if inet_net_pton seems to work... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stdlib $cares_includes_arpa_inet $cares_includes_string int main (void) { unsigned char ipv6a[16+1]; unsigned char ipv4a[4+1]; const char *ipv6net1 = "fe80::214:4fff:fe0b:76c8"; const char *ipv6net2 = "::fffe:7f00:1"; const char *ipv6net3 = "7f20:1::/64"; const char *ipv6net4 = "7f20:1::/2147483649"; const char *ipv4net1 = "192.168.100.1"; const char *ipv4net2 = "192.168.100/32"; const char *ipv4net3 = "192.168.100.1/2147483649"; /* - */ memset(ipv4a, 1, sizeof(ipv4a)); if(32 != inet_net_pton(AF_INET, ipv4net1, ipv4a, 4)) exit(1); /* fail */ /* - */ if( (ipv4a[0x00] != 0xc0) || (ipv4a[0x01] != 0xa8) || (ipv4a[0x02] != 0x64) || (ipv4a[0x03] != 0x01) || (ipv4a[0x04] != 0x01) ) exit(1); /* fail */ /* - */ memset(ipv4a, 1, sizeof(ipv4a)); if(32 != inet_net_pton(AF_INET, ipv4net2, ipv4a, 4)) exit(1); /* fail */ /* - */ if( (ipv4a[0x00] != 0xc0) || (ipv4a[0x01] != 0xa8) || (ipv4a[0x02] != 0x64) || (ipv4a[0x03] != 0x00) || (ipv4a[0x04] != 0x01) ) exit(1); /* fail */ /* - */ memset(ipv4a, 1, sizeof(ipv4a)); if(-1 != inet_net_pton(AF_INET, ipv4net3, ipv4a, 4)) exit(1); /* fail */ /* - */ memset(ipv6a, 1, sizeof(ipv6a)); if(128 != inet_net_pton(AF_INET6, ipv6net1, ipv6a, 16)) exit(1); /* fail */ /* - */ if( (ipv6a[0x00] != 0xfe) || (ipv6a[0x01] != 0x80) || (ipv6a[0x08] != 0x02) || (ipv6a[0x09] != 0x14) || (ipv6a[0x0a] != 0x4f) || (ipv6a[0x0b] != 0xff) || (ipv6a[0x0c] != 0xfe) || (ipv6a[0x0d] != 0x0b) || (ipv6a[0x0e] != 0x76) || (ipv6a[0x0f] != 0xc8) || (ipv6a[0x10] != 0x01) ) exit(1); /* fail */ /* - */ if( (ipv6a[0x02] != 0x0) || (ipv6a[0x03] != 0x0) || (ipv6a[0x04] != 0x0) || (ipv6a[0x05] != 0x0) || (ipv6a[0x06] != 0x0) || (ipv6a[0x07] != 0x0) ) exit(1); /* fail */ /* - */ memset(ipv6a, 0, sizeof(ipv6a)); ipv6a[0x10] = 0x01; if(128 != inet_net_pton(AF_INET6, ipv6net2, ipv6a, 16)) exit(1); /* fail */ /* - */ if( (ipv6a[0x0a] != 0xff) || (ipv6a[0x0b] != 0xfe) || (ipv6a[0x0c] != 0x7f) || (ipv6a[0x0f] != 0x01) || (ipv6a[0x10] != 0x01) ) exit(1); /* fail */ /* - */ if( (ipv6a[0x00] != 0x0) || (ipv6a[0x01] != 0x0) || (ipv6a[0x02] != 0x0) || (ipv6a[0x03] != 0x0) || (ipv6a[0x04] != 0x0) || (ipv6a[0x05] != 0x0) || (ipv6a[0x06] != 0x0) || (ipv6a[0x07] != 0x0) || (ipv6a[0x08] != 0x0) || (ipv6a[0x09] != 0x0) || (ipv6a[0x0d] != 0x0) || (ipv6a[0x0e] != 0x0) ) exit(1); /* fail */ /* - */ memset(ipv6a, 1, sizeof(ipv6a)); if(64 != inet_net_pton(AF_INET6, ipv6net3, ipv6a, 16)) exit(1); /* fail */ if( (ipv6a[0x00] != 0x7f) || (ipv6a[0x01] != 0x20) || (ipv6a[0x03] != 0x01) || (ipv6a[0x08] != 0x01) || (ipv6a[0x09] != 0x01) || (ipv6a[0x0a] != 0x01) || (ipv6a[0x0b] != 0x01) || (ipv6a[0x0c] != 0x01) || (ipv6a[0x0d] != 0x01) || (ipv6a[0x0e] != 0x01) || (ipv6a[0x0f] != 0x01) || (ipv6a[0x10] != 0x01) ) exit(1); /* fail */ if( (ipv6a[0x02] != 0x0) || (ipv6a[0x04] != 0x0) || (ipv6a[0x05] != 0x0) || (ipv6a[0x06] != 0x0) || (ipv6a[0x07] != 0x0) || (ipv6a[0x07] != 0x0) ) exit(1); /* fail */ /* - */ memset(ipv6a, 1, sizeof(ipv6a)); if(-1 != inet_net_pton(AF_INET6, ipv6net4, ipv6a, 16)) exit(1); /* fail */ /* - */ exit(0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_works_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_works_inet_net_pton="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # if test "$tst_compi_inet_net_pton" = "yes" && test "$tst_works_inet_net_pton" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton usage allowed" >&5 $as_echo_n "checking if inet_net_pton usage allowed... " >&6; } if test "x$cares_disallow_inet_net_pton" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_inet_net_pton="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_net_pton might be used" >&5 $as_echo_n "checking if inet_net_pton might be used... " >&6; } if test "$tst_links_inet_net_pton" = "yes" && test "$tst_proto_inet_net_pton" = "yes" && test "$tst_compi_inet_net_pton" = "yes" && test "$tst_allow_inet_net_pton" = "yes" && test "$tst_works_inet_net_pton" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_INET_NET_PTON 1 _ACEOF ac_cv_func_inet_net_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_inet_net_pton="no" fi # tst_links_inet_ntop="unknown" tst_proto_inet_ntop="unknown" tst_compi_inet_ntop="unknown" tst_works_inet_ntop="unknown" tst_allow_inet_ntop="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop can be linked" >&5 $as_echo_n "checking if inet_ntop can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inet_ntop innocuous_inet_ntop #ifdef __STDC__ # include #else # include #endif #undef inet_ntop #ifdef __cplusplus extern "C" #endif char inet_ntop (); #if defined __stub_inet_ntop || defined __stub___inet_ntop choke me #endif int main (void) { return inet_ntop (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_inet_ntop="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_inet_ntop" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop is prototyped" >&5 $as_echo_n "checking if inet_ntop is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "inet_ntop" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_inet_ntop="no" fi rm -f conftest* fi # if test "$tst_proto_inet_ntop" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop is compilable" >&5 $as_echo_n "checking if inet_ntop is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet int main (void) { if(0 != inet_ntop(0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_inet_ntop="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "x$cross_compiling" != "xyes" && test "$tst_compi_inet_ntop" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop seems to work" >&5 $as_echo_n "checking if inet_ntop seems to work... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stdlib $cares_includes_arpa_inet $cares_includes_string int main (void) { char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; char ipv4res[sizeof "255.255.255.255"]; unsigned char ipv6a[26]; unsigned char ipv4a[5]; char *ipv6ptr = 0; char *ipv4ptr = 0; /* - */ ipv4res[0] = '\0'; ipv4a[0] = 0xc0; ipv4a[1] = 0xa8; ipv4a[2] = 0x64; ipv4a[3] = 0x01; ipv4a[4] = 0x01; /* - */ ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res)); if(!ipv4ptr) exit(1); /* fail */ if(ipv4ptr != ipv4res) exit(1); /* fail */ if(!ipv4ptr[0]) exit(1); /* fail */ if(memcmp(ipv4res, "192.168.100.1", 13) != 0) exit(1); /* fail */ /* - */ ipv6res[0] = '\0'; memset(ipv6a, 0, sizeof(ipv6a)); ipv6a[0] = 0xfe; ipv6a[1] = 0x80; ipv6a[8] = 0x02; ipv6a[9] = 0x14; ipv6a[10] = 0x4f; ipv6a[11] = 0xff; ipv6a[12] = 0xfe; ipv6a[13] = 0x0b; ipv6a[14] = 0x76; ipv6a[15] = 0xc8; ipv6a[25] = 0x01; /* - */ ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res)); if(!ipv6ptr) exit(1); /* fail */ if(ipv6ptr != ipv6res) exit(1); /* fail */ if(!ipv6ptr[0]) exit(1); /* fail */ if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0) exit(1); /* fail */ /* - */ exit(0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_works_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_works_inet_ntop="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # if test "$tst_compi_inet_ntop" = "yes" && test "$tst_works_inet_ntop" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop usage allowed" >&5 $as_echo_n "checking if inet_ntop usage allowed... " >&6; } if test "x$cares_disallow_inet_ntop" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_inet_ntop="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_ntop might be used" >&5 $as_echo_n "checking if inet_ntop might be used... " >&6; } if test "$tst_links_inet_ntop" = "yes" && test "$tst_proto_inet_ntop" = "yes" && test "$tst_compi_inet_ntop" = "yes" && test "$tst_allow_inet_ntop" = "yes" && test "$tst_works_inet_ntop" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_INET_NTOP 1 _ACEOF ac_cv_func_inet_ntop="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_inet_ntop="no" fi # tst_links_inet_pton="unknown" tst_proto_inet_pton="unknown" tst_compi_inet_pton="unknown" tst_works_inet_pton="unknown" tst_allow_inet_pton="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton can be linked" >&5 $as_echo_n "checking if inet_pton can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inet_pton innocuous_inet_pton #ifdef __STDC__ # include #else # include #endif #undef inet_pton #ifdef __cplusplus extern "C" #endif char inet_pton (); #if defined __stub_inet_pton || defined __stub___inet_pton choke me #endif int main (void) { return inet_pton (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_inet_pton="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_inet_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton is prototyped" >&5 $as_echo_n "checking if inet_pton is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "inet_pton" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_inet_pton="no" fi rm -f conftest* fi # if test "$tst_proto_inet_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton is compilable" >&5 $as_echo_n "checking if inet_pton is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_arpa_inet int main (void) { if(0 != inet_pton(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_inet_pton="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "x$cross_compiling" != "xyes" && test "$tst_compi_inet_pton" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton seems to work" >&5 $as_echo_n "checking if inet_pton seems to work... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stdlib $cares_includes_arpa_inet $cares_includes_string int main (void) { unsigned char ipv6a[16+1]; unsigned char ipv4a[4+1]; const char *ipv6src = "fe80::214:4fff:fe0b:76c8"; const char *ipv4src = "192.168.100.1"; /* - */ memset(ipv4a, 1, sizeof(ipv4a)); if(1 != inet_pton(AF_INET, ipv4src, ipv4a)) exit(1); /* fail */ /* - */ if( (ipv4a[0] != 0xc0) || (ipv4a[1] != 0xa8) || (ipv4a[2] != 0x64) || (ipv4a[3] != 0x01) || (ipv4a[4] != 0x01) ) exit(1); /* fail */ /* - */ memset(ipv6a, 1, sizeof(ipv6a)); if(1 != inet_pton(AF_INET6, ipv6src, ipv6a)) exit(1); /* fail */ /* - */ if( (ipv6a[0] != 0xfe) || (ipv6a[1] != 0x80) || (ipv6a[8] != 0x02) || (ipv6a[9] != 0x14) || (ipv6a[10] != 0x4f) || (ipv6a[11] != 0xff) || (ipv6a[12] != 0xfe) || (ipv6a[13] != 0x0b) || (ipv6a[14] != 0x76) || (ipv6a[15] != 0xc8) || (ipv6a[16] != 0x01) ) exit(1); /* fail */ /* - */ if( (ipv6a[2] != 0x0) || (ipv6a[3] != 0x0) || (ipv6a[4] != 0x0) || (ipv6a[5] != 0x0) || (ipv6a[6] != 0x0) || (ipv6a[7] != 0x0) ) exit(1); /* fail */ /* - */ exit(0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_works_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_works_inet_pton="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # if test "$tst_compi_inet_pton" = "yes" && test "$tst_works_inet_pton" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton usage allowed" >&5 $as_echo_n "checking if inet_pton usage allowed... " >&6; } if test "x$cares_disallow_inet_pton" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_inet_pton="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if inet_pton might be used" >&5 $as_echo_n "checking if inet_pton might be used... " >&6; } if test "$tst_links_inet_pton" = "yes" && test "$tst_proto_inet_pton" = "yes" && test "$tst_compi_inet_pton" = "yes" && test "$tst_allow_inet_pton" = "yes" && test "$tst_works_inet_pton" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_INET_PTON 1 _ACEOF ac_cv_func_inet_pton="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_inet_pton="no" fi cares_includes_stropts="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_STROPTS_H # include #endif /* includes end */" for ac_header in sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_stropts " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_ioctl="unknown" tst_proto_ioctl="unknown" tst_compi_ioctl="unknown" tst_allow_ioctl="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl can be linked" >&5 $as_echo_n "checking if ioctl can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define ioctl innocuous_ioctl #ifdef __STDC__ # include #else # include #endif #undef ioctl #ifdef __cplusplus extern "C" #endif char ioctl (); #if defined __stub_ioctl || defined __stub___ioctl choke me #endif int main (void) { return ioctl (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_ioctl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_ioctl="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl is prototyped" >&5 $as_echo_n "checking if ioctl is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "ioctl" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_ioctl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_ioctl="no" fi rm -f conftest* fi # if test "$tst_proto_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl is compilable" >&5 $as_echo_n "checking if ioctl is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts int main (void) { if(0 != ioctl(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctl="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl usage allowed" >&5 $as_echo_n "checking if ioctl usage allowed... " >&6; } if test "x$cares_disallow_ioctl" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctl="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctl="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl might be used" >&5 $as_echo_n "checking if ioctl might be used... " >&6; } if test "$tst_links_ioctl" = "yes" && test "$tst_proto_ioctl" = "yes" && test "$tst_compi_ioctl" = "yes" && test "$tst_allow_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTL 1 _ACEOF ac_cv_func_ioctl="yes" # tst_compi_ioctl_fionbio="unknown" tst_allow_ioctl_fionbio="unknown" # if test "$ac_cv_func_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl FIONBIO is compilable" >&5 $as_echo_n "checking if ioctl FIONBIO is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts int main (void) { int flags = 0; if(0 != ioctl(0, FIONBIO, &flags)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctl_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctl_fionbio="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctl_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl FIONBIO usage allowed" >&5 $as_echo_n "checking if ioctl FIONBIO usage allowed... " >&6; } if test "x$cares_disallow_ioctl_fionbio" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctl_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctl_fionbio="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl FIONBIO might be used" >&5 $as_echo_n "checking if ioctl FIONBIO might be used... " >&6; } if test "$tst_compi_ioctl_fionbio" = "yes" && test "$tst_allow_ioctl_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTL_FIONBIO 1 _ACEOF ac_cv_func_ioctl_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctl_fionbio="no" fi # tst_compi_ioctl_siocgifaddr="unknown" tst_allow_ioctl_siocgifaddr="unknown" # if test "$ac_cv_func_ioctl" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl SIOCGIFADDR is compilable" >&5 $as_echo_n "checking if ioctl SIOCGIFADDR is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts #include int main (void) { struct ifreq ifr; if(0 != ioctl(0, SIOCGIFADDR, &ifr)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctl_siocgifaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctl_siocgifaddr="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl SIOCGIFADDR usage allowed" >&5 $as_echo_n "checking if ioctl SIOCGIFADDR usage allowed... " >&6; } if test "x$cares_disallow_ioctl_siocgifaddr" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctl_siocgifaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctl_siocgifaddr="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctl SIOCGIFADDR might be used" >&5 $as_echo_n "checking if ioctl SIOCGIFADDR might be used... " >&6; } if test "$tst_compi_ioctl_siocgifaddr" = "yes" && test "$tst_allow_ioctl_siocgifaddr" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTL_SIOCGIFADDR 1 _ACEOF ac_cv_func_ioctl_siocgifaddr="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctl_siocgifaddr="no" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctl="no" fi # tst_links_ioctlsocket="unknown" tst_proto_ioctlsocket="unknown" tst_compi_ioctlsocket="unknown" tst_allow_ioctlsocket="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket can be linked" >&5 $as_echo_n "checking if ioctlsocket can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 int main (void) { if(0 != ioctlsocket(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_ioctlsocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_ioctlsocket="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_ioctlsocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket is prototyped" >&5 $as_echo_n "checking if ioctlsocket is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "ioctlsocket" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_ioctlsocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_ioctlsocket="no" fi rm -f conftest* fi # if test "$tst_proto_ioctlsocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket is compilable" >&5 $as_echo_n "checking if ioctlsocket is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 int main (void) { if(0 != ioctlsocket(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctlsocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctlsocket="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctlsocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket usage allowed" >&5 $as_echo_n "checking if ioctlsocket usage allowed... " >&6; } if test "x$cares_disallow_ioctlsocket" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctlsocket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctlsocket="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket might be used" >&5 $as_echo_n "checking if ioctlsocket might be used... " >&6; } if test "$tst_links_ioctlsocket" = "yes" && test "$tst_proto_ioctlsocket" = "yes" && test "$tst_compi_ioctlsocket" = "yes" && test "$tst_allow_ioctlsocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTLSOCKET 1 _ACEOF ac_cv_func_ioctlsocket="yes" # tst_compi_ioctlsocket_fionbio="unknown" tst_allow_ioctlsocket_fionbio="unknown" # if test "$ac_cv_func_ioctlsocket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket FIONBIO is compilable" >&5 $as_echo_n "checking if ioctlsocket FIONBIO is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 int main (void) { int flags = 0; if(0 != ioctlsocket(0, FIONBIO, &flags)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctlsocket_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctlsocket_fionbio="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket FIONBIO usage allowed" >&5 $as_echo_n "checking if ioctlsocket FIONBIO usage allowed... " >&6; } if test "x$cares_disallow_ioctlsocket_fionbio" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctlsocket_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctlsocket_fionbio="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ioctlsocket FIONBIO might be used" >&5 $as_echo_n "checking if ioctlsocket FIONBIO might be used... " >&6; } if test "$tst_compi_ioctlsocket_fionbio" = "yes" && test "$tst_allow_ioctlsocket_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTLSOCKET_FIONBIO 1 _ACEOF ac_cv_func_ioctlsocket_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctlsocket_fionbio="no" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctlsocket="no" fi # tst_links_ioctlsocket_camel="unknown" tst_proto_ioctlsocket_camel="unknown" tst_compi_ioctlsocket_camel="unknown" tst_allow_ioctlsocket_camel="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket can be linked" >&5 $as_echo_n "checking if IoctlSocket can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define IoctlSocket innocuous_IoctlSocket #ifdef __STDC__ # include #else # include #endif #undef IoctlSocket #ifdef __cplusplus extern "C" #endif char IoctlSocket (); #if defined __stub_IoctlSocket || defined __stub___IoctlSocket choke me #endif int main (void) { return IoctlSocket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_ioctlsocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_ioctlsocket_camel="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_ioctlsocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket is prototyped" >&5 $as_echo_n "checking if IoctlSocket is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "IoctlSocket" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_ioctlsocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_ioctlsocket_camel="no" fi rm -f conftest* fi # if test "$tst_proto_ioctlsocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket is compilable" >&5 $as_echo_n "checking if IoctlSocket is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts int main (void) { if(0 != IoctlSocket(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctlsocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctlsocket_camel="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctlsocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket usage allowed" >&5 $as_echo_n "checking if IoctlSocket usage allowed... " >&6; } if test "x$cares_disallow_ioctlsocket_camel" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctlsocket_camel="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctlsocket_camel="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket might be used" >&5 $as_echo_n "checking if IoctlSocket might be used... " >&6; } if test "$tst_links_ioctlsocket_camel" = "yes" && test "$tst_proto_ioctlsocket_camel" = "yes" && test "$tst_compi_ioctlsocket_camel" = "yes" && test "$tst_allow_ioctlsocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTLSOCKET_CAMEL 1 _ACEOF ac_cv_func_ioctlsocket_camel="yes" # tst_compi_ioctlsocket_camel_fionbio="unknown" tst_allow_ioctlsocket_camel_fionbio="unknown" # if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket FIONBIO is compilable" >&5 $as_echo_n "checking if IoctlSocket FIONBIO is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_stropts int main (void) { long flags = 0; if(0 != ioctlsocket(0, FIONBIO, &flags)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_ioctlsocket_camel_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_ioctlsocket_camel_fionbio="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket FIONBIO usage allowed" >&5 $as_echo_n "checking if IoctlSocket FIONBIO usage allowed... " >&6; } if test "x$cares_disallow_ioctlsocket_camel_fionbio" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_ioctlsocket_camel_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_ioctlsocket_camel_fionbio="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if IoctlSocket FIONBIO might be used" >&5 $as_echo_n "checking if IoctlSocket FIONBIO might be used... " >&6; } if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" && test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1 _ACEOF ac_cv_func_ioctlsocket_camel_fionbio="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctlsocket_camel_fionbio="no" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_ioctlsocket_camel="no" fi # tst_links_setsockopt="unknown" tst_proto_setsockopt="unknown" tst_compi_setsockopt="unknown" tst_allow_setsockopt="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt can be linked" >&5 $as_echo_n "checking if setsockopt can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket int main (void) { if(0 != setsockopt(0, 0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_setsockopt="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_setsockopt="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_setsockopt" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt is prototyped" >&5 $as_echo_n "checking if setsockopt is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "setsockopt" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_setsockopt="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_setsockopt="no" fi rm -f conftest* fi # if test "$tst_proto_setsockopt" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt is compilable" >&5 $as_echo_n "checking if setsockopt is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket int main (void) { if(0 != setsockopt(0, 0, 0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_setsockopt="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_setsockopt="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_setsockopt" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt usage allowed" >&5 $as_echo_n "checking if setsockopt usage allowed... " >&6; } if test "x$cares_disallow_setsockopt" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_setsockopt="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_setsockopt="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt might be used" >&5 $as_echo_n "checking if setsockopt might be used... " >&6; } if test "$tst_links_setsockopt" = "yes" && test "$tst_proto_setsockopt" = "yes" && test "$tst_compi_setsockopt" = "yes" && test "$tst_allow_setsockopt" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_SETSOCKOPT 1 _ACEOF ac_cv_func_setsockopt="yes" # tst_compi_setsockopt_so_nonblock="unknown" tst_allow_setsockopt_so_nonblock="unknown" # if test "$ac_cv_func_setsockopt" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt SO_NONBLOCK is compilable" >&5 $as_echo_n "checking if setsockopt SO_NONBLOCK is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket int main (void) { if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_setsockopt_so_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_setsockopt_so_nonblock="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt SO_NONBLOCK usage allowed" >&5 $as_echo_n "checking if setsockopt SO_NONBLOCK usage allowed... " >&6; } if test "x$cares_disallow_setsockopt_so_nonblock" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_setsockopt_so_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_setsockopt_so_nonblock="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if setsockopt SO_NONBLOCK might be used" >&5 $as_echo_n "checking if setsockopt SO_NONBLOCK might be used... " >&6; } if test "$tst_compi_setsockopt_so_nonblock" = "yes" && test "$tst_allow_setsockopt_so_nonblock" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_SETSOCKOPT_SO_NONBLOCK 1 _ACEOF ac_cv_func_setsockopt_so_nonblock="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_setsockopt_so_nonblock="no" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_setsockopt="no" fi # tst_links_socket="unknown" tst_proto_socket="unknown" tst_compi_socket="unknown" tst_allow_socket="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if socket can be linked" >&5 $as_echo_n "checking if socket can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket int main (void) { if(0 != socket(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_socket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_socket="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_socket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if socket is prototyped" >&5 $as_echo_n "checking if socket is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "socket" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_socket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_socket="no" fi rm -f conftest* fi # if test "$tst_proto_socket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if socket is compilable" >&5 $as_echo_n "checking if socket is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_winsock2 $cares_includes_sys_socket $cares_includes_socket int main (void) { if(0 != socket(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_socket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_socket="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_socket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if socket usage allowed" >&5 $as_echo_n "checking if socket usage allowed... " >&6; } if test "x$cares_disallow_socket" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_socket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_socket="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if socket might be used" >&5 $as_echo_n "checking if socket might be used... " >&6; } if test "$tst_links_socket" = "yes" && test "$tst_proto_socket" = "yes" && test "$tst_compi_socket" = "yes" && test "$tst_allow_socket" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_SOCKET 1 _ACEOF ac_cv_func_socket="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_socket="no" fi # tst_links_strcasecmp="unknown" tst_proto_strcasecmp="unknown" tst_compi_strcasecmp="unknown" tst_allow_strcasecmp="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcasecmp can be linked" >&5 $as_echo_n "checking if strcasecmp can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strcasecmp innocuous_strcasecmp #ifdef __STDC__ # include #else # include #endif #undef strcasecmp #ifdef __cplusplus extern "C" #endif char strcasecmp (); #if defined __stub_strcasecmp || defined __stub___strcasecmp choke me #endif int main (void) { return strcasecmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strcasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strcasecmp="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strcasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcasecmp is prototyped" >&5 $as_echo_n "checking if strcasecmp is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strcasecmp" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strcasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strcasecmp="no" fi rm -f conftest* fi # if test "$tst_proto_strcasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcasecmp is compilable" >&5 $as_echo_n "checking if strcasecmp is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strcasecmp(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strcasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strcasecmp="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strcasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcasecmp usage allowed" >&5 $as_echo_n "checking if strcasecmp usage allowed... " >&6; } if test "x$cares_disallow_strcasecmp" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strcasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strcasecmp="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcasecmp might be used" >&5 $as_echo_n "checking if strcasecmp might be used... " >&6; } if test "$tst_links_strcasecmp" = "yes" && test "$tst_proto_strcasecmp" = "yes" && test "$tst_compi_strcasecmp" = "yes" && test "$tst_allow_strcasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRCASECMP 1 _ACEOF ac_cv_func_strcasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strcasecmp="no" fi # tst_links_strcmpi="unknown" tst_proto_strcmpi="unknown" tst_compi_strcmpi="unknown" tst_allow_strcmpi="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcmpi can be linked" >&5 $as_echo_n "checking if strcmpi can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strcmpi innocuous_strcmpi #ifdef __STDC__ # include #else # include #endif #undef strcmpi #ifdef __cplusplus extern "C" #endif char strcmpi (); #if defined __stub_strcmpi || defined __stub___strcmpi choke me #endif int main (void) { return strcmpi (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strcmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strcmpi="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strcmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcmpi is prototyped" >&5 $as_echo_n "checking if strcmpi is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strcmpi" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strcmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strcmpi="no" fi rm -f conftest* fi # if test "$tst_proto_strcmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcmpi is compilable" >&5 $as_echo_n "checking if strcmpi is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strcmpi(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strcmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strcmpi="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strcmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcmpi usage allowed" >&5 $as_echo_n "checking if strcmpi usage allowed... " >&6; } if test "x$cares_disallow_strcmpi" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strcmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strcmpi="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strcmpi might be used" >&5 $as_echo_n "checking if strcmpi might be used... " >&6; } if test "$tst_links_strcmpi" = "yes" && test "$tst_proto_strcmpi" = "yes" && test "$tst_compi_strcmpi" = "yes" && test "$tst_allow_strcmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRCMPI 1 _ACEOF ac_cv_func_strcmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strcmpi="no" fi # tst_links_strdup="unknown" tst_proto_strdup="unknown" tst_compi_strdup="unknown" tst_allow_strdup="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strdup can be linked" >&5 $as_echo_n "checking if strdup can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strdup innocuous_strdup #ifdef __STDC__ # include #else # include #endif #undef strdup #ifdef __cplusplus extern "C" #endif char strdup (); #if defined __stub_strdup || defined __stub___strdup choke me #endif int main (void) { return strdup (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strdup="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strdup="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strdup" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strdup is prototyped" >&5 $as_echo_n "checking if strdup is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strdup" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strdup="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strdup="no" fi rm -f conftest* fi # if test "$tst_proto_strdup" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strdup is compilable" >&5 $as_echo_n "checking if strdup is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strdup(0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strdup="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strdup="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strdup" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strdup usage allowed" >&5 $as_echo_n "checking if strdup usage allowed... " >&6; } if test "x$cares_disallow_strdup" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strdup="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strdup="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strdup might be used" >&5 $as_echo_n "checking if strdup might be used... " >&6; } if test "$tst_links_strdup" = "yes" && test "$tst_proto_strdup" = "yes" && test "$tst_compi_strdup" = "yes" && test "$tst_allow_strdup" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRDUP 1 _ACEOF ac_cv_func_strdup="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strdup="no" fi # tst_links_stricmp="unknown" tst_proto_stricmp="unknown" tst_compi_stricmp="unknown" tst_allow_stricmp="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if stricmp can be linked" >&5 $as_echo_n "checking if stricmp can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define stricmp innocuous_stricmp #ifdef __STDC__ # include #else # include #endif #undef stricmp #ifdef __cplusplus extern "C" #endif char stricmp (); #if defined __stub_stricmp || defined __stub___stricmp choke me #endif int main (void) { return stricmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_stricmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_stricmp="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_stricmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if stricmp is prototyped" >&5 $as_echo_n "checking if stricmp is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "stricmp" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_stricmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_stricmp="no" fi rm -f conftest* fi # if test "$tst_proto_stricmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if stricmp is compilable" >&5 $as_echo_n "checking if stricmp is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != stricmp(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_stricmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_stricmp="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_stricmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if stricmp usage allowed" >&5 $as_echo_n "checking if stricmp usage allowed... " >&6; } if test "x$cares_disallow_stricmp" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_stricmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_stricmp="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if stricmp might be used" >&5 $as_echo_n "checking if stricmp might be used... " >&6; } if test "$tst_links_stricmp" = "yes" && test "$tst_proto_stricmp" = "yes" && test "$tst_compi_stricmp" = "yes" && test "$tst_allow_stricmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRICMP 1 _ACEOF ac_cv_func_stricmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_stricmp="no" fi # tst_links_strncasecmp="unknown" tst_proto_strncasecmp="unknown" tst_compi_strncasecmp="unknown" tst_allow_strncasecmp="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncasecmp can be linked" >&5 $as_echo_n "checking if strncasecmp can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strncasecmp innocuous_strncasecmp #ifdef __STDC__ # include #else # include #endif #undef strncasecmp #ifdef __cplusplus extern "C" #endif char strncasecmp (); #if defined __stub_strncasecmp || defined __stub___strncasecmp choke me #endif int main (void) { return strncasecmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strncasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strncasecmp="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strncasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncasecmp is prototyped" >&5 $as_echo_n "checking if strncasecmp is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strncasecmp" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strncasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strncasecmp="no" fi rm -f conftest* fi # if test "$tst_proto_strncasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncasecmp is compilable" >&5 $as_echo_n "checking if strncasecmp is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strncasecmp(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strncasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strncasecmp="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strncasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncasecmp usage allowed" >&5 $as_echo_n "checking if strncasecmp usage allowed... " >&6; } if test "x$cares_disallow_strncasecmp" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strncasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strncasecmp="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncasecmp might be used" >&5 $as_echo_n "checking if strncasecmp might be used... " >&6; } if test "$tst_links_strncasecmp" = "yes" && test "$tst_proto_strncasecmp" = "yes" && test "$tst_compi_strncasecmp" = "yes" && test "$tst_allow_strncasecmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRNCASECMP 1 _ACEOF ac_cv_func_strncasecmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strncasecmp="no" fi # tst_links_strncmpi="unknown" tst_proto_strncmpi="unknown" tst_compi_strncmpi="unknown" tst_allow_strncmpi="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncmpi can be linked" >&5 $as_echo_n "checking if strncmpi can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strncmpi innocuous_strncmpi #ifdef __STDC__ # include #else # include #endif #undef strncmpi #ifdef __cplusplus extern "C" #endif char strncmpi (); #if defined __stub_strncmpi || defined __stub___strncmpi choke me #endif int main (void) { return strncmpi (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strncmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strncmpi="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strncmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncmpi is prototyped" >&5 $as_echo_n "checking if strncmpi is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strncmpi" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strncmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strncmpi="no" fi rm -f conftest* fi # if test "$tst_proto_strncmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncmpi is compilable" >&5 $as_echo_n "checking if strncmpi is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strncmpi(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strncmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strncmpi="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strncmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncmpi usage allowed" >&5 $as_echo_n "checking if strncmpi usage allowed... " >&6; } if test "x$cares_disallow_strncmpi" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strncmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strncmpi="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strncmpi might be used" >&5 $as_echo_n "checking if strncmpi might be used... " >&6; } if test "$tst_links_strncmpi" = "yes" && test "$tst_proto_strncmpi" = "yes" && test "$tst_compi_strncmpi" = "yes" && test "$tst_allow_strncmpi" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRNCMPI 1 _ACEOF ac_cv_func_strncmpi="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strncmpi="no" fi # tst_links_strnicmp="unknown" tst_proto_strnicmp="unknown" tst_compi_strnicmp="unknown" tst_allow_strnicmp="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strnicmp can be linked" >&5 $as_echo_n "checking if strnicmp can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define strnicmp innocuous_strnicmp #ifdef __STDC__ # include #else # include #endif #undef strnicmp #ifdef __cplusplus extern "C" #endif char strnicmp (); #if defined __stub_strnicmp || defined __stub___strnicmp choke me #endif int main (void) { return strnicmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_strnicmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_strnicmp="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_strnicmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strnicmp is prototyped" >&5 $as_echo_n "checking if strnicmp is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "strnicmp" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_strnicmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_strnicmp="no" fi rm -f conftest* fi # if test "$tst_proto_strnicmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strnicmp is compilable" >&5 $as_echo_n "checking if strnicmp is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_string int main (void) { if(0 != strnicmp(0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_strnicmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_strnicmp="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_strnicmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strnicmp usage allowed" >&5 $as_echo_n "checking if strnicmp usage allowed... " >&6; } if test "x$cares_disallow_strnicmp" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_strnicmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_strnicmp="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strnicmp might be used" >&5 $as_echo_n "checking if strnicmp might be used... " >&6; } if test "$tst_links_strnicmp" = "yes" && test "$tst_proto_strnicmp" = "yes" && test "$tst_compi_strnicmp" = "yes" && test "$tst_allow_strnicmp" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRNICMP 1 _ACEOF ac_cv_func_strnicmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_strnicmp="no" fi cares_includes_sys_uio="\ /* includes start */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_UIO_H # include #endif /* includes end */" for ac_header in sys/types.h sys/uio.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$cares_includes_sys_uio " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # tst_links_writev="unknown" tst_proto_writev="unknown" tst_compi_writev="unknown" tst_allow_writev="unknown" # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if writev can be linked" >&5 $as_echo_n "checking if writev can be linked... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define writev innocuous_writev #ifdef __STDC__ # include #else # include #endif #undef writev #ifdef __cplusplus extern "C" #endif char writev (); #if defined __stub_writev || defined __stub___writev choke me #endif int main (void) { return writev (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_links_writev="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_links_writev="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$tst_links_writev" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if writev is prototyped" >&5 $as_echo_n "checking if writev is prototyped... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_uio _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "writev" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_proto_writev="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_proto_writev="no" fi rm -f conftest* fi # if test "$tst_proto_writev" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if writev is compilable" >&5 $as_echo_n "checking if writev is compilable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $cares_includes_sys_uio int main (void) { if(0 != writev(0, 0, 0)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_compi_writev="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_compi_writev="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # if test "$tst_compi_writev" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if writev usage allowed" >&5 $as_echo_n "checking if writev usage allowed... " >&6; } if test "x$cares_disallow_writev" != "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } tst_allow_writev="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } tst_allow_writev="no" fi fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking if writev might be used" >&5 $as_echo_n "checking if writev might be used... " >&6; } if test "$tst_links_writev" = "yes" && test "$tst_proto_writev" = "yes" && test "$tst_compi_writev" = "yes" && test "$tst_allow_writev" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_WRITEV 1 _ACEOF ac_cv_func_writev="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_cv_func_writev="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PF_INET6" >&5 $as_echo_n "checking for PF_INET6... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif #ifdef PF_INET6 VARIABLEWASDEFINED #else NJET #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "VARIABLEWASDEFINED" >/dev/null 2>&1; then : ac_constant="yes" else ac_constant="no" fi rm -f conftest* if test "$ac_constant" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_PF_INET6 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AF_INET6" >&5 $as_echo_n "checking for AF_INET6... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #endif #ifdef AF_INET6 VARIABLEWASDEFINED #else NJET #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "VARIABLEWASDEFINED" >/dev/null 2>&1; then : ac_constant="yes" else ac_constant="no" fi rm -f conftest* if test "$ac_constant" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_AF_INET6 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct in6_addr" >&5 $as_echo_n "checking for struct in6_addr... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #endif int main (void) { struct in6_addr struct_instance; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_struct="yes" else ac_found="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ac_struct" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_IN6_ADDR 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct sockaddr_in6" >&5 $as_echo_n "checking for struct sockaddr_in6... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #endif int main (void) { struct sockaddr_in6 struct_instance; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_struct="yes" else ac_found="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ac_struct" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_IN6 1 _ACEOF ac_have_sockaddr_in6=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ac_fn_c_check_member "$LINENO" "struct sockaddr_in6" "sin6_scope_id" "ac_cv_member_struct_sockaddr_in6_sin6_scope_id" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #endif " if test "x$ac_cv_member_struct_sockaddr_in6_sin6_scope_id" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 _ACEOF fi ac_fn_c_check_member "$LINENO" "struct addrinfo" "ai_flags" "ac_cv_member_struct_addrinfo_ai_flags" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #endif " if test "x$ac_cv_member_struct_addrinfo_ai_flags" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_ADDRINFO 1 _ACEOF fi for ac_func in bitncmp \ gettimeofday \ if_indextoname do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else func="$ac_func" { $as_echo "$as_me:${as_lineno-$LINENO}: checking deeper for $func" >&5 $as_echo_n "checking deeper for $func... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { $func (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } eval "ac_cv_func_$func=yes" cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$func" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | sed 's/^A-Z0-9_/_/g'` 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: but still no" >&5 $as_echo "but still no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi done # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct in6_addr" >&5 $as_echo_n "checking size of struct in6_addr... " >&6; } if ${ac_cv_sizeof_struct_in6_addr+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct in6_addr))" "ac_cv_sizeof_struct_in6_addr" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #endif "; then : else if test "$ac_cv_type_struct_in6_addr" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (struct in6_addr) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_struct_in6_addr=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_in6_addr" >&5 $as_echo "$ac_cv_sizeof_struct_in6_addr" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_STRUCT_IN6_ADDR $ac_cv_sizeof_struct_in6_addr _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct in_addr" >&5 $as_echo_n "checking size of struct in_addr... " >&6; } if ${ac_cv_sizeof_struct_in_addr+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct in_addr))" "ac_cv_sizeof_struct_in_addr" " #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #endif "; then : else if test "$ac_cv_type_struct_in_addr" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (struct in_addr) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_struct_in_addr=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_in_addr" >&5 $as_echo "$ac_cv_sizeof_struct_in_addr" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_STRUCT_IN_ADDR $ac_cv_sizeof_struct_in_addr _ACEOF for ac_header in sys/types.h sys/socket.h netdb.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getnameinfo" >&5 $as_echo_n "checking for getnameinfo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define getnameinfo innocuous_getnameinfo #ifdef __STDC__ # include #else # include #endif #undef getnameinfo #ifdef __cplusplus extern "C" #endif char getnameinfo (); #if defined __stub_getnameinfo || defined __stub___getnameinfo choke me #endif int main (void) { return getnameinfo (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_getnameinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } curl_cv_getnameinfo="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # if test "$curl_cv_getnameinfo" != "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking deeper for getnameinfo" >&5 $as_echo_n "checking deeper for getnameinfo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { getnameinfo(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_getnameinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: but still no" >&5 $as_echo "but still no" >&6; } curl_cv_getnameinfo="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # if test "$curl_cv_getnameinfo" != "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking deeper and deeper for getnameinfo" >&5 $as_echo_n "checking deeper and deeper for getnameinfo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #endif int main (void) { getnameinfo(0, 0, 0, 0, 0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } curl_cv_getnameinfo="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: but still no" >&5 $as_echo "but still no" >&6; } curl_cv_getnameinfo="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # if test "$curl_cv_getnameinfo" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for getnameinfo" >&5 $as_echo_n "checking types of arguments for getnameinfo... " >&6; } if ${curl_cv_func_getnameinfo_args+:} false; then : $as_echo_n "(cached) " >&6 else curl_cv_func_getnameinfo_args="unknown" for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do for gni_arg2 in 'socklen_t' 'size_t' 'int'; do for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do for gni_arg7 in 'int' 'unsigned int'; do if test "$curl_cv_func_getnameinfo_args" = "unknown"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef inline #ifdef HAVE_WINDOWS_H #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif #include #ifdef HAVE_WINSOCK2_H #include #ifdef HAVE_WS2TCPIP_H #include #endif #endif #define GNICALLCONV WSAAPI #else #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #define GNICALLCONV #endif extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, char *, $gni_arg46, char *, $gni_arg46, $gni_arg7); int main (void) { $gni_arg2 salen=0; $gni_arg46 hostlen=0; $gni_arg46 servlen=0; $gni_arg7 flags=0; int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi done done done done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $curl_cv_func_getnameinfo_args" >&5 $as_echo "$curl_cv_func_getnameinfo_args" >&6; } # AC-CACHE-CHECK if test "$curl_cv_func_getnameinfo_args" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find proper types to use for getnameinfo args" >&5 $as_echo "$as_me: WARNING: Cannot find proper types to use for getnameinfo args" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: HAVE_GETNAMEINFO will not be defined" >&5 $as_echo "$as_me: WARNING: HAVE_GETNAMEINFO will not be defined" >&2;} else gni_prev_IFS=$IFS; IFS=',' set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` IFS=$gni_prev_IFS shift # gni_qual_type_arg1=$1 # cat >>confdefs.h <<_ACEOF #define GETNAMEINFO_TYPE_ARG2 $2 _ACEOF cat >>confdefs.h <<_ACEOF #define GETNAMEINFO_TYPE_ARG46 $3 _ACEOF cat >>confdefs.h <<_ACEOF #define GETNAMEINFO_TYPE_ARG7 $4 _ACEOF # prev_sh_opts=$- # case $prev_sh_opts in *f*) ;; *) set -f ;; esac # case "$gni_qual_type_arg1" in const*) gni_qual_arg1=const gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'` ;; *) gni_qual_arg1= gni_type_arg1=$gni_qual_type_arg1 ;; esac # cat >>confdefs.h <<_ACEOF #define GETNAMEINFO_QUAL_ARG1 $gni_qual_arg1 _ACEOF cat >>confdefs.h <<_ACEOF #define GETNAMEINFO_TYPE_ARG1 $gni_type_arg1 _ACEOF # case $prev_sh_opts in *f*) ;; *) set +f ;; esac # cat >>confdefs.h <<_ACEOF #define HAVE_GETNAMEINFO 1 _ACEOF ac_cv_func_getnameinfo="yes" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main (void) { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main (void) { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define ARES_BIG_ENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: couldn't figure out endianess, assuming little endian!" >&5 $as_echo "$as_me: WARNING: couldn't figure out endianess, assuming little endian!" >&2;} ;; esac # Check whether --with-random was given. if test "${with_random+set}" = set; then : withval=$with_random; RANDOM_FILE="$withval" else if test "$cross_compiling" = "no"; then as_ac_File=`$as_echo "ac_cv_file_"/dev/urandom"" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/dev/urandom\"" >&5 $as_echo_n "checking for \"/dev/urandom\"... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r ""/dev/urandom""; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : RANDOM_FILE="/dev/urandom" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for /dev/urandom while cross compiling; assuming none" >&5 $as_echo "$as_me: WARNING: cannot check for /dev/urandom while cross compiling; assuming none" >&2;} fi fi if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then cat >>confdefs.h <<_ACEOF #define RANDOM_FILE "$RANDOM_FILE" _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable non-blocking communications" >&5 $as_echo_n "checking whether to enable non-blocking communications... " >&6; } OPT_NONBLOCKING="default" # Check whether --enable-nonblocking was given. if test "${enable_nonblocking+set}" = set; then : enableval=$enable_nonblocking; OPT_NONBLOCKING=$enableval fi case "$OPT_NONBLOCKING" in no) want_nonblocking="no" ;; default) want_nonblocking="yes" ;; *) want_nonblocking="yes" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $want_nonblocking" >&5 $as_echo "$want_nonblocking" >&6; } # tst_method="unknown" if test "$want_nonblocking" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to set a socket into non-blocking mode" >&5 $as_echo_n "checking how to set a socket into non-blocking mode... " >&6; } if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then tst_method="fcntl O_NONBLOCK" elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then tst_method="ioctl FIONBIO" elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then tst_method="ioctlsocket FIONBIO" elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then tst_method="IoctlSocket FIONBIO" elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then tst_method="setsockopt SO_NONBLOCK" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tst_method" >&5 $as_echo "$tst_method" >&6; } if test "$tst_method" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine non-blocking socket method." >&5 $as_echo "$as_me: WARNING: cannot determine non-blocking socket method." >&2;} fi fi if test "$tst_method" = "unknown"; then cat >>confdefs.h <<_ACEOF #define USE_BLOCKING_SOCKETS 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: non-blocking sockets disabled." >&5 $as_echo "$as_me: WARNING: non-blocking sockets disabled." >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether hiding of library internal symbols will actually happen" >&5 $as_echo_n "checking whether hiding of library internal symbols will actually happen... " >&6; } CFLAG_CARES_SYMBOL_HIDING="" doing_symbol_hiding="no" if test x"$ac_cv_native_windows" != "xyes" && test "$want_symbol_hiding" = "yes" && test "$supports_symbol_hiding" = "yes"; then doing_symbol_hiding="yes" CFLAG_CARES_SYMBOL_HIDING="$symbol_hiding_CFLAGS" cat >>confdefs.h <<_ACEOF #define CARES_SYMBOL_SCOPE_EXTERN $symbol_hiding_EXTERN _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x$doing_symbol_hiding = xyes; then DOING_CARES_SYMBOL_HIDING_TRUE= DOING_CARES_SYMBOL_HIDING_FALSE='#' else DOING_CARES_SYMBOL_HIDING_TRUE='#' DOING_CARES_SYMBOL_HIDING_FALSE= fi CARES_PRIVATE_LIBS="$LIBS" CARES_CFLAG_EXTRAS="" if test X"$want_werror" = Xyes; then CARES_CFLAG_EXTRAS="-Werror" fi squeeze CFLAGS squeeze CPPFLAGS squeeze DEFS squeeze LDFLAGS squeeze LIBS squeeze CARES_PRIVATE_LIBS xc_bad_var_libs=no for xc_word in $LIBS; do case "$xc_word" in -l* | --library=*) : ;; *) xc_bad_var_libs=yes ;; esac done if test $xc_bad_var_libs = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using LIBS: $LIBS" >&5 $as_echo "$as_me: using LIBS: $LIBS" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: LIBS error: LIBS may only be used to specify libraries (-lname)." >&5 $as_echo "$as_me: LIBS error: LIBS may only be used to specify libraries (-lname)." >&6;} fi xc_bad_var_ldflags=no for xc_word in $LDFLAGS; do case "$xc_word" in -D*) xc_bad_var_ldflags=yes ;; -U*) xc_bad_var_ldflags=yes ;; -I*) xc_bad_var_ldflags=yes ;; -l* | --library=*) xc_bad_var_ldflags=yes ;; esac done if test $xc_bad_var_ldflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using LDFLAGS: $LDFLAGS" >&5 $as_echo "$as_me: using LDFLAGS: $LDFLAGS" >&6;} xc_bad_var_msg="LDFLAGS error: LDFLAGS may only be used to specify linker flags, not" for xc_word in $LDFLAGS; do case "$xc_word" in -D*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&6;} ;; -U*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&6;} ;; -I*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi xc_bad_var_cppflags=no for xc_word in $CPPFLAGS; do case "$xc_word" in -rpath*) xc_bad_var_cppflags=yes ;; -L* | --library-path=*) xc_bad_var_cppflags=yes ;; -l* | --library=*) xc_bad_var_cppflags=yes ;; esac done if test $xc_bad_var_cppflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using CPPFLAGS: $CPPFLAGS" >&5 $as_echo "$as_me: using CPPFLAGS: $CPPFLAGS" >&6;} xc_bad_var_msg="CPPFLAGS error: CPPFLAGS may only be used to specify C preprocessor flags, not" for xc_word in $CPPFLAGS; do case "$xc_word" in -rpath*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&6;} ;; -L* | --library-path=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi xc_bad_var_cflags=no for xc_word in $CFLAGS; do case "$xc_word" in -D*) xc_bad_var_cflags=yes ;; -U*) xc_bad_var_cflags=yes ;; -I*) xc_bad_var_cflags=yes ;; -rpath*) xc_bad_var_cflags=yes ;; -L* | --library-path=*) xc_bad_var_cflags=yes ;; -l* | --library=*) xc_bad_var_cflags=yes ;; esac done if test $xc_bad_var_cflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: using CFLAGS: $CFLAGS" >&5 $as_echo "$as_me: using CFLAGS: $CFLAGS" >&6;} xc_bad_var_msg="CFLAGS error: CFLAGS may only be used to specify C compiler flags, not" for xc_word in $CFLAGS; do case "$xc_word" in -D*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word" >&6;} ;; -U*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word" >&6;} ;; -I*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word" >&6;} ;; -rpath*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word" >&6;} ;; -L* | --library-path=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word" >&6;} ;; -l* | --library=*) { $as_echo "$as_me:${as_lineno-$LINENO}: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&5 $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS for: $xc_word" >&6;} ;; esac done fi if test $xc_bad_var_libs = yes || test $xc_bad_var_cflags = yes || test $xc_bad_var_ldflags = yes || test $xc_bad_var_cppflags = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Continuing even with errors mentioned immediately above this line." >&5 $as_echo "$as_me: WARNING: Continuing even with errors mentioned immediately above this line." >&2;} fi ac_config_files="$ac_config_files Makefile libcares.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${CARES_LT_SHLIB_USE_VERSION_INFO_TRUE}" && test -z "${CARES_LT_SHLIB_USE_VERSION_INFO_FALSE}"; then as_fn_error $? "conditional \"CARES_LT_SHLIB_USE_VERSION_INFO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CARES_LT_SHLIB_USE_NO_UNDEFINED_TRUE}" && test -z "${CARES_LT_SHLIB_USE_NO_UNDEFINED_FALSE}"; then as_fn_error $? "conditional \"CARES_LT_SHLIB_USE_NO_UNDEFINED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CARES_LT_SHLIB_USE_MIMPURE_TEXT_TRUE}" && test -z "${CARES_LT_SHLIB_USE_MIMPURE_TEXT_FALSE}"; then as_fn_error $? "conditional \"CARES_LT_SHLIB_USE_MIMPURE_TEXT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_CPPFLAG_CARES_STATICLIB_TRUE}" && test -z "${USE_CPPFLAG_CARES_STATICLIB_FALSE}"; then as_fn_error $? "conditional \"USE_CPPFLAG_CARES_STATICLIB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CURLDEBUG_TRUE}" && test -z "${CURLDEBUG_FALSE}"; then as_fn_error $? "conditional \"CURLDEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DOING_NATIVE_WINDOWS_TRUE}" && test -z "${DOING_NATIVE_WINDOWS_FALSE}"; then as_fn_error $? "conditional \"DOING_NATIVE_WINDOWS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DOING_CARES_SYMBOL_HIDING_TRUE}" && test -z "${DOING_CARES_SYMBOL_HIDING_FALSE}"; then as_fn_error $? "conditional \"DOING_CARES_SYMBOL_HIDING\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by c-ares $as_me 1.10.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ c-ares config.status 1.10.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "ares_config.h") CONFIG_HEADERS="$CONFIG_HEADERS ares_config.h" ;; "ares_build.h") CONFIG_HEADERS="$CONFIG_HEADERS ares_build.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "libcares.pc") CONFIG_FILES="$CONFIG_FILES libcares.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi gevent-1.1.0/c-ares/get_ver.awk0000644000076500000000000000223412666555342017051 0ustar jmaddenwheel00000000000000# *************************************************************************** # * Project: c-ares # * # *************************************************************************** # awk script which fetches c-ares version number and string from input # file and writes them to STDOUT. Here you can get an awk version for Win32: # http://www.gknw.net/development/prgtools/awk-20100523.zip # BEGIN { while ((getline < ARGV[1]) > 0) { sub("\r", "") # make MSYS gawk work with CRLF header input. if (match ($0, /^#define ARES_COPYRIGHT "[^"]+"$/)) copyright_string = substr($0, 25, length($0)-25) else if (match ($0, /^#define ARES_VERSION_STR "[^"]+"$/)) version_string = substr($3, 2, length($3)-2) else if (match ($0, /^#define ARES_VERSION_MAJOR [0-9]+$/)) version_major = $3 else if (match ($0, /^#define ARES_VERSION_MINOR [0-9]+$/)) version_minor = $3 else if (match ($0, /^#define ARES_VERSION_PATCH [0-9]+$/)) version_patch = $3 } print "LIBCARES_VERSION = " version_major "," version_minor "," version_patch print "LIBCARES_VERSION_STR = " version_string print "LIBCARES_COPYRIGHT_STR = " copyright_string } gevent-1.1.0/c-ares/gitinfo0000644000076500000000000000003012666555342016264 0ustar jmaddenwheel00000000000000cares-1_9_1-12-g805c736 gevent-1.1.0/c-ares/inet_net_pton.c0000644000076500000000000002620112666555342017723 0ustar jmaddenwheel00000000000000 /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996,1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_ipv6.h" #include "ares_nowarn.h" #include "ares_inet_net_pton.h" const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }; #ifndef HAVE_INET_NET_PTON /* * static int * inet_net_pton_ipv4(src, dst, size) * convert IPv4 network number from presentation to network format. * accepts hex octets, hex strings, decimal octets, and /CIDR. * "size" is in bytes and describes "dst". * return: * number of bits, either imputed classfully or specified with /CIDR, * or -1 if some failure occurred (check errno). ENOENT means it was * not an IPv4 network specification. * note: * network byte order assumed. this means 192.5.5.240/28 has * 0b11110000 in its fourth octet. * note: * On Windows we store the error in the thread errno, not * in the winsock error code. This is to avoid loosing the * actual last winsock error. So use macro ERRNO to fetch the * errno this funtion sets when returning (-1), not SOCKERRNO. * author: * Paul Vixie (ISC), June 1996 */ static int inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) { static const char xdigits[] = "0123456789abcdef"; static const char digits[] = "0123456789"; int n, ch, tmp = 0, dirty, bits; const unsigned char *odst = dst; ch = *src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ISASCII(src[1]) && ISXDIGIT(src[1])) { /* Hexadecimal: Eat nybble string. */ if (!size) goto emsgsize; dirty = 0; src++; /* skip x or X. */ while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) { if (ISUPPER(ch)) ch = tolower(ch); n = aresx_sztosi(strchr(xdigits, ch) - xdigits); if (dirty == 0) tmp = n; else tmp = (tmp << 4) | n; if (++dirty == 2) { if (!size--) goto emsgsize; *dst++ = (unsigned char) tmp; dirty = 0; } } if (dirty) { /* Odd trailing nybble? */ if (!size--) goto emsgsize; *dst++ = (unsigned char) (tmp << 4); } } else if (ISASCII(ch) && ISDIGIT(ch)) { /* Decimal: eat dotted digit string. */ for (;;) { tmp = 0; do { n = aresx_sztosi(strchr(digits, ch) - digits); tmp *= 10; tmp += n; if (tmp > 255) goto enoent; } while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch)); if (!size--) goto emsgsize; *dst++ = (unsigned char) tmp; if (ch == '\0' || ch == '/') break; if (ch != '.') goto enoent; ch = *src++; if (!ISASCII(ch) || !ISDIGIT(ch)) goto enoent; } } else goto enoent; bits = -1; if (ch == '/' && ISASCII(src[0]) && ISDIGIT(src[0]) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ ch = *src++; /* Skip over the /. */ bits = 0; do { n = aresx_sztosi(strchr(digits, ch) - digits); bits *= 10; bits += n; if (bits > 32) goto enoent; } while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch)); if (ch != '\0') goto enoent; } /* Firey death and destruction unless we prefetched EOS. */ if (ch != '\0') goto enoent; /* If nothing was written to the destination, we found no address. */ if (dst == odst) goto enoent; /* If no CIDR spec was given, infer width from net class. */ if (bits == -1) { if (*odst >= 240) /* Class E */ bits = 32; else if (*odst >= 224) /* Class D */ bits = 8; else if (*odst >= 192) /* Class C */ bits = 24; else if (*odst >= 128) /* Class B */ bits = 16; else /* Class A */ bits = 8; /* If imputed mask is narrower than specified octets, widen. */ if (bits < ((dst - odst) * 8)) bits = aresx_sztosi(dst - odst) * 8; /* * If there are no additional bits specified for a class D * address adjust bits to 4. */ if (bits == 8 && *odst == 224) bits = 4; } /* Extend network to cover the actual mask. */ while (bits > ((dst - odst) * 8)) { if (!size--) goto emsgsize; *dst++ = '\0'; } return (bits); enoent: SET_ERRNO(ENOENT); return (-1); emsgsize: SET_ERRNO(EMSGSIZE); return (-1); } static int getbits(const char *src, int *bitsp) { static const char digits[] = "0123456789"; int n; int val; char ch; val = 0; n = 0; while ((ch = *src++) != '\0') { const char *pch; pch = strchr(digits, ch); if (pch != NULL) { if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += aresx_sztosi(pch - digits); if (val > 128) /* range */ return (0); continue; } return (0); } if (n == 0) return (0); *bitsp = val; return (1); } static int getv4(const char *src, unsigned char *dst, int *bitsp) { static const char digits[] = "0123456789"; unsigned char *odst = dst; int n; unsigned int val; char ch; val = 0; n = 0; while ((ch = *src++) != '\0') { const char *pch; pch = strchr(digits, ch); if (pch != NULL) { if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += aresx_sztoui(pch - digits); if (val > 255) /* range */ return (0); continue; } if (ch == '.' || ch == '/') { if (dst - odst > 3) /* too many octets? */ return (0); *dst++ = (unsigned char)val; if (ch == '/') return (getbits(src, bitsp)); val = 0; n = 0; continue; } return (0); } if (n == 0) return (0); if (dst - odst > 3) /* too many octets? */ return (0); *dst = (unsigned char)val; return 1; } static int inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; unsigned int val; int digits; int bits; size_t bytes; int words; int ipv4; memset((tp = tmp), '\0', NS_IN6ADDRSZ); endp = tp + NS_IN6ADDRSZ; colonp = NULL; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') goto enoent; curtok = src; saw_xdigit = 0; val = 0; digits = 0; bits = -1; ipv4 = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_u), ch); if (pch != NULL) { val <<= 4; val |= aresx_sztoui(pch - xdigits); if (++digits > 4) goto enoent; saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { if (colonp) goto enoent; colonp = tp; continue; } else if (*src == '\0') goto enoent; if (tp + NS_INT16SZ > endp) return (0); *tp++ = (unsigned char)((val >> 8) & 0xff); *tp++ = (unsigned char)(val & 0xff); saw_xdigit = 0; digits = 0; val = 0; continue; } if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && getv4(curtok, tp, &bits) > 0) { tp += NS_INADDRSZ; saw_xdigit = 0; ipv4 = 1; break; /* '\0' was seen by inet_pton4(). */ } if (ch == '/' && getbits(src, &bits) > 0) break; goto enoent; } if (saw_xdigit) { if (tp + NS_INT16SZ > endp) goto enoent; *tp++ = (unsigned char)((val >> 8) & 0xff); *tp++ = (unsigned char)(val & 0xff); } if (bits == -1) bits = 128; words = (bits + 15) / 16; if (words < 2) words = 2; if (ipv4) words = 8; endp = tmp + 2 * words; if (colonp != NULL) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ const ssize_t n = tp - colonp; ssize_t i; if (tp == endp) goto enoent; for (i = 1; i <= n; i++) { *(endp - i) = *(colonp + n - i); *(colonp + n - i) = 0; } tp = endp; } if (tp != endp) goto enoent; bytes = (bits + 7) / 8; if (bytes > size) goto emsgsize; memcpy(dst, tmp, bytes); return (bits); enoent: SET_ERRNO(ENOENT); return (-1); emsgsize: SET_ERRNO(EMSGSIZE); return (-1); } /* * int * inet_net_pton(af, src, dst, size) * convert network number from presentation to network format. * accepts hex octets, hex strings, decimal octets, and /CIDR. * "size" is in bytes and describes "dst". * return: * number of bits, either imputed classfully or specified with /CIDR, * or -1 if some failure occurred (check errno). ENOENT means it was * not a valid network specification. * note: * On Windows we store the error in the thread errno, not * in the winsock error code. This is to avoid loosing the * actual last winsock error. So use macro ERRNO to fetch the * errno this funtion sets when returning (-1), not SOCKERRNO. * author: * Paul Vixie (ISC), June 1996 */ int ares_inet_net_pton(int af, const char *src, void *dst, size_t size) { switch (af) { case AF_INET: return (inet_net_pton_ipv4(src, dst, size)); case AF_INET6: return (inet_net_pton_ipv6(src, dst, size)); default: SET_ERRNO(EAFNOSUPPORT); return (-1); } } #endif /* HAVE_INET_NET_PTON */ #ifndef HAVE_INET_PTON int ares_inet_pton(int af, const char *src, void *dst) { int result; size_t size; if (af == AF_INET) size = sizeof(struct in_addr); else if (af == AF_INET6) size = sizeof(struct ares_in6_addr); else { SET_ERRNO(EAFNOSUPPORT); return -1; } result = ares_inet_net_pton(af, src, dst, size); if (result == -1 && ERRNO == ENOENT) return 0; return (result > -1 ? 1 : -1); } #else /* HAVE_INET_PTON */ int ares_inet_pton(int af, const char *src, void *dst) { /* just relay this to the underlying function */ return inet_pton(af, src, dst); } #endif gevent-1.1.0/c-ares/inet_net_pton.h0000644000076500000000000000214112666555342017725 0ustar jmaddenwheel00000000000000#ifndef HEADER_CARES_INET_NET_PTON_H #define HEADER_CARES_INET_NET_PTON_H /* Copyright (C) 2005-2010 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifdef HAVE_INET_PTON #define ares_inet_pton(x,y,z) inet_pton(x,y,z) #else int ares_inet_pton(int af, const char *src, void *dst); #endif #ifdef HAVE_INET_NET_PTON #define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) #else int ares_inet_net_pton(int af, const char *src, void *dst, size_t size); #endif #endif /* HEADER_CARES_INET_NET_PTON_H */ gevent-1.1.0/c-ares/inet_ntop.c0000644000076500000000000001340412666555342017056 0ustar jmaddenwheel00000000000000/* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "ares_setup.h" #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #else # include "nameser.h" #endif #ifdef HAVE_ARPA_NAMESER_COMPAT_H # include #endif #include "ares.h" #include "ares_ipv6.h" #ifndef HAVE_INET_NTOP /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static const char *inet_ntop4(const unsigned char *src, char *dst, size_t size); static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size); /* char * * inet_ntop(af, src, dst, size) * convert a network format address to presentation format. * return: * pointer to presentation format address (`dst'), or NULL (see errno). * note: * On Windows we store the error in the thread errno, not * in the winsock error code. This is to avoid loosing the * actual last winsock error. So use macro ERRNO to fetch the * errno this funtion sets when returning NULL, not SOCKERRNO. * author: * Paul Vixie, 1996. */ const char * ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size) { switch (af) { case AF_INET: return (inet_ntop4(src, dst, (size_t)size)); case AF_INET6: return (inet_ntop6(src, dst, (size_t)size)); default: SET_ERRNO(EAFNOSUPPORT); return (NULL); } /* NOTREACHED */ } /* const char * * inet_ntop4(src, dst, size) * format an IPv4 address * return: * `dst' (as a const) * notes: * (1) uses no statics * (2) takes a unsigned char* not an in_addr as input * author: * Paul Vixie, 1996. */ static const char * inet_ntop4(const unsigned char *src, char *dst, size_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof("255.255.255.255")]; if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size) { SET_ERRNO(ENOSPC); return (NULL); } strcpy(dst, tmp); return (dst); } /* const char * * inet_ntop6(src, dst, size) * convert IPv6 binary address into presentation (printable) format * author: * Paul Vixie, 1996. */ static const char * inet_ntop6(const unsigned char *src, char *dst, size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough * to contain a value of the specified size. On some systems, like * Crays, there is no such thing as an integer variable with 16 bits. * Keep this in mind if you think this function should have been coded * to use pointer overlays. All the world's not a VAX. */ char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; char *tp; struct { int base, len; } best, cur; unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; int i; /* * Preprocess: * Copy the input (bytewise) array into a wordwise array. * Find the longest run of 0x00's in src[] for :: shorthanding. */ memset(words, '\0', sizeof(words)); for (i = 0; i < NS_IN6ADDRSZ; i++) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; best.len = 0; cur.base = -1; cur.len = 0; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) cur.base = i, cur.len = 1; else cur.len++; } else { if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; cur.base = -1; } } } if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; } if (best.base != -1 && best.len < 2) best.base = -1; /* * Format the result. */ tp = tmp; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { /* Are we inside the best run of 0x00's? */ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) { if (i == best.base) *tp++ = ':'; continue; } /* Are we following an initial run of 0x00s or any real hex? */ if (i != 0) *tp++ = ':'; /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 7 && words[7] != 0x0001) || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) return (NULL); tp += strlen(tp); break; } tp += sprintf(tp, "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ)) *tp++ = ':'; *tp++ = '\0'; /* * Check for overflow, copy, and we're done. */ if ((size_t)(tp - tmp) > size) { SET_ERRNO(ENOSPC); return (NULL); } strcpy(dst, tmp); return (dst); } #else /* HAVE_INET_NTOP */ const char * ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size) { /* just relay this to the underlying function */ return inet_ntop(af, src, dst, size); } #endif /* HAVE_INET_NTOP */ gevent-1.1.0/c-ares/inet_ntop.h0000644000076500000000000000164612666555342017070 0ustar jmaddenwheel00000000000000#ifndef __ARES_INET_NTOP_H #define __ARES_INET_NTOP_H /* Copyright (C) 2005 by Dominick Meglio * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #ifdef HAVE_INET_NTOP #define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z) #else const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size); #endif #endif /* __ARES_INET_NTOP_H */ gevent-1.1.0/c-ares/install-sh0000755000076500000000000001272012666555342016717 0ustar jmaddenwheel00000000000000#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 gevent-1.1.0/c-ares/missing0000755000076500000000000002415212666555342016314 0ustar jmaddenwheel00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gevent-1.1.0/c-ares/nameser.h0000644000076500000000000002036512666555342016522 0ustar jmaddenwheel00000000000000 #ifndef ARES_NAMESER_H #define ARES_NAMESER_H /* header file provided by liren@vivisimo.com */ #ifndef HAVE_ARPA_NAMESER_H #define NS_PACKETSZ 512 /* maximum packet size */ #define NS_MAXDNAME 256 /* maximum domain name */ #define NS_MAXCDNAME 255 /* maximum compressed domain name */ #define NS_MAXLABEL 63 #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ #define NS_INT16SZ 2 #define NS_INADDRSZ 4 #define NS_IN6ADDRSZ 16 #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ typedef enum __ns_class { ns_c_invalid = 0, /* Cookie. */ ns_c_in = 1, /* Internet. */ ns_c_2 = 2, /* unallocated/unsupported. */ ns_c_chaos = 3, /* MIT Chaos-net. */ ns_c_hs = 4, /* MIT Hesiod. */ /* Query class values which do not appear in resource records */ ns_c_none = 254, /* for prereq. sections in update requests */ ns_c_any = 255, /* Wildcard match. */ ns_c_max = 65536 } ns_class; typedef enum __ns_type { ns_t_invalid = 0, /* Cookie. */ ns_t_a = 1, /* Host address. */ ns_t_ns = 2, /* Authoritative server. */ ns_t_md = 3, /* Mail destination. */ ns_t_mf = 4, /* Mail forwarder. */ ns_t_cname = 5, /* Canonical name. */ ns_t_soa = 6, /* Start of authority zone. */ ns_t_mb = 7, /* Mailbox domain name. */ ns_t_mg = 8, /* Mail group member. */ ns_t_mr = 9, /* Mail rename name. */ ns_t_null = 10, /* Null resource record. */ ns_t_wks = 11, /* Well known service. */ ns_t_ptr = 12, /* Domain name pointer. */ ns_t_hinfo = 13, /* Host information. */ ns_t_minfo = 14, /* Mailbox information. */ ns_t_mx = 15, /* Mail routing information. */ ns_t_txt = 16, /* Text strings. */ ns_t_rp = 17, /* Responsible person. */ ns_t_afsdb = 18, /* AFS cell database. */ ns_t_x25 = 19, /* X_25 calling address. */ ns_t_isdn = 20, /* ISDN calling address. */ ns_t_rt = 21, /* Router. */ ns_t_nsap = 22, /* NSAP address. */ ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ ns_t_sig = 24, /* Security signature. */ ns_t_key = 25, /* Security key. */ ns_t_px = 26, /* X.400 mail mapping. */ ns_t_gpos = 27, /* Geographical position (withdrawn). */ ns_t_aaaa = 28, /* Ip6 Address. */ ns_t_loc = 29, /* Location Information. */ ns_t_nxt = 30, /* Next domain (security). */ ns_t_eid = 31, /* Endpoint identifier. */ ns_t_nimloc = 32, /* Nimrod Locator. */ ns_t_srv = 33, /* Server Selection. */ ns_t_atma = 34, /* ATM Address */ ns_t_naptr = 35, /* Naming Authority PoinTeR */ ns_t_kx = 36, /* Key Exchange */ ns_t_cert = 37, /* Certification record */ ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ ns_t_sink = 40, /* Kitchen sink (experimentatl) */ ns_t_opt = 41, /* EDNS0 option (meta-RR) */ ns_t_apl = 42, /* Address prefix list (RFC3123) */ ns_t_ds = 43, /* Delegation Signer (RFC4034) */ ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */ ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */ ns_t_nsec = 47, /* Next Secure (RFC4034) */ ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */ ns_t_tkey = 249, /* Transaction key */ ns_t_tsig = 250, /* Transaction signature. */ ns_t_ixfr = 251, /* Incremental zone transfer. */ ns_t_axfr = 252, /* Transfer zone of authority. */ ns_t_mailb = 253, /* Transfer mailbox records. */ ns_t_maila = 254, /* Transfer mail agent records. */ ns_t_any = 255, /* Wildcard match. */ ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ ns_t_max = 65536 } ns_type; typedef enum __ns_opcode { ns_o_query = 0, /* Standard query. */ ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ ns_o_status = 2, /* Name server status query (unsupported). */ /* Opcode 3 is undefined/reserved. */ ns_o_notify = 4, /* Zone change notification. */ ns_o_update = 5, /* Zone update message. */ ns_o_max = 6 } ns_opcode; typedef enum __ns_rcode { ns_r_noerror = 0, /* No error occurred. */ ns_r_formerr = 1, /* Format error. */ ns_r_servfail = 2, /* Server failure. */ ns_r_nxdomain = 3, /* Name error. */ ns_r_notimpl = 4, /* Unimplemented. */ ns_r_refused = 5, /* Operation refused. */ /* these are for BIND_UPDATE */ ns_r_yxdomain = 6, /* Name exists */ ns_r_yxrrset = 7, /* RRset exists */ ns_r_nxrrset = 8, /* RRset does not exist */ ns_r_notauth = 9, /* Not authoritative for zone */ ns_r_notzone = 10, /* Zone of record different from zone section */ ns_r_max = 11, /* The following are TSIG extended errors */ ns_r_badsig = 16, ns_r_badkey = 17, ns_r_badtime = 18 } ns_rcode; #endif /* HAVE_ARPA_NAMESER_H */ #ifndef HAVE_ARPA_NAMESER_COMPAT_H #define PACKETSZ NS_PACKETSZ #define MAXDNAME NS_MAXDNAME #define MAXCDNAME NS_MAXCDNAME #define MAXLABEL NS_MAXLABEL #define HFIXEDSZ NS_HFIXEDSZ #define QFIXEDSZ NS_QFIXEDSZ #define RRFIXEDSZ NS_RRFIXEDSZ #define INDIR_MASK NS_CMPRSFLGS #define NAMESERVER_PORT NS_DEFAULTPORT #define QUERY ns_o_query #define SERVFAIL ns_r_servfail #define NOTIMP ns_r_notimpl #define REFUSED ns_r_refused #undef NOERROR /* it seems this is already defined in winerror.h */ #define NOERROR ns_r_noerror #define FORMERR ns_r_formerr #define NXDOMAIN ns_r_nxdomain #define C_IN ns_c_in #define C_CHAOS ns_c_chaos #define C_HS ns_c_hs #define C_NONE ns_c_none #define C_ANY ns_c_any #define T_A ns_t_a #define T_NS ns_t_ns #define T_MD ns_t_md #define T_MF ns_t_mf #define T_CNAME ns_t_cname #define T_SOA ns_t_soa #define T_MB ns_t_mb #define T_MG ns_t_mg #define T_MR ns_t_mr #define T_NULL ns_t_null #define T_WKS ns_t_wks #define T_PTR ns_t_ptr #define T_HINFO ns_t_hinfo #define T_MINFO ns_t_minfo #define T_MX ns_t_mx #define T_TXT ns_t_txt #define T_RP ns_t_rp #define T_AFSDB ns_t_afsdb #define T_X25 ns_t_x25 #define T_ISDN ns_t_isdn #define T_RT ns_t_rt #define T_NSAP ns_t_nsap #define T_NSAP_PTR ns_t_nsap_ptr #define T_SIG ns_t_sig #define T_KEY ns_t_key #define T_PX ns_t_px #define T_GPOS ns_t_gpos #define T_AAAA ns_t_aaaa #define T_LOC ns_t_loc #define T_NXT ns_t_nxt #define T_EID ns_t_eid #define T_NIMLOC ns_t_nimloc #define T_SRV ns_t_srv #define T_ATMA ns_t_atma #define T_NAPTR ns_t_naptr #define T_KX ns_t_kx #define T_CERT ns_t_cert #define T_A6 ns_t_a6 #define T_DNAME ns_t_dname #define T_SINK ns_t_sink #define T_OPT ns_t_opt #define T_APL ns_t_apl #define T_DS ns_t_ds #define T_SSHFP ns_t_sshfp #define T_RRSIG ns_t_rrsig #define T_NSEC ns_t_nsec #define T_DNSKEY ns_t_dnskey #define T_TKEY ns_t_tkey #define T_TSIG ns_t_tsig #define T_IXFR ns_t_ixfr #define T_AXFR ns_t_axfr #define T_MAILB ns_t_mailb #define T_MAILA ns_t_maila #define T_ANY ns_t_any #endif /* HAVE_ARPA_NAMESER_COMPAT_H */ #endif /* ARES_NAMESER_H */ gevent-1.1.0/c-ares/README0000644000076500000000000000500312666555342015567 0ustar jmaddenwheel00000000000000c-ares ====== This is c-ares, an asynchronous resolver library. It is intended for applications which need to perform DNS queries without blocking, or need to perform multiple DNS queries in parallel. The primary examples of such applications are servers which communicate with multiple clients and programs with graphical user interfaces. The full source code is available in the 'c-ares' release archives, and in a git repository: http://github.com/bagder/c-ares If you find bugs, correct flaws, have questions or have comments in general in regard to c-ares (or by all means the original ares too), get in touch with us on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares c-ares is of course distributed under the same MIT-style license as the original ares. You'll find all c-ares details and news here: http://c-ares.haxx.se/ NOTES FOR C-ARES HACKERS * The distributed ares_build.h file is only intended to be used on systems which can not run the also distributed configure script. * The distributed ares_build.h file is generated as a copy of ares_build.h.dist when the c-ares source code distribution archive file is originally created. * If you check out from git on a non-configure platform, you must run the appropriate buildconf* script to set up ares_build.h and other local files before being able of compiling the library. * On systems capable of running the configure script, the configure process will overwrite the distributed ares_build.h file with one that is suitable and specific to the library being configured and built, this new file is generated from the ares_build.h.in template file. * If you intend to distribute an already compiled c-ares library you _MUST_ also distribute along with it the generated ares_build.h which has been used to compile it. Otherwise the library will be of no use for the users of the library that you have built. It is _your_ responsibility to provide this file. No one at the c-ares project can know how you have built the library. * File ares_build.h includes platform and configuration dependent info, and must not be modified by anyone. Configure script generates it for you. * We cannot assume anything else but very basic compiler features being present. While c-ares requires an ANSI C compiler to build, some of the earlier ANSI compilers clearly can't deal with some preprocessor operators. * Newlines must remain unix-style for older compilers' sake. * Comments must be written in the old-style /* unnested C-fashion */ gevent-1.1.0/c-ares/README.cares0000644000076500000000000000102712666555342016665 0ustar jmaddenwheel00000000000000c-ares ====== This package is based on ares 1.1.1 (written by Greg Hudson). I decided to fork and release a separate project since the ares author didn't want the improvements that were vital for our use of it. This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use within the curl project (hence the letter C) and it makes a nice pun. Also, c-ares is not API compatible with ares: a new name makes that more obvious to the public. The original libares was distributed at athena-dist.mit.edu:pub/ATHENA/ares. gevent-1.1.0/c-ares/RELEASE-NOTES0000644000076500000000000000244712666555342016611 0ustar jmaddenwheel00000000000000c-ares version 1.10.0 Changes: o Added ares_create_query(), to be used instead of ares_mkquery() o ares_inet_ntop() and ares_inet_pton() are now recognized c-ares functions Bug fixes: o include the ares_parse_soa_reply.* files in the tarball o read_udp_packets: bail out loop on bad sockets o get_DNS_AdaptersAddresses: fix IPv6 parsing o adig: perror() doesn't work for socket errors on windows o ares_parse_aaaa_reply: fix memory leak o setup_once.h: HP-UX issue workaround o configure: several fixes o config-dos.h: define strerror() to strerror_s_() for High-C o config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32 o ares_build.h.dist: enhance non-configure GCC ABI detection logic o ares.h: stricter CARES_EXTERN linkage decorations logic o ares_cancel(): cancel requests safely o protocol parsing: check input data stricter o library init: be recursive, reference count inits/cleanups o ares_parse_txt_reply: return a ares_txt_reply node for each sub-string o ares_set_servers_csv: fixed IPv6 address parsing o build: fix build on msvc11 Thanks go to these friendly people for their efforts and contributions: Eugeny Gladkih, Yang Tse, Gisle Vanem, Guenter Knauf, Horatiu Popescu, Alexander Klauer, Patrick Valsecchi, Paul Saab, Keith Shaw, Alex Loukissas Have fun! gevent-1.1.0/c-ares/setup_once.h0000644000076500000000000003600712666555342017234 0ustar jmaddenwheel00000000000000#ifndef __SETUP_ONCE_H #define __SETUP_ONCE_H /* Copyright (C) 2004 - 2013 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ /******************************************************************** * NOTICE * * ======== * * * * Content of header files lib/setup_once.h and ares/setup_once.h * * must be kept in sync. Modify the other one if you change this. * * * ********************************************************************/ /* * Inclusion of common header files. */ #include #include #include #include #include #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef NEED_MALLOC_H #include #endif #ifdef NEED_MEMORY_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME #include #endif #else #ifdef HAVE_TIME_H #include #endif #endif #ifdef WIN32 #include #include #endif #if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T) #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef __hpux # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) # ifdef _APP32_64BIT_OFF_T # define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T # undef _APP32_64BIT_OFF_T # else # undef OLD_APP32_64BIT_OFF_T # endif # endif #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef __hpux # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) # ifdef OLD_APP32_64BIT_OFF_T # define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T # undef OLD_APP32_64BIT_OFF_T # endif # endif #endif /* * Definition of timeval struct for platforms that don't have it. */ #ifndef HAVE_STRUCT_TIMEVAL struct timeval { long tv_sec; long tv_usec; }; #endif /* * If we have the MSG_NOSIGNAL define, make sure we use * it as the fourth argument of function send() */ #ifdef HAVE_MSG_NOSIGNAL #define SEND_4TH_ARG MSG_NOSIGNAL #else #define SEND_4TH_ARG 0 #endif #if defined(__minix) /* Minix doesn't support recv on TCP sockets */ #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ (RECV_TYPE_ARG3)(z)) #elif defined(HAVE_RECV) /* * The definitions for the return type and arguments types * of functions recv() and send() belong and come from the * configuration file. Do not define them in any other place. * * HAVE_RECV is defined if you have a function named recv() * which is used to read incoming data from sockets. If your * function has another name then don't define HAVE_RECV. * * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2, * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also * be defined. * * HAVE_SEND is defined if you have a function named send() * which is used to write outgoing data on a connected socket. * If yours has another name then don't define HAVE_SEND. * * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2, * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and * SEND_TYPE_RETV must also be defined. */ #if !defined(RECV_TYPE_ARG1) || \ !defined(RECV_TYPE_ARG2) || \ !defined(RECV_TYPE_ARG3) || \ !defined(RECV_TYPE_ARG4) || \ !defined(RECV_TYPE_RETV) /* */ Error Missing_definition_of_return_and_arguments_types_of_recv /* */ #else #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ (RECV_TYPE_ARG3)(z), \ (RECV_TYPE_ARG4)(0)) #endif #else /* HAVE_RECV */ #ifndef sread /* */ Error Missing_definition_of_macro_sread /* */ #endif #endif /* HAVE_RECV */ #if defined(__minix) /* Minix doesn't support send on TCP sockets */ #define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ (SEND_TYPE_ARG2)(y), \ (SEND_TYPE_ARG3)(z)) #elif defined(HAVE_SEND) #if !defined(SEND_TYPE_ARG1) || \ !defined(SEND_QUAL_ARG2) || \ !defined(SEND_TYPE_ARG2) || \ !defined(SEND_TYPE_ARG3) || \ !defined(SEND_TYPE_ARG4) || \ !defined(SEND_TYPE_RETV) /* */ Error Missing_definition_of_return_and_arguments_types_of_send /* */ #else #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ (SEND_TYPE_ARG2)(y), \ (SEND_TYPE_ARG3)(z), \ (SEND_TYPE_ARG4)(SEND_4TH_ARG)) #endif #else /* HAVE_SEND */ #ifndef swrite /* */ Error Missing_definition_of_macro_swrite /* */ #endif #endif /* HAVE_SEND */ #if 0 #if defined(HAVE_RECVFROM) /* * Currently recvfrom is only used on udp sockets. */ #if !defined(RECVFROM_TYPE_ARG1) || \ !defined(RECVFROM_TYPE_ARG2) || \ !defined(RECVFROM_TYPE_ARG3) || \ !defined(RECVFROM_TYPE_ARG4) || \ !defined(RECVFROM_TYPE_ARG5) || \ !defined(RECVFROM_TYPE_ARG6) || \ !defined(RECVFROM_TYPE_RETV) /* */ Error Missing_definition_of_return_and_arguments_types_of_recvfrom /* */ #else #define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \ (RECVFROM_TYPE_ARG2 *)(b), \ (RECVFROM_TYPE_ARG3) (bl), \ (RECVFROM_TYPE_ARG4) (0), \ (RECVFROM_TYPE_ARG5 *)(f), \ (RECVFROM_TYPE_ARG6 *)(fl)) #endif #else /* HAVE_RECVFROM */ #ifndef sreadfrom /* */ Error Missing_definition_of_macro_sreadfrom /* */ #endif #endif /* HAVE_RECVFROM */ #ifdef RECVFROM_TYPE_ARG6_IS_VOID # define RECVFROM_ARG6_T int #else # define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6 #endif #endif /* if 0 */ /* * Function-like macro definition used to close a socket. */ #if defined(HAVE_CLOSESOCKET) # define sclose(x) closesocket((x)) #elif defined(HAVE_CLOSESOCKET_CAMEL) # define sclose(x) CloseSocket((x)) #elif defined(HAVE_CLOSE_S) # define sclose(x) close_s((x)) #else # define sclose(x) close((x)) #endif /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. */ #define ISSPACE(x) (isspace((int) ((unsigned char)x))) #define ISDIGIT(x) (isdigit((int) ((unsigned char)x))) #define ISALNUM(x) (isalnum((int) ((unsigned char)x))) #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) #define ISGRAPH(x) (isgraph((int) ((unsigned char)x))) #define ISALPHA(x) (isalpha((int) ((unsigned char)x))) #define ISPRINT(x) (isprint((int) ((unsigned char)x))) #define ISUPPER(x) (isupper((int) ((unsigned char)x))) #define ISLOWER(x) (islower((int) ((unsigned char)x))) #define ISASCII(x) (isascii((int) ((unsigned char)x))) #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \ (((unsigned char)x) == '\t')) #define TOLOWER(x) (tolower((int) ((unsigned char)x))) /* * 'bool' stuff compatible with HP-UX headers. */ #if defined(__hpux) && !defined(HAVE_BOOL_T) typedef int bool; # define false 0 # define true 1 # define HAVE_BOOL_T #endif /* * 'bool' exists on platforms with , i.e. C99 platforms. * On non-C99 platforms there's no bool, so define an enum for that. * On C99 platforms 'false' and 'true' also exist. Enum uses a * global namespace though, so use bool_false and bool_true. */ #ifndef HAVE_BOOL_T typedef enum { bool_false = 0, bool_true = 1 } bool; /* * Use a define to let 'true' and 'false' use those enums. There * are currently no use of true and false in libcurl proper, but * there are some in the examples. This will cater for any later * code happening to use true and false. */ # define false bool_false # define true bool_true # define HAVE_BOOL_T #endif /* * Redefine TRUE and FALSE too, to catch current use. With this * change, 'bool found = 1' will give a warning on MIPSPro, but * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro, * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too. */ #ifndef TRUE #define TRUE true #endif #ifndef FALSE #define FALSE false #endif /* * Macro WHILE_FALSE may be used to build single-iteration do-while loops, * avoiding compiler warnings. Mostly intended for other macro definitions. */ #define WHILE_FALSE while(0) #if defined(_MSC_VER) && !defined(__POCC__) # undef WHILE_FALSE # if (_MSC_VER < 1500) # define WHILE_FALSE while(1, 0) # else # define WHILE_FALSE \ __pragma(warning(push)) \ __pragma(warning(disable:4127)) \ while(0) \ __pragma(warning(pop)) # endif #endif /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ #ifndef HAVE_SIG_ATOMIC_T typedef int sig_atomic_t; #define HAVE_SIG_ATOMIC_T #endif /* * Convenience SIG_ATOMIC_T definition */ #ifdef HAVE_SIG_ATOMIC_T_VOLATILE #define SIG_ATOMIC_T static sig_atomic_t #else #define SIG_ATOMIC_T static volatile sig_atomic_t #endif /* * Default return type for signal handlers. */ #ifndef RETSIGTYPE #define RETSIGTYPE void #endif /* * Macro used to include code only in debug builds. */ #ifdef DEBUGBUILD #define DEBUGF(x) x #else #define DEBUGF(x) do { } WHILE_FALSE #endif /* * Macro used to include assertion code only in debug builds. */ #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else #define DEBUGASSERT(x) do { } WHILE_FALSE #endif /* * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno * (or equivalent) on this platform to hide platform details to code using it. */ #ifdef USE_WINSOCK #define SOCKERRNO ((int)WSAGetLastError()) #define SET_SOCKERRNO(x) (WSASetLastError((int)(x))) #else #define SOCKERRNO (errno) #define SET_SOCKERRNO(x) (errno = (x)) #endif /* * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno * (or equivalent) on this platform to hide platform details to code using it. */ #if defined(WIN32) && !defined(WATT32) #define ERRNO ((int)GetLastError()) #define SET_ERRNO(x) (SetLastError((DWORD)(x))) #else #define ERRNO (errno) #define SET_ERRNO(x) (errno = (x)) #endif /* * Portable error number symbolic names defined to Winsock error codes. */ #ifdef USE_WINSOCK #undef EBADF /* override definition in errno.h */ #define EBADF WSAEBADF #undef EINTR /* override definition in errno.h */ #define EINTR WSAEINTR #undef EINVAL /* override definition in errno.h */ #define EINVAL WSAEINVAL #undef EWOULDBLOCK /* override definition in errno.h */ #define EWOULDBLOCK WSAEWOULDBLOCK #undef EINPROGRESS /* override definition in errno.h */ #define EINPROGRESS WSAEINPROGRESS #undef EALREADY /* override definition in errno.h */ #define EALREADY WSAEALREADY #undef ENOTSOCK /* override definition in errno.h */ #define ENOTSOCK WSAENOTSOCK #undef EDESTADDRREQ /* override definition in errno.h */ #define EDESTADDRREQ WSAEDESTADDRREQ #undef EMSGSIZE /* override definition in errno.h */ #define EMSGSIZE WSAEMSGSIZE #undef EPROTOTYPE /* override definition in errno.h */ #define EPROTOTYPE WSAEPROTOTYPE #undef ENOPROTOOPT /* override definition in errno.h */ #define ENOPROTOOPT WSAENOPROTOOPT #undef EPROTONOSUPPORT /* override definition in errno.h */ #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #undef EOPNOTSUPP /* override definition in errno.h */ #define EOPNOTSUPP WSAEOPNOTSUPP #define EPFNOSUPPORT WSAEPFNOSUPPORT #undef EAFNOSUPPORT /* override definition in errno.h */ #define EAFNOSUPPORT WSAEAFNOSUPPORT #undef EADDRINUSE /* override definition in errno.h */ #define EADDRINUSE WSAEADDRINUSE #undef EADDRNOTAVAIL /* override definition in errno.h */ #define EADDRNOTAVAIL WSAEADDRNOTAVAIL #undef ENETDOWN /* override definition in errno.h */ #define ENETDOWN WSAENETDOWN #undef ENETUNREACH /* override definition in errno.h */ #define ENETUNREACH WSAENETUNREACH #undef ENETRESET /* override definition in errno.h */ #define ENETRESET WSAENETRESET #undef ECONNABORTED /* override definition in errno.h */ #define ECONNABORTED WSAECONNABORTED #undef ECONNRESET /* override definition in errno.h */ #define ECONNRESET WSAECONNRESET #undef ENOBUFS /* override definition in errno.h */ #define ENOBUFS WSAENOBUFS #undef EISCONN /* override definition in errno.h */ #define EISCONN WSAEISCONN #undef ENOTCONN /* override definition in errno.h */ #define ENOTCONN WSAENOTCONN #define ESHUTDOWN WSAESHUTDOWN #define ETOOMANYREFS WSAETOOMANYREFS #undef ETIMEDOUT /* override definition in errno.h */ #define ETIMEDOUT WSAETIMEDOUT #undef ECONNREFUSED /* override definition in errno.h */ #define ECONNREFUSED WSAECONNREFUSED #undef ELOOP /* override definition in errno.h */ #define ELOOP WSAELOOP #ifndef ENAMETOOLONG /* possible previous definition in errno.h */ #define ENAMETOOLONG WSAENAMETOOLONG #endif #define EHOSTDOWN WSAEHOSTDOWN #undef EHOSTUNREACH /* override definition in errno.h */ #define EHOSTUNREACH WSAEHOSTUNREACH #ifndef ENOTEMPTY /* possible previous definition in errno.h */ #define ENOTEMPTY WSAENOTEMPTY #endif #define EPROCLIM WSAEPROCLIM #define EUSERS WSAEUSERS #define EDQUOT WSAEDQUOT #define ESTALE WSAESTALE #define EREMOTE WSAEREMOTE #endif /* * Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid() */ #if defined(__VMS) && \ defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64) #define getpwuid __32_getpwuid #endif /* * Macro argv_item_t hides platform details to code using it. */ #ifdef __VMS #define argv_item_t __char_ptr32 #else #define argv_item_t char * #endif /* * We use this ZERO_NULL to avoid picky compiler warnings, * when assigning a NULL pointer to a function pointer var. */ #define ZERO_NULL 0 #endif /* __SETUP_ONCE_H */ gevent-1.1.0/c-ares/TODO0000644000076500000000000000132712666555342015404 0ustar jmaddenwheel00000000000000TODO ==== ares_reinit() - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much like the res_init() resolver function offers ares_gethostbyname - When built to support IPv6, it needs to also support PF_UNSPEC or similar, so that an application can ask for any protocol and then c-ares would return all known resolves and not just explicitly IPv4 _or_ IPv6 resolves. ares_process - Upon next ABI breakage ares_process() should be changed to return 'int' and return ARES_ENOTINITIALIZED if ares_library_init() has not been called. ares_process_fd - Upon next ABI breakage ares_process_fd() should be changed to return 'int' and return ARES_ENOTINITIALIZED if library has not been initialized. gevent-1.1.0/c-ares/windows_port.c0000644000076500000000000000062312666555342017614 0ustar jmaddenwheel00000000000000#include "ares_setup.h" /* only do the following on windows */ #if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS) #ifdef __WATCOMC__ /* * Watcom needs a DllMain() in order to initialise the clib startup code. */ BOOL WINAPI DllMain (HINSTANCE hnd, DWORD reason, LPVOID reserved) { (void) hnd; (void) reason; (void) reserved; return (TRUE); } #endif #endif /* WIN32 builds only */ gevent-1.1.0/changelog.rst0000644000076500000000000026335112666555342016232 0ustar jmaddenwheel00000000000000=========== Changelog =========== .. currentmodule:: gevent 1.1.0 (Mar 5, 2016) =================== - Python 3: A monkey-patched :class:`threading.RLock` now properly blocks (or deadlocks) in ``acquire`` if the default value for *timeout* of -1 is used (which differs from gevent's default of None). The ``acquire`` method also raises the same :exc:`ValueError` exceptions that the standard library does for invalid parameters. Reported in :issue:`750` by Joy Zheng. - Fix a race condition in :class:`~gevent.event.Event` that made it return ``False`` when the event was set and cleared by the same greenlet before allowing a switch to already waiting greenlets. (Found by the 3.4 and 3.5 standard library test suites; the same as Python `bug 13502`_. Note that the Python 2 standard library still has this race condition.) - :class:`~gevent.event.Event` and :class:`~.AsyncResult` now wake waiting greenlets in the same (unspecified) order. Previously, ``AsyncResult`` tended to use a FIFO order, but this was never guaranteed. Both classes also use less per-instance memory. - Using a :class:`~logging.Logger` as a :mod:`pywsgi` error or request log stream no longer produces extra newlines. Reported in :issue:`756` by ael-code. - Windows: Installing from an sdist (.tar.gz) on PyPI no longer requires having Cython installed first. (Note that the binary installation formats (wheels, exes, msis) are preferred on Windows.) Reported in :issue:`757` by Ned Batchelder. - Issue a warning when :func:`~gevent.monkey.patch_all` is called with ``os`` set to False (*not* the default) but ``signal`` is still True (the default). This combination of parameters will cause signal handlers for ``SIGCHLD`` to not get called. In the future this might raise an error. Reported by Josh Zuech. - Issue a warning when :func:`~gevent.monkey.patch_all` is called more than once with different arguments. That causes the cumulative set of all True arguments to be patched, which may cause unexpected results. - Fix returning the original values of certain ``threading`` attributes from :func:`gevent.monkey.get_original`. .. _bug 13502: http://bugs.python.org/issue13502 1.1rc5 (Feb 24, 2016) ===================== - SSL: Attempting to send empty data using the :meth:`~socket.socket.sendall` method of a gevent SSL socket that has a timeout now returns immediately (like the standard library does), instead of incorrectly raising :exc:`ssl.SSLEOFError`. (Note that sending empty data with the :meth:`~socket.socket.send` method *does* raise ``SSLEOFError`` in both gevent and the standard library.) Reported in :issue:`719` by Mustafa Atik and Tymur Maryokhin, with a reproducible test case provided by Timo Savola. 1.1rc4 (Feb 16, 2016) ===================== - Python 2: Using the blocking API at import time when multiple greenlets are also importing should not lead to ``LoopExit``. Reported in :issue:`728` by Garrett Heel. - Python 2: Don't raise :exc:`OverflowError` when using the ``readline`` method of the WSGI input stream without a size hint or with a large size hint when the client is uploading a large amount of data. (This only impacted CPython 2; PyPy and Python 3 already handled this.) Reported in :issue:`289` by ggjjlldd, with contributions by Nathan Hoad. - :class:`~gevent.baseserver.BaseServer` and its subclasses like :class:`~gevent.pywsgi.WSGIServer` avoid allocating a new closure for each request, reducing overhead. - Python 2: Under 2.7.9 and above (or when the PEP 466 SSL interfaces are available), perform the same hostname validation that the standard library does; previously this was skipped. Also, reading, writing, or handshaking a closed :class:`~ssl.SSLSocket` now raises the same :exc:`ValueError` the standard library does, instead of an :exc:`AttributeError`. Found by updating gevent's copy of the standard library test cases. Initially reported in :issue:`735` by Dmitrij D. Czarkoff. - Python 3: Fix :meth:`~ssl.SSLSocket.unwrap` and SNI callbacks. Also raise the correct exceptions for unconnected SSL sockets and properly validate SSL hostnames. Found via updated standard library tests. - Python 3: Add missing support for :meth:`socket.socket.sendfile`. Found via updated standard library tests. - Python 3.4+: Add missing support for :meth:`socket.socket.get_inheritable` and :meth:`~socket.socket.set_inheritable`. Found via updated standard library tests. 1.1rc3 (Jan 04, 2016) ===================== - Python 2: Support the new PEP 466 :mod:`ssl` interfaces on any Python 2 version that supplies them, not just on the versions it officially shipped with. Some Linux distributions, including RedHat/CentOS and Amazon have backported the changes to older versions. Reported in :issue:`702`. - PyPy: An interaction between Cython compiled code and the garbage collector caused PyPy to crash when a previously-allocated Semaphore was used in a ``__del__`` method, something done in the popular libraries ``requests`` and ``urllib3``. Due to this and other Cython related issues, the Semaphore class is no longer compiled by Cython on PyPy. This means that it is now traceable and not exactly as atomic as the Cython version, though the overall semantics should remain the same. Reported in :issue:`704` by Shaun Crampton. - PyPy: Optimize the CFFI backend to use less memory (two pointers per watcher). - Python 3: The WSGI ``PATH_INFO`` entry is decoded from URL escapes using latin-1, not UTF-8. This improves compliance with PEP 3333 and compatibility with some frameworks like Django. Fixed in :pr:`712` by Ruben De Visscher. 1.1rc2 (Dec 11, 2015) ===================== - Exceptions raised by gevent's SSL sockets are more consistent with the standard library (e.g., gevent's Python 3 SSL sockets raise :exc:`socket.timeout` instead of :exc:`ssl.SSLError`, a change introduced in Python 3.2). - Python 2: gevent's socket's ``sendall`` method could completely ignore timeouts in some cases. The timeout now refers to the total time taken by ``sendall``. - gevent's SSL socket's ``sendall`` method should no longer raise ``SSL3_WRITE_PENDING`` in rare cases when sending large buffers. Reported in :issue:`317`. - :func:`gevent.signal.signal` now allows resetting (SIG_DFL) and ignoring (SIG_IGN) the SIGCHLD signal at the process level (although this may allow race conditions with libev child watchers). Reported in :issue:`696` by Adam Ning. - :func:`gevent.spawn_raw` now accepts keyword arguments, as previously (incorrectly) documented. Reported in :issue:`680` by Ron Rothman. - PyPy: PyPy 2.6.1 or later is now required (4.0.1 or later is recommended). - The CFFI backend is now built and usable on CPython implementations (except on Windows) if ``cffi`` is installed before gevent is installed. To use the CFFI backend, set the environment variable ``GEVENT_CORE_CFFI_ONLY`` before starting Python. This can aid debugging in some cases and helps ensure parity across all combinations of supported platforms. - The CFFI backend now calls the callback of a watcher whose ``args`` attribute is set to ``None``, just like the Cython backend does. It also only allows ``args`` to be a tuple or ``None``, again matching the Cython backend. - PyPy/CFFI: Fix a potential crash when using stat watchers. - PyPy/CFFI: Encode unicode paths for stat watchers using :meth:`sys.getfilesystemencoding` like the Cython backend. - The internal implementation modules ``gevent._fileobject2``, ``gevent._fileobject3``, and ``gevent._util`` were removed. These haven't been used or tested since 1.1b1. 1.1rc1 (Nov 14, 2015) ===================== - Windows/Python 3: Finish porting the :mod:`gevent.subprocess` module, fixing a large number of failing tests. Examples of failures are in :issue:`668` and :issue:`669` reported by srossross. - Python 3: The SSLSocket class should return an empty ``bytes`` object on an EOF instead of a ``str``. Fixed in :pr:`674` by Dahoon Kim. - Python 2: Workaround a buffering bug in the stdlib ``io`` module that caused ``FileObjectPosix`` to be slower than necessary in some cases. Reported in :issue:`675` by WGH-. - PyPy: Fix a crash. Reported in :issue:`676` by Jay Oster. .. caution:: There are some remaining, relatively rare, PyPy crashes, but their ultimate cause is unknown (gevent, CFFI, greenlet, the PyPy GC?). PyPy users can contribute to :issue:`677` to help track them down. - PyPy: Exceptions raised while handling an error raised by a loop callback function behave like the CPython implementation: the exception is printed, and the rest of the callbacks continue processing. - If a Hub object with active watchers was destroyed and then another one created for the same thread, which itself was then destroyed with ``destroy_loop=True``, the process could crash. Documented in :issue:`237` and fix based on :pr:`238`, both by Jan-Philip Gehrcke. - Python 3: Initializing gevent's hub for the first time simultaneously in multiple native background threads could fail with ``AttributeError`` and ``ImportError``. Reported in :issue:`687` by Gregory Petukhov. 1.1b6 (Oct 17, 2015) ==================== - PyPy: Fix a memory leak for code that allocated and disposed of many :class:`gevent.lock.Semaphore` subclasses. If monkey-patched, this could also apply to :class:`threading.Semaphore` objects. Reported in :issue:`660` by Jay Oster. - PyPy: Cython version 0.23.4 or later must be used to avoid a memory leak (`details`_). Thanks to Jay Oster. - Allow subclasses of :class:`~.WSGIHandler` to handle invalid HTTP client requests. Reported by not-bob. - :class:`~.WSGIServer` more robustly supports :class:`~logging.Logger`-like parameters for ``log`` and ``error_log`` (as introduced in 1.1b1, this could cause integration issues with gunicorn). Reported in :issue:`663` by Jay Oster. - :class:`~gevent.threading._DummyThread` objects, created in a monkey-patched system when :func:`threading.current_thread` is called in a new greenlet (which often happens implicitly, such as when logging) are much lighter weight. For example, they no longer allocate and then delete a :class:`~gevent.lock.Semaphore`, which is especially important for PyPy. - Request logging by :mod:`gevent.pywsgi` formats the status code correctly on Python 3. Reported in :issue:`664` by Kevin Chen. - Restore the ability to take a weak reference to instances of exactly :class:`gevent.lock.Semaphore`, which was unintentionally removed as part of making ``Semaphore`` atomic on PyPy on 1.1b1. Reported in :issue:`666` by Ivan-Zhu. - Build Windows wheels for Python 3.5. Reported in :pr:`665` by Hexchain Tong. .. _details: https://mail.python.org/pipermail/cython-devel/2015-October/004571.html 1.1b5 (Sep 18, 2015) ==================== - :mod:`gevent.subprocess` works under Python 3.5. In general, Python 3.5 has preliminary support. Reported in :issue:`653` by Squeaky. - :func:`Popen.communicate ` honors a ``timeout`` argument even if there is no way to communicate with the child process (none of stdin, stdout and stderr were set to ``PIPE``). Noticed as part of the Python 3.5 test suite for the new function ``subprocess.run`` but impacts all versions (``timeout`` is an official argument under Python 3 and a gevent extension with slightly different semantics under Python 2). - Fix a possible ``ValueError`` from :meth:`Queue.peek `. Reported in :issue:`647` by Kevin Chen. - Restore backwards compatibility for using ``gevent.signal`` as a callable, which, depending on the order of imports, could be broken after the addition of the ``gevent.signal`` module. Reported in :issue:`648` by Sylvain Zimmer. - gevent blocking operations performed at the top-level of a module after the system was monkey-patched under Python 2 could result in raising a :exc:`~gevent.hub.LoopExit` instead of completing the expected blocking operation. Note that performing gevent blocking operations in the top-level of a module is typically not recommended, but this situation can arise when monkey-patching existing scripts. Reported in :issue:`651` and :issue:`652` by Mike Kaplinskiy. - ``SIGCHLD`` and ``waitpid`` now work for the pids returned by the (monkey-patched) ``os.forkpty`` and ``pty.fork`` functions in the same way they do for the ``os.fork`` function. Reported in :issue:`650` by Erich Heine. - :class:`~gevent.pywsgi.WSGIServer` and :class:`~gevent.pywsgi.WSGIHandler` do a better job detecting and reporting potential encoding errors for headers and the status line during :meth:`~gevent.pywsgi.WSGIHandler.start_response` as recommended by the `WSGI specification`_. In addition, under Python 2, unnecessary encodings and decodings (often a trip through the ASCII encoding) are avoided for conforming applications. This is an enhancement of an already documented and partially enforced constraint: beginning in 1.1a1, under Python 2, ``u'abc'`` would typically previously have been allowed, but ``u'\u1f4a3'`` would not; now, neither will be allowed, more closely matching the specification, improving debugability and performance and allowing for better error handling both by the application and by gevent (previously, certain encoding errors could result in gevent writing invalid/malformed HTTP responses). Reported by Greg Higgins and Carlos Sanchez. - Code coverage by tests is now reported on `coveralls.io`_. .. _WSGI specification: https://www.python.org/dev/peps/pep-3333/#the-start-response-callable .. _coveralls.io: https://coveralls.io/github/gevent/gevent 1.1b4 (Sep 4, 2015) =================== - Detect and raise an error for several important types of programming errors even if Python interpreter optimizations are enabled with ``-O`` or ``PYTHONOPTIMIZE``. Previously these would go undetected if optimizations were enabled, potentially leading to erratic, difficult to debug behaviour. - Fix an ``AttributeError`` from ``gevent.queue.Queue`` when ``peek`` was called on an empty ``Queue``. Reported in :issue:`643` by michaelvol. - Make ``SIGCHLD`` handlers specified to :func:`gevent.signal.signal` work with the child watchers that are used by default. Also make :func:`gevent.os.waitpid` work with a first argument of -1. (Also applies to the corresponding monkey-patched stdlib functions.) Noted by users of gunicorn. - Under Python 2, any timeout set on a socket would be ignored when using the results of ``socket.makefile``. Reported in :issue:`644` by Karan Lyons. 1.1b3 (Aug 16, 2015) ==================== - Fix an ``AttributeError`` from ``gevent.monkey.patch_builtins`` on Python 2 when the `future`_ library is also installed. Reported by Carlos Sanchez. - PyPy: Fix a ``DistutilsModuleError`` or ``ImportError`` if the CFFI module backing ``gevent.core`` needs to be compiled when the hub is initialized (due to a missing or invalid ``__pycache__`` directory). Now, the module will be automtically compiled when gevent is imported (this may produce compiler output on stdout). Reported in :issue:`619` by Thinh Nguyen and :issue:`631` by Andy Freeland, with contributions by Jay Oster and Matt Dupre. - PyPy: Improve the performance of ``gevent.socket.socket:sendall`` with large inputs. `bench_sendall.py`_ now performs about as well on PyPy as it does on CPython, an improvement of 10x (from ~60MB/s to ~630MB/s). See this `pypy bug`_ for details. - Fix a possible ``TypeError`` when calling ``gevent.socket.wait``. Reported in #635 by lanstin. - ``gevent.socket.socket:sendto`` properly respects the socket's blocking status (meaning it can raise EWOULDBLOCK now in cases it wouldn't have before). Reported in :pr:`634` by Mike Kaplinskiy. - Common lookup errors using the :mod:`threaded resolver ` are no longer always printed to stderr since they are usually out of the programmer's control and caught explicitly. (Programming errors like ``TypeError`` are still printed.) Reported in :issue:`617` by Jay Oster and Carlos Sanchez. - PyPy: Fix a ``TypeError`` from ``gevent.idle()``. Reported in :issue:`639` by chilun2008. - The :func:`~gevent.pool.Pool.imap_unordered` methods of a pool-like object support a ``maxsize`` parameter to limit the number of results buffered waiting for the consumer. Reported in :issue:`638` by Sylvain Zimmer. - The class :class:`gevent.queue.Queue` now consistently orders multiple blocked waiting ``put`` and ``get`` callers in the order they arrived. Previously, due to an implementation quirk this was often roughly the case under CPython, but not under PyPy. Now they both behave the same. - The class :class:`gevent.queue.Queue` now supports the :func:`len` function. .. _future: http://python-future.org .. _bench_sendall.py: https://raw.githubusercontent.com/gevent/gevent/master/greentest/bench_sendall.py .. _pypy bug: https://bitbucket.org/pypy/pypy/issues/2091/non-blocking-socketsend-slow-gevent 1.1b2 (Aug 5, 2015) =================== - Enable using the :mod:`c-ares resolver ` under PyPy. Note that its performance characteristics are probably sub-optimal. - On some versions of PyPy on some platforms (notably 2.6.0 on 64-bit Linux), enabling ``gevent.monkey.patch_builtins`` could cause PyPy to crash. Reported in :issue:`618` by Jay Oster. - :func:`gevent.kill` raises the correct exception in the target greenlet. Reported in :issue:`623` by Jonathan Kamens. - Various fixes on Windows. Reported in :issue:`625`, :issue:`627`, and :issue:`628` by jacekt and Yuanteng (Jeff) Pei. Fixed in :pr:`624`. - Add :meth:`~gevent.fileobject.FileObjectPosix.readable` and :meth:`~gevent.fileobject.FileObjectPosix.writable` methods to :class:`~gevent.fileobject.FileObjectPosix`; this fixes e.g., help() on Python 3 when monkey-patched. 1.1b1 (Jul 17, 2015) ==================== - ``setup.py`` can be run from a directory containing spaces. Reported in :issue:`319` by Ivan Smirnov. - ``setup.py`` can build with newer versions of clang on OS X. They enforce the distinction between CFLAGS and CPPFLAGS. - ``gevent.lock.Semaphore`` is atomic on PyPy, just like it is on CPython. This comes at a small performance cost on PyPy. - Fixed regression that failed to set the ``successful`` value to False when killing a greenlet before it ran with a non-default exception. Fixed in :pr:`608` by Heungsub Lee. - libev's child watchers caused :func:`os.waitpid` to become unreliable due to the use of signals on POSIX platforms. This was especially noticeable when using :mod:`gevent.subprocess` in combination with ``multiprocessing``. Now, the monkey-patched ``os`` module provides a :func:`~gevent.os.waitpid` function that seeks to ameliorate this. Reported in :issue:`600` by champax and :issue:`452` by Łukasz Kawczyński. - On platforms that implement :class:`select.poll`, provide a gevent-friendly :class:`gevent.select.poll` and corresponding monkey-patch. Implemented in :pr:`604` by Eddi Linder. - Allow passing of events to the io callback under PyPy. Reported in :issue:`531` by M. Nunberg and implemented in :pr:`604`. - :func:`gevent.thread.allocate_lock` (and so a monkey-patched standard library :func:`~thread.allocate_lock`) more closely matches the behaviour of the builtin: an unlocked lock cannot be released, and attempting to do so throws the correct exception (``thread.error`` on Python 2, ``RuntimeError`` on Python 3). Previously, over-releasing a lock was silently ignored. Reported in :issue:`308` by Jędrzej Nowak. - :class:`gevent.fileobject.FileObjectThread` uses the threadpool to close the underling file-like object. Reported in :issue:`201` by vitaly-krugl. - Malicious or malformed HTTP chunked transfer encoding data sent to the :class:`pywsgi handler ` is handled more robustly, resulting in "HTTP 400 bad request" responses instead of a 500 error or, in the worst case, a server-side hang. Reported in :issue:`229` by Björn Lindqvist. - Importing the standard library ``threading`` module *before* using ``gevent.monkey.patch_all()`` no longer causes Python 3.4 to fail to get the ``repr`` of the main thread, and other CPython platforms to return an unjoinable DummyThread. (Note that this is not recommended.) Reported in :issue:`153`. - Under Python 2, use the ``io`` package to implement :class:`~gevent.fileobject.FileObjectPosix`. This unifies the code with the Python 3 implementation, and fixes problems with using ``seek()``. See :issue:`151`. - Under Python 2, importing a module that uses gevent blocking functions at its top level from multiple greenlets no longer produces import errors (Python 3 handles this case natively). Reported in :issue:`108` by shaun and initial fix based on code by Sylvain Zimmer. - :func:`gevent.spawn`, :func:`spawn_raw` and :func:`spawn_later`, as well as the :class:`~gevent.Greenlet` constructor, immediately produce useful ``TypeErrors`` if asked to run something that cannot be run. Previously, the spawned greenlet would die with an uncaught ``TypeError`` the first time it was switched to. Reported in :issue:`119` by stephan. - Recursive use of :meth:`ThreadPool.apply ` no longer raises a ``LoopExit`` error (using ``ThreadPool.spawn`` and then ``get`` on the result still could; you must be careful to use the correct hub). Reported in :issue:`131` by 8mayday. - When the :mod:`threading` module is :func:`monkey-patched `, the module-level lock in the :mod:`logging` module is made greenlet-aware, as are the instance locks of any configured handlers. This makes it safer to import modules that use the standard pattern of creating a module-level :class:`~logging.Logger` instance before monkey-patching. Configuring ``logging`` with a basic configuration and then monkey-patching is also safer (but not configurations that involve such things as the ``SocketHandler``). - Fix monkey-patching of :class:`threading.RLock` under Python 3. - Under Python 3, monkey-patching at the top-level of a module that was imported by another module could result in a :exc:`RuntimeError` from :mod:`importlib`. Reported in :issue:`615` by Daniel Mizyrycki. (The same thing could happen under Python 2 if a ``threading.RLock`` was held around the monkey-patching call; this is less likely but not impossible with import hooks.) - Fix configuring c-ares for a 32-bit Python when running on a 64-bit platform. Reported in :issue:`381` and fixed in :pr:`616` by Chris Lane. Additional fix in :pr:`626` by Kevin Chen. - (Experimental) Let the :class:`pywsgi.WSGIServer` accept a :class:`logging.Logger` instance for its ``log`` and (new) ``error_log`` parameters. Take care that the system is fully monkey-patched very early in the process's lifetime if attempting this, and note that non-file handlers have not been tested. Fixes :issue:`106`. 1.1a2 (Jul 8, 2015) =================== - ``gevent.threadpool.ThreadPool.imap`` and ``imap_unordered`` now accept multiple iterables. - (Experimental) Exceptions raised from iterating using the ``ThreadPool`` or ``Group`` mapping/application functions should now have the original traceback. - :meth:`gevent.threadpool.ThreadPool.apply` now raises any exception raised by the called function, the same as :class:`~gevent.pool.Group`/:class:`~gevent.pool.Pool` and the builtin :func:`apply` function. This obsoletes the undocumented ``apply_e`` function. Original PR :issue:`556` by Robert Estelle. - Monkey-patch the ``selectors`` module from ``patch_all`` and ``patch_select`` on Python 3.4. See :issue:`591`. - Additional query functions for the :mod:`gevent.monkey` module allow knowing what was patched. Discussed in :issue:`135` and implemented in :pr:`325` by Nathan Hoad. - In non-monkey-patched environments under Python 2.7.9 or above or Python 3, using a gevent SSL socket could cause the greenlet to block. See :issue:`597` by David Ford. - :meth:`gevent.socket.socket.sendall` supports arbitrary objects that implement the buffer protocol (such as ctypes structures), just like native sockets. Reported in :issue:`466` by tzickel. - Added support for the ``onerror`` attribute present in CFFI 1.2.0 for better signal handling under PyPy. Thanks to Armin Rigo and Omer Katz. (See https://bitbucket.org/cffi/cffi/issue/152/handling-errors-from-signal-handlers-in) - The :mod:`gevent.subprocess` module is closer in behaviour to the standard library under Python 3, at least on POSIX. The ``pass_fds``, ``restore_signals``, and ``start_new_session`` arguments are now implemented, as are the ``timeout`` parameters to various functions. Under Python 2, the previously undocumented ``timeout`` parameter to :meth:`Popen.communicate ` raises an exception like its Python 3 counterpart. - An exception starting a child process with the :mod:`gevent.subprocess` module no longer leaks file descriptors. Reported in :pr:`374` by 陈小玉. - The example ``echoserver.py`` no longer binds to the standard X11 TCP port. Reported in :issue:`485` by minusf. - :func:`gevent.iwait` no longer throws :exc:`~gevent.hub.LoopExit` if the caller switches greenlets between return values. Reported and initial patch in :issue:`467` by Alexey Borzenkov. - The default threadpool and default threaded resolver work in a forked child process, such as with :class:`multiprocessing.Process`. Previously the child process would hang indefinitely. Reported in :issue:`230` by Lx Yu. - Fork watchers are more likely to (eventually) get called in a multi-threaded program (except on Windows). See :issue:`154`. - :func:`gevent.killall` accepts an arbitrary iterable for the greenlets to kill. Reported in :issue:`404` by Martin Bachwerk; seen in combination with older versions of simple-requests. - :class:`gevent.local.local` objects are now eligible for garbage collection as soon as the greenlet finishes running, matching the behaviour of the built-in :class:`threading.local` (when implemented natively). Reported in :issue:`387` by AusIV. - Killing a greenlet (with :func:`gevent.kill` or :meth:`gevent.Greenlet.kill`) before it is actually started and switched to now prevents the greenlet from ever running, instead of raising an exception when it is later switched to. See :issue:`330` reported by Jonathan Kamens. 1.1a1 (Jun 29, 2015) ==================== - Add support for Python 3.3 and 3.4. Many people have contributed to this effort, including but not limited to Fantix King, hashstat, Elizabeth Myers, jander, Luke Woydziak, and others. See :issue:`38`. - Add support for PyPy. See :issue:`248`. Note that for best results, you'll need a very recent PyPy build including CFFI 1.2.0. - Drop support for Python 2.5. Python 2.5 users can continue to use gevent 1.0.x. - Fix :func:`gevent.joinall` to not ignore ``count`` when ``raise_error`` is False. See :pr:`512` by Ivan Diao. - Fix :class:`gevent.subprocess.Popen` to not ignore the ``bufsize`` argument. Note that this changes the (platform dependent) default, typically from buffered to unbuffered. See :pr:`542` by Romuald Brunet. - Upgraded c-ares to 1.10.0. See :pr:`579` by Omer Katz. .. caution:: The c-ares ``configure`` script is now more strict about the contents of environment variables such as ``CFLAGS`` and ``LDFLAGS`` and they may have to be modified (for example, ``CFLAGS`` is no longer allowed to include ``-I`` directives, which must instead be placed in ``CPPFLAGS``). - Add a ``count`` argument to :func:`gevent.iwait`. See :pr:`482` by wiggin15. - Add a ``timeout`` argument to :meth:`gevent.queue.JoinableQueue.join` which now returns whether all items were waited for or not. - ``gevent.queue.JoinableQueue`` treats ``items`` passed to ``__init__`` as unfinished tasks, the same as if they were ``put``. Initial :pr:`554` by DuLLSoN. - ``gevent.pywsgi`` no longer prints debugging information for the normal conditions of a premature client disconnect. See :issue:`136`, fixed in :pr:`377` by Paul Collier. - (Experimental.) Waiting on or getting results from greenlets that raised exceptions now usually raises the original traceback. This should assist things like Sentry to track the original problem. See :issue:`450` and :issue:`528` by Rodolfo and Eddi Linder and :issue:`240` by Erik Allik. - Upgrade to libev 4.20. See :pr:`590` by Peter Renström. - Fix ``gevent.baseserver.BaseServer`` to be printable when its ``handle`` function is an instancemethod of itself. See :pr:`501` by Joe Jevnik. - Make the ``acquire`` method of ``gevent.lock.DummySemaphore`` always return True, supporting its use-case as an "infinite" or unbounded semaphore providing no exclusion, and allowing the idiom ``if sem.acquire(): ...``. See :pr:`544` by Mouad Benchchaoui. - Patch ``subprocess`` by default in ``gevent.monkey.patch_all``. See :issue:`446`. - ``gevent.pool.Group.imap`` and ``imap_unordered`` now accept multiple iterables like ``itertools.imap``. :issue:`565` reported by Thomas Steinacher. - *Compatibility note*: ``gevent.baseserver.BaseServer`` and its subclass ``gevent.server.StreamServer`` now deterministically close the client socket when the request handler returns. Previously, the socket was left at the mercies of the garbage collector; under CPython 2.x this meant when the last reference went away, which was usually, but not necessarily, when the request handler returned, but under PyPy it was some arbitrary point in the future and under CPython 3.x a ResourceWarning could be generated. This was undocumented behaviour, and the client socket could be kept open after the request handler returned either accidentally or intentionally. - *Compatibility note*: ``pywsgi`` now ensures that headers can be encoded in latin-1 (ISO-8859-1). This improves adherence to the HTTP standard (and is necessary under Python 3). Under certain conditions, previous versions could have allowed non-ISO-8859-1 headers to be sent, but their interpretation by a conforming recipient is unknown; now, a UnicodeError will be raised. See :issue:`614`. Release 1.0.2 ============= - Fix LifoQueue.peek() to return correct element. :pr:`456`. Patch by Christine Spang. - Upgrade to libev 4.19 - Remove SSL3 entirely as default TLS protocol - Import socket on Windows (closes :issue:`459`) - Fix C90 syntax error (:pr:`449`) - Add compatibility with Python 2.7.9's SSL changes. :issue:`477`. Release 1.0.1 ============= - Fix :issue:`423`: Pool's imap/imap_unordered could hang forever. Based on patch and test by Jianfei Wang. Release 1.0 (Nov 26, 2013) ========================== - pywsgi: Pass copy of error list instead of direct reference. Thanks to Jonathan Kamens, Matt Iversen. - Ignore the autogenerated doc/gevent.*.rst files. Patch by Matthias Urlichs. - Fix cythonpp.py on Windows. Patch by Jeryn Mathew. - Remove gevent.run (use gevent.wait). Release 1.0rc3 (Sep 14, 2013) ============================= - Fix :issue:`251`: crash in gevent.core when accessing destroyed loop. - Fix :issue:`235`: Replace self._threadpool.close() with self._threadpool.kill() in hub.py. Patch by Jan-Philip Gehrcke. - Remove unused timeout from select.py (:issue:`254`). Patch by Saúl Ibarra Corretgé. - Rename Greenlet.link()'s argument to 'callback' (closes :issue:`244`). - Fix parallel build (:issue:`193`). Patch by Yichao Yu. - Fix :issue:`263`: potential UnboundLocalError: 'length' in gevent.pywsgi. - Simplify psycopg2_pool.py (:issue:`239`). Patch by Alex Gaynor. - pywsgi: allow Content-Length in GET requests (:issue:`264`). Patch by 陈小玉. - documentation fixes (:issue:`281`) [philipaconrad]. - Fix old documentation about default blocking behavior of kill, killall (:issue:`306`). Patch by Daniel Farina. - Fix :issue:`6`: patch sys after thread. Patch by Anton Patrushev. - subprocess: fix check_output on Py2.6 and older (:issue:`265`). Thanks to Marc Sibson for test. - Fix :issue:`302`: "python -m gevent.monkey" now sets __file__ properly. - pywsgi: fix logging when bound on unix socket (:issue:`295`). Thanks to Chris Meyers, Eugene Pankov. - pywsgi: readout request data to prevent ECONNRESET - Fix :issue:`303`: 'requestline' AttributeError in pywsgi. Thanks to Neil Chintomby. - Fix :issue:`79`: Properly handle HTTP versions. Patch by Luca Wehrstedt. - Fix :issue:`216`: propagate errors raised by Pool.map/imap Release 1.0rc2 (Dec 10, 2012) ============================= - Fixed :issue:`210`: callbacks were not run for non-default loop (bug introduced in 1.0rc1). - patch_all() no longer patches subprocess unless `subprocess=True` is passed. - Fixed AttributeError in hub.Waiter. - Fixed :issue:`181`: make hidden imports visible to freezing tools like py2exe. Patch by Ralf Schmitt. - Fixed :issue:`202`: periodically yield when running callbacks (sleep(0) cannot block the event loop now). - Fixed :issue:`204`: os.tp_read/tp_write did not propogate errors to the caller. - Fixed :issue:`217`: do not set SO_REUSEADDR on Windows. - Fixed bug in --module argument for gevent.monkey. Patch by Örjan Persson. - Remove warning from threadpool.py about mixing fork() and threads. - Cleaned up hub.py from code that was needed to support older greenlets. Patch by Saúl Ibarra Corretgé. - Allow for explicit default loop creation via `get_hub(default=True)`. Patch by Jan-Philip Gehrcke. Release 1.0rc1 (Oct 30, 2012) ============================= - Fixed hub.switch() not to touch stacktrace when switching. greenlet restores the exception information correctly since version 0.3.2. gevent now requires greenlet >= 0.3.2 - Added gevent.wait() and gevent.iwait(). This is like gevent.joinall() but supports more objects, including Greenlet, Event, Semaphore, Popen. Without arguments it waits for the event loop to finish (previously gevent.run() did that). gevent.run will be removed before final release and gevent.joinall() might be deprecated. - Reimplemented loop.run_callback with a list and a single prepare watcher; this fixes the order of spawns and improves performance a little. - Fixes Semaphore/Lock not to init hub in `__init__`, so that it's possible to have module-global locks without initializing the hub. This fixes monkey.patch_all() not to init the hub. - New implementation of callbacks that executes them in the order they were added. core.loop.callback is removed. - Fixed 2.5 compatibility. - Fixed crash on Windows when request 'prev' and 'attr' attributes of 'stat' watcher. The attribute access still fails, but now with an exception. - Added known_failures.txt that lists all the tests that fail. It can be used by testrunner.py via expected option. It's used when running the test suite in travis. - Fixed socket, ssl and fileobject to not mask EBADF error - it is now propogated to the caller. Previously EBADF was converted to empty read/write. Thanks to Vitaly Kruglikov - Removed gevent.event.waitall() - Renamed FileObjectThreadPool -> FileObjectThread - Greenlet: Fixed :issue:`143`: greenlet links are now executed in the order they were added - Synchronize access to FileObjectThread with Semaphore - EINVAL is no longer handled in fileobject. monkey: - Fixed :issue:`178`: disable monkey patch os.read/os.write - Fixed monkey.patch_thread() to patch threading._DummyThread to avoid leak in threading._active. Original patch by Wil Tan. - added Event=False argument to patch_all() and patch_thread - added patch_sys() which patches stdin, stdout, stderr with FileObjectThread wrappers. Experimental / buggy. - monkey patching everything no longer initializes the hub/event loop. socket: - create_connection: do not lookup IPv6 address if IPv6 is unsupported. Patch by Ralf Schmitt. pywsgi: - Fixed :issue:`86`: bytearray is now supported. Original patch by Aaron Westendorf. - Fixed :issue:`116`: Multiline HTTP headers are now handled properly. Patch by Ralf Schmitt. subprocess: - Fixed Windows compatibility. The wait() method now also supports 'timeout' argument on Windows. - Popen: Added rawlink() method, which makes Popen objects supported by gevent.wait(). Updated examples/processes.py - Fixed :issue:`148`: read from errpipe_read in small chunks, to avoid trigger EINVAL issue on Mac OS X. Patch by Vitaly Kruglikov - Do os._exit() in "finally" section to avoid executing unrelated code. Patch by Vitaly Kruglikov. resolver_ares: - improve getaddrinfo: For string ports (e.g. "http") resolver_ares/getaddrinfo previously only checked either getservbyname(port, "tcp") or getservbyname(port, "udp"), but never both. It now checks both of them. - gevent.ares.channel now accepts strings as arguments - upgraded c-ares to cares-1_9_1-12-g805c736 - it is now possible to configure resolver_ares directly with environ, like GEVENTARES_SERVERS os: - Renamed threadpool_read/write to tp_read/write. - Removed posix_read, posix_write. - Added nb_read, nb_write, make_nonblocking. hub: - The system error is now raised immediatelly in main greenlet in all cases. - Dropped support for old greenlet versions (need >= 0.3.2 now) core: - allow 'callback' property of watcher to be set to None. "del w.callback" no longer works. - added missing 'noinotify' flag Misc: - gevent.thread: allocate_lock is now an alias for LockType/Semaphore. That way it does not fail when being used as class member. - Updated greentest.py to start timeouts with `ref=False`. - pool: remove unused get_values() function - setup.py now recognizes GEVENTSETUP_EV_VERIFY env var which sets EV_VERIFY macro when compiling - Added a few micro benchmarks - stdlib tests that we care about are now included in greentest/2.x directories, so we don't depend on them being installed system-wide - updated util/makedist.py - the testrunner was completely rewritten. Release 1.0b4 (Sep 6, 2012) =========================== - Added gevent.os module with 'read' and 'write' functions. Patch by Geert Jansen. - Moved gevent.hub.fork to gevent.os module (it is still available as gevent.fork). - Fixed :issue:`148`: Made fileobject handle EINVAL, which is randomly raised by os.read/os.write on Mac OS X. Thanks to Mark Hingston. - Fixed :issue:`150`: gevent.fileobject.SocketAdapter.sendall() could needlessly wait for write event on the descriptor. Original patch by Mark Hingston. - Fixed AttributeError in baseserver. In case of error, start() would call kill() which was renamed to close(). Thanks to Vitaly Kruglikov. Release 1.0b3 (Jul 27, 2012) ============================ - New gevent.subprocess module - New gevent.fileobject module - Fixed ThreadPool to discard references of the objects passed to it (function, arguments) asap. Previously they could be stored for unlimited time until the thread gets a new job. - Fixed :issue:`138`: gevent.pool.Pool().imap_unordered hangs with an empty iterator. Thanks to exproxus. - Fixed :issue:`127`: ssl.py could raise TypeError in certain cases. Thanks to Johan Mjones. - Fixed socket.makefile() to keep the timeout setting of the socket instance. Thanks to Colin Marc. - Added 'copy()' method to queues. - The 'nochild' event loop config option is removed. The install_sigchld offer more flexible way of enabling child watchers. - core: all watchers except for 'child' now accept new 'priority' keyword argument - gevent.Timeout accepts new arguments: 'ref' and 'priority'. The default priority for Timeout is -1. - Hub.wait() uses Waiter now instead of raw switching - Updated libev to the latest CVS version - Made pywsgi to raise an AssertionError if non-zero content-length is passed to start_response(204/304) or if non-empty body is attempted to be written for 304/204 response - Removed pywsgi feature to capitalize the passed headers. - Fixed util/cythonpp.py to work on python3.2 (:issue:`123`). Patch by Alexandre Kandalintsev. - Added 'closed' readonly property to socket. - Added 'ref' read/write property to socket. - setup.py now parses CARES_EMBED and LIBEV_EMBED parameters, in addition to EMBED. - gevent.reinit() and gevent.fork() only reinit hub if it was created and do not create it themselves - Fixed setup.py not to add libev and c-ares to include dirs in non-embed mode. Patch by Ralf Schmitt. - Renamed util/make_dist.py to util/makedist.py - testrunner.py now saves more information about the system; the stat printing functionality is moved to a separate util/stat.py script. Release 1.0b2 (Apr 11, 2012) ============================ Major and backward-incompatible changes: - Made the threadpool-based resolver the default. To enable the ares-based resolver, set GEVENT_RESOLVER=ares env var. - Added support for child watchers (not available on Windows). - Libev loop now reaps all children by default. - If NOCHILD flag is passed to the loop, child watchers and child reaping are disabled. - Renamed gevent.coros to gevent.lock. The gevent.coros is still available but deprecated. - Added 'stat' watchers to loop. - The setup.py now recognizes gevent_embed env var. When set to "no", bundled c-ares and libev are ignored. - Added optional 'ref' argument to sleep(). When ref=false, the watchers created by sleep() do not hold gevent.run() from exiting. - ThreadPool now calls Hub.handle_error for exceptions in worker threads. - ThreadPool got new method: apply_e. - Added new extension module gevent._util and moved gevent.core.set_exc_info function there. - Added new extension module gevent._semaphore. It contains Semaphore class which is imported by gevent.lock as gevent.lock.Semaphore. Providing Semaphore in extension module ensures that trace function set with settrace will not be called during __exit__. Thanks to Ralf Schmitt. - It is now possible to kill or pre-spawn threads in ThreadPool by setting its 'size' property. core: - Make sure the default loop cannot be destroyed more than once, thus crashing the process. - Make Hub.destroy() method not to destroy the default loop, unless *destroy_loop* is *True*. Non-default loops are still destroyed by default. - loop: Removed properties from loop: fdchangecnt, timercnt, asynccnt. - loop: Added properties: sigfd, origflags, origflags_int - loop: The EVFLAG_NOENV is now always passed to libev. Thus LIBEV_FLAGS env variable is no longer checked. Use GEVENT_BACKEND. Misc: - Check that the argument of link() is callable. Raise TypeError when it's not. - Fixed TypeError in baseserver when parsing an address. - Pool: made add() and discard() usable by external users. Thanks to Danil Eremeev. - When specifying a class to import, it is now possible to use format path/package.module.name - pywsgi: Made sure format_request() does not fail if 'status' attribute is not set yet - pywsgi: Added REMOTE_PORT variable to the environment. Examples: - portforwarder.py now shows how to use gevent.run() to implement graceful shutdown of a server. - psycopg2_pool.py: Changed execute() to return rowcount. - psycopg2_pool.py: Added fetchall() and fetchiter() methods. Developer utilities: - When building, CYTHON env variable can be used to specify Cython executable to use. - util/make_dist.py now recongizes --fast and --revert options. Previous --rsync option is removed. - Added util/winvbox.py which automates building/testing/making binaries on Windows VM. - Fixed typos in exception handling code in testrunner.py - Fixed patching unittest.runner on Python2.7. This caused the details of test cases run lost. - Made testrunner.py kill the whole process group after test is done. Release 1.0b1 (Jan 10, 2012) ============================ Backward-incompatible changes: - Removed "link to greenlet" feature of Greenlet. - If greenlet module older than 0.3.2 is used, then greenlet.GreenletExit.__bases__ is monkey patched to derive from BaseException and not Exception. That way gevent.GreenletExit is always derived from BaseException, regardless of installed greenlet version. - Some code supporting Python 2.4 has been removed. Release highlights: - Added thread pool: gevent.threadpool.ThreadPool. - Added thread pool-based resolver. Enable with GEVENT_RESOLVER=thread. - Added UDP server: gevent.server.DatagramServer - A "configure" is now run on libev. This fixes a problem of 'kqueue' not being available on Mac OS X. - Gevent recognizes some environment variables now: - GEVENT_BACKEND allows passing argument to loop, e.g. "GEVENT_BACKEND=select" for force select backend - GEVENT_RESOLVER allows choosing resolver class. - GEVENT_THREADPOOL allows choosing thread pool class. - Added new examples: portforwarder, psycopg2_pool.py, threadpool.py, udp_server.py - Fixed non-embedding build. To build against system libev, remove or rename 'libev' directory. To build against system c-ares, remove or rename 'c-ares'. Thanks to Örjan Persson. misc: - gevent.joinall() method now accepts optional 'count' keyword. - gevent.fork() only calls reinit() in the child process now. - gevent.run() now returns False when exiting because of timeout or event (previous None). - Hub got a new method: destroy(). - Hub got a new property: threadpool. ares.pyx: - Fixed :issue:`104`: made ares_host_result pickable. Thanks to Shaun Cutts. pywsgi: - Removed unused deprecated 'wfile' property from WSGIHandler - Fixed :issue:`92`: raise IOError on truncated POST requests. - Fixed :issue:`93`: do not sent multiple "100 continue" responses core: - Fixed :issue:`97`: the timer watcher now calls ev_now_update() in start() and again() unless 'update' keyword is passed and set to False. - add set_syserr_cb() function; it's used by gevent internally. - gevent now installs syserr callback using libev's set_syserr_cb. This callback is called when libev encounters an error it cannot recover from. The default action is to print a message and abort. With the callback installed, a SystemError() is now raised in the main greenlet. - renamed 'backend_fd' property to 'fileno()' method. (not available if you build gevent against system libev) - added 'asynccnt' property (not available if you build gevent against system libev) - made loop.__repr__ output a bit more compact - the watchers check the arguments for validness now (previously invalid argument would crash libev). - The 'async' watcher now has send() method; - fixed time() function - libev has been upgraded to latest CVS version. - libev has been patched to use send()/recv() for evpipe on windows when libev_vfd.h is in effect resolver_ares: - Slightly improved compatibility with stdlib's socket in some error cases. socket: - Fixed close() method not to reference any globals - Fixed :issue:`115`: _dummy gets unexpected Timeout arg - Removed _fileobject used for python 2.4 compatibility in socket.py - Fixed :issue:`94`: fallback to buffer if memoryview fails in _get_memory on python 2.7 monkey: - Removed patch_httplib() - Fixed :issue:`112`: threading._sleep is not patched. Thanks to David LaBissoniere. - Added get_unpatched() function. However, it is slightly broken at the moment. backdoor: - make 'locals()' not spew out __builtin__.__dict__ in backdoor - add optional banner argument to BackdoorServer servers: - add server.DatagramServer; - StreamServer: 'ssl_enabled' is now a read-only property - servers no longer have 'kill' method; it has been renamed to 'close'. - listeners can now be configured as strings, e.g. ':80' or 80 - modify baseserver.BaseServer in such a way that makes it a good base class for both StreamServer and DatagramServer - BaseServer no longer accepts 'backlog' parameter. It is now done by StreamServer. - BaseServer implements start_accepting() and stop_accepting() methods - BaseServer now implements "temporarily stop accepting" strategy - BaseServer now has _do_read method which does everything except for actually calling accept()/recvfrom() - pre_start() method is renamed to init_socket() - renamed _stopped_event to _stop_event - 'started' is now a read-only property (which actually reports state of _stop_event) - post_stop() method is removed - close() now sets _stop_event(), thus setting 'started' to False, thus causing serve_forever() to exit - _tcp_listener() function is moved from baseserver.py to server.py - added 'fatal_errors' class attribute which is a tuple of all errnos that should kill the server coros: - Semaphore: add _start_notify() method - Semaphore: avoid copying list of links; rawlink() no longer schedules notification Release 1.0a3 (Sep 15, 2011) ============================ Added 'ref' property to all watchers. Settings it to False make watcher call ev_unref/ev_ref appropriately so that this watcher does not prevent loop.run()/hub.join()/run() from exiting. Made resolver_ares.Resolver use 'ref' property for internal watcher. In all servers, method "kill" was renamed to "close". The old name is available as deprecated alias. Added a few properties to the loop: backend_fd, fdchangecnt, timercnt. Upgraded c-ares to 1.7.5+patch. Fixed getaddrinfo to return results in the order (::1, IPv4, IPv6). Fixed getaddrinfo() to handle integer of string type. Thanks to kconor. Fixed gethostbyname() to handle '' (empty string). Fixed getaddrinfo() to convert UnicodeEncodeError into error('Int or String expected'). Fixed getaddrinfo() to uses the lowest 16 bits of passed port integer similar to built-in _socket. Fixed getnameinfo() to call getaddrinfo() to process arguments similar to built-in _socket. Fixed gethostbyaddr() to use getaddrinfo() to process arguments. version_info is now a 5-tuple. Added handle_system_error() method to Hub (used internally). Fixed Hub's run() method to never exit. This prevent inappropriate switches into parent greenlet. Fixed Hub.join() to return True if Hub was already dead. Added 'event' argument to Hub.join(). Added `run()` function to gevent top level package. Fixed Greenlet.start() to exit silently if greenlet was already started rather than raising :exc:`AssertionError`. Fixed Greenlet.start() not to schedule another switch if greenlet is already dead. Fixed gevent.signal() to spawn Greenlet instead of raw greenlet. Also it'll switch into the new greenlet immediately instead of scheduling additional callback. Do monkey patch create_connection() as gevent's version works better with gevent.socket.socket than the standard create_connection. pywsgi: make sure we don't try to read more requests if socket operation failed with EPIPE pywsgi: if we failed to send the reply, change 'status' to socket error so that the logs mention the error. Release 1.0a2 (Aug 2, 2011) =========================== Fixed a bug in gevent.queue.Channel class. (Thanks to Alexey Borzenkov) Release 1.0a1 (Aug 2, 2011) =========================== Backward-incompatible changes: - Dropped support for Python 2.4. - `Queue(0)` is now equivalent to an unbound queue and raises :exc:`DeprecationError`. Use :class:`gevent.queue.Channel` if you need a channel. - Deprecated ability to pass a greenlet instance to :meth:`Greenlet.link`, :meth:`Greenlet.link_value` and :meth:`Greenlet.link_exception`. - All of :mod:`gevent.core` has been rewritten and the interface is not compatible. - :exc:`SystemExit` and :exc:`SystemError` now kill the whole process instead of printing a traceback. - Removed deprecated :class:`util.lazy_property` property. - Removed :mod:`gevent.dns` module. - Removed deprecated gevent.sslold module - Removed deprecated gevent.rawgreenlet module - Removed deprecated name `GreenletSet` which used to be alias for :class:`Group`. Release highlights: - The :mod:`gevent.core` module now wraps libev's API and is not compatible with gevent 0.x. - Added a concept of pluggable event loops. By default gevent.core.loop is used, which is a wrapper around libev. - Added a concept of pluggable name resolvers. By default a resolver based on c-ares library is used. - Added support for multiple OS threads, each new thread will get its own Hub instance with its own event loop. - The release now includes and embeds the dependencies: libev and c-ares. - The standard :mod:`signal` works now as expected. - The unhandled errors are now handled uniformely by `Hub.handle_error` function. - Added :class:`Channel` class to :mod:`gevent.queue` module. It is equivalent to `Queue(0)` in gevent 0.x, which is deprecated now. - Added method :meth:`peek` to :class:`Queue` class. - Added :func:`idle` function which blocks until the event loop is idle. - Added a way to gracefully shutdown the application by waiting for all outstanding greenlets/servers/watchers: :meth:`Hub.join`. - Added new :mod:`gevent.ares` C extension which wraps `c-ares` and provides asynchronous DNS resolver. - Added new :mod:`gevent.resolver_ares` module provides synchronous API on top of :mod:`gevent.ares`. The :mod:`gevent.socket` module: - DNS functions now use c-ares library rather than libevent-dns. This fixes a number of problems with name resolving: - Fix :issue:`2`: DNS resolver no longer breaks after `fork()`. You still need to call :func:`gevent.fork` (`os.fork` is monkey patched with it if `monkey.patch_all()` was called). - DNS resolver no longer ignores `/etc/resolv.conf` and `/etc/hosts`. - The following functions were added to socket module - gethostbyname_ex - getnameinfo - gethostbyaddr - getfqdn - Removed undocumented bind_and_listen and tcp_listener The :class:`Hub` object: - Added :meth:`join` method which waits until the event loop exits or optional timeout expires. - Added :meth:`wait` method which waits until a watcher has got an event. - Added :meth:`handle_error` method which is called by all of gevent in case of unhandled exception. - Added :meth:`print_exception` method which is called by `handle_error` to print the exception traceback. The :class:`Greenlet` objects: - Added `__nonzero__` implementation that returns `True` after greenlet was started until it's dead. Previously greenlet was `False` after `start()` until it was first switched to. The mod:`gevent.pool` module: - It is now possible to add raw greenlets to the pool. - The :meth:`map` and :meth:`imap` methods now start yielding the results as soon as possible. - The :meth:`imap_unordered` no longer swallows an exception raised while iterating its argument. Miscellaneous: - `gevent.sleep()` no longer raises an exception, instead it does `sleep(0)`. - Added method `clear` to internal `Waiter` class. - Removed `wait` method from internal `Waiter` class. - The :class:`WSGIServer` now sets `max_accept` to 1 if `wsgi.multiprocessing` is set to `True`. - Added :func:`monkey.patch_module` function that monkey patches module using `__implements__` list provided by gevent module. All of gevent modules that replace stdlib module now have `__implements__` attribute. Release 0.13.8 (September 6, 2012) ================================== - Fixed :issue:`80`: gevent.httplib failed with RequestFailed errors because timeout was reset to 1s. Patch by Tomasz Prus. - core: fix compilation with the latest Cython: remove emit_ifdef/emit_else/emit_endif. - Fixed :issue:`132`: gevent.socket.gethostbyname() now does ascii encoding and uses gevent's resolver rather than calling built-in resolver. Patch by Alexey Borzenkov. Release 0.13.7 (April 12, 2012) =============================== - Fixed :issue:`94`: fallback to buffer if memoryview fails in _get_memory on python 2.7. - Fixed :issue:`103`: ``Queue(None).full()`` returns ``False`` now (previously it returned ``True``). - Fixed :issue:`112`: threading._sleep is not patched. Thanks to David LaBissoniere. - Fixed :issue:`115`: _dummy gets unexpected Timeout arg. Release 0.13.6 (May 2, 2011) ============================ - Added ``__copy__`` method to :class:`gevent.local.local` class that implements copy semantics compatible with built-in ``threading.local``. Patch by **Galfy Pundee**. - Fixed :class:`StreamServer` class to catch ``EWOULDBLOCK`` rather than ``EAGAIN``. This fixes lots of spurious tracebacks on Windows where these two constants are not the same. Patch by **Alexey Borzenkov**. - Fixed :issue:`65`: :func:`fork` now calls ``event_reinit`` only in the child process; otherwise the process could hang when using libevent2. Patch by **Alexander Boudkar**. Release 0.13.5 (Apr 21, 2011) ============================= - Fixed build problem on Python 2.5 Release 0.13.4 (Apr 11, 2011) ============================= - Fixed :exc:`TypeError` that occurred when ``environ["wsgi.input"].read`` function was called with an integer argument. - Fixed :issue:`63`: :func:`monkey.patch_thread` now patches :mod:`threading` too, even if it's already imported. Patch by **Shaun Lindsay**. - Fixed :issue:`64`: :func:`joinall` and :func:`killall` functions used to hang if their argument contained duplicate greenlets. - Fixed :issue:`69`: :class:`pywsgi.WSGIServer` reported "Connection reset by peer" if the client did not close the connection gracefully after the last request. Such errors are now ignored. - Fixed :issue:`67`: Made :class:`wsgi.WSGIServer` add ``REQUEST_URI`` to environ. Patch by **Andreas Blixt**. - Fixed :issue:`71`: monkey patching ``httplib`` with :mod:`gevent.httplib` used to break ``HTTPSConnection``. Patch by **Nick Barkas**. - Fixed :issue:`74`: :func:`create_connection ` now raises proper exception when ``getaddrinfo`` fails. - Fixed :meth:`BaseServer.__repr__` method, :attr:`BaseServer.server_host` and :attr:`BaseServer.server_port` attributes to handle the case of ``AF_UNIX`` addresses properly. Previously they assumed address is always a tuple. - Fixed :class:`pywsgi.WSGIServer` to handle ``AF_UNIX`` listeners. The server now sets ``environ["SERVER_NAME"]`` and ``environ["SERVER_PORT"]`` to empty string in such case. - Make :class:`StreamServer` (and thus :class:`pywsgi.WSGIServer`) accept up to 100 connections per one readiness notification. This behaviour is controlled by :attr:`StreamServer.max_accept` class attribute. - If bind fails, the servers now include the address that caused bind to fail in the error message. Release 0.13.3 (Feb 7, 2011) ============================ - Fixed typo in :mod:`gevent.httplib` that rendered it unusable. - Removed unnecessary delay in :func:`getaddrinfo ` by calling ``resolve_ipv4`` and ``resolve_ipv6`` concurrently rather than sequentially in ``AF_UNSPEC`` case. Release 0.13.2 (Jan 28, 2011) ============================= - Added :mod:`gevent.httplib` -- **experimental** support for libevent-http client (:issue:`9`). Thanks to **Tommie Gannert**, **Örjan Persson**. - Fixed crash on Mac OS X (:issue:`31`). Patch by **Alexey Borzenkov**. - Fixed compatiblity of :mod:`gevent.wsgi` with libevent2 (:issue:`62`). - Fixed compilation issues with libevent2. Patch by **Ralf Schmitt**. - Fixed :mod:`pywsgi` not to use chunked transfer encoding in case of 304 and 204 responses as it creates a non-empty message body which is against RFC and causes some browsers to fail. Patch by **Nicholas Piël**. - Fixed :func:`socket.getaddrinfo` to handle ``AF_UNSPEC`` properly and resolve service names (:issue:`56`). Thanks to **Elizabeth Jennifer Myers**. - Fixed :func:`socket.getaddrinfo` to handle international domain names. - Fixed leaking of traceback object when switching out of greenlet with ``sys.exc_info`` set. Leaking is prevented by not preserving traceback at all and only keeping the value of the exception. Thanks to **Ned Rockson**. - Fixed :meth:`ssl.SSLSocket.unwrap` to shutdown :class:`SSLSocket` properly, without raising ``SSLError(read operation timeout)``. - Fixed :exc:`TypeError` inside :class:`Hub` on Python 2.4. - Made a number of internal improvements to :mod:`gevent.pywsgi` to make subclassing easier. - Changed :class:`WSGIServer ` to explicitly close the socket after the last request. Patch by **Ralf Schmitt**. - Fixed :class:`pywsgi.WSGIHandler` not to add ``CONTENT_TYPE`` to the *environ* dict when there's no ``Content-Type`` header in the request. Previously a default ``text/plain`` was added in such case. - Added proper implementation of :meth:`imap_unordered ` to :class:`Pool` class. Unlike previous "dummy" implementation this one starts yielding the results as soon as they are ready. - Implemented iterator protocol in :class:`Queue `. The main use case is the implementation of :meth:`Pool.imap_unordered`. - Fixed :attr:`BaseServer.started` property: it is now set to ``True`` after :meth:`start ` until :meth:`stop ` or :meth:`kill `. Previously it could become ``False`` for short period of times, because :class:`StreamServer` could stop accepting for a while in presence of errors and :attr:`StreamServer.started` was defined as "whether the server is currently accepting". - Fixed :class:`wsgi.WSGIServer` to reply with 500 error immediatelly if the application raises an error (:issue:`58`). Thanks to **Jon Aslund**. - Added :func:`monkey.patch_httplib` function which is disabled by default. - Added *httplib* parameter to :func:`monkey.patch_all` (defaults to ``False``). - Added :func:`write ` method to :class:`core.buffer`. - Fixed :exc:`OverflowError` that could happen in :meth:`core.event.__str__`. - Made :meth:`http_request.get_input_headers` return header names in lower case. - Fixed :class:`StreamServer` to accept *ciphers* as an SSL argument. - Added ``build_exc --cython=`` option to ``setup.py``. Patch by **Ralf Schmitt**. - Updated :class:`local ` to raise :exc:`AttributeError` if ``__dict__`` attribute is set or deleted. Release 0.13.1 (Sep 23, 2010) ============================= Release highlights: - Fixed :mod:`monkey` to patch :func:`socket.create_connection `. - Updated :mod:`gevent.ssl` module to fully match the functionality of :mod:`ssl` on Python 2.7. - Fixed :meth:`Group.join` to handle ``raise_error=True`` properly, it used to raise :exc:`TypeError` (:issue:`36`). Thanks to by **David Hain**. - Fixed :mod:`gevent.wsgi` and :mod:`gevent.pywsgi` to join multiple ``Cookie`` headers (:issue:`40`). - Fixed :func:`select ` to recognize ``long`` arguments in addition to ``int``. - Fixed :meth:`Semaphore.acquire` to return ``False`` when timeout expires instead of raising :exc:`AssertionError` (:issue:`39`). Patch by **Erik Näslund**. - Fixed :meth:`JoinableQueue.join` to return immediatelly if queue is already empty (:issue:`45`). Patch by **Dmitry Chechik**. - Deprecated :mod:`gevent.sslold` module. :mod:`gevent.socket` module: - Overrode :meth:`socket.shutdown` method to interrupt read/write operations on socket. - Fixed possible :exc:`NameError` in :meth:`socket.connect_ex` method. Patch by **Alexey Borzenkov**. - Fixed socket leak in :func:`create_connection` function. - Made :mod:`gevent.socket` import all public items from stdlib :mod:`socket` that do not do I/O. :mod:`gevent.ssl` module: - Imported a number of patches from stdlib by **Antoine Pitrou**: - Calling :meth:`makefile` method on an SSL object would prevent the underlying socket from being closed until all objects get truely destroyed (Python issue #5238). - SSL handshake would ignore the socket timeout and block indefinitely if the other end didn't respond (Python issue #5103). - When calling :meth:`getpeername` in ``SSLSocket.__init__``, only silence exceptions caused by the "socket not connected" condition. - Added support for *ciphers* argument. - Updated ``SSLSocket.send`` and ``SSLSocket.recv`` methods to match the behavior of stdlib :mod:`ssl` better. - Fixed :class:`ssl.SSLObject` to delete events used by other greenlets when closing the instance (:issue:`34`). Miscellaneous: - Made :class:`BaseServer` accept ``long`` values as *pool* argument in addition to ``int``. - Made :attr:`http._requests` attribute public. - Updated webchat example to use file on disk rather than in-memory sqlite database to avoid :exc:`OperationalError`. - Fixed ``webproxy.py`` example to be runnable under external WSGI server. - Fixed bogus failure in ``test__exc_info.py``. - Added new test to check PEP8 conformance: ``xtest_pep8.py``. - Fixed :class:`BackdoorServer` close the connection on :exc:`SystemExit` and simplified the code. - Made :class:`Pool` raise :exc:`ValueError` when initialized with ``size=0``. - Updated ``setup.py --libevent`` to configure and make libevent if it's not built already. - Updated ``setup.py`` to use ``setuptools`` if present and add dependency on ``greenlet``. - Fixed doc/mysphinxext.py to work with Sphinx 1. Thanks by **Örjan Persson**. Release 0.13.0 (Jul 14, 2010) ============================= Release highlights: - Added :mod:`gevent.server` module with :class:`StreamServer` class for easy implementing of TCP and SSL servers. - Added :mod:`gevent.baseserver` module with :class:`BaseServer` class. - Added new implementation of :mod:`gevent.pywsgi` based on :mod:`gevent.server`. Contributed by **Ralf Schmitt**. - Added :mod:`gevent.local` module. Fixed :issue:`24`. Thanks to **Ted Suzman**. - Fixed a number of bugs in :mod:`gevent.wsgi` module. - Fixed :issue:`26`: closing a socket now interrupts all pending read/write operations on it. - Implemented workaround that prevents greenlets from leaking ``exc_info``. - Fixed :meth:`socket.sendall` to use buffer object to prevent string copies. - Made the interfaces of :mod:`gevent.wsgi` and :mod:`gevent.pywsgi` much more similar to each other. - Fixed compilation on Windows with libevent-2. - Improved Windows compatibility. Fixed :issue:`30`. Thanks to **Luigi Pugnetti**. - Fixed compatibility with Python 2.7. Backward-incompatible changes: - Blocking is now the default behaviour for the :meth:`Greenlet.kill` method and other kill* methods. - Changed the inteface of :class:`http.HTTPServer` to match the interface of other servers. - Changed :class:`Pool`'s :meth:`spawn` method to block until there's a free slot. - Removed deprecated :func:`backdoor.backdoor_server` function. - Removed deprecated functions in :mod:`socket` module: - :func:`socket_bind_and_listen` - :func:`set_reuse_addr` - :func:`connect_tcp` - :func:`tcp_server` - Removed deprecated :attr:`socket.fd` property. - Deprecated use of negative numbers to indicate infinite timeout in :func:`core.event.add` and :func:`socket.wait_read` and similar. Use ``None`` from now on, which is compatible with the previous versions. - Derived :class:`backdoor.BackdoorServer` from :class:`StreamServer` rather than from :class:`Greenlet`. This adds lots of new features and removes a few old ones. - Removed non-standard :attr:`balance` property from :class:`Semaphore`. - Removed :func:`start`, :func:`set_cb` and :func:`set_gencb` from :class:`core.http`. - Removed :func:`set_closecb` from :class:`core.http_connection`. It is now used internally to detach the requests of the closed connections. - Deprecated :mod:`rawgreenlet` module. - Deprecated :func:`util.lazy_property`. - Renamed :class:`GreenletSet` to :class:`Group`. The old name is currently available as an alias. :mod:`gevent.socket` module: - Fixed issues :issue:`26` and :issue:`34`: closing the socket while reading/writing/connecting is now safe. Thanks to **Cyril Bay**. - Imported :func:`getfqdn` from :mod:`socket` module. - The module now uses ``sys.platform`` to detect Windows rather than :mod:`platform` module. - Fixed :issue:`27`: :func:`getaddrinfo` used to handle the case when *socktype* or *proto* were equal to ``0``. Thanks to **Randall Leeds**. :mod:`gevent.coros` module: - Added :class:`RLock` class. - Added :class:`DummySemaphore` class. - Fixed :class:`BoundedSemaphore` class to behave like :class:`threading.BoundedSemaphore` behaves. :mod:`gevent.event` module: - Made :meth:`Event.wait` return internal flag instead of ``None``. - Made :meth:`AsyncResult.wait` return its ``value`` instead of ``None``. - Added :meth:`ready` method as an alias for :meth:`is_set`. :mod:`gevent.wsgi` module: - Removed :class:`wsgi.buffer_proxy`. :mod:`gevent.pywsgi` module: - Rewritten to use :mod:`server` and not to depend on :mod:`BaseHTTPServer`. - Changed the interface to match :mod:`wsgi` module. Removed :func:`server` function, add :class:`Server` class, added :class:`WSGIServer` class. - Renamed :class:`HttpProtocol` to :class:`WSGIHandler`. - Fixed compatibility with webob by allowing an optional argument to :meth:`readline`. :mod:`gevent.core` module: - Fixed reference leaks in :class:`event` class. - Avoid Python name lookups when accessing EV_* constants from Cython code. Patch by **Daniele Varrazzo**. - Added *persist* argument to :class:`read_event`, :class:`write_event` and :class:`readwrite_event`. - Made all of the event loop callbacks clear the exception info before exiting. - Added :attr:`flags_str` property to :class:`event`. It is used by ``__str__`` and ``__repr__``. - :class:`buffer `: - Added :meth:`detach` method. - Implemented iterator protocol. - Fixed :meth:`readline` and :meth:`readlines` methods. - :class:`http_request`: - Fixed :meth:`detach` to detach input and output buffers too. - Changed the response to send 500 error upon deallocation, if no response was sent by the user. - Made :attr:`input_buffer` and :attr:`output_buffer` store and reuse the :class:`buffer` object they create. - Fixed :meth:`__str__` and meth:`__repr__` to include spaces where needed. - :class:`http` class no longer has :meth:`set_cb` and :meth:`set_gencb`. Instead its contructor accepts *handle* which will be called on each request. :mod:`gevent.http` and :mod:`gevent.wsgi` modules: - Made :class:`HTTPServer` use ``"Connection: close"`` header by default. - Class :class:`HTTPServer` now derives from :class:`baseserver.BaseServer`. Thus its :meth:`start` method no longer accepts socket to listen on, it must be passed to the contructor. - The *spawn* argument now accepts a :class:`Pool` instance. While the pool is full, the server replies with 503 error. - The server no longer links to the greenlets it spawns to detect errors. Instead, it relies on :class:`http_request` which will send 500 reply when deallocated if the user hasn't send any. Miscellaneous: - Changed :mod:`gevent.thread` to use :class:`Greenlet` instead of raw greenlets. This means monkey patched thread will become :class:`Greenlet` too. - Added :attr:`started` property to :class:`Greenlet`. - Put common server code in :mod:`gevent.baseserver` module. All servers in gevent package are now derived from :class:`BaseServer`. - Fixed :issue:`20`: :func:`sleep` now raises :exc:`IOError` if passed a negative argument. - Remove the code related to finding out libevent version from setup.py as macro ``USE_LIBEVENT_?`` is no longer needed to build ``gevent.core``. - Increased default backlog in all servers (from 5 to 256). Thanks to **Nicholas Piël**. - Fixed doc/conf.py to work in Python older than 2.6. Thanks to **Örjan Persson**. - Silented SystemError raised in :mod:`backdoor` when a client typed ``quit()``. - If importing :mod:`greenlet` failed with ImportError, keep the original error message, because sometimes the error originates in setuptools. - Changed :func:`select.select` to return all the file descriptors signalled, not just the first one. - Made :mod:`thread` (and thus monkey patched threads) to spawn :class:`Greenlet` instances, rather than raw greenlets. Examples: - Updated echoserver.py to use :class:`StreamServer`. - Added geventsendfile.py. - Added wsgiserver_ssl.py. Thanks to **Ralf Schmitt** for :mod:`pywsgi`, a number of fixes for :mod:`wsgi`, help with :mod:`baseserver` and :mod:`server` modules, improving setup.py and various other patches and suggestions. Thanks to **Uriel Katz** for :mod:`pywsgi` patches. Release 0.12.2 (Mar 2, 2010) ============================ * Fixed http server to put the listening socket into a non-blocking mode. Contributed by **Ralf Schmitt**. Release 0.12.1 (Feb 26, 2010) ============================= * Removed a symlink from the distribution (that causes pip to fail). Thanks to **Brad Clements** for reporting it. * setup.py: automatically create symlink from ``build/lib.../gevent/core.so`` to ``gevent/core.so``. * :mod:`gevent.socket`: Improved compatibility with stdlib's socket: - Fixed :class:`socket ` to raise ``timeout("timed out")`` rather than simply ``timeout``. - Imported ``_GLOBAL_DEFAULT_TIMEOUT`` from standard :mod:`socket` module instead of creating a new object. Release 0.12.0 (Feb 5, 2010) ============================ Release highlights: - Added :mod:`gevent.ssl` module. - Fixed Windows compatibility (experimental). - Improved performance of :meth:`socket.recv`, :meth:`socket.send` and similar methods. - Added a new module - :mod:`dns` - with synchronous wrappers around libevent's DNS API. - Added :class:`core.readwrite_event` and :func:`socket.wait_readwrite` functions. - Fixed several incompatibilities of :mod:`wsgi` module with the WSGI spec. - Deprecated :mod:`pywsgi` module. :mod:`gevent.wsgi` module: - Made ``env["REMOTE_PORT"]`` into a string. - Fixed the server to close the iterator returned by the application. - Made ``wsgi.input`` object iterable. :mod:`gevent.core` module: - Made DNS functions no longer accept/return IP addresses in dots-and-numbers format. They work with packed IPs now. - Made DNS functions no longer accept additional arguments to pass to the callback. - Fixed DNS functions to check the return value of the libevent functions and raise :exc:`IOError` if they failed. - Added :func:`core.dns_err_to_string`. - Made core.event.cancel not to raise if event_del reports an error. instead, the return code is passed to the caller. - Fixed minor issue in string representation of the events. :mod:`gevent.socket` module: - Fixed bug in socket.accept. It could return unwrapped socket instance if socket's timeout is 0. - Fixed socket.sendall implementation never to call underlying socket's sendall. - Fixed :func:`gethostbyname` and :func:`getaddrinfo` to call the stdlib if the passed hostname has no dots. - Fixed :func:`getaddrinfo` to filter the results using *socktype* and *proto* arguments. - Removed :func:`getnameinfo` as it didn't quite match the stdlib interface. Use :func:`dns.resolve_reverse` for reverse resolutions. - Fixed :meth:`socket.connect_ex` to use cooperative :func:`gethostbyname`. - Fixed :meth:`socket.dup` not to call underlying socket's :meth:`dup` (which is not available on Windows) but to use Python's reference counting similar to how the stdlib's socket implements :meth:`dup` - Added *_sock* argument to :class:`socket`'s constructor. Passing the socket instance as first argument is no longer supported. - Fixed :func:`socket.connect` to ignore ``WSAEINVAL`` on Windows. - Fixed :func:`socket.connect` to use :func:`wait_readwrite` instead of :func:`wait_write`. - Fixed :func:`socket.connect` to consult ``SO_ERROR``. - Fixed :func:`socket.send` and :func:`socket.sendall` to support *flags* argument. - Renamed :func:`socket_bind_and_listen` to :func:`socket.bind_and_listen`. The old name is still available as a deprecated alias. - The underlying socket object is now stored as ``_sock`` property. - Imported the constants and some utility functions from stdlib's :mod:`socket` into :mod:`gevent.socket`. (Thanks to **Matt Goodall** for the original patch). - Renamed :meth:`wrap_ssl` to :meth:`ssl`. (the old name is still available but deprecated) - Deprecated :func:`connect_tcp` and :func:`tcp_server`. - Added :exc:`sslerror` to ``socket.__all__``. - Removed :class:`GreenSocket` alias for socket class. - Moved PyOpenSSL-based implementation of :func:`socket.ssl` into :mod:`gevent.oldssl` module. It's imported into :mod:`gevent.socket` if importing :mod:`gevent.ssl` fails. Miscellaneous: - Fixed Greenlet.spawn_link* and GreenletSet.spawn_link* classmethods not to assume anything about their arguments. (Thanks to **Marcus Cavanaugh** for pointing that out). - Fixed :func:`select ` to clean up properly if event creation fails. - Fixed :func:`select ` to raise :exc:`select.error` instead of :exc:`IOError`. - Fixed setup.py to proceed with compilation even if libevent version cannot be determined. 1.x.x is assumed in this case. - Fixed compatibility of .pyx files with Cython 0.12.0. - Renamed arguments for :func:`select.select` to what they are called in the stdlib. - Removed internal function :func:`getLinkedCompleted` from :mod:`gevent.greenlet`. - Remove ``#warning`` directives from ``libevent.h``. They are not supported by vc90. - Removed some deprecated stuff from :mod:`coros`. - Internal class :class:`Waiter ` now stores the value if no one's waiting for it. - Added ``testrunner.py`` script that replaces a bunch of small scripts that were used before. - Removed ``is_secure`` attribute from sockets and ssl objects. - Made :class:`Greenlet` not to print a traceback when a not-yet-started greenlet is killed. - Added :class:`BackdoorServer` class to :mod:`backdoor`. Removed :func:`backdoor` function and deprecated :func:`backdoor_server` function. - Removed ``__getattr__`` from socket class. - Fixed :func:`monkey.patch_socket` not to fail if :func:`socket.ssl` is not present in :mod:`gevent.socket`. - Added :func:`monkey.patch_ssl`. - Added *aggressive* argument to :func:`monkey.patch_all`. - Tests from stdlib no longer included in greentest package. Instead, there are number of stubs that import those tests from ``test`` package directly and run them in monkey patched environment. - Added examples/process.py by **Marcus Cavanaugh**. Release 0.11.2 (Dec 10, 2009) ============================= * Fixed :mod:`wsgi` to unquote ``environ['PATH_INFO']`` before passing to application. * Added ``SERVER_SOFTWARE`` variable to :mod:`wsgi` environ. * Fixed bug in :meth:`JoinableQueue.task_done` that caused :class:`ValueError` to be raised incorrectly here. * Fixed :mod:`gevent.socket` not to fail with :class:`ImportError` if Python was not built with ssl support. Release 0.11.1 (Nov 15, 2009) ============================= * Fixed bug in :func:`select.select` function. Passing non-empty list of write descriptors used to cause this function to fail. * Changed setup.py to go ahead with the compilation even if the actual version of libevent cannot be determined (version 1.x.x is assumed in that case). Contributed by **Ludvig Ericson**: * Fixed :mod:`wsgi`'s ``start_response`` to recognize *exc_info* argument. * Fixed setup.py to look for libevent.dylib rather than .so on Darwin platforms. Release 0.11.0 (Oct 9, 2009) ============================ * Fixed timeout bug in :func:`joinall`, :meth:`Greenlet.join`, :meth:`pool.Pool.join`: if timeout has expired it used to raise :class:`Timeout`; now it returns silently. * Fixed :func:`signal` to run the signal handler in a new greenlet; it was run in the :class:`Hub` greenlet before. * Fixed :meth:`Timeout.start_new`: if passed a :class:`Timeout` instance, it now calls its :meth:`start ` method before returning it. * Fixed :mod:`gevent.monkey` to patch :class:`threading.local` properly. * Fixed :meth:`Queue.empty` and :meth:`Queue.full` to be compatible with the standard :mod:`Queue`. It tried to take into account the greenlets currently blocking on :meth:`get `/:meth:`put ` which was not useful and hard to reason about. Now it simply compares :meth:`qsize ` to *maxsize*, which what the standard :mod:`Queue` does too. * Fixed :class:`Event` to behave exactly like the standard :class:`threading.Event`: - :meth:`Event.set` does not accept a parameter anymore; it's now either set or not. - ``Event.get`` method is gone. - ``Event.set(); Event.clear()`` used to be a no-op; now it properly wakes up all the waiters. - :class:`AsyncResult` behaves exactly like before, but it does not inherit from :class:`Event` anymore and does miss ``clear()`` method. * Renamed internal helpers :meth:`socket.wait_reader`/:meth:`socket.wait_writer` to :meth:`socket.wait_read`/:meth:`socket.wait_write`. * Renamed :class:`gevent.socket.GreenSocket` to :class:`gevent.socket.socket`. ``GreenSocket`` is still available as an alias but will be removed in the future. * :mod:`gevent.core` now includes wrappers for evbuffer, evdns, evhttp. * Renamed the old ``gevent.wsgi`` to :mod:`gevent.pywsgi`. * Added a new HTTP server :mod:`gevent.http` module based on libevent-http wrappers. * Added a new WSGI server :mod:`gevent.wsgi` module based on :mod:`gevent.http`. * Added evdns wrappers to :mod:`gevent.core` and DNS functions to :mod:`gevent.socket` module. Contributed by **Jason Toffaletti.**. * Added a few a few options to ``setup.py`` to select a libevent library to compile against. Check them out with ``setup.py -h``. * Added ``__all__`` to many modules that missed it. * Converted the docstrings and the changelog to sphinx/rst markup. * Added sphinx/rst documentation. It is available online at http://www.gevent.org. Release 0.10.0 (Aug 26, 2009) ============================= * Changed :class:`Timeout` API in a backward-incompatible way: :meth:`Timeout.__init__` does not start the timer immediately anymore; :meth:`Timeout.start` must be called explicitly. A shortcut - :meth:`Timeout.start_new` - is provided that creates and starts a :class:`Timeout`. * Added :class:`gevent.Greenlet` class which is a subclass of greenlet that adds a few useful methods :meth:`join `/:meth:`get `/:meth:`kill `/:meth:`link `. * :func:`spawn` now returns :class:`Greenlet` instance. The old ``spawn``, which returns ``py.magic.greenlet`` instance, can be still accessed as :meth:`spawn_raw`. .. note:: The implementation of :class:`Greenlet` is an improvement on ``proc`` module, with these bugs fixed: * Proc was not a subclass of greenlet which makes :func:`getcurrent` useless and using Procs as keys in dict impossible. * Proc executes links sequentially, so one could block the rest from being executed. :class:`Greenlet` executes each link in a new greenlet by default, unless it is set up with :class:`Greenlet.rawlink` method. * Proc cannot be easily subclassed. To subclass :class:`Greenlet`, override its _run and __init__ methods. * Added :class:`pool.Pool` class with the methods compatible to the standard :mod:`multiprocessing.pool`: :meth:`apply `, :meth:`map ` and others. It also has :meth:`spawn ` method which is always async and returns a :class:`Greenlet` instance. * Added :mod:`gevent.event` module with 2 classes: :class:`Event` and :class:`AsyncResult`. :class:`Event` is a drop-in replacement for :class:`threading.Event`, supporting :meth:`set `/:meth:`wait `/``get`` methods. :class:`AsyncResult` is an extension of :class:`Event` that supports exception passing via :meth:`set_exception ` method. * Added :class:`queue.JoinableQueue` class with :meth:`task_done ` and :meth:`join ` methods. * Renamed ``core.read`` and ``core.write`` classes to :class:`core.read_event` and :class:`core.write_event`. * :mod:`gevent.pywsgi`: pulled **Mike Barton's** eventlet patches that fix double content-length issue. * Fixed ``setup.py`` to search more places for system libevent installation. This fixes 64bit CentOS 5.3 installation issues, hopefully covers other platforms as well. The following items were added to the gevent top level package: - :func:`spawn_link` - :func:`spawn_link_value` - :func:`spawn_link_exception` - :func:`spawn_raw` - :func:`joinall` - :func:`killall` - :class:`Greenlet` - :exc:`GreenletExit` - :mod:`core` The following items were marked as deprecated: - gevent.proc module (:class:`wrap_errors` helper was moved to :mod:`util` module) - gevent.coros.event - gevent.coros.Queue and gevent.coros.Channel Internally, ``gevent.greenlet`` was split into a number of modules: - :mod:`gevent.hub` provides :class:`Hub` class and basic utilities, like :func:`sleep`; :class:`Hub` is now a subclass of greenlet. - :mod:`gevent.timeout` provides :class:`Timeout` and :func:`with_timeout`; - :mod:`gevent.greenlet` provides :class:`Greenlet` class and helpers like :func:`joinall` and :func:`killall`. - :mod:`gevent.rawgreenlet` contains the old "polling" versions of :func:`joinall ` and :func:`killall ` (they do not need :meth:`link ` functionality and work with any greenlet by polling their status and sleeping in a loop) Thanks to **Jason Toffaletti** for reporting the installation issue and providing a test case for WSGI double content-length header bug. Release 0.9.3 (Aug 3, 2009) =========================== * Fixed all known bugs in the :mod:`gevent.queue` module and made it 2.4-compatible. :class:`LifoQueue` and :class:`PriorityQueue` are implemented as well. :mod:`gevent.queue` will deprecate both ``coros.Queue`` and ``coros.Channel``. * Fixed :class:`Timeout` to raise itself by default. ``TimeoutError`` is gone. Silent timeout is now created by passing ``False`` instead of ``None``. * Fixed bug in :func:`gevent.select.select` where it could silent the wrong timeout. * :func:`spawn` and :func:`spawn_later` now avoid creating a closure and this decreases spawning time by 50%. * ``kill``'s and ``killall``'s *wait* argument was renamed to *block*. The polling is now implemented by ``greenlet.join`` and ``greenlet.joinall`` functions and it become more responsive, with gradual increase of sleep time. * Renamed ``proc.RunningProcSet`` to ``proc.ProcSet``. * Added :func:`shutdown` function, which blocks until libevent has finished dispatching the events. * The return value of ``event_add`` and ``event_del`` in core.pyx are now checked properly and :exc:`IOError` is raised if they have failed. * Fixed backdoor.py, accidentally broken in the previous release. Release 0.9.2 (Jul 20, 2009) ============================ * Simplified :mod:`gevent.socket`'s implementation and fixed SSL bug reported on eventletdev by **Cesar Alaniz** as well as failures in ``test_socket_ssl.py``. * Removed ``GreenSocket.makeGreenFile``; Use :meth:`socket.socket.makefile` that returns :class:`_fileobject` and is available on both :class:`GreenSocket ` and :class:`GreenSSL `. The :mod:`gevent.socket` is still a work in progress. * Added new :class:`core.active_event` class that takes advantage of libevent's ``event_active`` function. ``core.active_event(func)`` schedules func to be run in this event loop iteration as opposed to ``core.timer(0, ...)`` which schedules an event to be run in the next iteration. :class:`active_event` is now used throughout the library wherever ``core.timer(0, ....)`` was previously used. This results in :func:`spawn` being at least 20% faster compared to release 0.9.1 and twice as fast compared to eventlet. (The results are obtained with bench_spawn.py script in ``greentest/`` directory) * Added boolean parameter *wait* to :func:`kill` and :func:`killall` functions. If set to ``True``, it makes the function block until the greenlet(s) is actually dead. By default, :func:`kill` and :func:`killall` are asynchronous, i.e. they don't unschedule the current greenlet. * Added a few new properties to :class:`gevent.core.event`: :attr:`fd `, :attr:`events `, :attr:`events_str ` and :attr:`flags `. It also has :meth:`__enter__ ` and :meth:`__exit__ ` now, so it can be used as a context manager. :class:`event`'s :attr:`callback ` signature has changed from ``(event, fd, evtype)`` to ``(event, evtype)``. * Fixed :class:`Hub`'s mainloop to never return successfully as this will screw up main greenlet's ``switch()`` call. Instead of returning it raises ``DispatchExit``. * Added :func:`reinit` function - wrapper for libevent's ``event_reinit``. This function is a must have at least for daemons, as it fixes ``epoll`` and some others eventloops to work after ``fork``. * Trying to use gevent in another thread will now raise an exception immediately, since it's not implemented. * Added a few more convenience methods ``spawn_link[exception/value]`` to ``proc.RunningProcSet``. * Fixed ``setup.py`` not to depend on ``setuptools``. * Removed ``gevent.timeout``. Use :class:`gevent.Timeout`. Release 0.9.1 (Jul 9, 2009) =========================== * Fixed compilation with libevent-1.3. Thanks to **Litao Wei** for reporting the problem. * Fixed :class:`Hub` to recover silently after ``event_dispatch()`` failures (I've seen this happen after ``fork`` even though ``event_reinit()`` is called as necessary). The end result is that :func:`fork` now works more reliably, as detected by ``test_socketserver.py`` - it used to fail occasionally, now it does not. * Reorganized the package, most of the stuff from ``gevent/__init__.py`` was moved to ``gevent/greenlet.py``. ``gevent/__init__.py`` imports some of it back but not everything. * Renamed ``gevent.timeout`` to :class:`gevent.Timeout`. The old name is available as an alias. * Fixed a few bugs in :class:`queue.Queue`. Added test_queue.py from standard tests to check how good is :class:`queue.Queue` a replacement for a standard :mod:`Queue` (not good at all, timeouts in :meth:`queue.Queue.put` don't work yet) * :mod:`monkey` now patches ssl module when on 2.6 (very limited support). * Improved compatibility with Python 2.6 and Python 2.4. * Greenlet installed from PyPI (without py.magic prefix) is properly recognized now. * core.pyx was accidentally left out of the source package, it's included now. * :class:`GreenSocket ` now wraps a ``socket`` object from ``_socket`` module rather than from :mod:`socket`. Release 0.9.0 (Jul 8, 2009) =========================== Started as eventlet_ 0.8.11 fork, with the intention to support only libevent as a backend. Compared to eventlet, this version has a much simpler API and implementation and a few severe bugs fixed, namely * Full duplex in sockets, i.e. ``read()`` and ``write()`` on the same fd do not cancel one another. * The :meth:`GreenSocket.close ` method does not hang as it could with eventlet. There's a test in my repo of eventlet that reproduces both of them: http://bitbucket.org/denis/eventlet/src/tip/greentest/test__socket.py Besides having less bugs and less code to care about the goals of the fork are: * Piggy-back on libevent as much as possible (use its http and dns code). * Use the interfaces and conventions from the standard Python library where possible. .. _eventlet: http://bitbucket.org/denis/eventlet gevent-1.1.0/dev-requirements.txt0000644000076500000000000000010212666555342017570 0ustar jmaddenwheel00000000000000setuptools cython>=0.23.4 greenlet>=0.4.9 coverage>=4.0 cffi -e . gevent-1.1.0/doc/0000755000076500000000000000000012666555432014304 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/_templates/0000755000076500000000000000000012666555432016441 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/_templates/layout.html0000644000076500000000000000022612666555342020644 0ustar jmaddenwheel00000000000000{% extends "!layout.html" %} {%- block rootrellink %}
  • Home{{ reldelim1 }}
  • {{ super() }} {%- endblock %} gevent-1.1.0/doc/community.rst0000644000076500000000000000225712666555342017070 0ustar jmaddenwheel00000000000000Community ========= The official mailing list is hosted on `Google Groups (gevent)`_. To subscribe via email, send a message to gevent+subscribe@googlegroups.com. Here's what people are saying now: .. raw:: html You're also welcome to join `#gevent`_ IRC channel on freenode. Russian group ------------- Русскоязычная группа находится здесь: `Google Groups (gevent-ru)`_. Чтобы подписаться, отправьте сообщение на gevent-ru+subscribe@googlegroups.com .. _Google Groups (gevent): http://groups.google.com/group/gevent .. _#gevent: http://webchat.freenode.net/?channels=gevent .. _Google Groups (gevent-ru): http://groups.google.com/group/gevent-ru gevent-1.1.0/doc/conf.py0000644000076500000000000002054612666555342015612 0ustar jmaddenwheel00000000000000# -*- coding: utf-8 -*- # # gevent documentation build configuration file, created by # sphinx-quickstart on Thu Oct 1 09:30:02 2009. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. from __future__ import print_function import sys import os os.system('%s generate_rst.py generate' % sys.executable) sys.path.append('.') # for mysphinxext if not os.path.exists('changelog.rst') and os.path.exists('../changelog.rst'): print('Linking ../changelog.rst to changelog.rst') if hasattr(os, 'symlink'): os.symlink('../changelog.rst', 'changelog.rst') else: import shutil shutil.copyfile('../changelog.rst', 'changelog.rst') # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage', 'sphinx.ext.intersphinx', 'mysphinxext', 'sphinx.ext.extlinks'] intersphinx_mapping = {'http://docs.python.org/': None, 'https://greenlet.readthedocs.org/en/latest/': None} extlinks = {'issue': ('https://github.com/gevent/gevent/issues/%s', 'issue #'), 'pr': ('https://github.com/gevent/gevent/pull/%s', 'pull request #')} autodoc_default_flags = ['members', 'show-inheritance'] autoclass_content = 'both' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' # The master toctree document. master_doc = 'contents' # General information about the project. project = u'gevent' copyright = u'2009-2015, gevent contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. from gevent import __version__ version = __version__ # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = False # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'perldoc' # A list of ignored prefixes for module index sorting. modindex_common_prefix = ['gevent.'] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'mytheme' html_theme_path = ['.'] html_theme_options = {'gevent_version': __version__} # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #if html_theme == 'default': # html_theme_options = {'rightsidebar' : True} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. html_short_title = 'Documentation' # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". #html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {'contentstable': 'contentstable.html'} # If false, no module index is generated. html_use_modindex = True # If false, no index is generated. html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = False # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'geventdoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'gevent.tex', u'gevent Documentation', u'gevent contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True ############################################################################### # prevent some stuff from showing up in docs import socket import gevent.socket del gevent.Greenlet.throw for item in gevent.socket.__all__[:]: if getattr(gevent.socket, item) is getattr(socket, item, None): gevent.socket.__all__.remove(item) # order the methods in the class documentation the same way they are ordered in the source code from sphinx.ext import autodoc from sphinx.ext.autodoc import ClassDocumenter class MyClassDocumenter(ClassDocumenter): def get_object_members(self, want_all): members_check_module, members = super(MyClassDocumenter, self).get_object_members(want_all) def key((name, obj)): try: return obj.im_func.func_code.co_firstlineno except AttributeError: return 0 members.sort(key=key) return members_check_module, members autodoc.ClassDocumenter = MyClassDocumenter gevent-1.1.0/doc/contents.rst0000644000076500000000000000025312666555342016673 0ustar jmaddenwheel00000000000000Table Of Contents ================= .. toctree:: intro whatsnew_1_1 reference whatsnew_1_0 changelog * :ref:`genindex` * :ref:`modindex` * :ref:`search` gevent-1.1.0/doc/dns.rst0000644000076500000000000000255512666555342015631 0ustar jmaddenwheel00000000000000======================= Name Resolution (DNS) ======================= gevent includes support for a pluggable hostname resolution system. Pluggable resolvers are (generally) intended to be cooperative. This pluggable resolution system is used automatically when the system is :mod:`monkey patched `, and may be used manually through the :attr:`resolver attribute ` of the :class:`gevent.hub.Hub` or the corresponding methods in the :mod:`gevent.socket` module. A resolver implements the 5 standandard functions from the :mod:`socket` module for resolving hostnames: * :func:`socket.gethostbyname` * :func:`socket.gethostbyname_ex` * :func:`socket.getaddrinfo` * :func:`socket.gethostbyaddr` * :func:`socket.getnameinfo` Configuration ============= gevent includes three implementations of resolvers, and applications can provide their own implementation. By default, gevent uses :class:`gevent.resolver_thread.Resolver`. Configuration can be done through the ``GEVENT_RESOLVER`` environment variable. Specify ``ares``, ``thread``, or ``block`` to use the :class:`gevent.resolver_ares.Resolver`, :class:`gevent.resolver_thread.Resolver`, or :class:`gevent.socket.BlockingResolver`, respectively, or set it to the fully-qualified name of an implementation of the standard functions. .. toctree:: gevent.resolver_thread gevent.resolver_ares gevent-1.1.0/doc/generate_rst.py0000755000076500000000000000665212666555342017354 0ustar jmaddenwheel00000000000000#!/usr/bin/env python from __future__ import print_function import os import glob from os.path import join, dirname, abspath, basename import gevent # do not generate .rst for the following modules as they imported into gevent package # and covered there SKIP = ['hub', 'timeout', 'greenlet'] template = '''.. AUTOGENERATED -- will be overwritten (remove this comment to save changes) %(title)s %(title_underline)s .. automodule:: gevent.%(module)s :members: :undoc-members: ''' directory = dirname(abspath(gevent.__file__)) print('Imported gevent from %s' % (directory, )) modules = glob.glob(join(directory, '*.py')) + glob.glob(join(directory, '*.pyc')) modules = set(basename(filename).split('.')[0] for filename in modules) modules = set(name for name in modules if name.startswith('_socket2') or name.startswith('_socket3') or name.startswith('_ssl') or not name.startswith('_')) import warnings warnings.simplefilter('ignore', DeprecationWarning) def _read(fname, count): with open(fname) as f: return f.read(count) def generate_rst_for_module(module, do=True): rst_filename = 'gevent.%s.rst' % module exists = os.path.exists(rst_filename) if exists: autogenerated = 'autogenerated' in _read(rst_filename, 200).lower() if not autogenerated: return m = __import__('gevent.%s' % module) m = getattr(m, module) title = getattr(m, '__doc__', None) if title: lines = title.strip().splitlines() for line in lines: # skip leading blanks. Support both styles of docstrings. if line: title = line.strip() break title = title.strip(' .') prefix = ':mod:`gevent.%s`' % module if title: title = prefix + ' -- %s' % (title, ) else: title = prefix title_underline = '=' * len(title) params = globals().copy() params.update(locals()) result = template % params if getattr(m, '_no_undoc_members', True): result = '\n'.join(result.splitlines()[:-1]) if exists: if _read(rst_filename, len(result) + 1) == result: return # already exists one which is the same if do: print('Generated %s from %s' % (rst_filename, m.__file__)) with open(rst_filename, 'w') as f: f.write(result) else: print('Would generate %s from %s' % (rst_filename, m.__file__)) def generate_rst(do=True): assert os.path.exists('contents.rst'), 'Wrong directory, contents.rst not found' for module in modules: if module not in SKIP: generate_rst_for_module(module, do=do) def iter_autogenerated(): for module in modules: rst_filename = 'gevent.%s.rst' % module exists = os.path.exists(rst_filename) if exists: autogenerated = 'autogenerated' in open(rst_filename).read(200).lower() if autogenerated: yield rst_filename if __name__ == '__main__': import sys if sys.argv[1:] == ['show']: for filename in iter_autogenerated(): print(filename) elif sys.argv[1:] == ['delete']: for filename in iter_autogenerated(): print('Removing', filename) os.unlink(filename) elif sys.argv[1:] == ['generate']: generate_rst() elif sys.argv[1:] == []: generate_rst(do=False) else: sys.exit('Invalid command line: %s' % (sys.argv[1:], )) gevent-1.1.0/doc/gevent.core.rst0000644000076500000000000000234312666555342017257 0ustar jmaddenwheel00000000000000:mod:`gevent.core` - event loop based on libev ============================================== .. automodule:: gevent.core This module is a wrapper around libev__ and follower the libev API pretty closely. Note, that gevent creates an event loop transparently for the user and runs it in a dedicated greenlet (called hub), so using this module is not necessary. In fact, if you do use it, chances are that your program is not compatible across different gevent version (gevent.core in 0.x has a completely different interface and 2.x will probably have yet another interface). On Windows, this wrapper will accept Windows handles rather than stdio file descriptors which libev requires. This is to simplify interaction with the rest of the Python, since it requires Windows handles. The current event loop can be obtained with ``gevent.get_hub().loop``. __ http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod events ------ .. autoclass:: loop(flags=None, default=True) :members: :undoc-members: misc functions -------------- .. autofunction:: get_version .. autofunction:: get_header_version .. autofunction:: supported_backends .. autofunction:: recommended_backends .. autofunction:: embeddable_backends .. autofunction:: time gevent-1.1.0/doc/gevent.event.rst0000644000076500000000000000066712666555342017457 0ustar jmaddenwheel00000000000000:mod:`gevent.event` -- Notifications of multiple listeners ========================================================== .. module:: gevent.event .. autoclass:: gevent.event.Event :members: set, clear, wait, rawlink, unlink .. method:: is_set() isSet() ready() Return true if and only if the internal flag is true. .. autoclass:: gevent.event.AsyncResult :members: :undoc-members: gevent-1.1.0/doc/gevent.hub.rst0000644000076500000000000000040712666555342017104 0ustar jmaddenwheel00000000000000==================================== :mod:`gevent.hub` - Event-loop hub ==================================== .. module:: gevent.hub .. autofunction:: get_hub .. autoclass:: Hub :members: :undoc-members: .. autoclass:: Waiter .. autoclass:: LoopExit gevent-1.1.0/doc/gevent.pool.rst0000644000076500000000000000027712666555342017304 0ustar jmaddenwheel00000000000000:mod:`gevent.pool` -- Managing greenlets in a group =================================================== .. automodule:: gevent.pool :members: :undoc-members: :inherited-members: gevent-1.1.0/doc/gevent.queue.rst0000644000076500000000000000123312666555342017450 0ustar jmaddenwheel00000000000000:mod:`gevent.queue` -- Synchronized queues ========================================== .. automodule:: gevent.queue :members: :undoc-members: .. exception:: Full An alias for :class:`Queue.Full` .. exception:: Empty An alias for :class:`Queue.Empty` Example of how to wait for enqueued tasks to be completed:: def worker(): while True: item = q.get() try: do_work(item) finally: q.task_done() q = JoinableQueue() for i in range(num_worker_threads): gevent.spawn(worker) for item in source(): q.put(item) q.join() # block until all tasks are done gevent-1.1.0/doc/gevent.rst0000644000076500000000000001306312666555342016331 0ustar jmaddenwheel00000000000000================================== :mod:`gevent` -- basic utilities ================================== .. module:: gevent The most common functions and classes are available in the :mod:`gevent` top level package. .. autodata:: __version__ .. autodata:: version_info Greenlet objects ================ :class:`Greenlet` is a light-weight cooperatively-scheduled execution unit. To start a new greenlet, pass the target function and its arguments to :class:`Greenlet` constructor and call :meth:`start`: >>> g = Greenlet(myfunction, 'arg1', 'arg2', kwarg1=1) >>> g.start() or use classmethod :meth:`spawn` which is a shortcut that does the same: >>> g = Greenlet.spawn(myfunction, 'arg1', 'arg2', kwarg1=1) To subclass a :class:`Greenlet`, override its ``_run()`` method and call ``Greenlet.__init__(self)`` in :meth:`__init__`: It also a good idea to override :meth:`__str__`: if :meth:`_run` raises an exception, its string representation will be printed after the traceback it generated. .. important:: You *SHOULD NOT* attempt to override the ``run()`` method. .. class:: Greenlet .. automethod:: Greenlet.__init__ .. attribute:: Greenlet.value Holds the value returned by the function if the greenlet has finished successfully. Until then, or if it finished in error, ``None``. .. tip:: Recall that a greenlet killed with the default :class:`GreenletExit` is considered to have finished successfully, and the ``GreenletExit`` exception will be its value. .. autoattribute:: Greenlet.exception .. automethod:: Greenlet.ready .. automethod:: Greenlet.successful .. automethod:: Greenlet.start .. automethod:: Greenlet.start_later .. automethod:: Greenlet.join .. automethod:: Greenlet.get .. automethod:: Greenlet.kill(exception=GreenletExit, block=True, timeout=None) .. automethod:: Greenlet.link(callback) .. automethod:: Greenlet.link_value(callback) .. automethod:: Greenlet.link_exception(callback) .. automethod:: Greenlet.rawlink .. automethod:: Greenlet.unlink Boolean Contexts ---------------- Greenlet objects have a boolean value (``__nonzero__`` or ``__bool__``) which is true if it's active: started but not dead yet. It's possible to use it like this:: >>> g = gevent.spawn(...) >>> while g: # do something while g is alive The Greenlet's ``__nonzero__`` is an improvement on greenlet's ``__nonzero__``. The greenlet's :meth:`__nonzero__ ` returns False if greenlet has not been switched to yet or is already dead. While the latter is OK, the former is not good, because a just spawned Greenlet has not been switched to yet and thus would evaluate to False. Raw greenlet Methods -------------------- Being a greenlet__ subclass, :class:`Greenlet` also has `switch() `_ and `throw() `_ methods. However, these should not be used at the application level as they can very easily lead to greenlets that are forever unscheduled. Prefer higher-level safe classes, like :class:`Event ` and :class:`Queue `, instead. __ http://greenlet.readthedocs.org/en/latest/#instantiation .. _switching: https://greenlet.readthedocs.org/en/latest/#switching .. _throw: https://greenlet.readthedocs.org/en/latest/#methods-and-attributes-of-greenlets .. exception:: GreenletExit A special exception that kills the greenlet silently. When a greenlet raises :exc:`GreenletExit` or a subclass, the traceback is not printed and the greenlet is considered :meth:`successful `. The exception instance is available under :attr:`value ` property as if it was returned by the greenlet, not raised. Spawn helpers ============= .. autofunction:: spawn(function, *args, **kwargs) .. autofunction:: spawn_later(seconds, function, *args, **kwargs) .. autofunction:: spawn_raw Useful general functions ======================== .. function:: getcurrent() Return the currently executing greenlet (the one that called this function). Note that this may be an instance of :class:`Greenlet` or :class:`greenlet.greenlet`. Sleeping -------- .. autofunction:: sleep .. autofunction:: idle Stopping Greenlets ------------------ .. autofunction:: kill(greenlet, exception=GreenletExit) .. autofunction:: killall(greenlets, exception=GreenletExit, block=True, timeout=None) Waiting ------- .. autofunction:: wait .. autofunction:: iwait .. autofunction:: joinall Working with muliple processes ------------------------------ .. autofunction:: fork .. autofunction:: reinit Signals ------- .. function:: signal(signalnum, handler, *args, **kwargs) Call the *handler* with the *args* and *kwargs* when the process receives the signal *signalnum*. The *handler* will be run in a new greenlet when the signal is delivered. This returns an object with the useful method ``cancel``, which, when called, will prevent future deliveries of *signalnum* from calling *handler*. .. note:: This may not operate correctly with SIGCHLD if libev child watchers are used (as they are by default with :func:`gevent.os.fork`). .. versionchanged:: 1.1b4 This is an alias for ``gevent.hub.signal``, included for backwards compatibility; the new module :doc:`gevent.signal ` is replacing this name. This alias will be removed in a future release. .. This is also in the docstring of gevent.hub.signal, which is the actual callable invoked Timeouts ======== .. autoclass:: Timeout :members: :undoc-members: .. autofunction:: with_timeout gevent-1.1.0/doc/gevent.socket.rst0000644000076500000000000000555312666555342017625 0ustar jmaddenwheel00000000000000==================================================================== :mod:`gevent.socket` -- Cooperative low-level networking interface ==================================================================== This module provides socket operations and some related functions. The API of the functions and classes matches the API of the corresponding items in the standard :mod:`socket` module exactly, but the synchronous functions in this module only block the current greenlet and let the others run. .. tip:: gevent's sockets, like most gevent objects, have thread affinity. That is, they can only be used from the operating system thread that created them (any greenlet in that thread can use the socket). The results of attempting to use the socket in another thread (for example, passing it to the threadpool) are not defined (but one common outcome is a :exc:`~gevent.hub.LoopExit` exception). For convenience, exceptions (like :class:`error ` and :class:`timeout `) as well as the constants from the :mod:`socket` module are imported into this module. In almost all cases one can simply replace ``import socket`` with ``from gevent import socket`` to start using cooperative sockets with no other changes (or use :func:`gevent.monkey.patch_socket` at startup if code changes are not desired or possible). Standard Library Interface ========================== The exact API exposed by this module varies depending on what version of Python you are using. The documents below describe the API for Python 2 and Python 3, respectively. .. note:: All the described APIs should be imported from ``gevent.socket``, and *not* from their implementation modules. Their organization is an implementation detail that may change at any time. .. toctree:: Python 3 interface Python 2 interface Gevent Extensions ================= Beyond the basic standard library interface, ``gevent.socket`` provides some extensions. These are identical and shared by all versions of Python. Waiting ------- These functions are used to block the current greenlet until an open file (socket) is ready to perform I/O operations. These are low-level functions not commonly used by many programs. .. note:: These use the underlying libev ``io`` watchers, which means that they share the same implementation limits. For example, on some platforms they can be used with more than just sockets, while on others the applicability is more limited (POSIX platforms like Linux and OS X can use pipes and fifos but Windows is limited to sockets). .. autofunction:: gevent.socket.wait_read .. autofunction:: gevent.socket.wait_write .. autofunction:: gevent.socket.wait_readwrite .. autofunction:: gevent.socket.wait .. autofunction:: gevent.socket.cancel_wait gevent-1.1.0/doc/gevent.ssl.rst0000644000076500000000000000211712666555342017127 0ustar jmaddenwheel00000000000000==================================================================== :mod:`gevent.ssl` -- Secure Sockets Layer (SSL/TLS) module ==================================================================== This module provides SSL/TLS operations and some related functions. The API of the functions and classes matches the API of the corresponding items in the standard :mod:`ssl` module exactly, but the synchronous functions in this module only block the current greenlet and let the others run. The exact API exposed by this module varies depending on what version of Python you are using. The documents below describe the API for Python 3, Python 2.7.9 and above, and Python 2.7.8 and below, respectively. .. warning:: All the described APIs should be imported from ``gevent.ssl``, and *not* from their implementation modules. Their organization is an implementation detail that may change at any time. .. toctree:: Python 3 interface Python 2.7.9 and above interface (including PyPy 2.6.1 and above) Python 2.7.8 and below interface gevent-1.1.0/doc/gevent.threadpool.rst0000644000076500000000000000235312666555342020471 0ustar jmaddenwheel00000000000000 ===================================================== :mod:`gevent.threadpool` - A pool of native threads ===================================================== .. currentmodule:: gevent.threadpool .. autoclass:: ThreadPool :inherited-members: :members: imap, imap_unordered, map, map_async, apply_async, kill, join, spawn .. method:: apply(func, args=None, kwds=None) Rough equivalent of the :func:`apply()` builtin function, blocking until the result is ready and returning it. The ``func`` will *usually*, but not *always*, be run in a way that allows the current greenlet to switch out (for example, in a new greenlet or thread, depending on implementation). But if the current greenlet or thread is already one that was spawned by this pool, the pool may choose to immediately run the `func` synchronously. .. note:: As implemented, attempting to use :meth:`Threadpool.appy` from inside another function that was itself spawned in a threadpool (any threadpool) will cause the function to be run immediately. .. versionchanged:: 1.1a2 Now raises any exception raised by *func* instead of dropping it. gevent-1.1.0/doc/gevent.wsgi.rst0000644000076500000000000000114412666555342017276 0ustar jmaddenwheel00000000000000 ============================================================================== :mod:`gevent.wsgi` -- Backwards compatibility alias for :mod:`gevent.pywsgi` ============================================================================== In the past, this module used libevent's http support, but that was dropped with the introduction of libev. libevent's http support had several limitations, including not supporting stream, not supporting pipelining, and not supporting SSL. This module now simply re-exports the contents of the :mod:`gevent.pywsgi` module. .. deprecated:: 1.1 Use :mod:`gevent.pywsgi` gevent-1.1.0/doc/index.rst0000644000076500000000000000513412666555342016150 0ustar jmaddenwheel00000000000000================= What is gevent? ================= gevent is a coroutine_ -based Python_ networking library that uses greenlet_ to provide a high-level synchronous API on top of the libev event loop. Features include: * **Fast event loop** based on libev (epoll on Linux, kqueue on FreeBSD). * **Lightweight execution units** based on greenlet. * API that re-uses concepts from the Python standard library (for example there are :class:`gevent.event.Events` and :class:`gevent.queue.Queues`). * :doc:`Cooperative sockets with SSL support ` * DNS queries performed through threadpool or c-ares. * :ref:`Monkey patching utility ` to get 3rd party modules to become cooperative gevent is `inspired by eventlet `_ but features more consistent API, simpler implementation and better performance. Read why others `use gevent `_ and check out the list of the `open source projects based on gevent. `_ gevent is written and maintained by `Denis Bilenko `_ with help from the `contributors `_ and is licensed under the MIT license. :ref:`Continue reading ` » If you like gevent, :doc:`donate ` to support the development. What are others saying? ======================= Twitter @gevent --------------- .. raw:: html Mailing List ------------ .. raw:: html .. _coroutine: https://en.wikipedia.org/wiki/Coroutine .. _Python: http://python.org .. _greenlet: http://greenlet.readthedocs.org gevent-1.1.0/doc/intro.rst0000644000076500000000000003452612666555342016203 0ustar jmaddenwheel00000000000000============== Introduction ============== gevent is a coroutine-based Python networking library. Features include: * Fast event loop based on libev (epoll on Linux, kqueue on FreeBSD, select on Mac OS X). * Lightweight execution units based on greenlet. * API that re-uses concepts from the Python standard library (e.g. :class:`gevent.event.Event`, :class:`gevent.queue.Queue`). * Cooperative :mod:`socket` and :mod:`ssl` modules. * Ability to use standard library and 3rd party modules written for standard blocking sockets (:mod:`gevent.monkey`). * DNS queries performed through threadpool (default) or through c-ares (enabled via GEVENT_RESOLVER=ares env var). * TCP/UDP/HTTP servers * Subprocess support (through :mod:`gevent.subprocess`) * Thread pools .. _installation: Installation and Requirements ============================= `gevent 1.1`_ runs on Python 2 and Python 3. Versions 2.6 and 2.7 of Python 2 are supported, and versions 3.3, 3.4, and 3.5 of Python 3 are supported. (Users of older versions of Python 2 need to install gevent 1.0.x; Python 3 is not supported by 1.0.) gevent requires the greenlet__ library. gevent 1.1 also runs on PyPy 2.6.1 and above, although 4.0 or above is strongly recommended. On PyPy, there are no external dependencies. .. note:: gevent does *not* run on PyPy on Windows because the CFFI backend does not build. gevent and greenlet can both be installed with `pip`_, e.g., ``pip install gevent``. On Windows and OS X, both gevent and greenlet are distributed as binary `wheels`_, so no C compiler is required (so long as pip is at least version 8.0). On Linux or for Mac OS X variants without pre-built wheels or if wheel installation is disabled, a C compiler (Xcode on OS X) and the Python development package are required. `cffi`_ can optionally be installed to build the CFFI backend in addition to the Cython backend on CPython. .. tip:: Some Linux distributions are now mounting their temporary directories with the ``noexec`` option. This can cause a standard ``pip install gevent`` to fail with an error like ``cannot run C compiled programs``. One fix is to mount the temporary directory without that option. Another may be to use the ``--build`` option to ``pip install`` to specify another directory. See :issue:`570` and :issue:`612` for examples. Development instructions can be found `on PyPI `_. __ http://pypi.python.org/pypi/greenlet .. _`pip`: https://pip.pypa.io/en/stable/installing/ .. _`wheels`: http://pythonwheels.com .. _`gevent 1.1`: whatsnew_1_1.html .. _`cffi`: http://cffi.readthedocs.org Example ======= The following example shows how to run tasks concurrently. >>> import gevent >>> from gevent import socket >>> urls = ['www.google.com', 'www.example.com', 'www.python.org'] >>> jobs = [gevent.spawn(socket.gethostbyname, url) for url in urls] >>> gevent.joinall(jobs, timeout=2) >>> [job.value for job in jobs] ['74.125.79.106', '208.77.188.166', '82.94.164.162'] After the jobs have been spawned, :func:`gevent.joinall` waits for them to complete, allowing up to 2 seconds. The results are then collected by checking the :attr:`~gevent.Greenlet.value` property. The :func:`gevent.socket.gethostbyname` function has the same interface as the standard :func:`socket.gethostbyname` but it does not block the whole interpreter and thus lets the other greenlets proceed with their requests unhindered. .. _monkey-patching: Monkey patching =============== The example above used :mod:`gevent.socket` for socket operations. If the standard :mod:`socket` module was used the example would have taken 3 times longer to complete because the DNS requests would be sequential (serialized). Using the standard socket module inside greenlets makes gevent rather pointless, so what about existing modules and packages that are built on top of :mod:`socket` (including the standard library modules like :mod:`urllib`)? That's where monkey patching comes in. The functions in :mod:`gevent.monkey` carefully replace functions and classes in the standard :mod:`socket` module with their cooperative counterparts. That way even the modules that are unaware of gevent can benefit from running in a multi-greenlet environment. >>> from gevent import monkey; monkey.patch_socket() >>> import urllib2 # it's usable from multiple greenlets now See `examples/concurrent_download.py`__ Beyond sockets -------------- Of course, there are several other parts of the standard library that can block the whole interpreter and result in serialized behavior. gevent provides cooperative versions of many of those as well. They can be patched independently through individual functions, but most programs using monkey patching will want to patch the entire recommended set of modules using the :func:`gevent.monkey.patch_all` function:: >>> from gevent import monkey; monkey.patch_all() >>> import subprocess # it's usable from multiple greenlets now .. tip:: When monkey patching, it is recommended to do so as early as possible in the lifetime of the process. If possible, monkey patching should be the first lines executed. Monkey patching later, especially if native threads have been created, :mod:`atexit` or signal handlers have been installed, or sockets have been created, may lead to unpredictable results including unexpected :exc:`~gevent.hub.LoopExit` errors. __ https://github.com/gevent/gevent/blob/master/examples/concurrent_download.py#L1 Event loop ========== Instead of blocking and waiting for socket operations to complete (a technique known as polling), gevent arranges for the operating system to deliver an event letting it know when, for example, data has arrived to be read from the socket. Having done that, gevent can move on to running another greenlet, perhaps one that itself now has an event ready for it. This repeated process of registering for events and reacting to them as they arrive is the event loop. Unlike other network libraries, though in a similar fashion as eventlet, gevent starts the event loop implicitly in a dedicated greenlet. There's no ``reactor`` that you must call a ``run()`` or ``dispatch()`` function on. When a function from gevent's API wants to block, it obtains the :class:`gevent.hub.Hub` instance --- a special greenlet that runs the event loop --- and switches to it (it is said that the greenlet *yielded* control to the Hub). If there's no :class:`~gevent.hub.Hub` instance yet, one is automatically created. .. tip:: Each operating system thread has its own :class:`~gevent.hub.Hub`. This makes it possible to use the gevent blocking API from multiple threads (with care). The event loop provided by libev uses the fastest polling mechanism available on the system by default. Please read the `libev documentation`_ for more information. .. As of 1.1 or before, we set the EVFLAG_NOENV so this isn't possible any more. It is possible to command libev to use a particular polling mechanism by setting the ``LIBEV_FLAGS`` environment variable. Possible values include ``LIBEV_FLAGS=1`` for the select backend, ``LIBEV_FLAGS=2`` for the poll backend, ``LIBEV_FLAGS=4`` for the epoll backend and ``LIBEV_FLAGS=8`` for the kqueue backend. .. _`libev documentation`: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONTROLLING_EVENT_LOOPS The Libev API is available under the :mod:`gevent.core` module. Note that the callbacks supplied to the libev API are run in the :class:`~gevent.hub.Hub` greenlet and thus cannot use the synchronous gevent API. It is possible to use the asynchronous API there, like :func:`gevent.spawn` and :meth:`gevent.event.Event.set`. Cooperative multitasking ======================== .. currentmodule:: gevent The greenlets all run in the same OS thread and are scheduled cooperatively. This means that until a particular greenlet gives up control, (by calling a blocking function that will switch to the :class:`~gevent.hub.Hub`), other greenlets won't get a chance to run. This is typically not an issue for an I/O bound app, but one should be aware of this when doing something CPU intensive, or when calling blocking I/O functions that bypass the libev event loop. .. tip:: Even some apparently cooperative functions, like :func:`gevent.sleep`, can temporarily take priority over waiting I/O operations in some circumstances. Synchronizing access to objects shared across the greenlets is unnecessary in most cases (because yielding control is usually explict), thus traditional synchronization devices like the :class:`~lock.BoundedSemaphore`, :class:`~lock.RLock` and :class:`~lock.Semaphore` classes, although present, aren't used very often. Other abstractions from threading and multiprocessing remain useful in the cooperative world: - :class:`~event.Event` allows one to wake up a number of greenlets that are calling :meth:`~event.Event.wait` method. - :class:`~event.AsyncResult` is similar to :class:`~event.Event` but allows passing a value or an exception to the waiters. - :class:`~queue.Queue` and :class:`~queue.JoinableQueue`. Lightweight pseudothreads ========================= .. currentmodule:: gevent.greenlet New greenlets are spawned by creating a :class:`~gevent.Greenlet` instance and calling its :meth:`start ` method. (The :func:`gevent.spawn` function is a shortcut that does exactly that). The :meth:`start ` method schedules a switch to the greenlet that will happen as soon as the current greenlet gives up control. If there is more than one active greenlet, they will be executed one by one, in an undefined order as they each give up control to the :class:`~gevent.hub.Hub`. If there is an error during execution it won't escape the greenlet's boundaries. An unhandled error results in a stacktrace being printed, annotated by the failed function's signature and arguments: >>> gevent.spawn(lambda : 1/0) >>> gevent.sleep(1) Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero > failed with ZeroDivisionError The traceback is asynchronously printed to ``sys.stderr`` when the greenlet dies. :class:`Greenlet` instances have a number of useful methods: - :meth:`join ` -- waits until the greenlet exits; - :meth:`kill ` -- interrupts greenlet's execution; - :meth:`get ` -- returns the value returned by greenlet or re-raises the exception that killed it. It is possible to customize the string printed after the traceback by subclassing the :class:`~gevent.Greenlet` class and redefining its ``__str__`` method. To subclass a :class:`gevent.Greenlet`, override its :meth:`gevent.Greenlet._run` method and call ``Greenlet.__init__(self)`` in ``__init__``:: class MyNoopGreenlet(Greenlet): def __init__(self, seconds): Greenlet.__init__(self) self.seconds = seconds def _run(self): gevent.sleep(self.seconds) def __str__(self): return 'MyNoopGreenlet(%s)' % self.seconds Greenlets can be killed synchronously from another greenlet. Killing will resume the sleeping greenlet, but instead of continuing execution, a :exc:`~gevent.greenlet.GreenletExit` will be raised. >>> g = MyNoopGreenlet(4) >>> g.start() >>> g.kill() >>> g.dead True The :exc:`gevent.greenlet.GreenletExit` exception and its subclasses are handled differently than other exceptions. Raising :exc:`~gevent.greenlet.GreenletExit` is not considered an exceptional situation, so the traceback is not printed. The :exc:`~gevent.greenlet.GreenletExit` is returned by :meth:`get ` as if it were returned by the greenlet, not raised. The :meth:`kill ` method can accept a custom exception to be raised: >>> g = MyNoopGreenlet.spawn(5) # spawn() creates a Greenlet and starts it >>> g.kill(Exception("A time to kill")) Traceback (most recent call last): ... Exception: A time to kill MyNoopGreenlet(5) failed with Exception The :meth:`kill ` can also accept a *timeout* argument specifying the number of seconds to wait for the greenlet to exit. Note that :meth:`kill ` cannot guarantee that the target greenlet will not ignore the exception (i.e., it might catch it), thus it's a good idea always to pass a timeout to :meth:`kill ` (otherwise, the greenlet doing the killing will remain blocked forever). .. tip:: The exact timing at which an exception is raised within a target greenlet as the result of :meth:`kill ` is not defined. See that function's documentation for more details. Timeouts ======== Many functions in the gevent API are synchronous, blocking the current greenlet until the operation is done. For example, :meth:`kill ` waits until the target greenlet is :attr:`~gevent.greenlet.Greenlet.dead` before returning [#f1]_. Many of those functions can be made asynchronous by passing the keyword argument ``block=False``. Furthermore, many of the synchronous functions accept a *timeout* argument, which specifies a limit on how long the function can block (examples include :meth:`gevent.event.Event.wait`, :meth:`gevent.Greenlet.join`, :meth:`gevent.Greenlet.kill`, :meth:`gevent.event.AsyncResult.get`, and many more). The :class:`socket ` and :class:`SSLObject ` instances can also have a timeout, set by the :meth:`settimeout ` method. When these are not enough, the :class:`~gevent.timeout.Timeout` class can be used to add timeouts to arbitrary sections of (cooperative, yielding) code. Futher reading ============== To limit concurrency, use the :class:`gevent.pool.Pool` class (see `example: dns_mass_resolve.py`_). Gevent comes with TCP/SSL/HTTP/WSGI servers. See :doc:`servers`. .. _`example: dns_mass_resolve.py`: https://github.com/gevent/gevent/blob/master/examples/dns_mass_resolve.py#L17 External resources ================== `Gevent for working Python developer`__ is a comprehensive tutorial. __ http://sdiehl.github.io/gevent-tutorial/ .. rubric:: Footnotes .. [#f1] This was not the case before 0.13.0, :meth:`kill ` method in 0.12.2 and older was asynchronous by default. gevent-1.1.0/doc/lowlevel.rst0000644000076500000000000000014712666555342016671 0ustar jmaddenwheel00000000000000=================== Low-level details =================== .. toctree:: gevent.hub gevent.core gevent-1.1.0/doc/make.bat0000644000076500000000000000577712666555342015731 0ustar jmaddenwheel00000000000000@ECHO OFF REM Command file for Sphinx documentation set SPHINXBUILD=sphinx-build set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\gevent.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\gevent.ghc goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end gevent-1.1.0/doc/Makefile0000644000076500000000000000627612666555342015757 0ustar jmaddenwheel00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The txt pages are in $(BUILDDIR)/text." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/gevent.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/gevent.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." gevent-1.1.0/doc/mysphinxext.py0000644000076500000000000000507212666555342017262 0ustar jmaddenwheel00000000000000from __future__ import print_function from sphinx.ext.autodoc import cut_lines from sphinx.ext import intersphinx from docutils import nodes noisy = 0 message_cache = set() def missing_reference(app, env, node, contnode): """Search the index for missing references. For example, resolve :class:`Event` to :class:`Event `""" # XXX methods and functions resolved by this function miss their () if intersphinx.missing_reference(app, env, node, contnode) is not None: # is there a better way to give intersphinx a bigger priority? return env = app.builder.env type = node['reftype'] target = node['reftarget'] modname = node.get('py:module') classname = node.get('py:class') if modname and classname: return def new_reference(refuri, reftitle): newnode = nodes.reference('', '') newnode['refuri'] = refuri newnode['reftitle'] = reftitle newnode['py:class'] = 'external-xref' newnode['classname'] = 'external-xref' newnode.append(contnode) msg = 'Resolved missing-reference: :%5s:`%s` -> %s' % (type, target, refuri) if noisy >= 1 or msg not in message_cache: print(msg) message_cache.add(msg) return newnode if noisy >= 1: print('Looking for %s' % [type, target, modname, classname]) print(node) for docname, items in env.indexentries.items(): if noisy >= 2: print(docname) for (i_type, i_string, i_target, i_aliasname) in items: if noisy >= 3: print('---', [i_type, i_string, i_target, i_aliasname]) if i_aliasname.endswith(target): stripped_aliasname = i_aliasname[len(docname):] if stripped_aliasname: assert stripped_aliasname[0] == '.', repr(stripped_aliasname) stripped_aliasname = stripped_aliasname[1:] if stripped_aliasname == target: if noisy >= 1: print('--- found %s %s in %s' % (type, target, i_aliasname)) return new_reference(docname + '.html#' + i_aliasname, i_aliasname) if type == 'mod': modules = [x for x in env.indexentries.keys() if x.startswith('gevent.')] target = 'gevent.' + target if target in modules: return new_reference(target + '.html', target) def setup(app): app.connect('missing-reference', missing_reference) app.connect('autodoc-process-docstring', cut_lines(2, what=['module'])) gevent-1.1.0/doc/mytheme/0000755000076500000000000000000012666555432015754 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/mytheme/changes/0000755000076500000000000000000012666555432017364 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/mytheme/changes/frameset.html0000644000076500000000000000062412666555342022062 0ustar jmaddenwheel00000000000000 {% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %} gevent-1.1.0/doc/mytheme/changes/rstsource.html0000644000076500000000000000064712666555342022312 0ustar jmaddenwheel00000000000000 {% trans filename=filename, docstitle=docstitle|e %}{{ filename }} — {{ docstitle }}{% endtrans %}
          {{ text }}
        
    gevent-1.1.0/doc/mytheme/changes/versionchanges.html0000644000076500000000000000233412666555342023272 0ustar jmaddenwheel00000000000000{% macro entries(changes) %}
      {% for entry, docname, lineno in changes %}
    • {{ entry }}
    • {% endfor %}
    {% endmacro -%} {% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}

    {% trans version=version|e %}Automatically generated list of changes in version {{ version }}{% endtrans %}

    {{ _('Library changes') }}

    {% for modname, changes in libchanges %}

    {{ modname }}

    {{ entries(changes) }} {% endfor %}

    {{ _('C API changes') }}

    {{ entries(apichanges) }}

    {{ _('Other changes') }}

    {% for (fn, title), changes in otherchanges %}

    {{ title }} ({{ fn }})

    {{ entries(changes) }} {% endfor %}
    gevent-1.1.0/doc/mytheme/defindex.html0000644000076500000000000000246312666555342020435 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Overview') %} {% block body %}

    {{ docstitle|e }}

    Welcome! This is {% block description %}the documentation for {{ project|e }} {{ release|e }}{% if last_updated %}, last updated {{ last_updated|e }}{% endif %}{% endblock %}.

    {% block tables %}

    {{ _('Indices and tables:') }}

    {% endblock %} {% endblock %} gevent-1.1.0/doc/mytheme/domainindex.html0000644000076500000000000000374112666555342021146 0ustar jmaddenwheel00000000000000{# basic/domainindex.html ~~~~~~~~~~~~~~~~~~~~~~ Template for domain indices (module index, ...). :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. #} {% extends "layout.html" %} {% set title = indextitle %} {% block extrahead %} {{ super() }} {% if not embedded and collapse_index %} {% endif %} {% endblock %} {% block body %} {%- set curr_group = 0 %}

    {{ indextitle }}

    {%- for (letter, entries) in content %} {{ letter }} {%- if not loop.last %} | {% endif %} {%- endfor %}
    {%- for letter, entries in content %} {%- for (name, grouptype, page, anchor, extra, qualifier, description) in entries %} {%- if grouptype == 1 %}{% set curr_group = curr_group + 1 %}{% endif %} {%- endfor %} {%- endfor %}
     
    {{ letter }}
    {% if grouptype == 1 -%} {%- endif %} {% if grouptype == 2 %}   {% endif %} {% if page %}{% endif -%} {{ name|e }} {%- if page %}{% endif %} {%- if extra %} ({{ extra|e }}){% endif -%} {% if qualifier %}{{ qualifier|e }}:{% endif %} {{ description|e }}
    {% endblock %} gevent-1.1.0/doc/mytheme/genindex-single.html0000644000076500000000000000272412666555342021727 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Index') %} {% block body %}

    {% trans key=key %}Index – {{ key }}{% endtrans %}

    {%- set breakat = count // 2 %} {%- set numcols = 1 %} {%- set numitems = 0 %} {% for entryname, (links, subitems) in entries %}
    {%- if links -%}{{ entryname|e }} {%- for link in links[1:] %}, [{{ loop.index }}]{% endfor -%} {%- else -%} {{ entryname|e }} {%- endif -%}
    {%- if subitems %}
    {%- for subentryname, subentrylinks in subitems %}
    {{ subentryname|e }} {%- for link in subentrylinks[1:] %}, [{{ loop.index }}]{% endfor -%}
    {%- endfor %}
    {%- endif -%} {%- set numitems = numitems + 1 + (subitems|length) -%} {%- if numcols < 2 and numitems > breakat -%} {%- set numcols = numcols+1 -%}
    {%- endif -%} {%- endfor %}
    {% endblock %} {% block sidebarrel %}

    Index

    {% for key, dummy in genindexentries -%} {{ key }} {% if not loop.last %}| {% endif %} {%- endfor %}

    {{ _('Full index on one page') }}

    {{ super() }} {% endblock %} gevent-1.1.0/doc/mytheme/genindex-split.html0000644000076500000000000000165012666555342021576 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Index') %} {% block body %}

    {{ _('Index') }}

    {{ _('Index pages by letter') }}:

    {% for key, dummy in genindexentries -%} {{ key }} {% if not loop.last %}| {% endif %} {%- endfor %}

    {{ _('Full index on one page') }} ({{ _('can be huge') }})

    {% endblock %} {% block sidebarrel %} {% if split_index %}

    Index

    {% for key, dummy in genindexentries -%} {{ key }} {% if not loop.last %}| {% endif %} {%- endfor %}

    {{ _('Full index on one page') }}

    {% endif %} {{ super() }} {% endblock %} gevent-1.1.0/doc/mytheme/genindex.html0000644000076500000000000000335612666555342020452 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Index') %} {% block body %}

    {{ _('Index') }}

    {% for key, dummy in genindexentries -%} {{ key }} {% if not loop.last %}| {% endif %} {%- endfor %}
    {% for key, entries in genindexentries %}

    {{ key }}

    {%- set breakat = genindexcounts[loop.index0] // 2 %} {%- set numcols = 1 %} {%- set numitems = 0 %} {% for entryname, (links, subitems) in entries %}
    {%- if links -%}{{ entryname|e }} {%- for link in links[1:] %}, [{{ loop.index }}]{% endfor -%} {%- else -%} {{ entryname|e }} {%- endif -%}
    {%- if subitems %}
    {%- for subentryname, subentrylinks in subitems %}
    {{ subentryname|e }} {%- for link in subentrylinks[1:] %}, [{{ loop.index }}]{% endfor -%}
    {%- endfor %}
    {%- endif -%} {%- set numitems = numitems + 1 + (subitems|length) -%} {%- if numcols < 2 and numitems > breakat -%} {%- set numcols = numcols+1 -%}
    {%- endif -%} {%- endfor %}
    {% endfor %} {% endblock %} {% block sidebarrel %} {% if split_index %}

    {{ _('Index') }}

    {% for key, dummy in genindexentries -%} {{ key }} {% if not loop.last %}| {% endif %} {%- endfor %}

    {{ _('Full index on one page') }}

    {% endif %} {{ super() }} {% endblock %} gevent-1.1.0/doc/mytheme/layout.html0000644000076500000000000002476112666555342020171 0ustar jmaddenwheel00000000000000{%- block doctype -%} {%- endblock %} {%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} {%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} {%- set url_root = pathto('', 1) %} {%- if url_root == '#' %}{% set url_root = '' %}{% endif %} {%- macro relbar() %} {%- endmacro %} {%- macro sidebar() %} {%- if not embedded %}{% if not theme_nosidebar|tobool %}
    {%- block sidebarlogo %} {%- if logo %} {%- endif %} {%- endblock %} {%- block sidebartoc %} {%- if display_toc %}

    {{ _('Table Of Contents') }}

    {{ toc }} {%- else %}

    {{ _('Navigation') }}

    {%- endif %} {%- endblock %} {%- block sidebarrel %}

    Related pages

    {%- endblock %} {%- block sidebarsourcelink %} {%- if show_source and has_source and sourcename %}

    {{ _('This Page') }}

    {%- endif %} {%- endblock %} {%- if customsidebar %} {% include customsidebar %} {%- endif %} {# {%- block sidebarsearch %} {%- if pagename != "search" %} {%- endif %} {%- endblock %} #}
    {%- endif %}{% endif %} {%- endmacro %} {{ metatags }} {%- if not embedded and docstitle %} {%- set titlesuffix = " — "|safe + docstitle|e %} {%- else %} {%- set titlesuffix = "" %} {%- endif %} {{ title|striptags }}{{ titlesuffix }} {%- if not embedded %} {# {%- for scriptfile in script_files %} {%- endfor %} {%- if use_opensearch %} {%- endif %} #} {%- if favicon %} {%- endif %} {%- endif %} {%- block linktags %} {%- if hasdoc('about') %} {%- endif %} {%- if hasdoc('genindex') %} {%- endif %} {%- if hasdoc('search') %} {%- endif %} {%- if hasdoc('copyright') %} {%- endif %} {%- if parents %} {%- endif %} {%- if next %} {%- endif %} {%- if prev %} {%- endif %} {%- endblock %} {%- block extrahead %} {% endblock %}
    {%- block document %}
    {%- if not embedded %}{% if not theme_nosidebar|tobool %}
    {%- endif %}{% endif %}
    {% block body %} {% endblock %} {%- if next %}

    Next page: {{ next.title }}

    {%- endif %}
    {%- if not embedded %}{% if not theme_nosidebar|tobool %}
    {%- endif %}{% endif %}
    {%- endblock %}
    {%- block sidebar2 %}{{ sidebar() }}{% endblock %}
     
    gevent-1.1.0/doc/mytheme/modindex.html0000644000076500000000000000313412666555342020452 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Global Module Index') %} {% block extrahead %} {{ super() }} {% if not embedded and collapse_modindex %} {% endif %} {% endblock %} {% block body %}

    {{ _('Global Module Index') }}

    {%- for letter in letters %} {{ letter }} {% if not loop.last %}| {% endif %} {%- endfor %}
    {%- for modname, collapse, cgroup, indent, fname, synops, pform, dep, stripped in modindexentries %} {%- if not modname -%} {%- else -%} {%- endif -%} {% endfor %}
     
    {{ fname }}
    {% if collapse -%} {%- endif %} {% if indent %}   {% endif %} {% if fname %}{% endif -%} {{ stripped|e }}{{ modname|e }} {%- if fname %}{% endif %} {%- if pform and pform[0] %} ({{ pform|join(', ') }}){% endif -%} {% if dep %}{{ _('Deprecated')}}:{% endif %} {{ synops|e }}
    {% endblock %} gevent-1.1.0/doc/mytheme/page.html0000644000076500000000000000011112666555342017547 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% block body %} {{ body }} {% endblock %} gevent-1.1.0/doc/mytheme/search.html0000644000076500000000000000303712666555342020112 0ustar jmaddenwheel00000000000000{% extends "layout.html" %} {% set title = _('Search') %} {% set script_files = script_files + ['_static/searchtools.js'] %} {% block body %}

    {{ _('Search') }}

    {% trans %}Please activate JavaScript to enable the search functionality.{% endtrans %}

    {% trans %}From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list.{% endtrans %}

    {% if search_performed %}

    {{ _('Search Results') }}

    {% if not search_results %}

    {{ _('Your search did not match any results.') }}

    {% endif %} {% endif %}
    {% if search_results %}
      {% for href, caption, context in search_results %}
    • {{ caption }}
      {{ context|e }}
    • {% endfor %}
    {% endif %}
    {% endblock %} {% block footer %} {{ super() }} {% endblock %} gevent-1.1.0/doc/mytheme/static/0000755000076500000000000000000012666555432017243 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/mytheme/static/basic.css_t0000644000076500000000000007312512666555342021371 0ustar jmaddenwheel00000000000000/* Template name: Simple Organization Template URI: http://templates.arcsin.se/simple-organization-website-template/ Release date: 2009-09-20 Last updated: 2009-09-24 Description: A simple and elegant template suitable for organizations. Author: Viktor Persson Author URI: http://arcsin.se/ This template is licensed under a Creative Commons Attribution 2.5 License: http://templates.arcsin.se/license/ */ /* Reset ------------------------------------------------------------------- */ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, /*pre,*/ a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, textarea, input, select {margin: 0; padding: 0; border: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline;} table {border-collapse: collapse; border-spacing: 0;} caption, th, td {text-align: left; font-weight: normal;} table, td, th {vertical-align: middle;} blockquote:before, blockquote:after, q:before, q:after {content: "";} blockquote, q {quotes: "" "";} a img {border: none;} :focus {outline: 0;} /* General ------------------------------------------------------------------- */ html { height: 100%; padding-bottom: 1px; /* force scrollbars */ } body { background: #FFF; color: #444; font: normal 75% sans-serif; line-height: 1.5; } /* Typography ------------------------------------------------------------------- */ /* Headings */ h1,h2,h3,h4,h5,h6 { color: #444; font-weight: normal; line-height: 1; margin-bottom: 0.3em; } /*h4,h5,h6 {font-weight: bold;}*/ h1 {font-size: 2em;} h2 {font-size: 2em;} h3 {font-size: 1.5em;} h4 {font-size: 1.25em;} h5 {font-size: 1.1em;} h6 {font-size: 1em;} h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin: 0;} .document h1, .document h2, .document h3 { /* label */ border-left-style: solid; border-left-width: 4px; margin-bottom: 0.2em; padding-left: 10px; /* label-green */ border-left-color: #B7D897; } .document h1 {font-size: 2em; margin-bottom: 1em; } .document h2 {font-size: 1.5em; margin-bottom: 1em; margin-top: 1em; } .document h3 {font-size: 1.25em; margin-bottom: 1em; margin-top: 1em; } .document h4 {font-size: 1.1em; margin-bottom: 1em; margin-top: 1em; } .document h5 {font-size: 1em; margin-bottom: 1em; margin-top: 1em; } .title {color: #7c9a5e;} /* Links */ a:focus,a:hover {color: {{ theme_linkcolor }}; /*#039;*/} a { color: #456; text-decoration: none; } a:hover {text-decoration: underline;} a.feed { background: url('img/icon-feed.gif') no-repeat left center; padding-left: 18px; } a.more { color: #579; font-weight: bold; } a.more:hover {color: #234;} h2 a {color: #444; text-decoration: none;} h3 a {color: #444; text-decoration: none;} h2 a:hover {color: #000; text-decoration: none;} h3 a:hover {color: #000; text-decoration: none;} a .regular {color: #444; } a.nobr { white-space: nowrap; } /* Text elements */ p {margin-bottom: 1em; margin-top: 1em; } abbr, acronym {border-bottom: 1px dotted #666;} address {margin-bottom: 1.5em;} blockquote {margin: 1.5em;} del, blockquote { color:#666; } em, dfn, blockquote, address {font-style: italic;} strong, dfn {font-weight: bold;} sup, sub {line-height: 0;} /*pre { margin: 1.5em 0; white-space: pre; } pre,code,tt { font: 1em monospace; line-height: 1.5; }*/ /* Lists */ li ul, li ol {margin-left: 1.5em;} ul, ol {margin: 1.5em 0 1.5em 1.5em;} /*ul {list-style-type: disc;}*/ ol { /*list-style-type: decimal;*/ margin-left: 1.9em; } dl {margin: 0 0 1.5em 0;} dl dt {font-weight: bold;} dd {margin-left: 1.5em;} /* Special lists */ ul.plain-list li, ul.nice-list li, ul.tabbed li { list-style: none; margin-top: 0; } ul.tabbed { display: inline; margin: 0; } ul.tabbed li {float: left;} ul.plain-list {margin: 0;} ul.nice-list {margin-left: 0;} ul.nice-list li { border-top: 1px solid #EEE; list-style: none; padding: 4px 0; } ul.nice-list li:first-child {border-top: none;} ul.nice-list li .right {color: #999;} /* Tables */ table {margin-bottom: 1.4em; width: 100%;} th {font-weight: bold;} thead th {background: #C3D9FF;} th,td,caption {padding: 4px 10px 4px 5px;} tr.even td {background: #F2F6FA;} tfoot {font-style: italic;} caption {background: #EEE;} table.data-table { border: 1px solid #CCB; margin-bottom: 2em; width: 100%; } table.data-table th { background: #F0F0F0; border: 1px solid #DDD; color: #555; text-align: left; } table.data-table tr {border-bottom: 1px solid #DDD;} table.data-table td, table th {padding: 10px;} table.data-table td { background: #F6F6F6; border: 1px solid #DDD; } table.data-table tr.even td {background: #FCFCFC;} /* Misc classes */ .small {font-size: 0.9em;} .smaller {font-size: 0.8em;} .smallest {font-size: 0.7em;} .large {font-size: 1.15em;} .larger {font-size: 1.25em;} .largest {font-size: 1.35em;} .hidden {display: none;} .quiet, .quiet a {color: #999;} .loud, .loud a {color: #000;} .highlight, .highlight a {background:#ff0;} .text-left {text-align: left;} .text-right {text-align: right;} .text-center {text-align: center;} .text-separator {padding: 0 5px;} .error, .notice, .success { border: 1px solid #DDD; margin-bottom: 1em; padding: 0.6em 0.8em; } .error {background: #FBE3E4; color: #8A1F11; border-color: #FBC2C4;} .error a {color: #8A1F11;} .notice {background: #FFF6BF; color: #514721; border-color: #FFD324;} .notice a {color: #514721;} .success {background: #E6EFC2; color: #264409; border-color: #C6D880;} .success a {color: #264409;} /* Labels */ h1.label { border-left-style: solid; border-left-width: 4px; margin-bottom: 0.2em; padding-left: 10px; } h1.label-blue {border-left-color: #55AADA;} h1.label-green {border-left-color: #B7D897;} h1.label-orange {border-left-color: #FA8F6F;} h2.label { border-left-style: solid; border-left-width: 4px; margin-bottom: 0.2em; padding-left: 10px; } h2.label-blue {border-left-color: #55AADA;} h2.label-green {border-left-color: #B7D897;} h2.label-orange {border-left-color: #FA8F6F;} /* Forms ------------------------------------------------------------------- */ label { cursor: pointer; font-weight: bold; } label.checkbox, label.radio {font-weight: normal;} legend { font-weight: bold; font-size: 1.2em; } textarea {overflow: auto;} input.text, textarea, select { background: #FCFCFC; border: 1px inset #AAA; margin: 0.5em 0; padding: 4px 5px; } input.text:focus, textarea:focus, select:focus {background: #FFFFF5;} input.button { background: #DDD; border: 1px outset #AAA; padding: 4px 5px; } input.button:active {border-style: inset;} /* Specific */ form .required {font-weight: bold;} .form-error {border-color: #F00;} .form-row {padding: 5px 0;} .form-row-submit { border-top: 1px solid #DDD; padding: 8px 0 10px 76px; margin-top: 10px; } .legend { background: #F0FAF0; border: 1px solid #D6DFD6; font-size: 1.5em; margin: 0; padding: 8px 14px; } .form-property, .form-value {float: left;} .form-property { padding-top: 8px; text-align: right; width: 60px; } .form-value {padding-left: 16px;} .form-error {border-color: #F00;} /* Alignment ------------------------------------------------------------------- */ /* General */ .center,.aligncenter { display: block; margin-left: auto; margin-right: auto; } /* Images */ img.bordered,img.alignleft,img.alignright,img.aligncenter { background-color: #FFF; border: 1px solid #DDD; padding: 3px; } img.alignleft, img.left {margin: 0 1.5em 1em 0;} img.alignright, img.right {margin: 0 0 1em 1.5em;} /* Floats */ .left,.alignleft {float: left;} .right,.alignright {float: right;} .clear,.clearer {clear: both;} .clearer { display: block; font-size: 0; line-height: 0; height: 0; } /* Separators ------------------------------------------------------------------- */ .content-separator, .archive-separator { background: #E5E5E5; clear: both; color: #FFE; display: block; font-size: 0; line-height: 0; height: 1px; } .content-separator {margin: 32px 0;} .archive-separator {margin-bottom: 20px;} /* Posts ------------------------------------------------------------------- */ .post {margin-bottom: 20px;} .post img.left, .post img.right {margin-bottom: 0;} .post-date { color: #777; margin: 2px 0 10px; } .post-date a {color: #444;} .post-meta a {color: #345; } .post-meta a:hover {color: #001;} /*.body {font-size: 133.33333%;}*/ .body {font-size: 1.1em;} .body a {color: {{ theme_linkcolor }}; /*#039;*/} .body a:hover {color: {{ theme_linkcolor }}; /*#039;*/} .body img.left, .body img.right {margin-bottom: 1em;} /* Archives */ .archive-pagination { color: #777; padding: 10px 0; } .archive-pagination-top { border-bottom: 2px solid #DDD; margin-bottom: 24px; } .archive-pagination-bottom { border-top: 2px solid #DDD; margin-top: 24px; } .archive-post-date { background: #F5F5F5; border-bottom: 1px solid #C5C5C5; border-right: 1px solid #CFCFCF; float: left; margin-right: 12px; padding: 2px 0 5px; text-align: center; width: 46px; } .archive-post-title .post-date {margin: 0;} .archive-post-title {padding-top: 4px;} .archive-post-day {font: normal 1.6em Georgia,serif;} /* Comments ------------------------------------------------------------------- */ /* .comment-input-text textarea {width: 80%;} // Comment list .comment-list-wrapper { background: #F6F6F6; margin: 10px 0 0; padding: 5px 12px 10px 7px; } .comment-list { margin: 0; padding: 0; } .comment-list li {list-style: none;} .comment-list ul {margin-bottom: 0;} .comment-profile-wrapper { text-align: center; width: 105px; } .comment-gravatar {margin-bottom: 3px;} .comment-content-wrapper { float: right; width: 481px; } .comment-parent, .comment-single {margin-top: 15px;} .comment-list ul.children, #comments #respond ul { border-left: 1px solid #CCC; margin: 0 0 0 130px; } .comment-list ul.children ul.children {margin-left: 15px;} .comment-list ul.children li { background: url('img/comment-reply.gif') no-repeat left top; margin: 0; padding: 10px 0 0 15px; } .comment-body { background: #FFF; border: 1px solid #DDD; padding: 10px 12px 0; } .comment-list ul.children .comment-body {background: #FCFCFC;} .comment-author {padding-top: 2px;} .comment-text p {margin-bottom: 0.8em;} .comment .post-date, .comment-author {font-size: 0.9em;} .comment .post-date .right a {color: #BBB;} .comment .post-date .right a:hover {color: #234;} .comment-arrow { background: url('img/comment-arrow.gif') no-repeat left top; display: block; float: left; height: 45px; margin: 3px 0 -45px -41px; position: absolute; width: 29px; } // Respond #respond li {list-style: none;} #respond { background: #F6F6F6; padding: 10px 12px; } #respond ul {margin: 0;} #respond .legend {margin-bottom: 10px;} #comments #respond {padding: 0;} #comments #respond .legend { border-bottom: 0; margin-bottom: 0; } #comments #respond ul { background: url('img/comment-reply.gif') no-repeat left top; padding: 10px 0 0 15px; } #comments ul.children #respond ul { margin-left: 30px; padding: 0; } #comments #respond .comment-profile-wrapper, #comments #respond .comment-arrow {display: none;} #comments #respond .comment-body {background: #FFF;} #comments #respond .comment-content-wrapper { float: none; width: 100%; } */ /* Layout ------------------------------------------------------------------- */ /* Common */ #top, #sub-nav {border-bottom: 1px solid #DDD;} /* Wrapper */ #site-wrapper { margin: 0 auto; width: 920px; } /* Header */ #header {padding-top: 24px;} /* Top */ #top {padding-bottom: 32px;} /* Logo */ #logo { border-right: 1px solid #DDD; padding: 10px 40px 10px 0; margin-right: 40px; } #logo img {} /* Splash */ #splash {padding-top: 32px;} /* Navigation */ .navigation a { color: #888; text-decoration: none; } .navigation a:hover {color: #002;} .navigation li.current-tab a {color: #222;} #main-nav li:first-child, #sub-nav li:first-child {margin-left: 0;} /* Main navigation */ #main-nav {padding-top: 0px;} #main-nav li {margin: 0 1.5em;} #main-nav a { font-size: 1.45em; line-height: 2em; padding-bottom: 2px; } #main-nav li.current-tab a {color: #333;} #main-nav a:hover {color: #002;} #main-nav li.current-tab a {border-bottom: 2px solid #94CC5F;} #main-nav li.current-tab a:hover {color: #002;} #title {color: #7c9a5e; text-decoration: none} #title:hover {text-decoration: none} /* Subnav */ #sub-nav { border-bottom: 1px solid #DDD; padding: 12px 0; } #sub-nav a { font-size: 1.2em; text-decoration: none; } #sub-nav li {margin: 0 1em;} #sub-nav li.current-tab a {font-weight: bold;} /* Main */ .main {margin: 24px 0;} .main#main-two-columns {background: url('img/main-two-columns.gif') repeat-y right top;} .main#main-two-columns-left {background: url('img/main-two-columns-left.gif') repeat-y left top;} .main#main-two-columns #main-content, .main#main-two-columns-left #main-content {width: 620px;} /* Sidebar */ #sidebar {width: 255px;} /* Columns */ .col3, .col3-mid {width: 31%;} .col3-mid {margin-left: 3%;} .col3big { width: 65% } /* Sections */ .section {margin-bottom: 24px;} .section-title { background-color: #F9F9F9; border-top: 2px solid #DDD; color: #7A7A7A; font: bold 1.2em sans-serif; margin-bottom: 16px; padding: 7px 10px 6px; } .section-title a {color: #7A7A7A;} .section-title a:hover {color: #444; text-decoration: none;} #sidebar .section-title {margin-bottom: 8px;} /* Footer */ #footer { border-top: 1px solid #DDD; color: #777; padding: 16px 0 4px; } #footer-left {width: 259px;} #footer-right { width: 659px; text-align: right; } #footer p {margin-bottom: 0.4em;} #footer .text-separator { padding: 0 3px; color: #BBB; } #footer a:hover {color: #000;} #footer a.quiet-link {text-decoration: none; color: #777} #footer a.quiet-link:hover {text-decoration: underline; color: #000} /* Misc overriding classes ------------------------------------------------------------------- */ /* Border */ .noborder {border: 0;} .notborder {border-top: 0;} .norborder {border-right: 0;} .nobborder {border-bottom: 0;} .nolborder {border-left: 0;} /* Margin */ .nomargin {margin: 0;} .notmargin {margin-top: 0;} .normargin {margin-right: 0;} .nobmargin {margin-bottom: 0;} .nolmargin {margin-left: 0;} /* Padding */ .nopadding {padding: 0;} .notpadding {padding-top: 0;} .norpadding {padding-right: 0;} .nobpadding {padding-bottom: 0;} .nolpadding {padding-left: 0;} /* IE Fixes (zzz) ------------------------------------------------------------------- */ * html .navigation, * html #footer, * html #splash, * html .comment ul {height: 0.01%;} * html #footer-left {width: 500px;} .navigation, #splash, .comment ul {min-height: 0.01%;} /* Sphinx stylesheet */ /* -- admonitions ----------------------------------------------------------- */ div.admonition { margin-top: 10px; margin-bottom: 10px; padding: 7px; } div.admonition dt { font-weight: bold; } div.admonition dl { margin-bottom: 0; } p.admonition-title { margin: 0px 10px 5px 0px; font-weight: bold; } div.body p.centered { text-align: center; margin-top: 25px; } tt { background-color: #ecf0f3; padding: 0 1px 0 1px; font-size: 110%; } .warning tt { background: #efc2c2 !important; } .note tt { background: #d6d6d6; } dt:target, .highlight { background-color: #fbe54e; } /* -- body styles ----------------------------------------------------------- */ a { color: {{ theme_linkcolor }}; text-decoration: none; } /* a:hover { text-decoration: underline; } */ a.headerlink { color: {{ theme_headlinkcolor }}; font-size: 0.8em; padding: 0 4px 0 4px; text-decoration: none; } a.headerlink:hover { background-color: {{ theme_headlinkcolor }}; color: white; } /* -- general body styles --------------------------------------------------- */ a.headerlink { visibility: hidden; } h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, dt:hover > a.headerlink { visibility: visible; } /* -- code displays --------------------------------------------------------- */ pre { overflow: auto; } td.linenos pre { padding: 5px 0px; border: 0; background-color: transparent; color: #aaa; } table.highlighttable { margin-left: 0.5em; } table.highlighttable td { padding: 0 0.5em 0 0.5em; } tt.descname { background-color: transparent; font-weight: bold; font-size: 1.2em; } tt.descclassname { background-color: transparent; } tt.xref, a tt { background-color: transparent; font-weight: bold; font-size: 1.2em; } h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { background-color: transparent; } div.admonition p.admonition-title + p { display: inline; } div.admonition p { margin-bottom: 5px; } div.admonition pre { margin-bottom: 5px; } div.admonition ul, div.admonition ol { margin-bottom: 5px; } div.note { background-color: #eee; border: 1px solid #ccc; } div.seealso { background-color: #ffc; border: 1px solid #ff6; } div.topic { background-color: #eee; } div.warning { background-color: #ffe4e4; border: 1px solid #f66; } div.caution { background-color: #fff6f1; border: 1px solid #ffaaa3; } div.hint, div.tip { border-left-style: solid; border-left-width: 2px; border-left-color: #B7D897; } p.admonition-title { display: inline; } p.admonition-title:after { content: ":"; } pre { padding: 5px; background-color: {{ theme_codebgcolor }}; color: {{ theme_codetextcolor }}; font-size: 120%; line-height: 150%; border: 1px solid #ac9; border-left: none; border-right: none; /*font-family: {{ theme_bodyfont }};*/ } /* -- other body styles ----------------------------------------------------- */ ol.arabic { list-style: decimal; } ol.loweralpha { list-style: lower-alpha; } ol.upperalpha { list-style: upper-alpha; } ol.lowerroman { list-style: lower-roman; } ol.upperroman { list-style: upper-roman; } dl { margin-bottom: 15px; } dd p { margin-top: 0px; } dd ul, dd table { margin-bottom: 10px; } dd { margin-top: 3px; margin-bottom: 10px; margin-left: 30px; } dt:target, .highlight { background-color: #fbe54e; } dl.glossary dt { font-weight: bold; font-size: 1.1em; } .field-list ul { margin: 0; padding-left: 1em; } .field-list p { margin: 0; } th.field-name { vertical-align: top; } .refcount { color: #060; } .optional { font-size: 1.3em; } .versionmodified { font-style: italic; } .system-message { background-color: #fda; padding: 5px; border: 3px solid red; } .footnote:target { background-color: #ffa } .line-block { display: block; margin-top: 1em; margin-bottom: 1em; } .line-block .line-block { margin-top: 0; margin-bottom: 0; margin-left: 1.5em; } .classifier { font-style: oblique; } ul ul { margin-top: 0em; margin-bottom: 0em; } p.rubric { margin-top: 30px; font-weight: bold; } /* // // Sphinx stylesheet -- basic theme // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // -- main layout ----------------------------------------------------------- div.clearer { clear: both; } // -- relbar ---------------------------------------------------------------- div.related { width: 100%; font-size: 90%; } div.related h3 { display: none; } div.related ul { margin: 0; padding: 0 0 0 10px; list-style: none; } div.related li { display: inline; } div.related li.right { float: right; margin-right: 5px; } // -- sidebar --------------------------------------------------------------- div.sphinxsidebarwrapper { padding: 10px 5px 0 10px; } div.sphinxsidebar { float: left; width: 230px; margin-left: -100%; font-size: 90%; } div.sphinxsidebar ul { list-style: none; } div.sphinxsidebar ul ul, div.sphinxsidebar ul.want-points { margin-left: 20px; list-style: square; } div.sphinxsidebar ul ul { margin-top: 0; margin-bottom: 0; } div.sphinxsidebar form { margin-top: 10px; } div.sphinxsidebar input { border: 1px solid #98dbcc; font-family: sans-serif; font-size: 1em; } img { border: 0; } // -- search page ----------------------------------------------------------- ul.search { margin: 10px 0 0 20px; padding: 0; } ul.search li { padding: 5px 0 5px 20px; background-image: url(file.png); background-repeat: no-repeat; background-position: 0 7px; } ul.search li a { font-weight: bold; } ul.search li div.context { color: #888; margin: 2px 0 0 30px; text-align: left; } ul.keywordmatches li.goodmatch a { font-weight: bold; } // -- index page ------------------------------------------------------------ table.contentstable { width: 90%; } table.contentstable p.biglink { line-height: 150%; } a.biglink { font-size: 1.3em; } span.linkdescr { font-style: italic; padding-top: 5px; font-size: 90%; } // -- general index --------------------------------------------------------- table.indextable td { text-align: left; vertical-align: top; } table.indextable dl, table.indextable dd { margin-top: 0; margin-bottom: 0; } table.indextable tr.pcap { height: 10px; } table.indextable tr.cap { margin-top: 10px; background-color: #f2f2f2; } img.toggler { margin-right: 3px; margin-top: 3px; cursor: pointer; } // -- general body styles --------------------------------------------------- div.body p.caption { text-align: inherit; } div.body td { text-align: left; } .field-list ul { padding-left: 1em; } .first { margin-top: 0 !important; } p.rubric { margin-top: 30px; font-weight: bold; } .align-left { text-align: left; } .align-center { clear: both; text-align: center; } .align-right { text-align: right; } // -- sidebars -------------------------------------------------------------- div.sidebar { margin: 0 0 0.5em 1em; border: 1px solid #ddb; padding: 7px 7px 0 7px; background-color: #ffe; width: 40%; float: right; } p.sidebar-title { font-weight: bold; } // -- topics ---------------------------------------------------------------- div.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; margin: 10px 0 10px 0; } p.topic-title { font-size: 1.1em; font-weight: bold; margin-top: 10px; } // -- tables ---------------------------------------------------------------- table.docutils { border: 0; border-collapse: collapse; } table.docutils td, table.docutils th { padding: 1px 8px 1px 0; border-top: 0; border-left: 0; border-right: 0; border-bottom: 1px solid #aaa; } table.field-list td, table.field-list th { border: 0 !important; } table.footnote td, table.footnote th { border: 0 !important; } th { text-align: left; padding-right: 5px; } table.citation { border-left: solid 1px gray; margin-left: 1px; } table.citation td { border-bottom: none; } // -- other body styles ----------------------------------------------------- ol.arabic { list-style: decimal; } ol.loweralpha { list-style: lower-alpha; } ol.upperalpha { list-style: upper-alpha; } ol.lowerroman { list-style: lower-roman; } ol.upperroman { list-style: upper-roman; } dl { margin-bottom: 15px; } dd p { margin-top: 0px; } dd ul, dd table { margin-bottom: 10px; } dd { margin-top: 3px; margin-bottom: 10px; margin-left: 30px; } dt:target, .highlight { background-color: #fbe54e; } dl.glossary dt { font-weight: bold; font-size: 1.1em; } .field-list ul { margin: 0; padding-left: 1em; } .field-list p { margin: 0; } .refcount { color: #060; } .optional { font-size: 1.3em; } .versionmodified { font-style: italic; } .system-message { background-color: #fda; padding: 5px; border: 3px solid red; } .footnote:target { background-color: #ffa } .line-block { display: block; margin-top: 1em; margin-bottom: 1em; } .line-block .line-block { margin-top: 0; margin-bottom: 0; margin-left: 1.5em; } .classifier { font-style: oblique; } // -- code displays --------------------------------------------------------- pre { overflow: auto; } td.linenos pre { padding: 5px 0px; border: 0; background-color: transparent; color: #aaa; } table.highlighttable { margin-left: 0.5em; } table.highlighttable td { padding: 0 0.5em 0 0.5em; } tt.descname { background-color: transparent; font-weight: bold; font-size: 1.2em; } tt.descclassname { background-color: transparent; } tt.xref, a tt { background-color: transparent; font-weight: bold; } h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { background-color: transparent; } // -- math display ---------------------------------------------------------- img.math { vertical-align: middle; } div.body div.math p { text-align: center; } span.eqno { float: right; } // -- printout stylesheet --------------------------------------------------- @media print { div.document, div.documentwrapper, div.bodywrapper { margin: 0 !important; width: 100%; } div.sphinxsidebar, div.related, div.footer, #top-link { display: none; } } // default theme body { font-family: {{ theme_bodyfont }}; font-size: 100%; background-color: {{ theme_footerbgcolor }}; color: #000; margin: 0; padding: 0; } div.document { background-color: {{ theme_sidebarbgcolor }}; } div.documentwrapper { float: left; width: 100%; } div.bodywrapper { margin: 0 0 0 230px; } div.body { background-color: {{ theme_bgcolor }}; color: {{ theme_textcolor }}; padding: 0 20px 30px 20px; } {%- if theme_rightsidebar|tobool %} div.bodywrapper { margin: 0 230px 0 0; } {%- endif %} div.footer { color: {{ theme_footertextcolor }}; width: 100%; padding: 9px 0 9px 0; text-align: center; font-size: 75%; } div.footer a { color: {{ theme_footertextcolor }}; text-decoration: underline; } div.related { background-color: {{ theme_relbarbgcolor }}; line-height: 30px; color: {{ theme_relbartextcolor }}; } div.related a { color: {{ theme_relbarlinkcolor }}; } div.sphinxsidebar { {%- if theme_stickysidebar|tobool %} top: 30px; bottom: 0; margin: 0; position: fixed; overflow: auto; height: auto; {%- endif %} {%- if theme_rightsidebar|tobool %} float: right; {%- if theme_stickysidebar|tobool %} right: 0; {%- endif %} {%- endif %} } {%- if theme_stickysidebar|tobool %} // this is nice, but it it leads to hidden headings when jumping // to an anchor // //div.related { // position: fixed; //} // //div.documentwrapper { // margin-top: 30px; //} {%- endif %} div.sphinxsidebar h3 { font-family: {{ theme_headfont }}; color: {{ theme_sidebartextcolor }}; font-size: 1.4em; font-weight: normal; margin: 0; padding: 0; } div.sphinxsidebar h3 a { color: {{ theme_sidebartextcolor }}; } div.sphinxsidebar h4 { font-family: {{ theme_headfont }}; color: {{ theme_sidebartextcolor }}; font-size: 1.3em; font-weight: normal; margin: 5px 0 0 0; padding: 0; } div.sphinxsidebar p { color: {{ theme_sidebartextcolor }}; } div.sphinxsidebar p.topless { margin: 5px 10px 10px 10px; } div.sphinxsidebar ul { margin: 10px; padding: 0; color: {{ theme_sidebartextcolor }}; } div.sphinxsidebar a { color: {{ theme_sidebarlinkcolor }}; } div.sphinxsidebar input { border: 1px solid {{ theme_sidebarlinkcolor }}; font-family: sans-serif; font-size: 1em; } // -- body styles ----------------------------------------------------------- a { color: {{ theme_linkcolor }}; text-decoration: none; } a:hover { text-decoration: underline; } div.body p, div.body dd, div.body li { text-align: justify; line-height: 130%; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: {{ theme_headfont }}; background-color: {{ theme_headbgcolor }}; font-weight: normal; color: {{ theme_headtextcolor }}; border-bottom: 1px solid #ccc; margin: 20px -20px 10px -20px; padding: 3px 0 3px 10px; } div.body h1 { margin-top: 0; font-size: 200%; } div.body h2 { font-size: 160%; } div.body h3 { font-size: 140%; } div.body h4 { font-size: 120%; } div.body h5 { font-size: 110%; } div.body h6 { font-size: 100%; } a.headerlink { color: {{ theme_headlinkcolor }}; font-size: 0.8em; padding: 0 4px 0 4px; text-decoration: none; } a.headerlink:hover { background-color: {{ theme_headlinkcolor }}; color: white; } div.body p, div.body dd, div.body li { text-align: justify; line-height: 130%; } div.admonition p.admonition-title + p { display: inline; } div.admonition p { margin-bottom: 5px; } div.admonition pre { margin-bottom: 5px; } div.admonition ul, div.admonition ol { margin-bottom: 5px; } div.note { background-color: #eee; border: 1px solid #ccc; } div.seealso { background-color: #ffc; border: 1px solid #ff6; } div.topic { background-color: #eee; } div.warning { background-color: #ffe4e4; border: 1px solid #f66; } p.admonition-title { display: inline; } p.admonition-title:after { content: ":"; } pre { padding: 5px; background-color: {{ theme_codebgcolor }}; color: {{ theme_codetextcolor }}; border: 1px solid #ac9; border-left: none; border-right: none; } tt { background-color: #ecf0f3; padding: 0 1px 0 1px; font-size: 0.95em; } .warning tt { background: #efc2c2; } .note tt { background: #d6d6d6; } */ gevent-1.1.0/doc/mytheme/static/file.png0000644000076500000000000000061012666555342020665 0ustar jmaddenwheel00000000000000PNG  IHDRabKGD pHYs  tIME  )TIDAT8˭J@Ir('[ "&xYZ X0!i|_@tD] #xjv YNaEi(əy@D&`6PZk$)5%"z.NA#Aba`Vs_3c,2mj [klvy|!Iմy;v "߮a?A7`c^nk?Bg}TЙD# "RD1yER*6MJ3K_Ut8F~IENDB`gevent-1.1.0/doc/mytheme/static/img/0000755000076500000000000000000012666555432020017 5ustar jmaddenwheel00000000000000gevent-1.1.0/doc/mytheme/static/img/main-two-columns.gif0000644000076500000000000000100312666555342023711 0ustar jmaddenwheel00000000000000GIF89a!,Dڋ<H}ʶ sjLcsĢ!<*LZ JSӪJybܨ ⲹF>ק4 ߸zdn?'8hVx((9iITyٓi):jtZTJ KU{K2+K\\{ }:M=j}} >)>Xn~>/G_w_迬@62( 2 "r!D.'2h 㭊p$3>tɔFVZLS.giΜxzMPM@(jҤ,2EԑӨ%Ra0UNXA`0, jNhN\;p:kI{/`|o⽋6xn专V^{mfvkhzjꨫf:ilzgns{f_gy/?A@2CCEFHIHTKWLY&OZ%'(\)]2(_*2+4`5>l-5=d7n?@pAHx@IpHBJtKSKS[~UV\]^]e_fghnopiqqxrxy{{ƒĊąŌƒǍɍȔɕ̖̐͗͝ΘϟЦѡӡҧөըԯ֩תװزٳڴں۵ݴܻ޼ݼU~P IDATh՚oHg~]? LuC9zuE)A ^PDhE_],Il J4涥!KjS2ZbrdKr[8ȑ3" ]cnyguwSyyј 8(t!.'!}!~Dԙ8E9B1d%zѺ%+*~Ν4]zj+ozբ^4f`&fD)l J+"!.E1P,ZG)|vYPnRpT_WDOo/bG>&+1Egqi~&fxWH1G"ԙUs!i߱/38 r9^fcLw1!I:C39=,:wXF%T1:;ssnSJbQO`PMΊADTۚ}X3\ ַ's2gax䚆mpg!Sqf17z5 j_,娸Yw?V[J&}6_ɾ:·c=@^N i#%.t0$/ Mē)9ipܨ*A[ ഡׁaů3畢)=)+ gM^TLP1hNad?KNWX i`Uѡ|oqU{Kzy]-H/mCSJcTl^C5kItuΒ!xh]~+|Pa 5w}q\KpGPᴋM^vP}3Pbp$5%}MCF9M.Ut( 3*x]fQl9ji{fyVWQoĨfcX3jq,5B8Yn(1> F7}_-FlfAj8@` :.±'ci,7fi\HM )fOg=~>t48 XSAOb0 I֮ҹG񸈇T< {˪K9і19f ;Yn7B:> iSȗ9 ^a {o[>%XQα Ì&[*,/- 9u.8 g*/H)_ #)1DSIk^S~^qhq$MY\Rٕ h:zO-!oُ+-A8[а]N[pݖ2q},x͖26V^ǂĥT䏯^Rv`LyG@5?b8.(*.Nd~/l '9Ea]"G@ݯZo9JK#,;j;1iFa .$XN4*{bv4r@Z0Wo%;_iz^ɑ9dž9:\ygn]zF52 8Q.Gf 6 vrD6#>t̮ZϡG$ Wb!f j*&|Hm"doS;i=5_cUZ.3 !ӄj7>u˄R(j<~xۍ~!0TqVC s`&2Cj`ަs+NI OJ㨸Y| >]e^1q<N,G7rVi+?BTkr2نVk7G3mUe(4X 3ޞSBM1Xޭ.laR\\o$a(ր,Q{ePmlT; UǚnZƀwk% BDbh:z,v]f}=&h=bUpl6B[n=sZY9Wxc~x%ٙ./.O*#U-9{%~IENDB`gevent-1.1.0/doc/mytheme/static/plus.png0000644000076500000000000000030712666555342020734 0ustar jmaddenwheel00000000000000PNG  IHDR &q pHYs  tIME 1l9tEXtComment̖RIDATcz(BpipPc |IENDB`gevent-1.1.0/doc/mytheme/static/spotify_logo.png0000644000076500000000000000271612666555342022474 0ustar jmaddenwheel00000000000000PNG  IHDR44sRGBPLTEZ2],Z/T\1VU$Y^#``%b5g{RzEv'z0|?|S|({1w)}Ty9|G~)|2x*NU}H{ *}3y+{;V~I|"+b<~4PW]}<-c{,QD$.^d|->E%~%kSY&/`fM&'0lN(UNms([*niV\]dXk_`lygzhtcio{jqwl~Eszu€†[ÔďŐǗȞȘȓəʛˏ˕̖̜q̤͗͝Θ͞ТШѣҤҪѰұҫլմծר׵ضھڸ۹ݼݽ!k pHYsaa?itIME07QCTIDATHc8PX@*P@`($GSQMF5j"[S!\SRH&`HM)B)pfTXIUAx@VAxxVJDF|!VM)yaP}:{Ll.oâ)w]'9yٛy}jᔗͧڤgo燢gۗ??_73}n_{|oGʥ<'>8vT[$Mэw1:g^16?ͿU|95i k*;qϋ^˿PoF޳xv%jzY}|v?Kqe~ϾeT%ӮE__rmS?oV*-ʑ=2']VzQgv pFqu3j];/KY'u{$9-랽;>bo`hVo6YtM7nr]塊9Şrg猄f >y|qW{?{?`|w0CSWxAt}TWc ft+/)ĕýRzh-P5m ]Bqq*IENDB`gevent-1.1.0/doc/mytheme/static/transparent.gif0000644000076500000000000000006112666555342022270 0ustar jmaddenwheel00000000000000GIF89a!,D;gevent-1.1.0/doc/mytheme/theme.conf0000644000076500000000000000122312666555342017723 0ustar jmaddenwheel00000000000000[theme] inherit = none stylesheet = basic.css pygments_style = sphinx [options] gevent_version = 0.0.0 nosidebar = false rightsidebar = false stickysidebar = false footerbgcolor = #11303d footertextcolor = #ffffff sidebarbgcolor = #1c4e63 sidebartextcolor = #ffffff sidebarlinkcolor = #98dbcc relbarbgcolor = #133f52 relbartextcolor = #ffffff relbarlinkcolor = #ffffff bgcolor = #ffffff textcolor = #000000 headbgcolor = #f2f2f2 headtextcolor = #20435c headlinkcolor = #c60f0f linkcolor = #355f7c codebgcolor = #eeffcc codetextcolor = #333333 bodyfont = sans-serif headfont = 'Trebuchet MS', sans-serif gevent-1.1.0/doc/networking.rst0000644000076500000000000000015312666555342017224 0ustar jmaddenwheel00000000000000Networking interfaces --------------------- .. toctree:: gevent.socket gevent.ssl gevent.select gevent-1.1.0/doc/reference.rst0000644000076500000000000000052512666555342016776 0ustar jmaddenwheel00000000000000API reference ------------- .. toctree:: gevent networking synchronization servers dns gevent.backdoor gevent.fileobject gevent.local gevent.monkey gevent.os gevent.signal gevent.pool gevent.queue gevent.server gevent.subprocess gevent.thread gevent.threadpool gevent.util lowlevel gevent-1.1.0/doc/servers.rst0000644000076500000000000000472112666555342016533 0ustar jmaddenwheel00000000000000.. implementing-servers: ====================== Implementing servers ====================== .. currentmodule:: gevent.baseserver There are a few classes to simplify server implementation with gevent. They all share a similar interface, inherited from :class:`BaseServer`:: def handle(socket, address): print('new connection!') server = StreamServer(('127.0.0.1', 1234), handle) # creates a new server server.start() # start accepting new connections At this point, any new connection accepted on ``127.0.0.1:1234`` will result in a new :class:`gevent.Greenlet` spawned running the *handle* function. To stop a server use :meth:`BaseServer.stop` method. In case of a :class:`gevent.pywsgi.WSGIServer`, *handle* must be a WSGI application callable. It is possible to limit the maximum number of concurrent connections, by passing a :class:`gevent.pool.Pool` instance. In addition, passing a pool allows the :meth:`BaseServer.stop` method to kill requests that are in progress:: pool = Pool(10000) # do not accept more than 10000 connections server = StreamServer(('127.0.0.1', 1234), handle, spawn=pool) server.serve_forever() .. tip:: If you don't want to limit concurrency, but you *do* want to be able to kill outstanding requests, use a pool created with a size of ``None``. The :meth:`BaseServer.serve_forever` method calls :meth:`BaseServer.start` and then waits until interrupted or until the server is stopped. The :mod:`gevent.pywsgi` module contains an implementation of a :pep:`3333` :class:`WSGI server `. In addition, gunicorn_ is a stand-alone server that supports gevent. Gunicorn has its own HTTP parser but can also use :mod:`gevent.wsgi` module. More examples are available in the `code repository`_: - `echoserver.py`_ - demonstrates :class:`StreamServer` - `wsgiserver.py`_ - demonstrates :class:`wsgi.WSGIServer ` - `wsgiserver_ssl.py`_ - demonstrates :class:`pywsgi.WSGIServer ` .. _`code repository`: https://github.com/gevent/gevent/tree/master/examples .. _gunicorn: http://gunicorn.org .. _`echoserver.py`: https://github.com/gevent/gevent/blob/master/examples/echoserver.py#L34 .. _`wsgiserver.py`: https://github.com/gevent/gevent/blob/master/examples/wsgiserver.py#L18 .. _`wsgiserver_ssl.py`: https://github.com/gevent/gevent/blob/master/examples/wsgiserver_ssl.py#L17 .. toctree:: gevent.baseserver gevent.server gevent.pywsgi gevent.wsgi gevent-1.1.0/doc/sfc.rst0000644000076500000000000000353312666555342015615 0ustar jmaddenwheel00000000000000.. raw:: html gevent-1.1.0/doc/success.rst0000644000076500000000000001124212666555342016506 0ustar jmaddenwheel00000000000000Success stories =============== If you have a success story for Gevent, contact denis.bilenko@gmail.com or post to the `google group`_. .. _google group: http://groups.google.com/group/gevent/ Omegle_ ------- I've been using gevent to power Omegle, my high-volume chat site, since 2010. Omegle is used by nearly half a million people every day, and it has as many as 20,000 users chatting at any given time. It needs to needs to perform well and be extremely reliable, and gevent makes that easy to do: gevent gives you power to do more creative things, and it's fast enough that you can more easily write apps that stand up to a lot of load. gevent is well-engineered, and its development has been maintaining an active, dedicated pace for as long as I've been following it. Any time I've had an issue with gevent that I couldn't solve on my own, the friendly community has been extremely helpful and knowledgeable. I really think gevent is the best library of its type for Python right now, and I would recommend it to anyone who needs a good networking library. -- Leif K-Brooks, Founder, Omegle.com_ .. _Omegle: http://omegle.com .. _Omegle.com: http://omegle.com Pediapress_ ----------- Pediapress_ powers Wikipedia_'s PDF rendering cluster. I've started using gevent in 2009 after our NFS based job queue showed serious performance problems on Wikipedia's PDF rendering cluster. I've replaced that with a gevent based job queue server in a short time. gevent is managing the generation of around 100000 PDF files daily and is serving them to wikipedia users. Recently I've refactored the component that fetches articles and images from wikipedia to use gevent instead of twisted. The code is much cleaner and much more manageable then before. -- Ralf Schmitt, Developer, Pediapress_ .. _Pediapress: http://pediapress.com/ .. _Wikipedia: http://www.wikipedia.org/ `ESN Social Software`_ ---------------------- Wanting to avoid the ravages of asynchronous programming we choose to base our real-time web development framework Planet on gevent and Python. We’ve found gevent to be stable, efficient, highly functional and still simplistic enough for our needs and our customer’s requirements. -- Jonas Tärnström, Product Manager, `ESN Social Software`_ .. _ESN Social Software: http://esn.me `Blue Shell Games`_ ------------------- At Blue Shell Games we use gevent to power the application servers that connect more than a million daily players of our social casino games. Recognizing that our game code is largely I/O bound — whether waiting on a database, social networking data providers, or the clients themselves — we chose gevent as our asynchronous networking framework. Not only does gevent offer the best performance of any of the Python async networking packages, its threading model makes multithreaded application servers far easier to write than traditional kernel threading-based approaches. As our applications add more real-time multiplayer features, gevent is ready to handle these kinds of problems with ease. -- David Young, CTO, Co-Founder, `Blue Shell Games`_ .. _Blue Shell Games: http://www.blueshellgames.com/ TellApart_ ---------- At TellApart, we have been using gevent since 2010 as the underpinnings of our frontend servers. It enables us to serve millions of requests every hour through only a handful of servers, while achieving the strict latency constraints of Real-Time Bidding ad exchanges. Since then, we've expanded our use of gevent throughout our stack. Combined with tools such as closures and generators, gevent makes complicated queuing, distribution, and streaming workloads dramatically easier to implement. Our open-source event aggregation service, Taba, couldn't have been built without it. See also: `Gevent at TellApart`_ -- Kevin Ballard, Software Engineer, TellApart_ .. _TellApart: http://tellapart.com .. _Gevent at TellApart: http://tellapart.com/gevent-at-tellapart Disqus ------ See: `Making Disqus Realtime`_ .. _`Making Disqus Realtime`: https://ep2012.europython.eu/conference/talks/making-disqus-realtime Pinterest --------- Pinterest is one of the biggest players of gevents. We started using gevent in 2011 to query our mysql shards concurrently. It served us well so far. We run all our WSGI containers using gevent. We are in the process of making all our service calls gevented. We use a gevented based thrift server which proved to be way more efficient than the normal python version. I think there is a cost upfront to make your code greenlet safe but we saw pretty huge win later. If you are looking to scale out on python gevent is your best friend. -- Yash Nelapati, Engineer, Pinterest_ .. _Pinterest: http://pinterest.com/ TBA: Spotify, Twilio gevent-1.1.0/doc/synchronization.rst0000644000076500000000000000016512666555342020301 0ustar jmaddenwheel00000000000000Synchronization primitives -------------------------- .. toctree:: gevent.event gevent.queue gevent.lock gevent-1.1.0/doc/whatsnew_1_0.rst0000644000076500000000000001357612666555342017351 0ustar jmaddenwheel00000000000000========================== What's new in gevent 1.0 ========================== The detailed information is available in changelog. Below is the summary of all changes since 0.13.8. Gevent 1.0 supports Python 2.5 - 2.7. The version of greenlet required is 0.3.2. The source distribution now includes the dependencies (libev and c-ares) and has no dependencies other than greenlet. New core ======== Now the event loop is using libev instead of libevent (see http://blog.gevent.org/2011/04/28/libev-and-libevent/ for motivation). The new :mod:`gevent.core` has been rewritten to wrap libev's API. (On Windows, the :mod:`gevent.core` accepts Windows handles rather than stdio file descriptors.). The signal handlers set with the standard signal module are no longer blocked by the event loop. The event loops are now pluggable. The GEVENT_LOOP enviroment variable can specify the alternative class to use (the default is ``gevent.core.loop``). The error handling is now done by Hub.handle_error(). The system errors that usually kill the process (SystemError, SystemExit, KeyboardInterrupt) are now re-raised in the main greenlet. Thus ``sys.exit()`` when run inside a greenlet is no longer trapped and kills the process as expected. New dns resolver ================ Two new DNS resolvers: threadpool-based one (enabled by default) and c-ares based one. That threadpool-based resolver was added mostly for Windows and Mac OS X platforms where c-ares might behave differently w.r.t system configuration. On Linux, however, the c-ares based resolver is probably a better choice. To enable c-ares resolver set GEVENT_RESOLVER=ares environment variable. This fixes some major issues with DNS on 0.13.x, namely: - Issue #2: DNS resolver no longer breaks after ``fork()``. You still need to call :func:`gevent.fork` (``os.fork`` is monkey patched with it if ``monkey.patch_all()`` was called). - DNS resolver no longer ignores ``/etc/resolv.conf`` and ``/etc/hosts``. The following functions were added to socket module: - gethostbyname_ex - getnameinfo - gethostbyaddr - getfqdn It is possible to implement your own DNS resolver and make gevent use it. The GEVENT_RESOLVER variable can point to alternative implementation using the format: ``package.module.class``. The default is ``gevent.resolver_thread.Resolver``. The alternative "ares" resolver is an alias for ``gevent.resolver_ares.Resolver``. New API ======= - :func:`gevent.wait` and :func:`gevent.iwait` - UDP server: gevent.server.DatagramServer - Subprocess support New :mod:`gevent.subprocess` implements the interface of the standard subprocess module in a cooperative way. It is possible to monkey patch the standard subprocess module with ``patch_all(subprocess=True)`` (not done by default). - Thread pool **Warning:** this feature is experimental and should be used with care. The :mod:`gevent.threadpool` module provides the usual pool methods (apply, map, imap, etc) but runs passed functions in a real OS thread. There's a default threadpool, available as ``gevent.get_hub().threadpool``. Breaking changes ================ Removed features ---------------- - gevent.dns module (wrapper around libevent-dns) - gevent.http module (wrapper around libevent-http) - ``util.lazy_property`` property. - deprecated gevent.sslold module - deprecated gevent.rawgreenlet module - deprecated name ``GreenletSet`` which used to be alias for :class:`Group`. - link to greenlet feature of Greenlet - undocumented bind_and_listen and tcp_listener Renamed gevent.coros to gevent.lock. The gevent.coros is still available but deprecated. API changes ----------- In all servers, method "kill" was renamed to "close". The old name is available as deprecated alias. - ``Queue(0)`` is now equivalent to an unbound queue and raises :exc:`DeprecationError`. Use :class:`gevent.queue.Channel` if you need a channel. The :class:`gevent.Greenlet` objects: - Added ``__nonzero__`` implementation that returns `True` after greenlet was started until it's dead. This overrides greenlet's __nonzero__ which returned `False` after `start()` until it was first switched to. Bugfixes ======== - Issue #302: "python -m gevent.monkey" now sets __file__ properly. - Issue #143: greenlet links are now executed in the order they were added - Fixed monkey.patch_thread() to patch threading._DummyThread to avoid leak in threading._active. - gevent.thread: allocate_lock is now an alias for LockType/Semaphore. That way it does not fail when being used as class member. - It is now possible to add raw greenlets to the pool. - The :meth:`map` and :meth:`imap` methods now start yielding the results as soon as possible. - The :meth:`imap_unordered` no longer swallows an exception raised while iterating its argument. - `gevent.sleep()` no longer raises an exception, instead it does `sleep(0)`. - The :class:`WSGIServer` now sets `max_accept` to 1 if `wsgi.multiprocessing` is set to `True`. - Added :func:`monkey.patch_module` function that monkey patches module using `__implements__` list provided by gevent module. All of gevent modules that replace stdlib module now have `__implements__` attribute. pywsgi: - Fix logging when bound on unix socket (#295). - readout request data to prevent ECONNRESET - Fix #79: Properly handle HTTP versions. - Fix #86: bytearray is now supported. - Fix #92: raise IOError on truncated POST requests. - Fix #93: do not sent multiple "100 continue" responses - Fix #116: Multiline HTTP headers are now handled properly. - Fix #216: propagate errors raised by Pool.map/imap - Fix #303: 'requestline' AttributeError in pywsgi. - Raise an AssertionError if non-zero content-length is passed to start_response(204/304) or if non-empty body is attempted to be written for 304/204 response - Made sure format_request() does not fail if 'status' attribute is not set yet - Added REMOTE_PORT variable to the environment. - Removed unused deprecated 'wfile' property from WSGIHandler gevent-1.1.0/doc/whatsnew_1_1.rst0000644000076500000000000003665112666555342017351 0ustar jmaddenwheel00000000000000========================== What's new in gevent 1.1 ========================== Detailed information an what has changed is available in the :doc:`changelog`. This document summarizes the most important changes since :doc:`gevent 1.0.2 `. Broader Platform Support ======================== gevent 1.1 supports Python 2.6, 2.7, 3.3, and 3.4 on the CPython (`python.org`_) interpreter. It also supports `PyPy`_ 2.6.1 and above (PyPy 4.0.1 or higher is recommended); PyPy3 is not supported. Support for Python 2.5 was removed when support for Python 3 was added. Any further releases in the 1.0.x line will maintain support for Python 2.5. Python 3.5 has preliminary support, which means that gevent is expected to generally run and function with the same level of support as on Python 3.4, but new features and APIs introduced in 3.5 may not be properly supported (e.g., `DevpollSelector`_) and due to the recent arrival of Python 3.5, the level of testing it has received is lower. For ease of installation on Windows and OS X, gevent 1.1 is distributed as pre-compiled binary wheels, in addition to source code. .. _python.org: http://www.python.org/downloads/ .. _PyPy: http://pypy.org .. _DevpollSelector: https://docs.python.org/3.5/whatsnew/3.5.html#selectors PyPy Notes ---------- PyPy has been tested on OS X and 64-bit Linux from version 2.6.1 through 4.0.0 and 4.0.1, and on 32-bit ARM on Raspbian with version 4.0.1. .. note:: PyPy is not supported on Windows. (gevent's CFFI backend is not available on Windows.) - Version 4.0.1 or above is **highly recommended** due to its extensive bug fixes relative to earlier versions. - Version 2.6.1 or above is **required** for proper signal handling. Prior to 2.6.1 and its inclusion of `cffi 1.3.0`_, signals could be delivered incorrectly or fail to be delivered during a blocking operation. (PyPy 2.5.0 includes CFFI 0.8.6 while 2.6.0 has 1.1.0; the necessary feature was added in `1.2.0`_ which is not itself directly present in any PyPy release.) CFFI 1.3.0 also allows using the CFFI backend on CPython. - Overall performance seems to be quite acceptable with newer versions of PyPy. The benchmarks distributed with gevent typically perform as well or better on PyPy than on CPython at least on some platforms. Things that are known or expected to be (relatively) slower under PyPy include the :mod:`c-ares resolver ` and :class:`~gevent.lock.Semaphore`. Whether or not these matter will depend on the workload of each application (:pr:`708` mentions some specific benchmarks for ``Semaphore``). .. caution:: The ``c-ares`` resolver is considered highly experimental under PyPy and is not recommended for production use. Released versions of PyPy through at least 4.0.1 have `a bug`_ that can cause a memory leak when subclassing objects that are implemented in Cython, as is the c-ares resolver. In addition, thanks to reports like :issue:`704`, we know that the PyPy garbage collector can interact badly with Cython-compiled code, leading to crashes. While the intended use of the ares resolver has been loosely audited for these issues, no guarantees are made. .. note:: PyPy 4.0.x on Linux is known to *rarely* (once per 24 hours) encounter crashes when running heavily loaded, heavily networked gevent programs (even without ``c-ares``). The exact cause is unknown and is being tracked in :issue:`677`. .. _cffi 1.3.0: https://bitbucket.org/cffi/cffi/src/ad3140a30a7b0ca912185ef500546a9fb5525ece/doc/source/whatsnew.rst?at=default .. _1.2.0: https://cffi.readthedocs.org/en/latest/whatsnew.html#v1-2-0 .. _a bug: https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext Operating Systems ----------------- gevent is regularly built and tested on Mac OS X, Ubuntu Linux, and Windows, in both 32- and 64-bit configurations. All three platforms are primarily tested on the x86/amd64 architecture, while Linux is also occasionally tested on Raspian on ARM. In general, gevent should work on any platform that both Python and `libev support`_. However, some less commonly used platforms may require tweaks to the gevent source code or user environment to compile (e.g., `SmartOS`_). Also, due to differences in things such as timing, some platforms may not be able to fully pass gevent's extensive test suite (e.g., `OpenBSD`_). .. _libev support: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#PORTABILITY_NOTES .. _SmartOS: https://github.com/gevent/gevent/pull/711 .. _OpenBSD: https://github.com/gevent/gevent/issues/737 Bug Fixes ========= Since 1.0.2, gevent 1.1 contains over 600 commits from nearly two dozen contributors. Over 200 issues were closed, and over 50 pull requests were merged. Improved subprocess support =========================== In gevent 1.0, support and monkey patching for the :mod:`subprocess` module was added. Monkey patching this module was off by default. In 1.1, monkey patching ``subprocess`` is on by default due to improvements in handling child processes and requirements by downstream libraries, notably `gunicorn`_. - :func:`gevent.os.fork`, which is monkey patched by default (and should be used to fork a gevent-aware process that expects to use gevent in the child process) has been improved and cooperates with :func:`gevent.os.waitpid` (again monkey patched by default) and :func:`gevent.signal.signal` (which is monkey patched only for the :data:`signal.SIGCHLD` case). The latter two patches are new in 1.1. - In gevent 1.0, use of libev child watchers (which are used internally by ``gevent.subprocess``) had race conditions with user-provided ``SIGCHLD`` handlers, causing many types of unpredictable breakage. The two new APIs described above are intended to rectify this. - Fork-watchers will be called, even in multi-threaded programs (except on Windows). - The default threadpool and threaded resolver work in child processes. - File descriptors are no longer leaked if :class:`gevent.subprocess.Popen` fails to start the child. In addition, simple use of :class:`multiprocessing.Process` is now possible in a monkey patched system, at least on POSIX platforms. .. caution:: Use of :class:`multiprocessing.Queue` when :mod:`thread` has been monkey-patched will lead to a hang due to ``Queue``'s internal use of a blocking pipe and threads. For the same reason, :class:`concurrent.futures.ProcessPoolExecutor`, which internally uses a ``Queue``, will hang. .. caution:: It is not possible to use :mod:`gevent.subprocess` from native threads. See :mod:`gevent.subprocess` for details. .. note:: If the ``SIGCHLD`` signal is to be handled, it is important to monkey patch (or directly use) both :mod:`os` and :mod:`signal`; this is the default for :func:`~gevent.monkey.patch_all`. Failure to do so can result in the ``SIGCHLD`` signal being lost. .. tip:: All of the above entail forking a child process. Forking a child process that uses gevent, greenlets, and libev can have some unexpected consequences if the child doesn't immediately ``exec`` a new binary. Be sure you understand these consequences before using this functionality, especially late in a program's lifecycle. For a more robust solution to certain uses of child process, consider `gipc`_. .. _gunicorn: http://gunicorn.org .. _gipc: https://gehrcke.de/gipc/ Monkey patching =============== Monkey patching is more robust, especially if the standard library :mod:`threading` or :mod:`logging` modules had been imported before applying the patch. In addition, there are now supported ways to determine if something has been monkey patched. API Additions ============= Numerous APIs offer slightly expanded functionality in this version. Look for "changed in version 1.1" or "added in version 1.1" throughout the documentation for specifics. Highlights include: - A gevent-friendly version of :obj:`select.poll` (on platforms that implement it). - :class:`~gevent.fileobject.FileObjectPosix` uses the :mod:`io` package on both Python 2 and Python 3, increasing its functionality, correctness, and performance. (Previously, the Python 2 implementation used the undocumented class :class:`socket._fileobject`.) - Locks raise the same error as standard library locks if they are over-released. Likewise, SSL sockets raise the same errors as their bundled counterparts if they are read or written after being closed. - :meth:`ThreadPool.apply ` can now be used recursively. - The various pool objects (:class:`~gevent.pool.Group`, :class:`~gevent.pool.Pool`, :class:`~gevent.threadpool.ThreadPool`) support the same improved APIs: :meth:`imap ` and :meth:`imap_unordered ` accept multiple iterables, :meth:`apply ` raises any exception raised by the target callable, etc. - Killing a greenlet (with :func:`gevent.kill` or :meth:`Greenlet.kill `) before it is actually started and switched to now prevents the greenlet from ever running, instead of raising an exception when it is later switched to. Attempting to spawn a greenlet with an invalid target now immediately produces a useful :exc:`TypeError`, instead of spawning a greenlet that would (usually) immediately die the first time it was switched to. - Almost anywhere that gevent raises an exception from one greenlet to another (e.g., :meth:`Greenlet.get `), the original traceback is preserved and raised. - Various logging/debugging outputs have been cleaned up. - The WSGI server found in :mod:`gevent.pywsgi` is more robust against errors in either the client or the WSGI application, fixing several hangs or HTTP protocol violations. It also supports new functionality such as configurable error handling and logging. - Documentation has been expanded and clarified. Library Updates =============== The two C libraries that are bundled with gevent have been updated. libev has been updated from 4.19 to 4.20 (`libev release notes`_) and c-ares has been updated from 1.9.1 to 1.10.0 (`c-ares release notes`_). .. caution:: The c-ares ``configure`` script is now *much* stricter about the contents of compilation environment variables such as ``$CFLAGS`` and ``$LDFLAGS``. For example, ``$CFLAGS`` is no longer allowed to contain ``-I`` directives; instead, these must be placed in ``$CPPFLAGS``. That's one common cause of an error like the following when compiling from scratch on a POSIX platform:: Running '(cd "/tmp/easy_install-NT921u/gevent-1.1b2/c-ares" && if [ -e ares_build.h ]; then cp ares_build.h ares_build.h.orig; fi && /bin/sh ./configure CONFIG_COMMANDS= CONFIG_FILES= && cp ares_config.h ares_build.h "$OLDPWD" && mv ares_build.h.orig ares_build.h) > configure-output.txt' in /tmp/easy_install-NT921u/gevent-1.1b2/build/temp.linux-x86_64-2.7/c-ares configure: error: Can not continue. Fix errors mentioned immediately above this line. .. _libev release notes: https://github.com/gevent/gevent/blob/master/libev/Changes#L17 .. _c-ares release notes: https://raw.githubusercontent.com/bagder/c-ares/cares-1_10_0/RELEASE-NOTES Compatibility ============= This release is intended to be compatible with 1.0.x with minimal or no changes to client source code. However, there are a few changes to be aware of that might affect some applications. Most of these changes are due to the increased platform support of Python 3 and PyPy and reduce the cases of undocumented or non-standard behaviour. - :class:`gevent.baseserver.BaseServer` deterministically `closes its sockets `_. As soon as a request completes (the request handler returns), the ``BaseServer`` and its subclasses including :class:`gevent.server.StreamServer` and :class:`gevent.pywsgi.WSGIServer` close the client socket. In gevent 1.0, the client socket was left to the mercies of the garbage collector (this was undocumented). In the typical case, the socket would still be closed as soon as the request handler returned due to CPython's reference-counting garbage collector. But this meant that a reference cycle could leave a socket dangling open for an indeterminate amount of time, and a reference leak would result in it never being closed. It also meant that Python 3 would produce ResourceWarnings, and PyPy (which, unlike CPython, `does not use a reference-counted GC`_) would only close (and flush!) the socket at an arbitrary time in the future. If your application relied on the socket not being closed when the request handler returned (e.g., you spawned a greenlet that continued to use the socket) you will need to keep the request handler from returning (e.g., ``join`` the greenlet). If for some reason that isn't possible, you may subclass the server to prevent it from closing the socket, at which point the responsibility for closing and flushing the socket is now yours; *but* the former approach is strongly preferred, and subclassing the server for this reason may not be supported in the future. .. _does not use a reference-counted GC: http://doc.pypy.org/en/latest/cpython_differences.html#differences-related-to-garbage-collection-strategies - :class:`gevent.pywsgi.WSGIServer` ensures that headers and the status line set by the application can be encoded in the ISO-8859-1 (Latin-1) charset and are of the *native string type*. Under gevent 1.0, non-``bytes`` headers (that is, ``unicode``, since gevent 1.0 only ran on Python 2) were encoded according to the current default Python encoding. In some cases, this could allow non-Latin-1 characters to be sent in the headers, but this violated the HTTP specification, and their interpretation by the recipient is unknown. In other cases, gevent could send malformed partial HTTP responses. Now, a :exc:`UnicodeError` will be raised proactively. Most applications that adhered to the WSGI PEP, :pep:`3333`, will not need to make any changes. See :issue:`614` for more discussion. - Under Python 2, the previously undocumented ``timeout`` parameter to :meth:`Popen.wait ` (a gevent extension ) now throws an exception, just like the documented parameter to the same stdlib method in Python 3. - Under Python 3, several standard library methods added ``timeout`` parameters. These often default to -1 to mean "no timeout", whereas gevent uses a default of ``None`` to mean the same thing, potentially leading to great confusion and bugs in portable code. In gevent, using a negative value has always been ill-defined and hard to reason about. Because of those two things, as of this release, negative ``timeout`` values should be considered deprecated (unless otherwise documented). The current ill-defined behaviour is maintained, but future releases may choose to treat it the same as ``None`` or raise an error. No runtime warnings are issued for this change for performance reasons. - The previously undocumented class ``gevent.fileobject.SocketAdapter`` has been removed, as have the internal ``gevent._util`` module and some internal implementation modules found in early pre-releases of 1.1. gevent-1.1.0/examples/0000755000076500000000000000000012666555432015355 5ustar jmaddenwheel00000000000000gevent-1.1.0/examples/concurrent_download.py0000755000076500000000000000135212666555342022004 0ustar jmaddenwheel00000000000000#!/usr/bin/python # Copyright (c) 2009 Denis Bilenko. See LICENSE for details. """Spawn multiple workers and wait for them to complete""" from __future__ import print_function import gevent from gevent import monkey # patches stdlib (including socket and ssl modules) to cooperate with other greenlets monkey.patch_all() import sys urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://www.python.org'] if sys.version_info[0] == 3: from urllib.request import urlopen else: from urllib2 import urlopen def print_head(url): print('Starting %s' % url) data = urlopen(url).read() print('%s: %s bytes: %r' % (url, len(data), data[:50])) jobs = [gevent.spawn(print_head, url) for url in urls] gevent.wait(jobs) gevent-1.1.0/examples/dns_mass_resolve.py0000755000076500000000000000176312666555342021307 0ustar jmaddenwheel00000000000000#!/usr/bin/python """Resolve hostnames concurrently, exit after 2 seconds. Under the hood, this might use an asynchronous resolver based on c-ares (the default) or thread-pool-based resolver. You can choose between resolvers using GEVENT_RESOLVER environment variable. To enable threading resolver: GEVENT_RESOLVER=thread python dns_mass_resolve.py """ from __future__ import print_function import gevent from gevent import socket from gevent.pool import Pool N = 1000 # limit ourselves to max 10 simultaneous outstanding requests pool = Pool(10) finished = 0 def job(url): global finished try: try: ip = socket.gethostbyname(url) print('%s = %s' % (url, ip)) except socket.gaierror as ex: print('%s failed with %s' % (url, ex)) finally: finished += 1 with gevent.Timeout(2, False): for x in range(10, 10 + N): pool.spawn(job, '%s.com' % x) pool.join() print('finished within 2 seconds: %s/%s' % (finished, N)) gevent-1.1.0/examples/echoserver.py0000755000076500000000000000247712666555342020111 0ustar jmaddenwheel00000000000000#!/usr/bin/env python """Simple server that listens on port 16000 and echos back every input to the client. Connect to it with: telnet localhost 16000 Terminate the connection by terminating telnet (typically Ctrl-] and then 'quit'). """ from __future__ import print_function from gevent.server import StreamServer # this handler will be run for each incoming connection in a dedicated greenlet def echo(socket, address): print('New connection from %s:%s' % address) socket.sendall(b'Welcome to the echo server! Type quit to exit.\r\n') # using a makefile because we want to use readline() rfileobj = socket.makefile(mode='rb') while True: line = rfileobj.readline() if not line: print("client disconnected") break if line.strip().lower() == b'quit': print("client quit") break socket.sendall(line) print("echoed %r" % line) rfileobj.close() if __name__ == '__main__': # to make the server use SSL, pass certfile and keyfile arguments to the constructor server = StreamServer(('0.0.0.0', 16000), echo) # to start the server asynchronously, use its start() method; # we use blocking serve_forever() here because we have no other jobs print('Starting echo server on port 16000') server.serve_forever() gevent-1.1.0/examples/geventsendfile.py0000644000076500000000000000145212666555342020733 0ustar jmaddenwheel00000000000000"""An example how to use sendfile[1] with gevent. [1] http://pypi.python.org/pypi/py-sendfile/ """ from errno import EAGAIN from sendfile import sendfile as original_sendfile from gevent.socket import wait_write def gevent_sendfile(out_fd, in_fd, offset, count): total_sent = 0 while total_sent < count: try: _offset, sent = original_sendfile(out_fd, in_fd, offset + total_sent, count - total_sent) #print('%s: sent %s [%d%%]' % (out_fd, sent, 100*total_sent/count)) total_sent += sent except OSError as ex: if ex.args[0] == EAGAIN: wait_write(out_fd) else: raise return offset + total_sent, total_sent def patch_sendfile(): import sendfile sendfile.sendfile = gevent_sendfile gevent-1.1.0/examples/portforwarder.py0000644000076500000000000000626612666555342020641 0ustar jmaddenwheel00000000000000"""Port forwarder with graceful exit. Run the example as python portforwarder.py :8080 gevent.org:80 Then direct your browser to http://localhost:8080 or do "telnet localhost 8080". When the portforwarder receives TERM or INT signal (type Ctrl-C), it closes the listening socket and waits for all existing connections to finish. The existing connections will remain unaffected. The program will exit once the last connection has been closed. """ import socket import sys import signal import gevent from gevent.server import StreamServer from gevent.socket import create_connection, gethostbyname class PortForwarder(StreamServer): def __init__(self, listener, dest, **kwargs): StreamServer.__init__(self, listener, **kwargs) self.dest = dest def handle(self, source, address): log('%s:%s accepted', *address[:2]) try: dest = create_connection(self.dest) except IOError as ex: log('%s:%s failed to connect to %s:%s: %s', address[0], address[1], self.dest[0], self.dest[1], ex) return forwarders = (gevent.spawn(forward, source, dest, self), gevent.spawn(forward, dest, source, self)) # if we return from this method, the stream will be closed out # from under us, so wait for our children gevent.joinall(forwarders) def close(self): if self.closed: sys.exit('Multiple exit signals received - aborting.') else: log('Closing listener socket') StreamServer.close(self) def forward(source, dest, server): source_address = '%s:%s' % source.getpeername()[:2] dest_address = '%s:%s' % dest.getpeername()[:2] try: while True: try: data = source.recv(1024) log('%s->%s: %r', source_address, dest_address, data) if not data: break dest.sendall(data) except KeyboardInterrupt: # On Windows, a Ctrl-C signal (sent by a program) usually winds # up here, not in the installed signal handler. if not server.closed: server.close() break except socket.error: if not server.closed: server.close() break finally: source.close() dest.close() server = None def parse_address(address): try: hostname, port = address.rsplit(':', 1) port = int(port) except ValueError: sys.exit('Expected HOST:PORT: %r' % address) return gethostbyname(hostname), port def main(): args = sys.argv[1:] if len(args) != 2: sys.exit('Usage: %s source-address destination-address' % __file__) source = args[0] dest = parse_address(args[1]) server = PortForwarder(source, dest) log('Starting port forwarder %s:%s -> %s:%s', *(server.address[:2] + dest)) gevent.signal(signal.SIGTERM, server.close) gevent.signal(signal.SIGINT, server.close) server.start() gevent.wait() def log(message, *args): message = message % args sys.stderr.write(message + '\n') if __name__ == '__main__': main() gevent-1.1.0/examples/processes.py0000755000076500000000000000103012666555342017732 0ustar jmaddenwheel00000000000000#!/usr/bin/env python from __future__ import print_function import gevent from gevent import subprocess # run 2 jobs in parallel p1 = subprocess.Popen(['uname'], stdout=subprocess.PIPE) p2 = subprocess.Popen(['ls'], stdout=subprocess.PIPE) gevent.wait([p1, p2], timeout=2) # print the results (if available) if p1.poll() is not None: print('uname: %r' % p1.stdout.read()) else: print('uname: job is still running') if p2.poll() is not None: print('ls: %r' % p2.stdout.read()) else: print('ls: job is still running') gevent-1.1.0/examples/psycopg2_pool.py0000644000076500000000000001115612666555342020532 0ustar jmaddenwheel00000000000000from __future__ import print_function import sys import contextlib import gevent from gevent.queue import Queue from gevent.socket import wait_read, wait_write from psycopg2 import extensions, OperationalError, connect if sys.version_info[0] >= 3: integer_types = int, else: import __builtin__ integer_types = int, __builtin__.long def gevent_wait_callback(conn, timeout=None): """A wait callback useful to allow gevent to work with Psycopg.""" while 1: state = conn.poll() if state == extensions.POLL_OK: break elif state == extensions.POLL_READ: wait_read(conn.fileno(), timeout=timeout) elif state == extensions.POLL_WRITE: wait_write(conn.fileno(), timeout=timeout) else: raise OperationalError( "Bad result from poll: %r" % state) extensions.set_wait_callback(gevent_wait_callback) class DatabaseConnectionPool(object): def __init__(self, maxsize=100): if not isinstance(maxsize, integer_types): raise TypeError('Expected integer, got %r' % (maxsize, )) self.maxsize = maxsize self.pool = Queue() self.size = 0 def get(self): pool = self.pool if self.size >= self.maxsize or pool.qsize(): return pool.get() else: self.size += 1 try: new_item = self.create_connection() except: self.size -= 1 raise return new_item def put(self, item): self.pool.put(item) def closeall(self): while not self.pool.empty(): conn = self.pool.get_nowait() try: conn.close() except Exception: pass @contextlib.contextmanager def connection(self, isolation_level=None): conn = self.get() try: if isolation_level is not None: if conn.isolation_level == isolation_level: isolation_level = None else: conn.set_isolation_level(isolation_level) yield conn except: if conn.closed: conn = None self.closeall() else: conn = self._rollback(conn) raise else: if conn.closed: raise OperationalError("Cannot commit because connection was closed: %r" % (conn, )) conn.commit() finally: if conn is not None and not conn.closed: if isolation_level is not None: conn.set_isolation_level(isolation_level) self.put(conn) @contextlib.contextmanager def cursor(self, *args, **kwargs): isolation_level = kwargs.pop('isolation_level', None) with self.connection(isolation_level) as conn: yield conn.cursor(*args, **kwargs) def _rollback(self, conn): try: conn.rollback() except: gevent.get_hub().handle_error(conn, *sys.exc_info()) return return conn def execute(self, *args, **kwargs): with self.cursor(**kwargs) as cursor: cursor.execute(*args) return cursor.rowcount def fetchone(self, *args, **kwargs): with self.cursor(**kwargs) as cursor: cursor.execute(*args) return cursor.fetchone() def fetchall(self, *args, **kwargs): with self.cursor(**kwargs) as cursor: cursor.execute(*args) return cursor.fetchall() def fetchiter(self, *args, **kwargs): with self.cursor(**kwargs) as cursor: cursor.execute(*args) while True: items = cursor.fetchmany() if not items: break for item in items: yield item class PostgresConnectionPool(DatabaseConnectionPool): def __init__(self, *args, **kwargs): self.connect = kwargs.pop('connect', connect) maxsize = kwargs.pop('maxsize', None) self.args = args self.kwargs = kwargs DatabaseConnectionPool.__init__(self, maxsize) def create_connection(self): return self.connect(*self.args, **self.kwargs) if __name__ == '__main__': import time pool = PostgresConnectionPool("dbname=postgres", maxsize=3) start = time.time() for _ in range(4): gevent.spawn(pool.execute, 'select pg_sleep(1);') gevent.wait() delay = time.time() - start print('Running "select pg_sleep(1);" 4 times with 3 connections. Should take about 2 seconds: %.2fs' % delay) gevent-1.1.0/examples/server.crt0000644000076500000000000000156712666555342017406 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICYzCCAcwCCQD5jx1Aa0dytjANBgkqhkiG9w0BAQQFADB2MQswCQYDVQQGEwJU UzENMAsGA1UECBMEVGVzdDENMAsGA1UEBxMEVGVzdDEWMBQGA1UEChMNVGVzdCBF dmVudGxldDENMAsGA1UECxMEVGVzdDENMAsGA1UEAxMEVGVzdDETMBEGCSqGSIb3 DQEJARYEVGVzdDAeFw0wODA3MDgyMTExNDJaFw0xMDAyMDgwODE1MTBaMHYxCzAJ BgNVBAYTAlRTMQ0wCwYDVQQIEwRUZXN0MQ0wCwYDVQQHEwRUZXN0MRYwFAYDVQQK Ew1UZXN0IEV2ZW50bGV0MQ0wCwYDVQQLEwRUZXN0MQ0wCwYDVQQDEwRUZXN0MRMw EQYJKoZIhvcNAQkBFgRUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDM WcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6OxFVq7XWZMDnDFVnb ZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOGHjxw++Opjf1uoHwP EBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQABMA0GCSqGSIb3DQEB BAUAA4GBAKM71aP0r26gEEEBzovfXm1IwKav6R9/xiWsJ4pFsUXVotcaIjcVBDG1 Z7tz688hokb+GNxsTI2gNfqanqUnfP9wZxnKRmfTSOvb5aWHIiaiMXSgjiPlqBcm 6mnSeEbSMM9cw479wWhh1YqY8tf3gYJa+sxznVWLSfVLpsjRMphe -----END CERTIFICATE----- gevent-1.1.0/examples/server.key0000644000076500000000000000157312666555342017403 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQDMWcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6O xFVq7XWZMDnDFVnbZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOG Hjxw++Opjf1uoHwPEBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQAB AoGBAKWfvq0IIvok7Ncm92ew/0D6/R1+2rT8xwdGQ/Nt31q98WwkqLEjxctlbKPd J2PLIUomf0955BhhFH4JoSwjiHJQ6uishY7srjQQDX/Dxdi5wZAyxYCIVW/kAA9N /u2s75hSD3s/rqAwOZ182DwAPIqJc4KQoYzvlKERSMDT1PJhAkEA5SUFsiSzBEMX FyZ++ZMMs1vHrTu5oTK7WHznh9lk7dvsnp9BoUPqhiu8iJ7Q23zj0u5asz2czu11 nnczXgU6XwJBAORM5Ib4I7nAsoUWn9wDiTwVQeE+D9P1ac9p7EHm7XXuf8o2irRZ wYYfpXXsjk496YfyQFcQRMk0tU0gegCP7hECQFWRWqwoajUoPIInnPjjwbVki48U I4CfqjgkBG3Fb5wnKRgezmpDK1vJD1FRRRsBay4EVhhi5KCdKfPv/V2ZxC8CQQCu U5SxBytofJ8UhxkcTErvaR/8GYLGi//21GAGVop+YdaMlydE3cCrZODYcgCb+CSp nS7KDG8p4KiMMz9VzJGxAkEAv85K6Sa3H8g9h7LwopBZ5tFNZUaFWo7lEP7DDMH0 eckZTb1JVpyT/8zrDtsis4WlV9zVkVHxkIaad503BjqvEQ== -----END RSA PRIVATE KEY----- gevent-1.1.0/examples/threadpool.py0000644000076500000000000000052312666555342020070 0ustar jmaddenwheel00000000000000from __future__ import print_function import time import gevent from gevent.threadpool import ThreadPool pool = ThreadPool(3) start = time.time() for _ in range(4): pool.spawn(time.sleep, 1) gevent.wait() delay = time.time() - start print('Running "time.sleep(1)" 4 times with 3 threads. Should take about 2 seconds: %.3fs' % delay) gevent-1.1.0/examples/udp_client.py0000644000076500000000000000122612666555342020056 0ustar jmaddenwheel00000000000000# Copyright (c) 2012 Denis Bilenko. See LICENSE for details. """Send a datagram to localhost:9000 and receive a datagram back. Usage: python udp_client.py MESSAGE Make sure you're running a UDP server on port 9000 (see udp_server.py). There's nothing gevent-specific here. """ from __future__ import print_function import sys from gevent import socket address = ('localhost', 9000) message = ' '.join(sys.argv[1:]) sock = socket.socket(type=socket.SOCK_DGRAM) sock.connect(address) print('Sending %s bytes to %s:%s' % ((len(message), ) + address)) sock.send(message.encode()) data, address = sock.recvfrom(8192) print('%s:%s: got %r' % (address + (data, ))) gevent-1.1.0/examples/udp_server.py0000644000076500000000000000111312666555342020101 0ustar jmaddenwheel00000000000000# Copyright (c) 2012 Denis Bilenko. See LICENSE for details. """A simple UDP server. For every message received, it sends a reply back. You can use udp_client.py to send a message. """ from __future__ import print_function from gevent.server import DatagramServer class EchoServer(DatagramServer): def handle(self, data, address): print('%s: got %r' % (address[0], data)) self.socket.sendto(('Received %s bytes' % len(data)).encode('utf-8'), address) if __name__ == '__main__': print('Receiving datagrams on :9000') EchoServer(':9000').serve_forever() gevent-1.1.0/examples/unixsocket_client.py0000644000076500000000000000040612666555342021461 0ustar jmaddenwheel00000000000000from __future__ import print_function import socket s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("./unixsocket_server.py.sock") s.send('GET / HTTP/1.0\r\n\r\n') data = s.recv(1024) print('received %s bytes' % len(data)) print(data) s.close() gevent-1.1.0/examples/unixsocket_server.py0000644000076500000000000000074312666555342021515 0ustar jmaddenwheel00000000000000import os from gevent.pywsgi import WSGIServer from gevent import socket def application(environ, start_response): start_response('200 OK', []) return [] if __name__ == '__main__': listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sockname = './' + os.path.basename(__file__) + '.sock' if os.path.exists(sockname): os.remove(sockname) listener.bind(sockname) listener.listen(1) WSGIServer(listener, application).serve_forever() gevent-1.1.0/examples/webchat/0000755000076500000000000000000012666555432016772 5ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/__init__.py0000644000076500000000000000000012666555342021071 0ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/application.py0000755000076500000000000000073312666555342021655 0ustar jmaddenwheel00000000000000#!/usr/bin/python from gevent import monkey; monkey.patch_all() import os import traceback from django.core.handlers.wsgi import WSGIHandler from django.core.signals import got_request_exception from django.core.management import call_command os.environ['DJANGO_SETTINGS_MODULE'] = 'webchat.settings' def exception_printer(sender, **kwargs): traceback.print_exc() got_request_exception.connect(exception_printer) call_command('syncdb') application = WSGIHandler() gevent-1.1.0/examples/webchat/chat/0000755000076500000000000000000012666555432017711 5ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/chat/__init__.py0000644000076500000000000000000012666555342022010 0ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/chat/views.py0000644000076500000000000000433512666555342021425 0ustar jmaddenwheel00000000000000import uuid import simplejson from django.shortcuts import render_to_response from django.template.loader import render_to_string from django.http import HttpResponse from gevent.event import Event from webchat import settings class ChatRoom(object): cache_size = 200 def __init__(self): self.cache = [] self.new_message_event = Event() def main(self, request): if self.cache: request.session['cursor'] = self.cache[-1]['id'] return render_to_response('index.html', {'MEDIA_URL': settings.MEDIA_URL, 'messages': self.cache}) def message_new(self, request): name = request.META.get('REMOTE_ADDR') or 'Anonymous' forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') if forwarded_for and name == '127.0.0.1': name = forwarded_for msg = create_message(name, request.POST['body']) self.cache.append(msg) if len(self.cache) > self.cache_size: self.cache = self.cache[-self.cache_size:] self.new_message_event.set() self.new_message_event.clear() return json_response(msg) def message_updates(self, request): cursor = request.session.get('cursor') if not self.cache or cursor == self.cache[-1]['id']: self.new_message_event.wait() assert cursor != self.cache[-1]['id'], cursor try: for index, m in enumerate(self.cache): if m['id'] == cursor: return json_response({'messages': self.cache[index + 1:]}) return json_response({'messages': self.cache}) finally: if self.cache: request.session['cursor'] = self.cache[-1]['id'] else: request.session.pop('cursor', None) room = ChatRoom() main = room.main message_new = room.message_new message_updates = room.message_updates def create_message(from_, body): data = {'id': str(uuid.uuid4()), 'from': from_, 'body': body} data['html'] = render_to_string('message.html', dictionary={'message': data}) return data def json_response(value, **kwargs): kwargs.setdefault('content_type', 'text/javascript; charset=UTF-8') return HttpResponse(simplejson.dumps(value), **kwargs) gevent-1.1.0/examples/webchat/manage.py0000755000076500000000000000103212666555342020573 0ustar jmaddenwheel00000000000000#!/usr/bin/python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("""Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things. You'll have to run django-admin.py, passing it your settings module. (If the file settings.py does indeed exist, it's causing an ImportError somehow.) """ % __file__) raise if __name__ == "__main__": execute_manager(settings) gevent-1.1.0/examples/webchat/README0000644000076500000000000000020312666555342017645 0ustar jmaddenwheel00000000000000An example of AJAX chat taken from Tornado demos and converted to use django and gevent. To start the server, run $ python run.py gevent-1.1.0/examples/webchat/run_standalone.py0000755000076500000000000000031712666555342022364 0ustar jmaddenwheel00000000000000#!/usr/bin/python from __future__ import print_function from gevent.wsgi import WSGIServer from application import application print('Serving on 8000...') WSGIServer(('', 8000), application).serve_forever() gevent-1.1.0/examples/webchat/run_uwsgi0000755000076500000000000000025512666555342020744 0ustar jmaddenwheel00000000000000#!/bin/sh # see http://projects.unbit.it/uwsgi and http://projects.unbit.it/uwsgi/wiki/Gevent exec uwsgi --loop gevent --http-socket :8000 --module application --async 1000 gevent-1.1.0/examples/webchat/settings.py0000644000076500000000000000176312666555342021213 0ustar jmaddenwheel00000000000000from os.path import dirname, join, abspath __dir__ = dirname(abspath(__file__)) DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = () MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = '/tmp/gevent-webchat.sqlite' DATABASE_USER = '' DATABASE_PASSWORD = '' DATABASE_HOST = '' DATABASE_PORT = '' TIME_ZONE = 'America/Chicago' LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = True MEDIA_ROOT = join(__dir__, 'static') MEDIA_URL = '/media/' SECRET_KEY = 'nv8(yg*&1-lon-8i-3jcs0y!01+rem*54051^5xt#^tzujdj!c' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', ) ROOT_URLCONF = 'webchat.urls' TEMPLATE_DIRS = ( join(__dir__, 'templates') ) INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'webchat.chat', ) gevent-1.1.0/examples/webchat/static/0000755000076500000000000000000012666555432020261 5ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/static/chat.css0000644000076500000000000000200212666555342021704 0ustar jmaddenwheel00000000000000/* * Copyright 2009 FriendFeed * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ body { background: white; margin: 10px; } body, input { font-family: sans-serif; font-size: 10pt; color: black; } table { border-collapse: collapse; border: 0; } td { border: 0; padding: 0; } #body { position: absolute; bottom: 10px; left: 10px; right: 100px; } #input { margin-top: 0.5em; } #inbox .message { padding-top: 0.25em; } #nav { text-align: right; float: right; z-index: 99; } gevent-1.1.0/examples/webchat/static/chat.js0000644000076500000000000000720112666555342021536 0ustar jmaddenwheel00000000000000// Copyright 2009 FriendFeed // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. $(document).ready(function() { if (!window.console) window.console = {}; if (!window.console.log) window.console.log = function() {}; $("#messageform").live("submit", function() { newMessage($(this)); return false; }); $("#messageform").live("keypress", function(e) { if (e.keyCode == 13) { newMessage($(this)); return false; } }); $("#message").select(); updater.poll(); }); function newMessage(form) { var message = form.formToDict(); var disabled = form.find("input[type=submit]"); disabled.disable(); $.postJSON("/a/message/new", message, function(response) { updater.showMessage(response); if (message.id) { form.parent().remove(); } else { form.find("input[type=text]").val("").select(); disabled.enable(); } }); } function getCookie(name) { var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); return r ? r[1] : undefined; } jQuery.postJSON = function(url, args, callback) { args._xsrf = getCookie("_xsrf"); $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST", success: function(response) { if (callback) callback(eval("(" + response + ")")); }, error: function(response) { console.log("ERROR:", response) }}); }; jQuery.fn.formToDict = function() { var fields = this.serializeArray(); var json = {} for (var i = 0; i < fields.length; i++) { json[fields[i].name] = fields[i].value; } if (json.next) delete json.next; return json; }; jQuery.fn.disable = function() { this.enable(false); return this; }; jQuery.fn.enable = function(opt_enable) { if (arguments.length && !opt_enable) { this.attr("disabled", "disabled"); } else { this.removeAttr("disabled"); } return this; }; var updater = { errorSleepTime: 500, cursor: null, poll: function() { var args = {"_xsrf": getCookie("_xsrf")}; if (updater.cursor) args.cursor = updater.cursor; $.ajax({url: "/a/message/updates", type: "POST", dataType: "text", data: $.param(args), success: updater.onSuccess, error: updater.onError}); }, onSuccess: function(response) { try { updater.newMessages(eval("(" + response + ")")); } catch (e) { updater.onError(); return; } updater.errorSleepTime = 500; window.setTimeout(updater.poll, 0); }, onError: function(response) { updater.errorSleepTime *= 2; console.log("Poll error; sleeping for", updater.errorSleepTime, "ms"); window.setTimeout(updater.poll, updater.errorSleepTime); }, newMessages: function(response) { if (!response.messages) return; updater.cursor = response.cursor; var messages = response.messages; updater.cursor = messages[messages.length - 1].id; console.log(messages.length, "new messages, cursor:", updater.cursor); for (var i = 0; i < messages.length; i++) { updater.showMessage(messages[i]); } }, showMessage: function(message) { var existing = $("#m" + message.id); if (existing.length > 0) return; var node = $(message.html); node.hide(); $("#inbox").append(node); node.slideDown(); } }; gevent-1.1.0/examples/webchat/templates/0000755000076500000000000000000012666555432020770 5ustar jmaddenwheel00000000000000gevent-1.1.0/examples/webchat/templates/404.html0000644000076500000000000000002312666555342022160 0ustar jmaddenwheel00000000000000

    Not Found

    gevent-1.1.0/examples/webchat/templates/500.html0000644000076500000000000000003712666555342022162 0ustar jmaddenwheel00000000000000

    Internal Server Error

    gevent-1.1.0/examples/webchat/templates/index.html0000644000076500000000000000247712666555342022777 0ustar jmaddenwheel00000000000000 Chat Demo
    {% for message in messages %} {% include "message.html" %} {% endfor %}
    gevent-1.1.0/examples/webchat/templates/message.html0000644000076500000000000000014012666555342023275 0ustar jmaddenwheel00000000000000
    {{ message.from }}: {{ message.body }}
    gevent-1.1.0/examples/webchat/urls.py0000644000076500000000000000102212666555342020324 0ustar jmaddenwheel00000000000000from django.conf.urls.defaults import * from webchat import settings urlpatterns = patterns('webchat.chat.views', ('^$', 'main'), ('^a/message/new$', 'message_new'), ('^a/message/updates$', 'message_updates')) urlpatterns += patterns('django.views.static', (r'^%s(?P.*)$' % settings.MEDIA_URL.lstrip('/'), 'serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True})) gevent-1.1.0/examples/webproxy.py0000755000076500000000000001130712666555342017613 0ustar jmaddenwheel00000000000000#!/usr/bin/env python """A web application that retrieves other websites for you. To start serving the application on port 8088, type python webproxy.py To start the server on some other interface/port, use python -m gevent.wsgi -p 8000 -i 0.0.0.0 webproxy.py """ from __future__ import print_function from gevent import monkey; monkey.patch_all() import sys import re import traceback from cgi import escape try: import urllib2 from urlparse import urlparse from urllib import unquote except ImportError: from urllib import request as urllib2 from urllib.parse import urlparse from urllib.parse import unquote LISTEN = ":8088" def _as_bytes(s): if not isinstance(s, bytes): # Py3 s = s.encode('utf-8') return s def _as_str(s): if not isinstance(s, str): # Py3 s = s.decode('latin-1') return s def application(env, start_response): proxy_url = 'http://%s/' % env['HTTP_HOST'] method = env['REQUEST_METHOD'] path = env['PATH_INFO'] if env['QUERY_STRING']: path += '?' + env['QUERY_STRING'] path = path.lstrip('/') if (method, path) == ('GET', ''): start_response('200 OK', [('Content-Type', 'text/html')]) return [FORM] elif method == 'GET': return proxy(path, start_response, proxy_url) elif (method, path) == ('POST', ''): key, value = env['wsgi.input'].read().strip().split(b'=') assert key == b'url', repr(key) value = _as_str(value) start_response('302 Found', [('Location', _as_str(join(proxy_url, unquote(value))))]) elif method == 'POST': start_response('404 Not Found', []) else: start_response('501 Not Implemented', []) return [] def proxy(path, start_response, proxy_url): if '://' not in path: path = 'http://' + path try: try: response = urllib2.urlopen(path) except urllib2.HTTPError as ex: response = ex print('%s: %s %s' % (path, response.code, response.msg)) headers = [(k, v) for (k, v) in response.headers.items() if k not in drop_headers] scheme, netloc, path, params, query, fragment = urlparse(path) host = (scheme or 'http') + '://' + netloc except Exception as ex: sys.stderr.write('error while reading %s:\n' % path) traceback.print_exc() tb = traceback.format_exc() start_response('502 Bad Gateway', [('Content-Type', 'text/html')]) error_str = escape(str(ex) or ex.__class__.__name__ or 'Error') error_str = '

    %s

    %s

    %s
    ' % (error_str, escape(path), escape(tb)) return [_as_bytes(error_str)] else: start_response('%s %s' % (response.code, response.msg), headers) data = response.read() data = fix_links(data, proxy_url, host) return [data] def join(url1, *rest): if not rest: return url1 url2, rest = rest[0], rest[1:] url1 = _as_bytes(url1) url2 = _as_bytes(url2) if url1.endswith(b'/'): if url2.startswith(b'/'): return join(url1 + url2[1:], *rest) else: return join(url1 + url2, *rest) elif url2.startswith(b'/'): return join(url1 + url2, *rest) else: return join(url1 + b'/' + url2, *rest) def fix_links(data, proxy_url, host_url): """ >>> fix_links("> %r' % (m.group(0), result)) return result data = _link_re_1.sub(fix_link_cb, data) data = _link_re_2.sub(fix_link_cb, data) return data _link_re_1 = re.compile(br'''(?P(href|src|action)\s*=\s*)(?P['"])(?P[^#].*?)(?P=quote)''') _link_re_2 = re.compile(br'''(?P(href|src|action)\s*=\s*)(?P[^'"#>][^ >]*)''') drop_headers = ['transfer-encoding', 'set-cookie'] FORM = b""" Web Proxy - gevent example
    Type in URL you want to visit and press Enter
    """ if __name__ == '__main__': from gevent.pywsgi import WSGIServer print('Serving on %s...' % LISTEN) WSGIServer(LISTEN, application).serve_forever() gevent-1.1.0/examples/webpy.py0000755000076500000000000000211112666555342017053 0ustar jmaddenwheel00000000000000#!/usr/bin/python """A web.py application powered by gevent""" from __future__ import print_function from gevent import monkey; monkey.patch_all() from gevent.pywsgi import WSGIServer import time import web urls = ("/", "index", '/long', 'long_polling') class index: def GET(self): return 'Hello, world!
    /long' class long_polling: # Since gevent's WSGIServer executes each incoming connection in a separate greenlet # long running requests such as this one don't block one another; # and thanks to "monkey.patch_all()" statement at the top, thread-local storage used by web.ctx # becomes greenlet-local storage thus making requests isolated as they should be. def GET(self): print('GET /long') time.sleep(10) # possible to block the request indefinitely, without harming others return 'Hello, 10 seconds later' if __name__ == "__main__": application = web.application(urls, globals()).wsgifunc() print('Serving on 8088...') WSGIServer(('', 8088), application).serve_forever() gevent-1.1.0/examples/wsgiserver.py0000755000076500000000000000102712666555342020132 0ustar jmaddenwheel00000000000000#!/usr/bin/python """WSGI server example""" from __future__ import print_function from gevent.pywsgi import WSGIServer def application(env, start_response): if env['PATH_INFO'] == '/': start_response('200 OK', [('Content-Type', 'text/html')]) return [b"hello world"] else: start_response('404 Not Found', [('Content-Type', 'text/html')]) return [b'

    Not Found

    '] if __name__ == '__main__': print('Serving on 8088...') WSGIServer(('', 8088), application).serve_forever() gevent-1.1.0/examples/wsgiserver_ssl.py0000755000076500000000000000134012666555342021011 0ustar jmaddenwheel00000000000000#!/usr/bin/python """Secure WSGI server example based on gevent.pywsgi""" from __future__ import print_function from gevent import pywsgi def hello_world(env, start_response): if env['PATH_INFO'] == '/': start_response('200 OK', [('Content-Type', 'text/html')]) return [b"hello world"] else: start_response('404 Not Found', [('Content-Type', 'text/html')]) return [b'

    Not Found

    '] print('Serving on https://127.0.0.1:8443') server = pywsgi.WSGIServer(('0.0.0.0', 8443), hello_world, keyfile='server.key', certfile='server.crt') # to start the server asynchronously, call server.start() # we use blocking serve_forever() here because we have no other jobs server.serve_forever() gevent-1.1.0/gevent/0000755000076500000000000000000012666555432015027 5ustar jmaddenwheel00000000000000gevent-1.1.0/gevent/__init__.py0000644000076500000000000001020112666555342017132 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. """ gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of libev event loop. See http://www.gevent.org/ for the documentation. """ from __future__ import absolute_import from collections import namedtuple _version_info = namedtuple('version_info', ('major', 'minor', 'micro', 'releaselevel', 'serial')) #: The programatic version identifier. The fields have (roughly) the #: same meaning as :data:`sys.version_info` version_info = _version_info(1, 1, 0, 'final', 0) #: The human-readable PEP 440 version identifier __version__ = '1.1.0' __all__ = ['get_hub', 'Greenlet', 'GreenletExit', 'spawn', 'spawn_later', 'spawn_raw', 'iwait', 'wait', 'killall', 'Timeout', 'with_timeout', 'getcurrent', 'sleep', 'idle', 'kill', 'signal', 'fork', 'reinit'] import sys if sys.platform == 'win32': import socket # trigger WSAStartup call del socket from gevent.hub import get_hub, iwait, wait, PYPY from gevent.greenlet import Greenlet, joinall, killall spawn = Greenlet.spawn spawn_later = Greenlet.spawn_later from gevent.timeout import Timeout, with_timeout from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, reinit try: from gevent.os import fork except ImportError: __all__.remove('fork') # See https://github.com/gevent/gevent/issues/648 # A temporary backwards compatibility shim to enable users to continue # to treat 'from gevent import signal' as a callable, to matter whether # the 'gevent.signal' module has been imported first from gevent.hub import signal as _signal_class from gevent import signal as _signal_module # The object 'gevent.signal' must: # - be callable, returning a gevent.hub.signal; # - answer True to isinstance(gevent.signal(...), gevent.signal); # - answer True to isinstance(gevent.signal(...), gevent.hub.signal) # - have all the attributes of the module 'gevent.signal'; # - answer True to isinstance(gevent.signal, types.ModuleType) (optional) # The only way to do this is to use a metaclass, an instance of which (a class) # is put in sys.modules and is substituted for gevent.hub.signal. # This handles everything except the last one. class _signal_metaclass(type): def __getattr__(self, name): return getattr(_signal_module, name) def __setattr__(self, name, value): # Because we can't know whether to try to go to the module # or the class, we don't allow setting an attribute after the fact raise TypeError("Cannot set attribute") def __instancecheck__(self, instance): return isinstance(instance, _signal_class) def __dir__(self): return dir(_signal_module) class signal(object): __doc__ = _signal_module.__doc__ def __new__(self, *args, **kwargs): return _signal_class(*args, **kwargs) # The metaclass is applied after the class declaration # for Python 2/3 compatibility signal = _signal_metaclass(str("signal"), (), dict(signal.__dict__)) sys.modules['gevent.signal'] = signal sys.modules['gevent.hub'].signal = signal del sys # the following makes hidden imports visible to freezing tools like # py2exe. see https://github.com/gevent/gevent/issues/181 def __dependencies_for_freezing(): from gevent import core, resolver_thread, resolver_ares, socket,\ threadpool, thread, threading, select, subprocess import pprint import traceback import signal del __dependencies_for_freezing if PYPY: # We need to make sure that the CFFI compilation is complete if # need be. Without this, we can get ImportError(ImportError: # Cannot import 'core' from ...) from the hub or # DistutilsModuleError (on OS X) depending on who first imports and inits # the hub. See https://github.com/gevent/gevent/issues/619 (There # is no automated test for this.) from gevent.core import loop del loop gevent-1.1.0/gevent/_corecffi_build.py0000644000076500000000000002176412666555342020511 0ustar jmaddenwheel00000000000000# pylint: disable=too-many-lines, protected-access, redefined-outer-name # This module is only used to create and compile the gevent._corecffi module; # nothing should be directly imported from it except `ffi`, which should only be # used for `ffi.compile()`; programs should import gevent._corecfffi. # However, because we are using "out-of-line" mode, it is necessary to examine # this file to know what functions are created and available on the generated # module. from __future__ import absolute_import, print_function import sys import os import struct __all__ = [] def system_bits(): return struct.calcsize('P') * 8 def st_nlink_type(): if sys.platform == "darwin" or sys.platform.startswith("freebsd"): return "short" elif system_bits() == 32: return "unsigned long" return "long long" from cffi import FFI ffi = FFI() _cdef = """ #define EV_MINPRI ... #define EV_MAXPRI ... #define EV_VERSION_MAJOR ... #define EV_VERSION_MINOR ... #define EV_UNDEF ... #define EV_NONE ... #define EV_READ ... #define EV_WRITE ... #define EV__IOFDSET ... #define EV_TIMER ... #define EV_PERIODIC ... #define EV_SIGNAL ... #define EV_CHILD ... #define EV_STAT ... #define EV_IDLE ... #define EV_PREPARE ... #define EV_CHECK ... #define EV_EMBED ... #define EV_FORK ... #define EV_CLEANUP ... #define EV_ASYNC ... #define EV_CUSTOM ... #define EV_ERROR ... #define EVFLAG_AUTO ... #define EVFLAG_NOENV ... #define EVFLAG_FORKCHECK ... #define EVFLAG_NOINOTIFY ... #define EVFLAG_SIGNALFD ... #define EVFLAG_NOSIGMASK ... #define EVBACKEND_SELECT ... #define EVBACKEND_POLL ... #define EVBACKEND_EPOLL ... #define EVBACKEND_KQUEUE ... #define EVBACKEND_DEVPOLL ... #define EVBACKEND_PORT ... /* #define EVBACKEND_IOCP ... */ #define EVBACKEND_ALL ... #define EVBACKEND_MASK ... #define EVRUN_NOWAIT ... #define EVRUN_ONCE ... #define EVBREAK_CANCEL ... #define EVBREAK_ONE ... #define EVBREAK_ALL ... struct ev_loop { int backend_fd; int activecnt; ...; }; // Watcher types // base for all watchers struct ev_watcher{...;}; struct ev_io { int fd; int events; void* data; ...; }; struct ev_timer { double at; void* data; ...; }; struct ev_signal { void* data; ...; }; struct ev_idle { void* data; ...; }; struct ev_prepare { void* data; ...; }; struct ev_check { void* data; ...; }; struct ev_fork { void* data; ...; }; struct ev_async { void* data; ...; }; struct ev_child { int pid; int rpid; int rstatus; void* data; ...; }; struct stat { """ + st_nlink_type() + """ st_nlink; ...; }; struct ev_stat { struct stat attr; const char* path; struct stat prev; double interval; void* data; ...; }; typedef double ev_tstamp; int ev_version_major(); int ev_version_minor(); unsigned int ev_supported_backends (void); unsigned int ev_recommended_backends (void); unsigned int ev_embeddable_backends (void); ev_tstamp ev_time (void); void ev_set_syserr_cb(void *); int ev_priority(void*); void ev_set_priority(void*, int); int ev_is_pending(void*); int ev_is_active(void*); void ev_io_init(struct ev_io*, void* callback, int fd, int events); void ev_io_start(struct ev_loop*, struct ev_io*); void ev_io_stop(struct ev_loop*, struct ev_io*); void ev_feed_event(struct ev_loop*, void*, int); void ev_timer_init(struct ev_timer*, void *callback, double, double); void ev_timer_start(struct ev_loop*, struct ev_timer*); void ev_timer_stop(struct ev_loop*, struct ev_timer*); void ev_timer_again(struct ev_loop*, struct ev_timer*); void ev_signal_init(struct ev_signal*, void* callback, int); void ev_signal_start(struct ev_loop*, struct ev_signal*); void ev_signal_stop(struct ev_loop*, struct ev_signal*); void ev_idle_init(struct ev_idle*, void* callback); void ev_idle_start(struct ev_loop*, struct ev_idle*); void ev_idle_stop(struct ev_loop*, struct ev_idle*); void ev_prepare_init(struct ev_prepare*, void* callback); void ev_prepare_start(struct ev_loop*, struct ev_prepare*); void ev_prepare_stop(struct ev_loop*, struct ev_prepare*); void ev_check_init(struct ev_check*, void* callback); void ev_check_start(struct ev_loop*, struct ev_check*); void ev_check_stop(struct ev_loop*, struct ev_check*); void ev_fork_init(struct ev_fork*, void* callback); void ev_fork_start(struct ev_loop*, struct ev_fork*); void ev_fork_stop(struct ev_loop*, struct ev_fork*); void ev_async_init(struct ev_async*, void* callback); void ev_async_start(struct ev_loop*, struct ev_async*); void ev_async_stop(struct ev_loop*, struct ev_async*); void ev_async_send(struct ev_loop*, struct ev_async*); int ev_async_pending(struct ev_async*); void ev_child_init(struct ev_child*, void* callback, int, int); void ev_child_start(struct ev_loop*, struct ev_child*); void ev_child_stop(struct ev_loop*, struct ev_child*); void ev_stat_init(struct ev_stat*, void* callback, char*, double); void ev_stat_start(struct ev_loop*, struct ev_stat*); void ev_stat_stop(struct ev_loop*, struct ev_stat*); struct ev_loop *ev_default_loop (unsigned int flags); struct ev_loop* ev_loop_new(unsigned int flags); void ev_loop_destroy(struct ev_loop*); void ev_loop_fork(struct ev_loop*); int ev_is_default_loop (struct ev_loop *); unsigned int ev_iteration(struct ev_loop*); unsigned int ev_depth(struct ev_loop*); unsigned int ev_backend(struct ev_loop*); void ev_verify(struct ev_loop*); void ev_run(struct ev_loop*, int flags); ev_tstamp ev_now (struct ev_loop *); void ev_now_update (struct ev_loop *); /* update event loop time */ void ev_ref(struct ev_loop*); void ev_unref(struct ev_loop*); void ev_break(struct ev_loop*, int); unsigned int ev_pending_count(struct ev_loop*); struct ev_loop* gevent_ev_default_loop(unsigned int flags); void gevent_install_sigchld_handler(); void (*gevent_noop)(struct ev_loop *_loop, struct ev_timer *w, int revents); void ev_sleep (ev_tstamp delay); /* sleep for a while */ """ if sys.platform.startswith('win'): # We must have the vfd_open, etc, functions on # Windows. But on other platforms, going through # CFFI to just return the file-descriptor is slower # than just doing it in Python, so we check for and # workaround their absence in corecffi.py _cdef += """ typedef int... vfd_socket_t; int vfd_open(vfd_socket_t); vfd_socket_t vfd_get(int); void vfd_free(int); """ _watcher_types = [ 'ev_async', 'ev_check', 'ev_child', 'ev_fork', 'ev_idle', 'ev_io', 'ev_prepare', 'ev_signal', 'ev_stat', 'ev_timer', ] _source = """ // passed to the real C compiler #define LIBEV_EMBED 1 #ifdef _WIN32 #define EV_STANDALONE 1 #include "libev_vfd.h" #endif #include "libev.h" static void _gevent_noop(struct ev_loop *_loop, struct ev_timer *w, int revents) { } void (*gevent_noop)(struct ev_loop *, struct ev_timer *, int) = &_gevent_noop; """ # Setup the watcher callbacks _cbs = """ static int (*python_callback)(void* handle, int revents); static void (*python_handle_error)(void* handle, int revents); static void (*python_stop)(void* handle); """ _cdef += _cbs _source += _cbs _watcher_type = None # We use a single C callback for every watcher type, which in turn calls the # Python callbacks. The ev_watcher pointer type can be used for every watcher type # because they all start with the same members---libev itself relies on this. Each # watcher types has a 'void* data' that stores the CFFI handle to the Python watcher # object. _cdef += """ static void _gevent_generic_callback(struct ev_loop* loop, struct ev_watcher* watcher, int revents); """ _source += """ static void _gevent_generic_callback(struct ev_loop* loop, struct ev_watcher* watcher, int revents) { void* handle = watcher->data; int cb_result = python_callback(handle, revents); switch(cb_result) { case -1: // in case of exception, call self.loop.handle_error; // this function is also responsible for stopping the watcher // and allowing memory to be freed python_handle_error(handle, revents); break; case 0: // Code to stop the event. Note that if python_callback // has disposed of the last reference to the handle, // `watcher` could now be invalid/disposed memory! if (!ev_is_active(watcher)) { python_stop(handle); } break; default: assert(cb_result == 1); // watcher is already stopped and dead, nothing to do. } } """ thisdir = os.path.dirname(os.path.abspath(__file__)) include_dirs = [ thisdir, # libev_vfd.h os.path.abspath(os.path.join(thisdir, '..', 'libev')), ] ffi.cdef(_cdef) ffi.set_source('gevent._corecffi', _source, include_dirs=include_dirs) if __name__ == '__main__': # XXX: Note, on Windows, we would need to specify the external libraries # that should be linked in, such as ws2_32 and (because libev_vfd.h makes # Python.h calls) the proper Python library---at least for PyPy. I never got # that to work though, and calling python functions is strongly discouraged # from CFFI code. ffi.compile() gevent-1.1.0/gevent/_fileobjectcommon.py0000644000076500000000000000035112666555342021056 0ustar jmaddenwheel00000000000000 try: from errno import EBADF except ImportError: EBADF = 9 cancel_wait_ex = IOError(EBADF, 'File descriptor was closed in another greenlet') FileObjectClosed = IOError(EBADF, 'Bad file descriptor (FileObject was closed)') gevent-1.1.0/gevent/_fileobjectposix.py0000644000076500000000000002424312666555342020736 0ustar jmaddenwheel00000000000000from __future__ import absolute_import import os import io from io import BufferedReader from io import BufferedWriter from io import BytesIO from io import DEFAULT_BUFFER_SIZE from io import RawIOBase from io import TextIOWrapper from io import UnsupportedOperation from gevent._fileobjectcommon import cancel_wait_ex from gevent.hub import get_hub from gevent.os import _read from gevent.os import _write from gevent.os import ignored_errors from gevent.os import make_nonblocking class GreenFileDescriptorIO(RawIOBase): # Note that RawIOBase has a __del__ method that calls # self.close(). (In C implementations like CPython, this is # the type's tp_dealloc slot; prior to Python 3, the object doesn't # appear to have a __del__ method, even though it functionally does) def __init__(self, fileno, mode='r', closefd=True): RawIOBase.__init__(self) self._closed = False self._closefd = closefd self._fileno = fileno make_nonblocking(fileno) self._readable = 'r' in mode self._writable = 'w' in mode self.hub = get_hub() io = self.hub.loop.io if self._readable: self._read_event = io(fileno, 1) else: self._read_event = None if self._writable: self._write_event = io(fileno, 2) else: self._write_event = None self._seekable = None def readable(self): return self._readable def writable(self): return self._writable def seekable(self): if self._seekable is None: try: os.lseek(self._fileno, 0, os.SEEK_CUR) except OSError: self._seekable = False else: self._seekable = True return self._seekable def fileno(self): return self._fileno @property def closed(self): return self._closed def close(self): if self._closed: return self.flush() self._closed = True if self._readable: self.hub.cancel_wait(self._read_event, cancel_wait_ex) if self._writable: self.hub.cancel_wait(self._write_event, cancel_wait_ex) fileno = self._fileno if self._closefd: self._fileno = None os.close(fileno) # RawIOBase provides a 'read' method that will call readall() if # the `size` was missing or -1 and otherwise call readinto(). We # want to take advantage of this to avoid single byte reads when # possible. This is highlighted by a bug in BufferedIOReader that # calls read() in a loop when its readall() method is invoked; # this was fixed in Python 3.3. See # https://github.com/gevent/gevent/issues/675) def __read(self, n): if not self._readable: raise UnsupportedOperation('read') while True: try: return _read(self._fileno, n) except (IOError, OSError) as ex: if ex.args[0] not in ignored_errors: raise self.hub.wait(self._read_event) def readall(self): ret = BytesIO() while True: data = self.__read(DEFAULT_BUFFER_SIZE) if not data: break ret.write(data) return ret.getvalue() def readinto(self, b): data = self.__read(len(b)) n = len(data) try: b[:n] = data except TypeError as err: import array if not isinstance(b, array.array): raise err b[:n] = array.array(b'b', data) return n def write(self, b): if not self._writable: raise UnsupportedOperation('write') while True: try: return _write(self._fileno, b) except (IOError, OSError) as ex: if ex.args[0] not in ignored_errors: raise self.hub.wait(self._write_event) def seek(self, offset, whence=0): return os.lseek(self._fileno, offset, whence) class FileObjectPosix(object): """ A file-like object that operates on non-blocking files but provides a synchronous, cooperative interface. .. caution:: This object is most effective wrapping files that can be used appropriately with :func:`select.select` such as sockets and pipes. In general, on most platforms, operations on regular files (e.g., ``open('/etc/hosts')``) are considered non-blocking already, even though they can take some time to complete as data is copied to the kernel and flushed to disk (this time is relatively bounded compared to sockets or pipes, though). A :func:`~os.read` or :func:`~os.write` call on such a file will still effectively block for some small period of time. Therefore, wrapping this class around a regular file is unlikely to make IO gevent-friendly: reading or writing large amounts of data could still block the event loop. If you'll be working with regular files and doing IO in large chunks, you may consider using :class:`~gevent.fileobject.FileObjectThread` or :func:`~gevent.os.tp_read` and :func:`~gevent.os.tp_write` to bypass this concern. .. note:: Random read/write (e.g., ``mode='rwb'``) is not supported. For that, use :class:`io.BufferedRWPair` around two instance of this class. .. tip:: Although this object provides a :meth:`fileno` method and so can itself be passed to :func:`fcntl.fcntl`, setting the :data:`os.O_NONBLOCK` flag will have no effect; however, removing that flag will cause this object to no longer be cooperative. .. versionchanged:: 1.1 Now uses the :mod:`io` package internally. Under Python 2, previously used the undocumented class :class:`socket._fileobject`. This provides better file-like semantics (and portability to Python 3). """ #: platform specific default for the *bufsize* parameter default_bufsize = io.DEFAULT_BUFFER_SIZE def __init__(self, fobj, mode='rb', bufsize=-1, close=True): """ :keyword fobj: Either an integer fileno, or an object supporting the usual :meth:`socket.fileno` method. The file *will* be put in non-blocking mode using :func:`gevent.os.make_nonblocking`. :keyword str mode: The manner of access to the file, one of "rb", "rU" or "wb" (where the "b" or "U" can be omitted). If "U" is part of the mode, IO will be done on text, otherwise bytes. :keyword int bufsize: If given, the size of the buffer to use. The default value means to use a platform-specific default, and a value of 0 is translated to a value of 1. Other values are interpreted as for the :mod:`io` package. Buffering is ignored in text mode. """ if isinstance(fobj, int): fileno = fobj fobj = None else: fileno = fobj.fileno() if not isinstance(fileno, int): raise TypeError('fileno must be int: %r' % fileno) orig_mode = mode mode = (mode or 'rb').replace('b', '') if 'U' in mode: self._translate = True mode = mode.replace('U', '') else: self._translate = False if len(mode) != 1 and mode not in 'rw': # pragma: no cover # Python 3 builtin `open` raises a ValueError for invalid modes; # Python 2 ignores it. In the past, we raised an AssertionError, if __debug__ was # enabled (which it usually was). Match Python 3 because it makes more sense # and because __debug__ may not be enabled. # NOTE: This is preventing a mode like 'rwb' for binary random access; # that code was never tested and was explicitly marked as "not used" raise ValueError('mode can only be [rb, rU, wb], not %r' % (orig_mode,)) self._fobj = fobj self._closed = False self._close = close self.fileio = GreenFileDescriptorIO(fileno, mode, closefd=close) if bufsize < 0 or bufsize == 1: bufsize = self.default_bufsize elif bufsize == 0: bufsize = 1 if mode == 'r': self.io = BufferedReader(self.fileio, bufsize) else: assert mode == 'w' self.io = BufferedWriter(self.fileio, bufsize) #else: # QQQ: not used, not reachable # # self.io = BufferedRandom(self.fileio, bufsize) if self._translate: self.io = TextIOWrapper(self.io) @property def closed(self): """True if the file is closed""" return self._closed def close(self): if self._closed: # make sure close() is only run once when called concurrently return self._closed = True try: self.io.close() self.fileio.close() finally: self._fobj = None def flush(self): self.io.flush() def fileno(self): return self.io.fileno() def write(self, data): self.io.write(data) def writelines(self, lines): self.io.writelines(lines) def read(self, size=-1): return self.io.read(size) def readline(self, size=-1): return self.io.readline(size) def readlines(self, sizehint=0): return self.io.readlines(sizehint) def readable(self): """ .. versionadded:: 1.1b2 """ return self.io.readable() def writable(self): """ .. versionadded:: 1.1b2 """ return self.io.writable() def seek(self, *args, **kwargs): return self.io.seek(*args, **kwargs) def seekable(self): return self.io.seekable() def tell(self): return self.io.tell() def truncate(self, size=None): return self.io.truncate(size) def __iter__(self): return self.io def __getattr__(self, name): # XXX: Should this really be _fobj, or self.io? # _fobj can easily be None but io never is return getattr(self._fobj, name) gevent-1.1.0/gevent/_semaphore.pxd0000644000076500000000000000136512666555342017673 0ustar jmaddenwheel00000000000000cdef class Semaphore: cdef public int counter cdef readonly object _links cdef readonly object _notifier cdef public int _dirty cdef object __weakref__ cpdef bint locked(self) cpdef int release(self) except -1000 cpdef rawlink(self, object callback) cpdef unlink(self, object callback) cpdef _start_notify(self) cpdef _notify_links(self) cdef _do_wait(self, object timeout) cpdef int wait(self, object timeout=*) except -1000 cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 cpdef __enter__(self) cpdef __exit__(self, object t, object v, object tb) cdef class BoundedSemaphore(Semaphore): cdef readonly int _initial_value cpdef int release(self) except -1000 gevent-1.1.0/gevent/_semaphore.py0000644000076500000000000002421312666555342017525 0ustar jmaddenwheel00000000000000import sys from gevent.hub import get_hub, getcurrent from gevent.timeout import Timeout __all__ = ['Semaphore', 'BoundedSemaphore'] class Semaphore(object): """ Semaphore(value=1) -> Semaphore A semaphore manages a counter representing the number of release() calls minus the number of acquire() calls, plus an initial value. The acquire() method blocks if necessary until it can return without making the counter negative. If not given, ``value`` defaults to 1. The semaphore is a context manager and can be used in ``with`` statements. This Semaphore's ``__exit__`` method does not call the trace function on CPython, but does under PyPy. .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents some classes of bugs. """ def __init__(self, value=1): if value < 0: raise ValueError("semaphore initial value must be >= 0") self.counter = value self._dirty = False # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef # readonly` or simply `cdef` attributes of type `object` can appear to leak if # a Python subclass is used (this is visible simply # instantiating this subclass if _links=[]). Our _links and # _notifier are such attributes, and gevent.thread subclasses # this class. Thus, we carefully manage the lifetime of the # objects we put in these attributes so that, in the normal # case of a semaphore used correctly (deallocated when it's not # locked and no one is waiting), the leak goes away (because # these objects are back to None). This can also be solved on PyPy # by simply not declaring these objects in the pxd file, but that doesn't work for # CPython ("No attribute...") # See https://github.com/gevent/gevent/issues/660 self._links = None self._notifier = None # we don't want to do get_hub() here to allow defining module-level locks # without initializing the hub def __str__(self): params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) return '<%s counter=%s _links[%s]>' % params def locked(self): """Return a boolean indicating whether the semaphore can be acquired. Most useful with binary semaphores.""" return self.counter <= 0 def release(self): """ Release the semaphore, notifying any waiters if needed. """ self.counter += 1 self._start_notify() return self.counter def _start_notify(self): if self._links and self.counter > 0 and not self._notifier: # We create a new self._notifier each time through the loop, # if needed. (it has a __bool__ method that tells whether it has # been run; once it's run once---at the end of the loop---it becomes # false.) # NOTE: Passing the bound method will cause a memory leak on PyPy # with Cython <= 0.23.3. You must use >= 0.23.4. # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546 self._notifier = get_hub().loop.run_callback(self._notify_links) def _notify_links(self): # Subclasses CANNOT override. This is a cdef method. # We release self._notifier here. We are called by it # at the end of the loop, and it is now false in a boolean way (as soon # as this method returns). # If we get acquired/released again, we will create a new one, but there's # no need to keep it around until that point (making it potentially climb # into older GC generations, notably on PyPy) notifier = self._notifier try: while True: self._dirty = False if not self._links: # In case we were manually unlinked before # the callback. Which shouldn't happen return for link in self._links: if self.counter <= 0: return try: link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory except: getcurrent().handle_error((link, self), *sys.exc_info()) if self._dirty: # We mutated self._links so we need to start over break if not self._dirty: return finally: # We should not have created a new notifier even if callbacks # released us because we loop through *all* of our links on the # same callback while self._notifier is still true. assert self._notifier is notifier self._notifier = None def rawlink(self, callback): """ rawlink(callback) -> None Register a callback to call when a counter is more than zero. *callback* will be called in the :class:`Hub `, so it must not use blocking gevent API. *callback* will be passed one argument: this instance. This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code will not need to use it. """ if not callable(callback): raise TypeError('Expected callable:', callback) if self._links is None: self._links = [callback] else: self._links.append(callback) self._dirty = True def unlink(self, callback): """ unlink(callback) -> None Remove the callback set by :meth:`rawlink`. This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code will not need to use it. """ try: self._links.remove(callback) self._dirty = True except (ValueError, AttributeError): pass if not self._links: self._links = None # TODO: Cancel a notifier if there are no links? def _do_wait(self, timeout): """ Wait for up to *timeout* seconds to expire. If timeout elapses, return the exception. Otherwise, return None. Raises timeout if a different timer expires. """ switch = getcurrent().switch self.rawlink(switch) try: timer = Timeout._start_new_or_dummy(timeout) try: try: result = get_hub().switch() assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) except Timeout as ex: if ex is not timer: raise return ex finally: timer.cancel() finally: self.unlink(switch) def wait(self, timeout=None): """ wait(timeout=None) -> int Wait until it is possible to acquire this semaphore, or until the optional *timeout* elapses. .. caution:: If this semaphore was initialized with a size of 0, this method will block forever if no timeout is given. :keyword float timeout: If given, specifies the maximum amount of seconds this method will block. :return: A number indicating how many times the semaphore can be acquired before blocking. """ if self.counter > 0: return self.counter self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout return self.counter def acquire(self, blocking=True, timeout=None): """ acquire(blocking=True, timeout=None) -> bool Acquire the semaphore. .. caution:: If this semaphore was initialized with a size of 0, this method will block forever (unless a timeout is given or blocking is set to false). :keyword bool blocking: If True (the default), this function will block until the semaphore is acquired. :keyword float timeout: If given, specifies the maximum amount of seconds this method will block. :return: A boolean indicating whether the semaphore was acquired. If ``blocking`` is True and ``timeout`` is None (the default), then (so long as this semaphore was initialized with a size greater than 0) this will always return True. If a timeout was given, and it expired before the semaphore was acquired, False will be returned. (Note that this can still raise a ``Timeout`` exception, if some other caller had already started a timer.) """ if self.counter > 0: self.counter -= 1 return True if not blocking: return False timeout = self._do_wait(timeout) if timeout is not None: # Our timer expired. return False # Neither our timer no another one expired, so we blocked until # awoke. Therefore, the counter is ours self.counter -= 1 assert self.counter >= 0 return True _py3k_acquire = acquire # PyPy needs this; it must be static for Cython def __enter__(self): self.acquire() def __exit__(self, t, v, tb): self.release() class BoundedSemaphore(Semaphore): """ BoundedSemaphore(value=1) -> BoundedSemaphore A bounded semaphore checks to make sure its current value doesn't exceed its initial value. If it does, :class:`ValueError` is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is released too many times it's a sign of a bug. If not given, *value* defaults to 1. """ #: For monkey-patching, allow changing the class of error we raise _OVER_RELEASE_ERROR = ValueError def __init__(self, *args, **kwargs): Semaphore.__init__(self, *args, **kwargs) self._initial_value = self.counter def release(self): if self.counter >= self._initial_value: raise self._OVER_RELEASE_ERROR("Semaphore released too many times") return Semaphore.release(self) gevent-1.1.0/gevent/_socket2.py0000644000076500000000000004472012666555342017121 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. """ Python 2 socket module. """ import time from gevent import _socketcommon from gevent.hub import PYPY for key in _socketcommon.__dict__: if key.startswith('__') or key in _socketcommon.__py3_imports__ or key in _socketcommon.__extensions__: continue globals()[key] = getattr(_socketcommon, key) __socket__ = _socketcommon.__socket__ __implements__ = _socketcommon._implements __extensions__ = _socketcommon.__extensions__ __imports__ = [i for i in _socketcommon.__imports__ if i not in _socketcommon.__py3_imports__] __dns__ = _socketcommon.__dns__ try: _fileobject = __socket__._fileobject _socketmethods = __socket__._socketmethods except AttributeError: # Allow this module to be imported under Python 3 # for building the docs _fileobject = object _socketmethods = ('bind', 'connect', 'connect_ex', 'fileno', 'listen', 'getpeername', 'getsockname', 'getsockopt', 'setsockopt', 'sendall', 'setblocking', 'settimeout', 'gettimeout', 'shutdown') else: # Python 2 doesn't natively support with statements on _fileobject; # but it eases our test cases if we can do the same with on both Py3 # and Py2. Implementation copied from Python 3 if not hasattr(_fileobject, '__enter__'): # we could either patch in place: #_fileobject.__enter__ = lambda self: self #_fileobject.__exit__ = lambda self, *args: self.close() if not self.closed else None # or we could subclass. subclassing has the benefit of not # changing the behaviour of the stdlib if we're just imported; OTOH, # under Python 2.6/2.7, test_urllib2net.py asserts that the class IS # socket._fileobject (sigh), so we have to work around that. class _fileobject(_fileobject): def __enter__(self): return self def __exit__(self, *args): if not self.closed: self.close() if sys.version_info[:2] < (2, 7): _get_memory = buffer else: def _get_memory(data): try: mv = memoryview(data) if mv.shape: return mv # No shape, probably working with a ctypes object, # or something else exotic that supports the buffer interface return mv.tobytes() except TypeError: # fixes "python2.7 array.array doesn't support memoryview used in # gevent.socket.send" issue # (http://code.google.com/p/gevent/issues/detail?id=94) return buffer(data) class _closedsocket(object): __slots__ = [] def _dummy(*args, **kwargs): raise error(EBADF, 'Bad file descriptor') # All _delegate_methods must also be initialized here. send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy if PYPY: def _drop(self): pass def _reuse(self): pass __getattr__ = _dummy timeout_default = object() class socket(object): """ gevent `socket.socket `_ for Python 2. This object should have the same API as the standard library socket linked to above. Not all methods are specifically documented here; when they are they may point out a difference to be aware of or may document a method the standard library does not. """ def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() if PYPY: self._sock._reuse() self._sock.setblocking(0) fileno = self._sock.fileno() self.hub = get_hub() io = self.hub.loop.io self._read_event = io(fileno, 1) self._write_event = io(fileno, 2) def __repr__(self): return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo()) def __str__(self): return '<%s %s>' % (type(self).__name__, self._formatinfo()) def _formatinfo(self): try: fileno = self.fileno() except Exception as ex: fileno = str(ex) try: sockname = self.getsockname() sockname = '%s:%s' % sockname except Exception: sockname = None try: peername = self.getpeername() peername = '%s:%s' % peername except Exception: peername = None result = 'fileno=%s' % fileno if sockname is not None: result += ' sock=' + str(sockname) if peername is not None: result += ' peer=' + str(peername) if getattr(self, 'timeout', None) is not None: result += ' timeout=' + str(self.timeout) return result def _get_ref(self): return self._read_event.ref or self._write_event.ref def _set_ref(self, value): self._read_event.ref = value self._write_event.ref = value ref = property(_get_ref, _set_ref) def _wait(self, watcher, timeout_exc=timeout('timed out')): """Block the current greenlet until *watcher* has pending events. If *timeout* is non-negative, then *timeout_exc* is raised after *timeout* second has passed. By default *timeout_exc* is ``socket.timeout('timed out')``. If :func:`cancel_wait` is called, raise ``socket.error(EBADF, 'File descriptor was closed in another greenlet')``. """ if watcher.callback is not None: raise _socketcommon.ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (watcher.callback, )) if self.timeout is not None: timeout = Timeout.start_new(self.timeout, timeout_exc, ref=False) else: timeout = None try: self.hub.wait(watcher) finally: if timeout is not None: timeout.cancel() def accept(self): sock = self._sock while True: try: client_socket, address = sock.accept() break except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) sockobj = socket(_sock=client_socket) if PYPY: client_socket._drop() return sockobj, address def close(self, _closedsocket=_closedsocket, cancel_wait_ex=cancel_wait_ex): # This function should not reference any globals. See Python issue #808164. self.hub.cancel_wait(self._read_event, cancel_wait_ex) self.hub.cancel_wait(self._write_event, cancel_wait_ex) s = self._sock self._sock = _closedsocket() if PYPY: s._drop() @property def closed(self): return isinstance(self._sock, _closedsocket) def connect(self, address): if self.timeout == 0.0: return self._sock.connect(address) sock = self._sock if isinstance(address, tuple): r = getaddrinfo(address[0], address[1], sock.family, sock.type, sock.proto) address = r[0][-1] if self.timeout is not None: timer = Timeout.start_new(self.timeout, timeout('timed out')) else: timer = None try: while True: err = sock.getsockopt(SOL_SOCKET, SO_ERROR) if err: raise error(err, strerror(err)) result = sock.connect_ex(address) if not result or result == EISCONN: break elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows): self._wait(self._write_event) else: raise error(result, strerror(result)) finally: if timer is not None: timer.cancel() def connect_ex(self, address): try: return self.connect(address) or 0 except timeout: return EAGAIN except error as ex: if type(ex) is error: return ex.args[0] else: raise # gaierror is not silented by connect_ex def dup(self): """dup() -> socket object Return a new socket object connected to the same system resource. Note, that the new socket does not inherit the timeout.""" return socket(_sock=self._sock) def makefile(self, mode='r', bufsize=-1): # Two things to look out for: # 1) Closing the original socket object should not close the # socket (hence creating a new instance) # 2) The resulting fileobject must keep the timeout in order # to be compatible with the stdlib's socket.makefile. # Pass self as _sock to preserve timeout. fobj = _fileobject(type(self)(_sock=self), mode, bufsize) if PYPY: self._sock._drop() return fobj def recv(self, *args): sock = self._sock # keeping the reference so that fd is not closed during waiting while True: try: return sock.recv(*args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise # QQQ without clearing exc_info test__refcount.test_clean_exit fails sys.exc_clear() self._wait(self._read_event) def recvfrom(self, *args): sock = self._sock while True: try: return sock.recvfrom(*args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) def recvfrom_into(self, *args): sock = self._sock while True: try: return sock.recvfrom_into(*args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) def recv_into(self, *args): sock = self._sock while True: try: return sock.recv_into(*args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) def send(self, data, flags=0, timeout=timeout_default): sock = self._sock if timeout is timeout_default: timeout = self.timeout try: return sock.send(data, flags) except error as ex: if ex.args[0] != EWOULDBLOCK or timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event) try: return sock.send(data, flags) except error as ex2: if ex2.args[0] == EWOULDBLOCK: return 0 raise def __send_chunk(self, data_memory, flags, timeleft, end): """ Send the complete contents of ``data_memory`` before returning. This is the core loop around :meth:`send`. :param timeleft: Either ``None`` if there is no timeout involved, or a float indicating the timeout to use. :param end: Either ``None`` if there is no timeout involved, or a float giving the absolute end time. :return: An updated value for ``timeleft`` (or None) :raises timeout: If ``timeleft`` was given and elapsed while sending this chunk. """ data_sent = 0 len_data_memory = len(data_memory) while data_sent < len_data_memory: chunk = data_memory[data_sent:] if timeleft is None: data_sent += self.send(chunk, flags) elif timeleft <= 0: # Check before sending to guarantee a check # happens even if each chunk successfully sends its data # (especially important for SSL sockets since they have large # buffers) raise timeout('timed out') else: data_sent += self.send(chunk, flags, timeout=timeleft) timeleft = end - time.time() return timeleft def sendall(self, data, flags=0): if isinstance(data, unicode): data = data.encode() # this sendall is also reused by gevent.ssl.SSLSocket subclass, # so it should not call self._sock methods directly data_memory = _get_memory(data) len_data_memory = len(data_memory) if not len_data_memory: # Don't send empty data, can cause SSL EOFError. # See issue 719 return 0 # On PyPy up through 2.6.0, subviews of a memoryview() object # copy the underlying bytes the first time the builtin # socket.send() method is called. On a non-blocking socket # (that thus calls socket.send() many times) with a large # input, this results in many repeated copies of an ever # smaller string, depending on the networking buffering. For # example, if each send() can process 1MB of a 50MB input, and # we naively pass the entire remaining subview each time, we'd # copy 49MB, 48MB, 47MB, etc, thus completely killing # performance. To workaround this problem, we work in # reasonable, fixed-size chunks. This results in a 10x # improvement to bench_sendall.py, while having no measurable impact on # CPython (since it doesn't copy at all the only extra overhead is # a few python function calls, which is negligible for large inputs). # See https://bitbucket.org/pypy/pypy/issues/2091/non-blocking-socketsend-slow-gevent # Too small of a chunk (the socket's buf size is usually too # small) results in reduced perf due to *too many* calls to send and too many # small copies. With a buffer of 143K (the default on my system), for # example, bench_sendall.py yields ~264MB/s, while using 1MB yields # ~653MB/s (matching CPython). 1MB is arbitrary and might be better # chosen, say, to match a page size? chunk_size = max(self.getsockopt(SOL_SOCKET, SO_SNDBUF), 1024 * 1024) data_sent = 0 end = None timeleft = None if self.timeout is not None: timeleft = self.timeout end = time.time() + timeleft while data_sent < len_data_memory: chunk_end = min(data_sent + chunk_size, len_data_memory) chunk = data_memory[data_sent:chunk_end] timeleft = self.__send_chunk(chunk, flags, timeleft, end) data_sent += len(chunk) # Guaranteed it sent the whole thing def sendto(self, *args): sock = self._sock try: return sock.sendto(*args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event) try: return sock.sendto(*args) except error as ex2: if ex2.args[0] == EWOULDBLOCK: return 0 raise def setblocking(self, flag): if flag: self.timeout = None else: self.timeout = 0.0 def settimeout(self, howlong): if howlong is not None: try: f = howlong.__float__ except AttributeError: raise TypeError('a float is required') howlong = f() if howlong < 0.0: raise ValueError('Timeout value out of range') self.__dict__['timeout'] = howlong # avoid recursion with any property on self.timeout def gettimeout(self): return self.__dict__['timeout'] # avoid recursion with any property on self.timeout def shutdown(self, how): if how == 0: # SHUT_RD self.hub.cancel_wait(self._read_event, cancel_wait_ex) elif how == 1: # SHUT_WR self.hub.cancel_wait(self._write_event, cancel_wait_ex) else: self.hub.cancel_wait(self._read_event, cancel_wait_ex) self.hub.cancel_wait(self._write_event, cancel_wait_ex) self._sock.shutdown(how) family = property(lambda self: self._sock.family) type = property(lambda self: self._sock.type) proto = property(lambda self: self._sock.proto) # delegate the functions that we haven't implemented to the real socket object _s = "def %s(self, *args): return self._sock.%s(*args)\n\n" for _m in set(_socketmethods) - set(locals()): exec(_s % (_m, _m,)) del _m, _s if PYPY: def _reuse(self): self._sock._reuse() def _drop(self): self._sock._drop() SocketType = socket if hasattr(_socket, 'socketpair'): def socketpair(*args): one, two = _socket.socketpair(*args) result = socket(_sock=one), socket(_sock=two) if PYPY: one._drop() two._drop() return result elif 'socketpair' in __implements__: __implements__.remove('socketpair') if hasattr(_socket, 'fromfd'): def fromfd(*args): s = _socket.fromfd(*args) result = socket(_sock=s) if PYPY: s._drop() return result elif 'fromfd' in __implements__: __implements__.remove('fromfd') if hasattr(__socket__, 'ssl'): def ssl(sock, keyfile=None, certfile=None): # deprecated in 2.7.9 but still present; # sometimes backported by distros. See ssl.py from gevent import ssl as _sslmod # wrap_socket is 2.7.9/backport, sslwrap_simple is older. They take # the same arguments. wrap = getattr(_sslmod, 'wrap_socket', None) or getattr(_sslmod, 'sslwrap_simple') return wrap(sock, keyfile, certfile) __implements__.append('ssl') __all__ = __implements__ + __extensions__ + __imports__ gevent-1.1.0/gevent/_socket3.py0000644000076500000000000010262412666555342017120 0ustar jmaddenwheel00000000000000# Port of Python 3.3's socket module to gevent """ Python 3 socket module. """ import io import os import sys import time from gevent import _socketcommon import _socket from os import dup for key in _socketcommon.__dict__: if key.startswith('__') or key in _socketcommon.__extensions__: continue globals()[key] = getattr(_socketcommon, key) __socket__ = _socketcommon.__socket__ __implements__ = _socketcommon._implements __extensions__ = _socketcommon.__extensions__ __imports__ = _socketcommon.__imports__ __dns__ = _socketcommon.__dns__ SocketIO = __socket__.SocketIO def _get_memory(data): mv = memoryview(data) if mv.shape: return mv # No shape, probably working with a ctypes object, # or something else exotic that supports the buffer interface return mv.tobytes() timeout_default = object() class _wrefsocket(_socket.socket): # Plain stdlib socket.socket objects subclass _socket.socket # and add weakref ability. The ssl module, for one, counts on this. # We don't create socket.socket objects (because they may have been # monkey patched to be the object from this module), but we still # need to make sure what we do create can be weakrefd. __slots__ = ("__weakref__", ) _closedsocket = _wrefsocket() _closedsocket.close() class socket(object): """ gevent `socket.socket `_ for Python 3. This object should have the same API as the standard library socket linked to above. Not all methods are specifically documented here; when they are they may point out a difference to be aware of or may document a method the standard library does not. """ # Subclasses can set this to customize the type of the # native _socket.socket we create. It MUST be a subclass # of _wrefsocket. (gevent internal usage only) _gevent_sock_class = _wrefsocket def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): # Take the same approach as socket2: wrap a real socket object, # don't subclass it. This lets code that needs the raw _sock (not tied to the hub) # get it. This shows up in tests like test__example_udp_server. self._sock = self._gevent_sock_class(family, type, proto, fileno) self._io_refs = 0 self._closed = False _socket.socket.setblocking(self._sock, False) fileno = _socket.socket.fileno(self._sock) self.hub = get_hub() io_class = self.hub.loop.io self._read_event = io_class(fileno, 1) self._write_event = io_class(fileno, 2) self.timeout = _socket.getdefaulttimeout() def __getattr__(self, name): return getattr(self._sock, name) if hasattr(_socket, 'SOCK_NONBLOCK'): # Only defined under Linux @property def type(self): # See https://github.com/gevent/gevent/pull/399 if self.timeout != 0.0: return self._sock.type & ~_socket.SOCK_NONBLOCK else: return self._sock.type def __enter__(self): return self def __exit__(self, *args): if not self._closed: self.close() def __repr__(self): """Wrap __repr__() to reveal the real class name.""" try: s = _socket.socket.__repr__(self._sock) except Exception as ex: # Observed on Windows Py3.3, printing the repr of a socket # that just sufferred a ConnectionResetError [WinError 10054]: # "OverflowError: no printf formatter to display the socket descriptor in decimal" # Not sure what the actual cause is or if there's a better way to handle this s = '' % ex if s.startswith(" socket object Return a new socket object connected to the same system resource. """ fd = dup(self.fileno()) sock = self.__class__(self.family, self.type, self.proto, fileno=fd) sock.settimeout(self.gettimeout()) return sock def accept(self): """accept() -> (socket object, address info) Wait for an incoming connection. Return a new socket representing the connection, and the address of the client. For IP sockets, the address info is a pair (hostaddr, port). """ while True: try: fd, addr = self._accept() break except BlockingIOError: if self.timeout == 0.0: raise self._wait(self._read_event) sock = socket(self.family, self.type, self.proto, fileno=fd) # Python Issue #7995: if no default timeout is set and the listening # socket had a (non-zero) timeout, force the new socket in blocking # mode to override platform-specific socket flags inheritance. # XXX do we need to do this? if getdefaulttimeout() is None and self.gettimeout(): sock.setblocking(True) return sock, addr def makefile(self, mode="r", buffering=None, *, encoding=None, errors=None, newline=None): """Return an I/O stream connected to the socket The arguments are as for io.open() after the filename, except the only mode characters supported are 'r', 'w' and 'b'. The semantics are similar too. """ # (XXX refactor to share code?) for c in mode: if c not in {"r", "w", "b"}: raise ValueError("invalid mode %r (only r, w, b allowed)") writing = "w" in mode reading = "r" in mode or not writing assert reading or writing binary = "b" in mode rawmode = "" if reading: rawmode += "r" if writing: rawmode += "w" raw = SocketIO(self, rawmode) self._io_refs += 1 if buffering is None: buffering = -1 if buffering < 0: buffering = io.DEFAULT_BUFFER_SIZE if buffering == 0: if not binary: raise ValueError("unbuffered streams must be binary") return raw if reading and writing: buffer = io.BufferedRWPair(raw, raw, buffering) elif reading: buffer = io.BufferedReader(raw, buffering) else: assert writing buffer = io.BufferedWriter(raw, buffering) if binary: return buffer text = io.TextIOWrapper(buffer, encoding, errors, newline) text.mode = mode return text def _decref_socketios(self): if self._io_refs > 0: self._io_refs -= 1 if self._closed: self.close() def _real_close(self, _ss=_socket.socket, cancel_wait_ex=cancel_wait_ex): # This function should not reference any globals. See Python issue #808164. self.hub.cancel_wait(self._read_event, cancel_wait_ex) self.hub.cancel_wait(self._write_event, cancel_wait_ex) _ss.close(self._sock) self._sock = _closedsocket def close(self): # This function should not reference any globals. See Python issue #808164. self._closed = True if self._io_refs <= 0: self._real_close() @property def closed(self): return self._closed def detach(self): """detach() -> file descriptor Close the socket object without closing the underlying file descriptor. The object cannot be used after this call, but the file descriptor can be reused for other purposes. The file descriptor is returned. """ self._closed = True return self._sock.detach() def connect(self, address): if self.timeout == 0.0: return _socket.socket.connect(self._sock, address) if isinstance(address, tuple): r = getaddrinfo(address[0], address[1], self.family) address = r[0][-1] if self.timeout is not None: timer = Timeout.start_new(self.timeout, timeout('timed out')) else: timer = None try: while True: err = self.getsockopt(SOL_SOCKET, SO_ERROR) if err: raise error(err, strerror(err)) result = _socket.socket.connect_ex(self._sock, address) if not result or result == EISCONN: break elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows): self._wait(self._write_event) else: raise error(result, strerror(result)) finally: if timer is not None: timer.cancel() def connect_ex(self, address): try: return self.connect(address) or 0 except timeout: return EAGAIN except error as ex: if type(ex) is error: return ex.args[0] else: raise # gaierror is not silented by connect_ex def recv(self, *args): while True: try: return _socket.socket.recv(self._sock, *args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise self._wait(self._read_event) def recvfrom(self, *args): while True: try: return _socket.socket.recvfrom(self._sock, *args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise self._wait(self._read_event) def recvfrom_into(self, *args): while True: try: return _socket.socket.recvfrom_into(self._sock, *args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise self._wait(self._read_event) def recv_into(self, *args): while True: try: return _socket.socket.recv_into(self._sock, *args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise self._wait(self._read_event) def send(self, data, flags=0, timeout=timeout_default): if timeout is timeout_default: timeout = self.timeout try: return _socket.socket.send(self._sock, data, flags) except error as ex: if ex.args[0] != EWOULDBLOCK or timeout == 0.0: raise self._wait(self._write_event) try: return _socket.socket.send(self._sock, data, flags) except error as ex2: if ex2.args[0] == EWOULDBLOCK: return 0 raise def sendall(self, data, flags=0): # XXX When we run on PyPy3, see the notes in _socket2.py's sendall() data_memory = _get_memory(data) len_data_memory = len(data_memory) if not len_data_memory: # Don't try to send empty data at all, no point, and breaks ssl # See issue 719 return 0 if self.timeout is None: data_sent = 0 while data_sent < len_data_memory: data_sent += self.send(data_memory[data_sent:], flags) else: timeleft = self.timeout end = time.time() + timeleft data_sent = 0 while True: data_sent += self.send(data_memory[data_sent:], flags, timeout=timeleft) if data_sent >= len_data_memory: break timeleft = end - time.time() if timeleft <= 0: raise timeout('timed out') def sendto(self, *args): try: return _socket.socket.sendto(self._sock, *args) except error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise self._wait(self._write_event) try: return _socket.socket.sendto(self._sock, *args) except error as ex2: if ex2.args[0] == EWOULDBLOCK: return 0 raise def setblocking(self, flag): if flag: self.timeout = None else: self.timeout = 0.0 def settimeout(self, howlong): if howlong is not None: try: f = howlong.__float__ except AttributeError: raise TypeError('a float is required') howlong = f() if howlong < 0.0: raise ValueError('Timeout value out of range') self.timeout = howlong def gettimeout(self): return self.timeout def shutdown(self, how): if how == 0: # SHUT_RD self.hub.cancel_wait(self._read_event, cancel_wait_ex) elif how == 1: # SHUT_WR self.hub.cancel_wait(self._write_event, cancel_wait_ex) else: self.hub.cancel_wait(self._read_event, cancel_wait_ex) self.hub.cancel_wait(self._write_event, cancel_wait_ex) self._sock.shutdown(how) # sendfile: new in 3.5. But there's no real reason to not # support it everywhere. Note that we can't use os.sendfile() # because it's not cooperative. def _sendfile_use_sendfile(self, file, offset=0, count=None): # This is called directly by tests raise __socket__._GiveupOnSendfile() def _sendfile_use_send(self, file, offset=0, count=None): self._check_sendfile_params(file, offset, count) if self.gettimeout() == 0: raise ValueError("non-blocking sockets are not supported") if offset: file.seek(offset) blocksize = min(count, 8192) if count else 8192 total_sent = 0 # localize variable access to minimize overhead file_read = file.read sock_send = self.send try: while True: if count: blocksize = min(count - total_sent, blocksize) if blocksize <= 0: break data = memoryview(file_read(blocksize)) if not data: break # EOF while True: try: sent = sock_send(data) except BlockingIOError: continue else: total_sent += sent if sent < len(data): data = data[sent:] else: break return total_sent finally: if total_sent > 0 and hasattr(file, 'seek'): file.seek(offset + total_sent) def _check_sendfile_params(self, file, offset, count): if 'b' not in getattr(file, 'mode', 'b'): raise ValueError("file should be opened in binary mode") if not self.type & SOCK_STREAM: raise ValueError("only SOCK_STREAM type sockets are supported") if count is not None: if not isinstance(count, int): raise TypeError( "count must be a positive integer (got {!r})".format(count)) if count <= 0: raise ValueError( "count must be a positive integer (got {!r})".format(count)) def sendfile(self, file, offset=0, count=None): """sendfile(file[, offset[, count]]) -> sent Send a file until EOF is reached by using high-performance os.sendfile() and return the total number of bytes which were sent. *file* must be a regular file object opened in binary mode. If os.sendfile() is not available (e.g. Windows) or file is not a regular file socket.send() will be used instead. *offset* tells from where to start reading the file. If specified, *count* is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is updated on return or also in case of error in which case file.tell() can be used to figure out the number of bytes which were sent. The socket must be of SOCK_STREAM type. Non-blocking sockets are not supported. .. versionadded:: 1.1rc4 Added in Python 3.5, but available under all Python 3 versions in gevent. """ return self._sendfile_use_send(file, offset, count) # get/set_inheritable new in 3.4 if hasattr(os, 'get_inheritable') or hasattr(os, 'get_handle_inheritable'): if os.name == 'nt': def get_inheritable(self): return os.get_handle_inheritable(self.fileno()) def set_inheritable(self, inheritable): os.set_handle_inheritable(self.fileno(), inheritable) else: def get_inheritable(self): return os.get_inheritable(self.fileno()) def set_inheritable(self, inheritable): os.set_inheritable(self.fileno(), inheritable) _added = "\n\n.. versionadded:: 1.1rc4 Added in Python 3.4" get_inheritable.__doc__ = "Get the inheritable flag of the socket" + _added set_inheritable.__doc__ = "Set the inheritable flag of the socket" + _added del _added if sys.version_info[:2] == (3, 4) and sys.version_info[:3] <= (3, 4, 2): # Python 3.4, up to and including 3.4.2, had a bug where the # SocketType enumeration overwrote the SocketType class imported # from _socket. This was fixed in 3.4.3 (http://bugs.python.org/issue20386 # and https://github.com/python/cpython/commit/0d2f85f38a9691efdfd1e7285c4262cab7f17db7). # Prior to that, if we replace SocketType with our own class, the implementation # of socket.type breaks with "OSError: [Errno 97] Address family not supported by protocol". # Therefore, on these old versions, we must preserve it as an enum; while this # seems like it could lead to non-green behaviour, code on those versions # cannot possibly be using SocketType as a class anyway. SocketType = __socket__.SocketType # Fixup __all__; note that we get exec'd multiple times during unit tests if 'SocketType' in __implements__: __implements__.remove('SocketType') if 'SocketType' not in __imports__: __imports__.append('SocketType') else: SocketType = socket def fromfd(fd, family, type, proto=0): """ fromfd(fd, family, type[, proto]) -> socket object Create a socket object from a duplicate of the given file descriptor. The remaining arguments are the same as for socket(). """ nfd = dup(fd) return socket(family, type, proto, nfd) if hasattr(_socket.socket, "share"): def fromshare(info): """ fromshare(info) -> socket object Create a socket object from a the bytes object returned by socket.share(pid). """ return socket(0, 0, 0, info) __implements__.append('fromshare') if hasattr(_socket, "socketpair"): def socketpair(family=None, type=SOCK_STREAM, proto=0): """socketpair([family[, type[, proto]]]) -> (socket object, socket object) Create a pair of socket objects from the sockets returned by the platform socketpair() function. The arguments are the same as for socket() except the default family is AF_UNIX if defined on the platform; otherwise, the default is AF_INET. """ if family is None: try: family = AF_UNIX except NameError: family = AF_INET a, b = _socket.socketpair(family, type, proto) a = socket(family, type, proto, a.detach()) b = socket(family, type, proto, b.detach()) return a, b elif 'socketpair' in __implements__: # Win32: not available # Multiple imports can cause this to be missing if _socketcommon # was successfully imported, leading to subsequent imports to cause # ValueError __implements__.remove('socketpair') # PyPy needs drop and reuse def _do_reuse_or_drop(socket, methname): try: method = getattr(socket, methname) except (AttributeError, TypeError): pass else: method() from io import BytesIO class _basefileobject(object): """Faux file object attached to a socket object.""" default_bufsize = 8192 name = "" __slots__ = ["mode", "bufsize", "softspace", # "closed" is a property, see below "_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf", "_wbuf_len", "_close"] def __init__(self, sock, mode='rb', bufsize=-1, close=False): _do_reuse_or_drop(sock, '_reuse') self._sock = sock self.mode = mode # Not actually used in this version if bufsize < 0: bufsize = self.default_bufsize self.bufsize = bufsize self.softspace = False # _rbufsize is the suggested recv buffer size. It is *strictly* # obeyed within readline() for recv calls. If it is larger than # default_bufsize it will be used for recv calls within read(). if bufsize == 0: self._rbufsize = 1 elif bufsize == 1: self._rbufsize = self.default_bufsize else: self._rbufsize = bufsize self._wbufsize = bufsize # We use BytesIO for the read buffer to avoid holding a list # of variously sized string objects which have been known to # fragment the heap due to how they are malloc()ed and often # realloc()ed down much smaller than their original allocation. self._rbuf = BytesIO() self._wbuf = [] # A list of strings self._wbuf_len = 0 self._close = close def _getclosed(self): return self._sock is None closed = property(_getclosed, doc="True if the file is closed") def close(self): try: if self._sock: self.flush() finally: s = self._sock self._sock = None if s is not None: if self._close: s.close() else: _do_reuse_or_drop(s, '_drop') def __del__(self): try: self.close() except: # close() may fail if __init__ didn't complete pass def flush(self): if self._wbuf: data = b"".join(self._wbuf) self._wbuf = [] self._wbuf_len = 0 buffer_size = max(self._rbufsize, self.default_bufsize) data_size = len(data) write_offset = 0 view = memoryview(data) try: while write_offset < data_size: self._sock.sendall(view[write_offset:write_offset + buffer_size]) write_offset += buffer_size finally: if write_offset < data_size: remainder = data[write_offset:] del view, data # explicit free self._wbuf.append(remainder) self._wbuf_len = len(remainder) def fileno(self): return self._sock.fileno() def write(self, data): if not isinstance(data, bytes): raise TypeError("Non-bytes data") if not data: return self._wbuf.append(data) self._wbuf_len += len(data) if (self._wbufsize == 0 or (self._wbufsize == 1 and b'\n' in data) or (self._wbufsize > 1 and self._wbuf_len >= self._wbufsize)): self.flush() def writelines(self, list): # XXX We could do better here for very long lists # XXX Should really reject non-string non-buffers lines = filter(None, map(str, list)) self._wbuf_len += sum(map(len, lines)) self._wbuf.extend(lines) if (self._wbufsize <= 1 or self._wbuf_len >= self._wbufsize): self.flush() def read(self, size=-1): # Use max, disallow tiny reads in a loop as they are very inefficient. # We never leave read() with any leftover data from a new recv() call # in our internal buffer. rbufsize = max(self._rbufsize, self.default_bufsize) # Our use of BytesIO rather than lists of string objects returned by # recv() minimizes memory usage and fragmentation that occurs when # rbufsize is large compared to the typical return value of recv(). buf = self._rbuf buf.seek(0, 2) # seek end if size < 0: # Read until EOF self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. while True: try: data = self._sock.recv(rbufsize) except InterruptedError: continue if not data: break buf.write(data) return buf.getvalue() else: # Read until size bytes or EOF seen, whichever comes first buf_len = buf.tell() if buf_len >= size: # Already have size bytes in our buffer? Extract and return. buf.seek(0) rv = buf.read(size) self._rbuf = BytesIO() self._rbuf.write(buf.read()) return rv self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. while True: left = size - buf_len # recv() will malloc the amount of memory given as its # parameter even though it often returns much less data # than that. The returned data string is short lived # as we copy it into a BytesIO and free it. This avoids # fragmentation issues on many platforms. try: data = self._sock.recv(left) except InterruptedError: continue if not data: break n = len(data) if n == size and not buf_len: # Shortcut. Avoid buffer data copies when: # - We have no data in our buffer. # AND # - Our call to recv returned exactly the # number of bytes we were asked to read. return data if n == left: buf.write(data) del data # explicit free break assert n <= left, "recv(%d) returned %d bytes" % (left, n) buf.write(data) buf_len += n del data # explicit free #assert buf_len == buf.tell() return buf.getvalue() def readline(self, size=-1): buf = self._rbuf buf.seek(0, 2) # seek end if buf.tell() > 0: # check if we already have it in our buffer buf.seek(0) bline = buf.readline(size) if bline.endswith(b'\n') or len(bline) == size: self._rbuf = BytesIO() self._rbuf.write(buf.read()) return bline del bline if size < 0: # Read until \n or EOF, whichever comes first if self._rbufsize <= 1: # Speed up unbuffered case buf.seek(0) buffers = [buf.read()] self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. data = None recv = self._sock.recv while True: try: while data != b"\n": data = recv(1) if not data: break buffers.append(data) except InterruptedError: # The try..except to catch EINTR was moved outside the # recv loop to avoid the per byte overhead. continue break return b"".join(buffers) buf.seek(0, 2) # seek end self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. while True: try: data = self._sock.recv(self._rbufsize) except InterruptedError: continue if not data: break nl = data.find(b'\n') if nl >= 0: nl += 1 buf.write(data[:nl]) self._rbuf.write(data[nl:]) del data break buf.write(data) return buf.getvalue() else: # Read until size bytes or \n or EOF seen, whichever comes first buf.seek(0, 2) # seek end buf_len = buf.tell() if buf_len >= size: buf.seek(0) rv = buf.read(size) self._rbuf = BytesIO() self._rbuf.write(buf.read()) return rv self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. while True: try: data = self._sock.recv(self._rbufsize) except InterruptedError: continue if not data: break left = size - buf_len # did we just receive a newline? nl = data.find(b'\n', 0, left) if nl >= 0: nl += 1 # save the excess data to _rbuf self._rbuf.write(data[nl:]) if buf_len: buf.write(data[:nl]) break else: # Shortcut. Avoid data copy through buf when returning # a substring of our first recv(). return data[:nl] n = len(data) if n == size and not buf_len: # Shortcut. Avoid data copy through buf when # returning exactly all of our first recv(). return data if n >= left: buf.write(data[:left]) self._rbuf.write(data[left:]) break buf.write(data) buf_len += n #assert buf_len == buf.tell() return buf.getvalue() def readlines(self, sizehint=0): total = 0 list = [] while True: line = self.readline() if not line: break list.append(line) total += len(line) if sizehint and total >= sizehint: break return list # Iterator protocols def __iter__(self): return self def next(self): line = self.readline() if not line: raise StopIteration return line __next__ = next try: from gevent.fileobject import FileObjectPosix except ImportError: # Manual implementation _fileobject = _basefileobject else: class _fileobject(FileObjectPosix): # Add the proper drop/reuse support for pypy, and match # the close=False default in the constructor def __init__(self, sock, mode='rb', bufsize=-1, close=False): _do_reuse_or_drop(sock, '_reuse') self._sock = sock FileObjectPosix.__init__(self, sock, mode, bufsize, close) def close(self): try: if self._sock: self.flush() finally: s = self._sock self._sock = None if s is not None: if self._close: FileObjectPosix.close(self) else: _do_reuse_or_drop(s, '_drop') def __del__(self): try: self.close() except: # close() may fail if __init__ didn't complete pass __all__ = __implements__ + __extensions__ + __imports__ gevent-1.1.0/gevent/_socketcommon.py0000644000076500000000000002247712666555342020255 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. from __future__ import absolute_import # standard functions and classes that this module re-implements in a gevent-aware way: _implements = ['create_connection', 'socket', 'SocketType', 'fromfd', 'socketpair'] __dns__ = ['getaddrinfo', 'gethostbyname', 'gethostbyname_ex', 'gethostbyaddr', 'getnameinfo', 'getfqdn'] _implements += __dns__ # non-standard functions that this module provides: __extensions__ = ['cancel_wait', 'wait_read', 'wait_write', 'wait_readwrite'] # standard functions and classes that this module re-imports __imports__ = ['error', 'gaierror', 'herror', 'htonl', 'htons', 'ntohl', 'ntohs', 'inet_aton', 'inet_ntoa', 'inet_pton', 'inet_ntop', 'timeout', 'gethostname', 'getprotobyname', 'getservbyname', 'getservbyport', 'getdefaulttimeout', 'setdefaulttimeout', # Windows: 'errorTab', ] __py3_imports__ = [# Python 3 'AddressFamily', 'SocketKind', 'CMSG_LEN', 'CMSG_SPACE', 'dup', 'if_indextoname', 'if_nameindex', 'if_nametoindex', 'sethostname'] __imports__.extend(__py3_imports__) import sys from gevent.hub import get_hub, string_types, integer_types from gevent.hub import ConcurrentObjectUseError from gevent.timeout import Timeout is_windows = sys.platform == 'win32' if is_windows: # no such thing as WSAEPERM or error code 10001 according to winsock.h or MSDN from errno import WSAEINVAL as EINVAL from errno import WSAEWOULDBLOCK as EWOULDBLOCK from errno import WSAEINPROGRESS as EINPROGRESS from errno import WSAEALREADY as EALREADY from errno import WSAEISCONN as EISCONN from gevent.win32util import formatError as strerror EAGAIN = EWOULDBLOCK else: from errno import EINVAL from errno import EWOULDBLOCK from errno import EINPROGRESS from errno import EALREADY from errno import EAGAIN from errno import EISCONN from os import strerror try: from errno import EBADF except ImportError: EBADF = 9 import _socket _realsocket = _socket.socket import socket as __socket__ for name in __imports__[:]: try: value = getattr(__socket__, name) globals()[name] = value except AttributeError: __imports__.remove(name) for name in __socket__.__all__: value = getattr(__socket__, name) if isinstance(value, integer_types) or isinstance(value, string_types): globals()[name] = value __imports__.append(name) del name, value class _NONE(object): def __repr__(self): return "" _NONE = _NONE() _timeout_error = timeout def wait(io, timeout=None, timeout_exc=_NONE): """ Block the current greenlet until *io* is ready. If *timeout* is non-negative, then *timeout_exc* is raised after *timeout* second has passed. By default *timeout_exc* is ``socket.timeout('timed out')``. If :func:`cancel_wait` is called on *io* by another greenlet, raise an exception in this blocking greenlet (``socket.error(EBADF, 'File descriptor was closed in another greenlet')`` by default). :param io: A libev watcher, most commonly an IO watcher obtained from :meth:`gevent.core.loop.io` :keyword timeout_exc: The exception to raise if the timeout expires. By default, a :class:`socket.timeout` exception is raised. If you pass a value for this keyword, it is interpreted as for :class:`gevent.timeout.Timeout`. """ if io.callback is not None: raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (io.callback, )) if timeout is not None: timeout_exc = timeout_exc if timeout_exc is not _NONE else _timeout_error('timed out') timeout = Timeout.start_new(timeout, timeout_exc) try: return get_hub().wait(io) finally: if timeout is not None: timeout.cancel() # rename "io" to "watcher" because wait() works with any watcher def wait_read(fileno, timeout=None, timeout_exc=_NONE): """ Block the current greenlet until *fileno* is ready to read. For the meaning of the other parameters and possible exceptions, see :func:`wait`. .. seealso:: :func:`cancel_wait` """ io = get_hub().loop.io(fileno, 1) return wait(io, timeout, timeout_exc) def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): """ Block the current greenlet until *fileno* is ready to write. For the meaning of the other parameters and possible exceptions, see :func:`wait`. :keyword event: Ignored. Applications should not pass this parameter. In the future, it may become an error. .. seealso:: :func:`cancel_wait` """ io = get_hub().loop.io(fileno, 2) return wait(io, timeout, timeout_exc) def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): """ Block the current greenlet until *fileno* is ready to read or write. For the meaning of the other parameters and possible exceptions, see :func:`wait`. :keyword event: Ignored. Applications should not pass this parameter. In the future, it may become an error. .. seealso:: :func:`cancel_wait` """ io = get_hub().loop.io(fileno, 3) return wait(io, timeout, timeout_exc) #: The exception raised by default on a call to :func:`cancel_wait` cancel_wait_ex = error(EBADF, 'File descriptor was closed in another greenlet') def cancel_wait(watcher, error=cancel_wait_ex): """See :meth:`gevent.hub.Hub.cancel_wait`""" get_hub().cancel_wait(watcher, error) class BlockingResolver(object): def __init__(self, hub=None): pass def close(self): pass for method in ['gethostbyname', 'gethostbyname_ex', 'getaddrinfo', 'gethostbyaddr', 'getnameinfo']: locals()[method] = staticmethod(getattr(_socket, method)) def gethostbyname(hostname): """ gethostbyname(host) -> address Return the IP address (a string of the form '255.255.255.255') for a host. .. seealso:: :doc:`dns` """ return get_hub().resolver.gethostbyname(hostname) def gethostbyname_ex(hostname): """ gethostbyname_ex(host) -> (name, aliaslist, addresslist) Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number. Resolve host and port into list of address info entries. .. seealso:: :doc:`dns` """ return get_hub().resolver.gethostbyname_ex(hostname) def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0): """ Resolve host and port into list of address info entries. Translate the host/port argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. host is a domain name, a string representation of an IPv4/v6 address or None. port is a string service name such as 'http', a numeric port number or None. By passing None as the value of host and port, you can pass NULL to the underlying C API. The family, type and proto arguments can be optionally specified in order to narrow the list of addresses returned. Passing zero as a value for each of these arguments selects the full range of results. .. seealso:: :doc:`dns` """ return get_hub().resolver.getaddrinfo(host, port, family, socktype, proto, flags) def gethostbyaddr(ip_address): """ gethostbyaddr(host) -> (name, aliaslist, addresslist) Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number. .. seealso:: :doc:`dns` """ return get_hub().resolver.gethostbyaddr(ip_address) def getnameinfo(sockaddr, flags): """ getnameinfo(sockaddr, flags) -> (host, port) Get host and port for a sockaddr. .. seealso:: :doc:`dns` """ return get_hub().resolver.getnameinfo(sockaddr, flags) def getfqdn(name=''): """Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname from gethostname() is returned. """ name = name.strip() if not name or name == '0.0.0.0': name = gethostname() try: hostname, aliases, ipaddrs = gethostbyaddr(name) except error: pass else: aliases.insert(0, hostname) for name in aliases: if isinstance(name, bytes): if b'.' in name: break elif '.' in name: break else: name = hostname return name gevent-1.1.0/gevent/_ssl2.py0000644000076500000000000004153012666555342016426 0ustar jmaddenwheel00000000000000# Wrapper module for _ssl. Written by Bill Janssen. # Ported to gevent by Denis Bilenko. """SSL wrapper for socket objects on Python 2.7.8 and below. For the documentation, refer to :mod:`ssl` module manual. This module implements cooperative SSL socket wrappers. """ from __future__ import absolute_import import ssl as __ssl__ try: _ssl = __ssl__._ssl except AttributeError: _ssl = __ssl__._ssl2 import sys import errno from gevent._socket2 import socket from gevent.socket import _fileobject, timeout_default from gevent.socket import error as socket_error, EWOULDBLOCK from gevent.socket import timeout as _socket_timeout from gevent.hub import string_types, PYPY try: long except NameError: # Make us importable under Py3k for documentation long = int __implements__ = ['SSLSocket', 'wrap_socket', 'get_server_certificate', 'sslwrap_simple'] __imports__ = ['SSLError', 'RAND_status', 'RAND_egd', 'RAND_add', 'cert_time_to_seconds', 'get_protocol_name', 'DER_cert_to_PEM_cert', 'PEM_cert_to_DER_cert'] for name in __imports__[:]: try: value = getattr(__ssl__, name) globals()[name] = value except AttributeError: __imports__.remove(name) for name in dir(__ssl__): if not name.startswith('_'): value = getattr(__ssl__, name) if isinstance(value, (int, long, tuple)) or isinstance(value, string_types): globals()[name] = value __imports__.append(name) del name, value # Py2.6 can get RAND_status added twice __all__ = list(set(__implements__) | set(__imports__)) class SSLSocket(socket): """ gevent `ssl.SSLSocket `_ for Pythons < 2.7.9. """ def __init__(self, sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True, ciphers=None): socket.__init__(self, _sock=sock) if PYPY: sock._drop() if certfile and not keyfile: keyfile = certfile # see if it's connected try: socket.getpeername(self) except socket_error as e: if e.args[0] != errno.ENOTCONN: raise # no, no connection yet self._sslobj = None else: # yes, create the SSL object if ciphers is None: self._sslobj = _ssl.sslwrap(self._sock, server_side, keyfile, certfile, cert_reqs, ssl_version, ca_certs) else: self._sslobj = _ssl.sslwrap(self._sock, server_side, keyfile, certfile, cert_reqs, ssl_version, ca_certs, ciphers) if do_handshake_on_connect: self.do_handshake() self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs self.ssl_version = ssl_version self.ca_certs = ca_certs self.ciphers = ciphers self.do_handshake_on_connect = do_handshake_on_connect self.suppress_ragged_eofs = suppress_ragged_eofs self._makefile_refs = 0 def read(self, len=1024): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" while True: try: return self._sslobj.read(len) except SSLError as ex: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: return '' elif ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise sys.exc_clear() # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) else: raise def write(self, data): """Write DATA to the underlying SSL channel. Returns number of bytes of DATA actually transmitted.""" while True: try: return self._sslobj.write(data) except SSLError as ex: if ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) else: raise def getpeercert(self, binary_form=False): """Returns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.""" return self._sslobj.peer_certificate(binary_form) def cipher(self): if not self._sslobj: return None else: return self._sslobj.cipher() def send(self, data, flags=0, timeout=timeout_default): if timeout is timeout_default: timeout = self.timeout if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to send() on %s" % self.__class__) while True: try: v = self._sslobj.write(data) except SSLError as x: if x.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: return 0 sys.exc_clear() self._wait(self._read_event) elif x.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: return 0 sys.exc_clear() self._wait(self._write_event) else: raise else: return v else: return socket.send(self, data, flags, timeout) # is it possible for sendall() to send some data without encryption if another end shut down SSL? def sendall(self, data, flags=0): try: socket.sendall(self, data) except _socket_timeout as ex: if self.timeout == 0.0: # Python 2 simply *hangs* in this case, which is bad, but # Python 3 raises SSLWantWriteError. We do the same. raise SSLError(SSL_ERROR_WANT_WRITE) # Convert the socket.timeout back to the sslerror raise SSLError(*ex.args) def sendto(self, *args): if self._sslobj: raise ValueError("sendto not allowed on instances of %s" % self.__class__) else: return socket.sendto(self, *args) def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) # QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior? return self.read(buflen) else: return socket.recv(self, buflen, flags) def recv_into(self, buffer, nbytes=None, flags=0): if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) while True: try: tmp_buffer = self.read(nbytes) v = len(tmp_buffer) buffer[:v] = tmp_buffer return v except SSLError as x: if x.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) continue else: raise else: return socket.recv_into(self, buffer, nbytes, flags) def recvfrom(self, *args): if self._sslobj: raise ValueError("recvfrom not allowed on instances of %s" % self.__class__) else: return socket.recvfrom(self, *args) def recvfrom_into(self, *args): if self._sslobj: raise ValueError("recvfrom_into not allowed on instances of %s" % self.__class__) else: return socket.recvfrom_into(self, *args) def pending(self): if self._sslobj: return self._sslobj.pending() else: return 0 def _sslobj_shutdown(self): while True: try: return self._sslobj.shutdown() except SSLError as ex: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: return '' elif ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) else: raise def unwrap(self): if self._sslobj: s = self._sslobj_shutdown() self._sslobj = None return socket(_sock=s) else: raise ValueError("No SSL wrapper around " + str(self)) def shutdown(self, how): self._sslobj = None socket.shutdown(self, how) def close(self): if self._makefile_refs < 1: self._sslobj = None socket.close(self) else: self._makefile_refs -= 1 if PYPY: def _reuse(self): self._makefile_refs += 1 def _drop(self): if self._makefile_refs < 1: self.close() else: self._makefile_refs -= 1 def do_handshake(self): """Perform a TLS/SSL handshake.""" while True: try: return self._sslobj.do_handshake() except SSLError as ex: if ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) else: raise def connect(self, addr): """Connects to remote ADDR, and then wraps the connection in an SSL channel.""" # Here we assume that the socket is client-side, and not # connected at the time of the call. We connect it, then wrap it. if self._sslobj: raise ValueError("attempt to connect already-connected SSLSocket!") socket.connect(self, addr) if self.ciphers is None: self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile, self.cert_reqs, self.ssl_version, self.ca_certs) else: self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile, self.cert_reqs, self.ssl_version, self.ca_certs, self.ciphers) if self.do_handshake_on_connect: self.do_handshake() def accept(self): """Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.""" sock = self._sock while True: try: client_socket, address = sock.accept() break except socket_error as ex: if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event) sslobj = SSLSocket(client_socket, keyfile=self.keyfile, certfile=self.certfile, server_side=True, cert_reqs=self.cert_reqs, ssl_version=self.ssl_version, ca_certs=self.ca_certs, do_handshake_on_connect=self.do_handshake_on_connect, suppress_ragged_eofs=self.suppress_ragged_eofs, ciphers=self.ciphers) return sslobj, address def makefile(self, mode='r', bufsize=-1): """Make and return a file-like object that works with the SSL connection. Just use the code from the socket module.""" if not PYPY: self._makefile_refs += 1 # close=True so as to decrement the reference count when done with # the file-like object. return _fileobject(self, mode, bufsize, close=True) if PYPY or not hasattr(SSLSocket, 'timeout'): # PyPy (and certain versions of CPython) doesn't have a direct # 'timeout' property on raw sockets, because that's not part of # the documented specification. We may wind up wrapping a raw # socket (when ssl is used with PyWSGI) or a gevent socket, which # does have a read/write timeout property as an alias for # get/settimeout, so make sure that's always the case because # pywsgi can depend on that. SSLSocket.timeout = property(lambda self: self.gettimeout(), lambda self, value: self.settimeout(value)) _SSLErrorReadTimeout = SSLError('The read operation timed out') _SSLErrorWriteTimeout = SSLError('The write operation timed out') _SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out') def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True, ciphers=None): """Create a new :class:`SSLSocket` instance.""" return SSLSocket(sock, keyfile=keyfile, certfile=certfile, server_side=server_side, cert_reqs=cert_reqs, ssl_version=ssl_version, ca_certs=ca_certs, do_handshake_on_connect=do_handshake_on_connect, suppress_ragged_eofs=suppress_ragged_eofs, ciphers=ciphers) def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): """Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.""" host, port = addr if (ca_certs is not None): cert_reqs = CERT_REQUIRED else: cert_reqs = CERT_NONE s = wrap_socket(socket(), ssl_version=ssl_version, cert_reqs=cert_reqs, ca_certs=ca_certs) s.connect(addr) dercert = s.getpeercert(True) s.close() return DER_cert_to_PEM_cert(dercert) def sslwrap_simple(sock, keyfile=None, certfile=None): """A replacement for the old socket.ssl function. Designed for compatability with Python 2.5 and earlier. Will disappear in Python 3.0.""" return SSLSocket(sock, keyfile, certfile) gevent-1.1.0/gevent/_ssl3.py0000644000076500000000000005265312666555342016437 0ustar jmaddenwheel00000000000000# Wrapper module for _ssl. Written by Bill Janssen. # Ported to gevent by Denis Bilenko. """SSL wrapper for socket objects on Python 3. For the documentation, refer to :mod:`ssl` module manual. This module implements cooperative SSL socket wrappers. """ from __future__ import absolute_import import ssl as __ssl__ _ssl = __ssl__._ssl import errno from gevent.socket import socket, timeout_default from gevent.socket import error as socket_error from gevent.socket import timeout as _socket_timeout from weakref import ref as _wref __implements__ = [ 'SSLContext', 'SSLSocket', 'wrap_socket', 'get_server_certificate', ] __imports__ = [] name = value = None for name in dir(__ssl__): if name in __implements__: continue if name.startswith('__'): continue if name == 'socket': # SSLSocket *must* subclass gevent.socket.socket; see issue 597 continue value = getattr(__ssl__, name) globals()[name] = value __imports__.append(name) del name, value __all__ = __implements__ + __imports__ orig_SSLContext = __ssl__.SSLContext class SSLContext(orig_SSLContext): def wrap_socket(self, sock, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True, server_hostname=None): return SSLSocket(sock=sock, server_side=server_side, do_handshake_on_connect=do_handshake_on_connect, suppress_ragged_eofs=suppress_ragged_eofs, server_hostname=server_hostname, _context=self) if not hasattr(orig_SSLContext, 'check_hostname'): # Python 3.3 lacks this check_hostname = False class _contextawaresock(socket._gevent_sock_class): # We have to pass the raw stdlib socket to SSLContext.wrap_socket. # That method in turn can pass that object on to things like SNI callbacks. # It wouldn't have access to any of the attributes on the SSLSocket, like # context, that it's supposed to (see test_ssl.test_sni_callback). Our # solution is to keep a weak reference to the SSLSocket on the raw # socket and delegate. # We keep it in a slot to avoid having the ability to set any attributes # we're not prepared for (because we don't know what to delegate.) __slots__ = ('_sslsock',) @property def context(self): return self._sslsock().context @context.setter def context(self, ctx): self._sslsock().context = ctx def __getattr__(self, name): try: return getattr(self._sslsock(), name) except RuntimeError: # XXX: If the attribute doesn't exist, # we infinitely recurse pass raise AttributeError(name) class SSLSocket(socket): """ gevent `ssl.SSLSocket `_ for Python 3. """ _gevent_sock_class = _contextawaresock def __init__(self, sock=None, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, suppress_ragged_eofs=True, npn_protocols=None, ciphers=None, server_hostname=None, _context=None): if _context: self._context = _context else: if server_side and not certfile: raise ValueError("certfile must be specified for server-side " "operations") if keyfile and not certfile: raise ValueError("certfile must be specified") if certfile and not keyfile: keyfile = certfile self._context = SSLContext(ssl_version) self._context.verify_mode = cert_reqs if ca_certs: self._context.load_verify_locations(ca_certs) if certfile: self._context.load_cert_chain(certfile, keyfile) if npn_protocols: self._context.set_npn_protocols(npn_protocols) if ciphers: self._context.set_ciphers(ciphers) self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs self.ssl_version = ssl_version self.ca_certs = ca_certs self.ciphers = ciphers # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get # mixed in. if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: raise NotImplementedError("only stream sockets are supported") if server_side and server_hostname: raise ValueError("server_hostname can only be specified " "in client mode") if self._context.check_hostname and not server_hostname: raise ValueError("check_hostname requires server_hostname") self.server_side = server_side self.server_hostname = server_hostname self.do_handshake_on_connect = do_handshake_on_connect self.suppress_ragged_eofs = suppress_ragged_eofs connected = False if sock is not None: socket.__init__(self, family=sock.family, type=sock.type, proto=sock.proto, fileno=sock.fileno()) self.settimeout(sock.gettimeout()) # see if it's connected try: sock.getpeername() except socket_error as e: if e.errno != errno.ENOTCONN: raise else: connected = True sock.detach() elif fileno is not None: socket.__init__(self, fileno=fileno) else: socket.__init__(self, family=family, type=type, proto=proto) self._sock._sslsock = _wref(self) self._closed = False self._sslobj = None self._connected = connected if connected: # create the SSL object try: self._sslobj = self.context._wrap_socket(self._sock, server_side, server_hostname) if do_handshake_on_connect: timeout = self.gettimeout() if timeout == 0.0: # non-blocking raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") self.do_handshake() except socket_error as x: self.close() raise x @property def context(self): return self._context @context.setter def context(self, ctx): self._context = ctx self._sslobj.context = ctx def dup(self): raise NotImplementedError("Can't dup() %s instances" % self.__class__.__name__) def _checkClosed(self, msg=None): # raise an exception here if you wish to check for spurious closes pass def _check_connected(self): if not self._connected: # getpeername() will raise ENOTCONN if the socket is really # not connected; note that we can be connected even without # _connected being set, e.g. if connect() first returned # EAGAIN. self.getpeername() def read(self, len=1024, buffer=None): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" self._checkClosed() if not self._sslobj: raise ValueError("Read on closed or unwrapped SSL socket.") while True: try: if buffer is not None: return self._sslobj.read(len, buffer) else: return self._sslobj.read(len or 1024) except SSLWantReadError: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) except SSLWantWriteError: if self.timeout == 0.0: raise # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) except SSLError as ex: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: if buffer is None: return b'' else: return 0 else: raise def write(self, data): """Write DATA to the underlying SSL channel. Returns number of bytes of DATA actually transmitted.""" self._checkClosed() if not self._sslobj: raise ValueError("Write on closed or unwrapped SSL socket.") while True: try: return self._sslobj.write(data) except SSLError as ex: if ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) else: raise def getpeercert(self, binary_form=False): """Returns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.""" self._checkClosed() self._check_connected() return self._sslobj.peer_certificate(binary_form) def selected_npn_protocol(self): self._checkClosed() if not self._sslobj or not _ssl.HAS_NPN: return None else: return self._sslobj.selected_npn_protocol() if hasattr(_ssl, 'HAS_ALPN'): # 3.5+ def selected_alpn_protocol(self): self._checkClosed() if not self._sslobj or not _ssl.HAS_ALPN: return None else: return self._sslobj.selected_alpn_protocol() def shared_ciphers(self): """Return a list of ciphers shared by the client during the handshake or None if this is not a valid server connection. """ return self._sslobj.shared_ciphers() def version(self): """Return a string identifying the protocol version used by the current SSL channel. """ if not self._sslobj: return None return self._sslobj.version() # We inherit sendfile from super(); it always uses `send` def cipher(self): self._checkClosed() if not self._sslobj: return None else: return self._sslobj.cipher() def compression(self): self._checkClosed() if not self._sslobj: return None else: return self._sslobj.compression() def send(self, data, flags=0, timeout=timeout_default): self._checkClosed() if timeout is timeout_default: timeout = self.timeout if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to send() on %s" % self.__class__) while True: try: return self._sslobj.write(data) except SSLWantReadError: if self.timeout == 0.0: return 0 self._wait(self._read_event) except SSLWantWriteError: if self.timeout == 0.0: return 0 self._wait(self._write_event) else: return socket.send(self, data, flags, timeout) def sendto(self, data, flags_or_addr, addr=None): self._checkClosed() if self._sslobj: raise ValueError("sendto not allowed on instances of %s" % self.__class__) elif addr is None: return socket.sendto(self, data, flags_or_addr) else: return socket.sendto(self, data, flags_or_addr, addr) def sendmsg(self, *args, **kwargs): # Ensure programs don't send data unencrypted if they try to # use this method. raise NotImplementedError("sendmsg not allowed on instances of %s" % self.__class__) def sendall(self, data, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to sendall() on %s" % self.__class__) try: return socket.sendall(self, data, flags) except _socket_timeout: if self.timeout == 0.0: # Raised by the stdlib on non-blocking sockets raise SSLWantWriteError("The operation did not complete (write)") raise def recv(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) return self.read(buflen) else: return socket.recv(self, buflen, flags) def recv_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError("non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) return self.read(nbytes, buffer) else: return socket.recv_into(self, buffer, nbytes, flags) def recvfrom(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: raise ValueError("recvfrom not allowed on instances of %s" % self.__class__) else: return socket.recvfrom(self, buflen, flags) def recvfrom_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if self._sslobj: raise ValueError("recvfrom_into not allowed on instances of %s" % self.__class__) else: return socket.recvfrom_into(self, buffer, nbytes, flags) def recvmsg(self, *args, **kwargs): raise NotImplementedError("recvmsg not allowed on instances of %s" % self.__class__) def recvmsg_into(self, *args, **kwargs): raise NotImplementedError("recvmsg_into not allowed on instances of " "%s" % self.__class__) def pending(self): self._checkClosed() if self._sslobj: return self._sslobj.pending() else: return 0 def shutdown(self, how): self._checkClosed() self._sslobj = None socket.shutdown(self, how) def unwrap(self): if self._sslobj: while True: try: s = self._sslobj.shutdown() break except SSLWantReadError: if self.timeout == 0.0: return 0 self._wait(self._read_event) except SSLWantWriteError: if self.timeout == 0.0: return 0 self._wait(self._write_event) self._sslobj = None # The return value of shutting down the SSLObject is the # original wrapped socket, i.e., _contextawaresock. But that # object doesn't have the gevent wrapper around it so it can't # be used. We have to wrap it back up with a gevent wrapper. sock = socket(family=s.family, type=s.type, proto=s.proto, fileno=s.fileno()) s.detach() return sock else: raise ValueError("No SSL wrapper around " + str(self)) def _real_close(self): self._sslobj = None # self._closed = True socket._real_close(self) def do_handshake(self): """Perform a TLS/SSL handshake.""" self._check_connected() while True: try: self._sslobj.do_handshake() break except SSLWantReadError: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) except SSLWantWriteError: if self.timeout == 0.0: raise self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) if self.context.check_hostname: if not self.server_hostname: raise ValueError("check_hostname needs server_hostname " "argument") match_hostname(self.getpeercert(), self.server_hostname) def _real_connect(self, addr, connect_ex): if self.server_side: raise ValueError("can't connect in server-side mode") # Here we assume that the socket is client-side, and not # connected at the time of the call. We connect it, then wrap it. if self._connected: raise ValueError("attempt to connect already-connected SSLSocket!") self._sslobj = self.context._wrap_socket(self._sock, False, self.server_hostname) try: if connect_ex: rc = socket.connect_ex(self, addr) else: rc = None socket.connect(self, addr) if not rc: if self.do_handshake_on_connect: self.do_handshake() self._connected = True return rc except socket_error: self._sslobj = None raise def connect(self, addr): """Connects to remote ADDR, and then wraps the connection in an SSL channel.""" self._real_connect(addr, False) def connect_ex(self, addr): """Connects to remote ADDR, and then wraps the connection in an SSL channel.""" return self._real_connect(addr, True) def accept(self): """Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.""" newsock, addr = socket.accept(self) newsock = self.context.wrap_socket(newsock, do_handshake_on_connect=self.do_handshake_on_connect, suppress_ragged_eofs=self.suppress_ragged_eofs, server_side=True) return newsock, addr def get_channel_binding(self, cb_type="tls-unique"): """Get channel binding data for current connection. Raise ValueError if the requested `cb_type` is not supported. Return bytes of the data or None if the data is not available (e.g. before the handshake). """ if cb_type not in CHANNEL_BINDING_TYPES: raise ValueError("Unsupported channel binding type") if cb_type != "tls-unique": raise NotImplementedError("{0} channel binding type not implemented".format(cb_type)) if self._sslobj is None: return None return self._sslobj.tls_unique_cb() # Python 3.2 onwards raise normal timeout errors, not SSLError. # See https://bugs.python.org/issue10272 _SSLErrorReadTimeout = _socket_timeout('The read operation timed out') _SSLErrorWriteTimeout = _socket_timeout('The write operation timed out') _SSLErrorHandshakeTimeout = _socket_timeout('The handshake operation timed out') def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True, ciphers=None): return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile, server_side=server_side, cert_reqs=cert_reqs, ssl_version=ssl_version, ca_certs=ca_certs, do_handshake_on_connect=do_handshake_on_connect, suppress_ragged_eofs=suppress_ragged_eofs, ciphers=ciphers) def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): """Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.""" host, port = addr if (ca_certs is not None): cert_reqs = CERT_REQUIRED else: cert_reqs = CERT_NONE s = create_connection(addr) s = wrap_socket(s, ssl_version=ssl_version, cert_reqs=cert_reqs, ca_certs=ca_certs) dercert = s.getpeercert(True) s.close() return DER_cert_to_PEM_cert(dercert) gevent-1.1.0/gevent/_sslgte279.py0000644000076500000000000006372712666555342017322 0ustar jmaddenwheel00000000000000# Wrapper module for _ssl. Written by Bill Janssen. # Ported to gevent by Denis Bilenko. """SSL wrapper for socket objects on Python 2.7.9 and above. For the documentation, refer to :mod:`ssl` module manual. This module implements cooperative SSL socket wrappers. """ from __future__ import absolute_import import ssl as __ssl__ _ssl = __ssl__._ssl import errno from gevent._socket2 import socket from gevent.socket import timeout_default from gevent.socket import error as socket_error from gevent.socket import timeout as _socket_timeout from gevent.hub import PYPY __implements__ = ['SSLContext', 'SSLSocket', 'wrap_socket', 'get_server_certificate', 'create_default_context', '_create_unverified_context', '_create_default_https_context', '_create_stdlib_context'] __imports__ = [] # Import all symbols from Python's ssl.py, except those that we are implementing # and "private" symbols. value = None for name in dir(__ssl__): if name in __implements__: continue if name.startswith('__'): continue if name == 'socket': # SSLSocket *must* subclass gevent.socket.socket; see issue 597 continue value = getattr(__ssl__, name) globals()[name] = value __imports__.append(name) del name, value try: _delegate_methods except NameError: # PyPy doesn't expose this detail _delegate_methods = ('recv', 'recvfrom', 'recv_into', 'recvfrom_into', 'send', 'sendto') __all__ = __implements__ + __imports__ orig_SSLContext = __ssl__.SSLContext class SSLContext(orig_SSLContext): def wrap_socket(self, sock, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True, server_hostname=None): return SSLSocket(sock=sock, server_side=server_side, do_handshake_on_connect=do_handshake_on_connect, suppress_ragged_eofs=suppress_ragged_eofs, server_hostname=server_hostname, _context=self) def create_default_context(purpose=Purpose.SERVER_AUTH, cafile=None, capath=None, cadata=None): """Create a SSLContext object with default settings. NOTE: The protocol and settings may change anytime without prior deprecation. The values represent a fair balance between maximum compatibility and security. """ if not isinstance(purpose, _ASN1Object): raise TypeError(purpose) context = SSLContext(PROTOCOL_SSLv23) # SSLv2 considered harmful. context.options |= OP_NO_SSLv2 # SSLv3 has problematic security and is only required for really old # clients such as IE6 on Windows XP context.options |= OP_NO_SSLv3 # disable compression to prevent CRIME attacks (OpenSSL 1.0+) context.options |= getattr(_ssl, "OP_NO_COMPRESSION", 0) if purpose == Purpose.SERVER_AUTH: # verify certs and host name in client mode context.verify_mode = CERT_REQUIRED context.check_hostname = True elif purpose == Purpose.CLIENT_AUTH: # Prefer the server's ciphers by default so that we get stronger # encryption context.options |= getattr(_ssl, "OP_CIPHER_SERVER_PREFERENCE", 0) # Use single use keys in order to improve forward secrecy context.options |= getattr(_ssl, "OP_SINGLE_DH_USE", 0) context.options |= getattr(_ssl, "OP_SINGLE_ECDH_USE", 0) # disallow ciphers with known vulnerabilities context.set_ciphers(_RESTRICTED_SERVER_CIPHERS) if cafile or capath or cadata: context.load_verify_locations(cafile, capath, cadata) elif context.verify_mode != CERT_NONE: # no explicit cafile, capath or cadata but the verify mode is # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system # root CA certificates for the given purpose. This may fail silently. context.load_default_certs(purpose) return context def _create_unverified_context(protocol=PROTOCOL_SSLv23, cert_reqs=None, check_hostname=False, purpose=Purpose.SERVER_AUTH, certfile=None, keyfile=None, cafile=None, capath=None, cadata=None): """Create a SSLContext object for Python stdlib modules All Python stdlib modules shall use this function to create SSLContext objects in order to keep common settings in one place. The configuration is less restrict than create_default_context()'s to increase backward compatibility. """ if not isinstance(purpose, _ASN1Object): raise TypeError(purpose) context = SSLContext(protocol) # SSLv2 considered harmful. context.options |= OP_NO_SSLv2 # SSLv3 has problematic security and is only required for really old # clients such as IE6 on Windows XP context.options |= OP_NO_SSLv3 if cert_reqs is not None: context.verify_mode = cert_reqs context.check_hostname = check_hostname if keyfile and not certfile: raise ValueError("certfile must be specified") if certfile or keyfile: context.load_cert_chain(certfile, keyfile) # load CA root certs if cafile or capath or cadata: context.load_verify_locations(cafile, capath, cadata) elif context.verify_mode != CERT_NONE: # no explicit cafile, capath or cadata but the verify mode is # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system # root CA certificates for the given purpose. This may fail silently. context.load_default_certs(purpose) return context # Used by http.client if no context is explicitly passed. _create_default_https_context = create_default_context # Backwards compatibility alias, even though it's not a public name. _create_stdlib_context = _create_unverified_context class SSLSocket(socket): """ gevent `ssl.SSLSocket `_ for Pythons >= 2.7.9 but less than 3. """ def __init__(self, sock=None, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, suppress_ragged_eofs=True, npn_protocols=None, ciphers=None, server_hostname=None, _context=None): if _context: self._context = _context else: if server_side and not certfile: raise ValueError("certfile must be specified for server-side " "operations") if keyfile and not certfile: raise ValueError("certfile must be specified") if certfile and not keyfile: keyfile = certfile self._context = SSLContext(ssl_version) self._context.verify_mode = cert_reqs if ca_certs: self._context.load_verify_locations(ca_certs) if certfile: self._context.load_cert_chain(certfile, keyfile) if npn_protocols: self._context.set_npn_protocols(npn_protocols) if ciphers: self._context.set_ciphers(ciphers) self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs self.ssl_version = ssl_version self.ca_certs = ca_certs self.ciphers = ciphers # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get # mixed in. if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: raise NotImplementedError("only stream sockets are supported") if PYPY: socket.__init__(self, _sock=sock) sock._drop() else: # CPython: XXX: Must pass the underlying socket, not our # potential wrapper; test___example_servers fails the SSL test # with a client-side EOF error. (Why?) socket.__init__(self, _sock=sock._sock) # The initializer for socket overrides the methods send(), recv(), etc. # in the instance, which we don't need -- but we want to provide the # methods defined in SSLSocket. for attr in _delegate_methods: try: delattr(self, attr) except AttributeError: pass if server_side and server_hostname: raise ValueError("server_hostname can only be specified " "in client mode") if self._context.check_hostname and not server_hostname: raise ValueError("check_hostname requires server_hostname") self.server_side = server_side self.server_hostname = server_hostname self.do_handshake_on_connect = do_handshake_on_connect self.suppress_ragged_eofs = suppress_ragged_eofs self.settimeout(sock.gettimeout()) # See if we are connected try: self.getpeername() except socket_error as e: if e.errno != errno.ENOTCONN: raise connected = False else: connected = True self._makefile_refs = 0 self._closed = False self._sslobj = None self._connected = connected if connected: # create the SSL object try: self._sslobj = self._context._wrap_socket(self._sock, server_side, server_hostname, ssl_sock=self) if do_handshake_on_connect: timeout = self.gettimeout() if timeout == 0.0: # non-blocking raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") self.do_handshake() except socket_error as x: self.close() raise x @property def context(self): return self._context @context.setter def context(self, ctx): self._context = ctx self._sslobj.context = ctx def dup(self): raise NotImplemented("Can't dup() %s instances" % self.__class__.__name__) def _checkClosed(self, msg=None): # raise an exception here if you wish to check for spurious closes pass def _check_connected(self): if not self._connected: # getpeername() will raise ENOTCONN if the socket is really # not connected; note that we can be connected even without # _connected being set, e.g. if connect() first returned # EAGAIN. self.getpeername() def read(self, len=0, buffer=None): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" self._checkClosed() if not self._sslobj: raise ValueError("Read on closed or unwrapped SSL socket.") while True: try: if buffer is not None: return self._sslobj.read(len, buffer) else: return self._sslobj.read(len or 1024) except SSLWantReadError: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) except SSLWantWriteError: if self.timeout == 0.0: raise # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) except SSLError as ex: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: if buffer is not None: return 0 else: return b'' else: raise def write(self, data): """Write DATA to the underlying SSL channel. Returns number of bytes of DATA actually transmitted.""" self._checkClosed() if not self._sslobj: raise ValueError("Write on closed or unwrapped SSL socket.") while True: try: return self._sslobj.write(data) except SSLError as ex: if ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) else: raise def getpeercert(self, binary_form=False): """Returns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.""" self._checkClosed() self._check_connected() return self._sslobj.peer_certificate(binary_form) def selected_npn_protocol(self): self._checkClosed() if not self._sslobj or not _ssl.HAS_NPN: return None else: return self._sslobj.selected_npn_protocol() if hasattr(_ssl, 'HAS_ALPN'): # 2.7.10+ def selected_alpn_protocol(self): self._checkClosed() if not self._sslobj or not _ssl.HAS_ALPN: return None else: return self._sslobj.selected_alpn_protocol() def cipher(self): self._checkClosed() if not self._sslobj: return None else: return self._sslobj.cipher() def compression(self): self._checkClosed() if not self._sslobj: return None else: return self._sslobj.compression() def __check_flags(self, meth, flags): if flags != 0: raise ValueError( "non-zero flags not allowed in calls to %s on %s" % (meth, self.__class__)) def send(self, data, flags=0, timeout=timeout_default): self._checkClosed() self.__check_flags('send', flags) if timeout is timeout_default: timeout = self.timeout if not self._sslobj: return socket.send(self, data, flags, timeout) while True: try: return self._sslobj.write(data) except SSLWantReadError: if self.timeout == 0.0: return 0 self._wait(self._read_event) except SSLWantWriteError: if self.timeout == 0.0: return 0 self._wait(self._write_event) def sendto(self, data, flags_or_addr, addr=None): self._checkClosed() if self._sslobj: raise ValueError("sendto not allowed on instances of %s" % self.__class__) elif addr is None: return socket.sendto(self, data, flags_or_addr) else: return socket.sendto(self, data, flags_or_addr, addr) def sendmsg(self, *args, **kwargs): # Ensure programs don't send data unencrypted if they try to # use this method. raise NotImplementedError("sendmsg not allowed on instances of %s" % self.__class__) def sendall(self, data, flags=0): self._checkClosed() self.__check_flags('sendall', flags) try: socket.sendall(self, data) except _socket_timeout as ex: if self.timeout == 0.0: # Python 2 simply *hangs* in this case, which is bad, but # Python 3 raises SSLWantWriteError. We do the same. raise SSLWantWriteError("The operation did not complete (write)") # Convert the socket.timeout back to the sslerror raise SSLError(*ex.args) def recv(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) return self.read(buflen) else: return socket.recv(self, buflen, flags) def recv_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) return self.read(nbytes, buffer) else: return socket.recv_into(self, buffer, nbytes, flags) def recvfrom(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: raise ValueError("recvfrom not allowed on instances of %s" % self.__class__) else: return socket.recvfrom(self, buflen, flags) def recvfrom_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if self._sslobj: raise ValueError("recvfrom_into not allowed on instances of %s" % self.__class__) else: return socket.recvfrom_into(self, buffer, nbytes, flags) def recvmsg(self, *args, **kwargs): raise NotImplementedError("recvmsg not allowed on instances of %s" % self.__class__) def recvmsg_into(self, *args, **kwargs): raise NotImplementedError("recvmsg_into not allowed on instances of " "%s" % self.__class__) def pending(self): self._checkClosed() if self._sslobj: return self._sslobj.pending() else: return 0 def shutdown(self, how): self._checkClosed() self._sslobj = None socket.shutdown(self, how) def close(self): if self._makefile_refs < 1: self._sslobj = None socket.close(self) else: self._makefile_refs -= 1 if PYPY: def _reuse(self): self._makefile_refs += 1 def _drop(self): if self._makefile_refs < 1: self.close() else: self._makefile_refs -= 1 def _sslobj_shutdown(self): while True: try: return self._sslobj.shutdown() except SSLError as ex: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: return '' elif ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) elif ex.args[0] == SSL_ERROR_WANT_WRITE: if self.timeout == 0.0: raise sys.exc_clear() self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) else: raise def unwrap(self): if self._sslobj: s = self._sslobj_shutdown() self._sslobj = None return socket(_sock=s) # match _ssl2; critical to drop/reuse here on PyPy else: raise ValueError("No SSL wrapper around " + str(self)) def _real_close(self): self._sslobj = None socket._real_close(self) def do_handshake(self): """Perform a TLS/SSL handshake.""" self._check_connected() while True: try: self._sslobj.do_handshake() break except SSLWantReadError: if self.timeout == 0.0: raise self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) except SSLWantWriteError: if self.timeout == 0.0: raise self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) if self.context.check_hostname: if not self.server_hostname: raise ValueError("check_hostname needs server_hostname " "argument") match_hostname(self.getpeercert(), self.server_hostname) def _real_connect(self, addr, connect_ex): if self.server_side: raise ValueError("can't connect in server-side mode") # Here we assume that the socket is client-side, and not # connected at the time of the call. We connect it, then wrap it. if self._connected: raise ValueError("attempt to connect already-connected SSLSocket!") self._sslobj = self.context._wrap_socket(self._sock, False, self.server_hostname, ssl_sock=self) try: if connect_ex: rc = socket.connect_ex(self, addr) else: rc = None socket.connect(self, addr) if not rc: self._connected = True if self.do_handshake_on_connect: self.do_handshake() return rc except socket_error: self._sslobj = None raise def connect(self, addr): """Connects to remote ADDR, and then wraps the connection in an SSL channel.""" self._real_connect(addr, False) def connect_ex(self, addr): """Connects to remote ADDR, and then wraps the connection in an SSL channel.""" return self._real_connect(addr, True) def accept(self): """Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.""" newsock, addr = socket.accept(self) newsock = self.context.wrap_socket(newsock, do_handshake_on_connect=self.do_handshake_on_connect, suppress_ragged_eofs=self.suppress_ragged_eofs, server_side=True) return newsock, addr def makefile(self, mode='r', bufsize=-1): """Make and return a file-like object that works with the SSL connection. Just use the code from the socket module.""" if not PYPY: self._makefile_refs += 1 # close=True so as to decrement the reference count when done with # the file-like object. return _fileobject(self, mode, bufsize, close=True) def get_channel_binding(self, cb_type="tls-unique"): """Get channel binding data for current connection. Raise ValueError if the requested `cb_type` is not supported. Return bytes of the data or None if the data is not available (e.g. before the handshake). """ if cb_type not in CHANNEL_BINDING_TYPES: raise ValueError("Unsupported channel binding type") if cb_type != "tls-unique": raise NotImplementedError( "{0} channel binding type not implemented" .format(cb_type)) if self._sslobj is None: return None return self._sslobj.tls_unique_cb() def version(self): """ Return a string identifying the protocol version used by the current SSL channel, or None if there is no established channel. """ if self._sslobj is None: return None return self._sslobj.version() if PYPY or not hasattr(SSLSocket, 'timeout'): # PyPy (and certain versions of CPython) doesn't have a direct # 'timeout' property on raw sockets, because that's not part of # the documented specification. We may wind up wrapping a raw # socket (when ssl is used with PyWSGI) or a gevent socket, which # does have a read/write timeout property as an alias for # get/settimeout, so make sure that's always the case because # pywsgi can depend on that. SSLSocket.timeout = property(lambda self: self.gettimeout(), lambda self, value: self.settimeout(value)) _SSLErrorReadTimeout = SSLError('The read operation timed out') _SSLErrorWriteTimeout = SSLError('The write operation timed out') _SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out') def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True, ciphers=None): return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile, server_side=server_side, cert_reqs=cert_reqs, ssl_version=ssl_version, ca_certs=ca_certs, do_handshake_on_connect=do_handshake_on_connect, suppress_ragged_eofs=suppress_ragged_eofs, ciphers=ciphers) def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): """Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.""" host, port = addr if ca_certs is not None: cert_reqs = CERT_REQUIRED else: cert_reqs = CERT_NONE context = _create_stdlib_context(ssl_version, cert_reqs=cert_reqs, cafile=ca_certs) with closing(create_connection(addr)) as sock: with closing(context.wrap_socket(sock)) as sslsock: dercert = sslsock.getpeercert(True) return DER_cert_to_PEM_cert(dercert) gevent-1.1.0/gevent/_tblib.py0000644000076500000000000002242212666555342016636 0ustar jmaddenwheel00000000000000# -*- coding: utf-8 -*- # A vendored version of part of https://github.com/ionelmc/python-tblib #### # Copyright (c) 2013-2014, Ionel Cristian Mărieș # All rights reserved. # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the # following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following # disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided with the distribution. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #### # cpython.py """ Taken verbatim from Jinja2. https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267 """ #import platform # XXX: gevent cannot import platform at the top level; interferes with monkey patching import sys def _init_ugly_crap(): """This function implements a few ugly things so that we can patch the traceback objects. The function returned allows resetting `tb_next` on any python traceback object. Do not attempt to use this on non cpython interpreters """ import ctypes from types import TracebackType # figure out side of _Py_ssize_t if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'): _Py_ssize_t = ctypes.c_int64 else: _Py_ssize_t = ctypes.c_int # regular python class _PyObject(ctypes.Structure): pass _PyObject._fields_ = [ ('ob_refcnt', _Py_ssize_t), ('ob_type', ctypes.POINTER(_PyObject)) ] # python with trace if hasattr(sys, 'getobjects'): class _PyObject(ctypes.Structure): pass _PyObject._fields_ = [ ('_ob_next', ctypes.POINTER(_PyObject)), ('_ob_prev', ctypes.POINTER(_PyObject)), ('ob_refcnt', _Py_ssize_t), ('ob_type', ctypes.POINTER(_PyObject)) ] class _Traceback(_PyObject): pass _Traceback._fields_ = [ ('tb_next', ctypes.POINTER(_Traceback)), ('tb_frame', ctypes.POINTER(_PyObject)), ('tb_lasti', ctypes.c_int), ('tb_lineno', ctypes.c_int) ] def tb_set_next(tb, next): """Set the tb_next attribute of a traceback object.""" if not (isinstance(tb, TracebackType) and (next is None or isinstance(next, TracebackType))): raise TypeError('tb_set_next arguments must be traceback objects') obj = _Traceback.from_address(id(tb)) if tb.tb_next is not None: old = _Traceback.from_address(id(tb.tb_next)) old.ob_refcnt -= 1 if next is None: obj.tb_next = ctypes.POINTER(_Traceback)() else: next = _Traceback.from_address(id(next)) next.ob_refcnt += 1 obj.tb_next = ctypes.pointer(next) return tb_set_next tb_set_next = None # try: # if platform.python_implementation() == 'CPython': # #tb_set_next = _init_ugly_crap() # tb_set_next = None # except Exception as exc: # sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc)) # del _init_ugly_crap # __init__.py try: from __pypy__ import tproxy except ImportError: tproxy = None #if not tb_set_next and not tproxy: # raise ImportError("Cannot use tblib. Runtime not supported.") from types import CodeType from types import TracebackType PY3 = sys.version_info[0] == 3 class _AttrDict(dict): def __getattr__(self, attr): return self[attr] class __traceback_maker(Exception): pass class Code(object): def __init__(self, code): self.co_filename = code.co_filename self.co_name = code.co_name self.co_nlocals = code.co_nlocals self.co_stacksize = code.co_stacksize self.co_flags = code.co_flags self.co_firstlineno = code.co_firstlineno class Frame(object): def __init__(self, frame): # gevent: python 2.6 syntax fix self.f_globals = {'__file__': frame.f_globals.get('__file__'), '__name__': frame.f_globals.get('__name__')} self.f_code = Code(frame.f_code) class Traceback(object): def __init__(self, tb): self.tb_frame = Frame(tb.tb_frame) self.tb_lineno = tb.tb_lineno if tb.tb_next is None: self.tb_next = None else: self.tb_next = Traceback(tb.tb_next) def as_traceback(self): if tproxy: return tproxy(TracebackType, self.__tproxy_handler) elif tb_set_next: f_code = self.tb_frame.f_code code = compile('\n' * (self.tb_lineno - 1) + 'raise __traceback_maker', self.tb_frame.f_code.co_filename, 'exec') if PY3: code = CodeType( 0, 0, f_code.co_nlocals, f_code.co_stacksize, f_code.co_flags, code.co_code, code.co_consts, code.co_names, code.co_varnames, f_code.co_filename, f_code.co_name, code.co_firstlineno, b"", (), () ) else: code = CodeType( 0, f_code.co_nlocals, f_code.co_stacksize, f_code.co_flags, code.co_code, code.co_consts, code.co_names, code.co_varnames, f_code.co_filename.encode(), f_code.co_name.encode(), code.co_firstlineno, b"", (), () ) try: exec(code, self.tb_frame.f_globals, {}) except: tb = sys.exc_info()[2].tb_next tb_set_next(tb, self.tb_next and self.tb_next.as_traceback()) try: return tb finally: del tb else: raise RuntimeError("Cannot re-create traceback !") def __tproxy_handler(self, operation, *args, **kwargs): if operation in ('__getattribute__', '__getattr__'): if args[0] == 'tb_next': return self.tb_next and self.tb_next.as_traceback() else: return getattr(self, args[0]) else: return getattr(self, operation)(*args, **kwargs) # pickling_support.py def unpickle_traceback(tb_frame, tb_lineno, tb_next): ret = object.__new__(Traceback) ret.tb_frame = tb_frame ret.tb_lineno = tb_lineno ret.tb_next = tb_next return ret.as_traceback() def pickle_traceback(tb): return unpickle_traceback, (Frame(tb.tb_frame), tb.tb_lineno, tb.tb_next and Traceback(tb.tb_next)) def install(): try: import copy_reg except ImportError: import copyreg as copy_reg copy_reg.pickle(TracebackType, pickle_traceback) # Added by gevent # We have to defer the initialization, and especially the import of platform, # until runtime. If we're monkey patched, we need to be sure to use # the original __import__ to avoid switching through the hub due to # import locks on Python 2. See also builtins.py for details. def _unlocked_imports(f): def g(a): gb = None if 'gevent.builtins' in sys.modules: gb = sys.modules['gevent.builtins'] gb._unlock_imports() try: return f(a) finally: if gb is not None: gb._lock_imports() g.__name__ = f.__name__ g.__module__ = f.__module__ return g def _import_dump_load(): global dumps global loads try: import cPickle as pickle except ImportError: import pickle dumps = pickle.dumps loads = pickle.loads dumps = loads = None _installed = False def _init(): global _installed global tb_set_next if _installed: return _installed = True import platform try: if platform.python_implementation() == 'CPython': tb_set_next = _init_ugly_crap() except Exception as exc: sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc)) try: from __pypy__ import tproxy except ImportError: tproxy = None if not tb_set_next and not tproxy: raise ImportError("Cannot use tblib. Runtime not supported.") _import_dump_load() install() @_unlocked_imports def dump_traceback(tb): # Both _init and dump/load have to be unlocked, because # copy_reg and pickle can do imports to resolve class names; those # class names are in this module and greenlet safe though _init() return dumps(tb) @_unlocked_imports def load_traceback(s): _init() return loads(s) gevent-1.1.0/gevent/_threading.py0000644000076500000000000003762412666555342017521 0ustar jmaddenwheel00000000000000"""A clone of threading module (version 2.7.2) that always targets real OS threads. (Unlike 'threading' which flips between green and OS threads based on whether the monkey patching is in effect or not). This module is missing 'Thread' class, but includes 'Queue'. """ try: from Queue import Full, Empty except ImportError: from queue import Full, Empty from collections import deque import heapq from time import time as _time, sleep as _sleep from gevent import monkey from gevent.hub import PY3 __all__ = ['Condition', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Queue', 'local', 'stack_size'] thread_name = '_thread' if PY3 else 'thread' start_new_thread, Lock, get_ident, local, stack_size = monkey.get_original(thread_name, [ 'start_new_thread', 'allocate_lock', 'get_ident', '_local', 'stack_size']) class RLock(object): def __init__(self): self.__block = Lock() self.__owner = None self.__count = 0 def __repr__(self): owner = self.__owner return "<%s owner=%r count=%d>" % ( self.__class__.__name__, owner, self.__count) def acquire(self, blocking=1): me = get_ident() if self.__owner == me: self.__count = self.__count + 1 return 1 rc = self.__block.acquire(blocking) if rc: self.__owner = me self.__count = 1 return rc __enter__ = acquire def release(self): if self.__owner != get_ident(): raise RuntimeError("cannot release un-acquired lock") self.__count = count = self.__count - 1 if not count: self.__owner = None self.__block.release() def __exit__(self, t, v, tb): self.release() # Internal methods used by condition variables def _acquire_restore(self, count_owner): count, owner = count_owner self.__block.acquire() self.__count = count self.__owner = owner def _release_save(self): count = self.__count self.__count = 0 owner = self.__owner self.__owner = None self.__block.release() return (count, owner) def _is_owned(self): return self.__owner == get_ident() class Condition(object): def __init__(self, lock=None): if lock is None: lock = RLock() self.__lock = lock # Export the lock's acquire() and release() methods self.acquire = lock.acquire self.release = lock.release # If the lock defines _release_save() and/or _acquire_restore(), # these override the default implementations (which just call # release() and acquire() on the lock). Ditto for _is_owned(). try: self._release_save = lock._release_save except AttributeError: pass try: self._acquire_restore = lock._acquire_restore except AttributeError: pass try: self._is_owned = lock._is_owned except AttributeError: pass self.__waiters = [] def __enter__(self): return self.__lock.__enter__() def __exit__(self, *args): return self.__lock.__exit__(*args) def __repr__(self): return "" % (self.__lock, len(self.__waiters)) def _release_save(self): self.__lock.release() # No state to save def _acquire_restore(self, x): self.__lock.acquire() # Ignore saved state def _is_owned(self): # Return True if lock is owned by current_thread. # This method is called only if __lock doesn't have _is_owned(). if self.__lock.acquire(0): self.__lock.release() return False else: return True def wait(self, timeout=None): if not self._is_owned(): raise RuntimeError("cannot wait on un-acquired lock") waiter = Lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() try: # restore state no matter what (e.g., KeyboardInterrupt) if timeout is None: waiter.acquire() else: # Balancing act: We can't afford a pure busy loop, so we # have to sleep; but if we sleep the whole timeout time, # we'll be unresponsive. The scheme here sleeps very # little at first, longer as time goes on, but never longer # than 20 times per second (or the timeout time remaining). endtime = _time() + timeout delay = 0.0005 # 500 us -> initial delay of 1 ms while True: gotit = waiter.acquire(0) if gotit: break remaining = endtime - _time() if remaining <= 0: break delay = min(delay * 2, remaining, .05) _sleep(delay) if not gotit: try: self.__waiters.remove(waiter) except ValueError: pass finally: self._acquire_restore(saved_state) def notify(self, n=1): if not self._is_owned(): raise RuntimeError("cannot notify on un-acquired lock") __waiters = self.__waiters waiters = __waiters[:n] if not waiters: return for waiter in waiters: waiter.release() try: __waiters.remove(waiter) except ValueError: pass def notify_all(self): self.notify(len(self.__waiters)) class Semaphore(object): # After Tim Peters' semaphore class, but not quite the same (no maximum) def __init__(self, value=1): if value < 0: raise ValueError("semaphore initial value must be >= 0") self.__cond = Condition(Lock()) self.__value = value def acquire(self, blocking=1): rc = False self.__cond.acquire() while self.__value == 0: if not blocking: break self.__cond.wait() else: self.__value = self.__value - 1 rc = True self.__cond.release() return rc __enter__ = acquire def release(self): self.__cond.acquire() self.__value = self.__value + 1 self.__cond.notify() self.__cond.release() def __exit__(self, t, v, tb): self.release() class BoundedSemaphore(Semaphore): """Semaphore that checks that # releases is <= # acquires""" def __init__(self, value=1): Semaphore.__init__(self, value) self._initial_value = value def release(self): if self.Semaphore__value >= self._initial_value: raise ValueError("Semaphore released too many times") return Semaphore.release(self) class Event(object): # After Tim Peters' event class (without is_posted()) def __init__(self): self.__cond = Condition(Lock()) self.__flag = False def _reset_internal_locks(self): # private! called by Thread._reset_internal_locks by _after_fork() self.__cond.__init__() def is_set(self): return self.__flag def set(self): self.__cond.acquire() try: self.__flag = True self.__cond.notify_all() finally: self.__cond.release() def clear(self): self.__cond.acquire() try: self.__flag = False finally: self.__cond.release() def wait(self, timeout=None): self.__cond.acquire() try: if not self.__flag: self.__cond.wait(timeout) return self.__flag finally: self.__cond.release() class Queue: """Create a queue object with a given maximum size. If maxsize is <= 0, the queue size is infinite. """ def __init__(self, maxsize=0): self.maxsize = maxsize self._init(maxsize) # mutex must be held whenever the queue is mutating. All methods # that acquire mutex must release it before returning. mutex # is shared between the three conditions, so acquiring and # releasing the conditions also acquires and releases mutex. self.mutex = Lock() # Notify not_empty whenever an item is added to the queue; a # thread waiting to get is notified then. self.not_empty = Condition(self.mutex) # Notify not_full whenever an item is removed from the queue; # a thread waiting to put is notified then. self.not_full = Condition(self.mutex) # Notify all_tasks_done whenever the number of unfinished tasks # drops to zero; thread waiting to join() is notified to resume self.all_tasks_done = Condition(self.mutex) self.unfinished_tasks = 0 def task_done(self): """Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises a ValueError if called more times than there were items placed in the queue. """ self.all_tasks_done.acquire() try: unfinished = self.unfinished_tasks - 1 if unfinished <= 0: if unfinished < 0: raise ValueError('task_done() called too many times') self.all_tasks_done.notify_all() self.unfinished_tasks = unfinished finally: self.all_tasks_done.release() def join(self): """Blocks until all items in the Queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. """ self.all_tasks_done.acquire() try: while self.unfinished_tasks: self.all_tasks_done.wait() finally: self.all_tasks_done.release() def qsize(self): """Return the approximate size of the queue (not reliable!).""" self.mutex.acquire() try: return self._qsize() finally: self.mutex.release() def empty(self): """Return True if the queue is empty, False otherwise (not reliable!).""" self.mutex.acquire() try: return not self._qsize() finally: self.mutex.release() def full(self): """Return True if the queue is full, False otherwise (not reliable!).""" self.mutex.acquire() try: if self.maxsize <= 0: return False if self.maxsize >= self._qsize(): return True finally: self.mutex.release() def put(self, item, block=True, timeout=None): """Put an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Full exception if no free slot was available within that time. Otherwise ('block' is false), put an item on the queue if a free slot is immediately available, else raise the Full exception ('timeout' is ignored in that case). """ self.not_full.acquire() try: if self.maxsize > 0: if not block: if self._qsize() >= self.maxsize: raise Full elif timeout is None: while self._qsize() >= self.maxsize: self.not_full.wait() elif timeout < 0: raise ValueError("'timeout' must be a positive number") else: endtime = _time() + timeout while self._qsize() >= self.maxsize: remaining = endtime - _time() if remaining <= 0.0: raise Full self.not_full.wait(remaining) self._put(item) self.unfinished_tasks += 1 self.not_empty.notify() finally: self.not_full.release() def put_nowait(self, item): """Put an item into the queue without blocking. Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception. """ return self.put(item, False) def get(self, block=True, timeout=None): """Remove and return an item from the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until an item is available. If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Empty exception if no item was available within that time. Otherwise ('block' is false), return an item if one is immediately available, else raise the Empty exception ('timeout' is ignored in that case). """ self.not_empty.acquire() try: if not block: if not self._qsize(): raise Empty elif timeout is None: while not self._qsize(): self.not_empty.wait() elif timeout < 0: raise ValueError("'timeout' must be a positive number") else: endtime = _time() + timeout while not self._qsize(): remaining = endtime - _time() if remaining <= 0.0: raise Empty self.not_empty.wait(remaining) item = self._get() self.not_full.notify() return item finally: self.not_empty.release() def get_nowait(self): """Remove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the Empty exception. """ return self.get(False) # Override these methods to implement other queue organizations # (e.g. stack or priority queue). # These will only be called with appropriate locks held # Initialize the queue representation def _init(self, maxsize): self.queue = deque() def _qsize(self, len=len): return len(self.queue) # Put a new item in the queue def _put(self, item): self.queue.append(item) # Get an item from the queue def _get(self): return self.queue.popleft() class PriorityQueue(Queue): '''Variant of Queue that retrieves open entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). ''' def _init(self, maxsize): self.queue = [] def _qsize(self, len=len): return len(self.queue) def _put(self, item, heappush=heapq.heappush): heappush(self.queue, item) def _get(self, heappop=heapq.heappop): return heappop(self.queue) class LifoQueue(Queue): '''Variant of Queue that retrieves most recently added entries first.''' def _init(self, maxsize): self.queue = [] def _qsize(self, len=len): return len(self.queue) def _put(self, item): self.queue.append(item) def _get(self): return self.queue.pop() gevent-1.1.0/gevent/_util_py2.py0000644000076500000000000000017212666555342017307 0ustar jmaddenwheel00000000000000# this produces syntax error on Python3 __all__ = ['reraise'] def reraise(type, value, tb): raise type, value, tb gevent-1.1.0/gevent/ares.pyx0000644000076500000000000003740112666555342016530 0ustar jmaddenwheel00000000000000# Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. cimport cares import sys from python cimport * from _socket import gaierror __all__ = ['channel'] cdef object string_types cdef object text_type if sys.version_info[0] >= 3: string_types = str, text_type = str else: string_types = __builtins__.basestring, text_type = __builtins__.unicode TIMEOUT = 1 DEF EV_READ = 1 DEF EV_WRITE = 2 cdef extern from "dnshelper.c": int AF_INET int AF_INET6 struct hostent: char* h_name int h_addrtype struct sockaddr_t "sockaddr": pass struct ares_channeldata: pass object parse_h_name(hostent*) object parse_h_aliases(hostent*) object parse_h_addr_list(hostent*) void* create_object_from_hostent(void*) # this imports _socket lazily object PyUnicode_FromString(char*) int PyTuple_Check(object) int PyArg_ParseTuple(object, char*, ...) except 0 struct sockaddr_in6: pass int gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, sockaddr_in6* sa6) void* malloc(int) void free(void*) void memset(void*, int, int) ARES_SUCCESS = cares.ARES_SUCCESS ARES_ENODATA = cares.ARES_ENODATA ARES_EFORMERR = cares.ARES_EFORMERR ARES_ESERVFAIL = cares.ARES_ESERVFAIL ARES_ENOTFOUND = cares.ARES_ENOTFOUND ARES_ENOTIMP = cares.ARES_ENOTIMP ARES_EREFUSED = cares.ARES_EREFUSED ARES_EBADQUERY = cares.ARES_EBADQUERY ARES_EBADNAME = cares.ARES_EBADNAME ARES_EBADFAMILY = cares.ARES_EBADFAMILY ARES_EBADRESP = cares.ARES_EBADRESP ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED ARES_ETIMEOUT = cares.ARES_ETIMEOUT ARES_EOF = cares.ARES_EOF ARES_EFILE = cares.ARES_EFILE ARES_ENOMEM = cares.ARES_ENOMEM ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION ARES_EBADSTR = cares.ARES_EBADSTR ARES_EBADFLAGS = cares.ARES_EBADFLAGS ARES_ENONAME = cares.ARES_ENONAME ARES_EBADHINTS = cares.ARES_EBADHINTS ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS ARES_ECANCELLED = cares.ARES_ECANCELLED ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP _ares_errors = dict([ (cares.ARES_SUCCESS, 'ARES_SUCCESS'), (cares.ARES_ENODATA, 'ARES_ENODATA'), (cares.ARES_EFORMERR, 'ARES_EFORMERR'), (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), (cares.ARES_EREFUSED, 'ARES_EREFUSED'), (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), (cares.ARES_EBADNAME, 'ARES_EBADNAME'), (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), (cares.ARES_EBADRESP, 'ARES_EBADRESP'), (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), (cares.ARES_EOF, 'ARES_EOF'), (cares.ARES_EFILE, 'ARES_EFILE'), (cares.ARES_ENOMEM, 'ARES_ENOMEM'), (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), (cares.ARES_EBADSTR, 'ARES_EBADSTR'), (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), (cares.ARES_ENONAME, 'ARES_ENONAME'), (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) # maps c-ares flag to _socket module flag _cares_flag_map = None cdef _prepare_cares_flag_map(): global _cares_flag_map import _socket _cares_flag_map = [ (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): if _cares_flag_map is None: _prepare_cares_flag_map() for socket_flag, cares_flag in _cares_flag_map: if socket_flag & flags: default |= cares_flag flags &= ~socket_flag if not flags: return default raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) cpdef strerror(code): return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) class InvalidIP(ValueError): pass cdef void gevent_sock_state_callback(void *data, int s, int read, int write): if not data: return cdef channel ch = data ch._sock_state_callback(s, read, write) cdef class result: cdef public object value cdef public object exception def __init__(self, object value=None, object exception=None): self.value = value self.exception = exception def __repr__(self): if self.exception is None: return '%s(%r)' % (self.__class__.__name__, self.value) elif self.value is None: return '%s(exception=%r)' % (self.__class__.__name__, self.exception) else: return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) # add repr_recursive precaution def successful(self): return self.exception is None def get(self): if self.exception is not None: raise self.exception return self.value class ares_host_result(tuple): def __new__(cls, family, iterable): cdef object self = tuple.__new__(cls, iterable) self.family = family return self def __getnewargs__(self): return (self.family, tuple(self)) cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): cdef channel channel cdef object callback channel, callback = arg Py_DECREF(arg) cdef object host_result try: if status or not host: callback(result(None, gaierror(status, strerror(status)))) else: try: host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) except: callback(result(None, sys.exc_info()[1])) else: callback(result(host_result)) except: channel.loop.handle_error(callback, *sys.exc_info()) cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): cdef channel channel cdef object callback channel, callback = arg Py_DECREF(arg) cdef object node cdef object service try: if status: callback(result(None, gaierror(status, strerror(status)))) else: if c_node: node = PyUnicode_FromString(c_node) else: node = None if c_service: service = PyUnicode_FromString(c_service) else: service = None callback(result((node, service))) except: channel.loop.handle_error(callback, *sys.exc_info()) cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: cdef public object loop cdef ares_channeldata* channel cdef public dict _watchers cdef public object _timer def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, udp_port=None, tcp_port=None, servers=None): cdef ares_channeldata* channel = NULL cdef cares.ares_options options memset(&options, 0, sizeof(cares.ares_options)) cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB options.sock_state_cb = gevent_sock_state_callback options.sock_state_cb_data = self if flags is not None: options.flags = int(flags) optmask |= cares.ARES_OPT_FLAGS if timeout is not None: options.timeout = int(float(timeout) * 1000) optmask |= cares.ARES_OPT_TIMEOUTMS if tries is not None: options.tries = int(tries) optmask |= cares.ARES_OPT_TRIES if ndots is not None: options.ndots = int(ndots) optmask |= cares.ARES_OPT_NDOTS if udp_port is not None: options.udp_port = int(udp_port) optmask |= cares.ARES_OPT_UDP_PORT if tcp_port is not None: options.tcp_port = int(tcp_port) optmask |= cares.ARES_OPT_TCP_PORT cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? if result: raise gaierror(result, strerror(result)) result = cares.ares_init_options(&channel, &options, optmask) if result: raise gaierror(result, strerror(result)) self._timer = loop.timer(TIMEOUT, TIMEOUT) self._watchers = {} self.channel = channel try: if servers is not None: self.set_servers(servers) self.loop = loop except: self.destroy() raise def __repr__(self): args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) return '<%s at 0x%x _timer=%r _watchers[%s]>' % args def destroy(self): if self.channel: # XXX ares_library_cleanup? cares.ares_destroy(self.channel) self.channel = NULL self._watchers.clear() self._timer.stop() self.loop = None def __dealloc__(self): if self.channel: # XXX ares_library_cleanup? cares.ares_destroy(self.channel) self.channel = NULL def set_servers(self, servers=None): if not self.channel: raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') if not servers: servers = [] if isinstance(servers, string_types): servers = servers.split(',') cdef int length = len(servers) cdef int result, index cdef char* string cdef cares.ares_addr_node* c_servers if length <= 0: result = cares.ares_set_servers(self.channel, NULL) else: c_servers = malloc(sizeof(cares.ares_addr_node) * length) if not c_servers: raise MemoryError try: index = 0 for server in servers: if isinstance(server, unicode): server = server.encode('ascii') string = server if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: c_servers[index].family = AF_INET elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: c_servers[index].family = AF_INET6 else: raise InvalidIP(repr(string)) c_servers[index].next = &c_servers[index] + 1 index += 1 if index >= length: break c_servers[length - 1].next = NULL index = cares.ares_set_servers(self.channel, c_servers) if index: raise ValueError(strerror(index)) finally: free(c_servers) # this crashes c-ares #def cancel(self): # cares.ares_cancel(self.channel) cdef _sock_state_callback(self, int socket, int read, int write): if not self.channel: return cdef object watcher = self._watchers.get(socket) cdef int events = 0 if read: events |= EV_READ if write: events |= EV_WRITE if watcher is None: if not events: return watcher = self.loop.io(socket, events) self._watchers[socket] = watcher elif events: if watcher.events == events: return watcher.stop() watcher.events = events else: watcher.stop() self._watchers.pop(socket, None) if not self._watchers: self._timer.stop() return watcher.start(self._process_fd, watcher, pass_events=True) self._timer.again(self._on_timer) def _on_timer(self): cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) def _process_fd(self, int events, object watcher): if not self.channel: return cdef int read_fd = watcher.fd cdef int write_fd = read_fd if not (events & EV_READ): read_fd = cares.ARES_SOCKET_BAD if not (events & EV_WRITE): write_fd = cares.ARES_SOCKET_BAD cares.ares_process_fd(self.channel, read_fd, write_fd) def gethostbyname(self, object callback, char* name, int family=AF_INET): if not self.channel: raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # note that for file lookups still AF_INET can be returned for AF_INET6 request cdef object arg = (self, callback) Py_INCREF(arg) cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) def gethostbyaddr(self, object callback, char* addr): if not self.channel: raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # will guess the family cdef char addr_packed[16] cdef int family cdef int length if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: family = AF_INET length = 4 elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: family = AF_INET6 length = 16 else: raise InvalidIP(repr(addr)) cdef object arg = (self, callback) Py_INCREF(arg) cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): if not self.channel: raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') cdef char* hostp = NULL cdef int port = 0 cdef int flowinfo = 0 cdef int scope_id = 0 cdef sockaddr_in6 sa6 if not PyTuple_Check(sockaddr): raise TypeError('expected a tuple, got %r' % (sockaddr, )) PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) if port < 0 or port > 65535: raise gaierror(-8, 'Invalid value for port: %r' % port) cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) if length <= 0: raise InvalidIP(repr(hostp)) cdef object arg = (self, callback) Py_INCREF(arg) cdef sockaddr_t* x = &sa6 cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) def getnameinfo(self, object callback, tuple sockaddr, int flags): return self._getnameinfo(callback, sockaddr, _convert_cares_flags(flags)) gevent-1.1.0/gevent/backdoor.py0000644000076500000000000001401512666555342017166 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2014, gevent contributors # Based on eventlet.backdoor Copyright (c) 2005-2006, Bob Ippolito """ Interactive greenlet-based network console that can be used in any process. The :class:`BackdoorServer` provides a REPL inside a running process. As long as the process is monkey-patched, the ``BackdoorServer`` can coexist with other elements of the process. .. seealso:: :class:`code.InteractiveConsole` """ from __future__ import print_function import sys from code import InteractiveConsole from gevent.greenlet import Greenlet from gevent.hub import getcurrent from gevent.server import StreamServer __all__ = ['BackdoorServer'] try: sys.ps1 except AttributeError: sys.ps1 = '>>> ' try: sys.ps2 except AttributeError: sys.ps2 = '... ' class _Greenlet_stdreplace(Greenlet): # A greenlet that replaces sys.std[in/out/err] while running. _fileobj = None def switch(self, *args, **kw): if self._fileobj is not None: self.switch_in() Greenlet.switch(self, *args, **kw) def switch_in(self): self.saved = sys.stdin, sys.stderr, sys.stdout sys.stdin = sys.stdout = sys.stderr = self._fileobj def switch_out(self): sys.stdin, sys.stderr, sys.stdout = self.saved self.saved = None def run(self): try: return Greenlet.run(self) finally: # XXX why is this necessary? self.switch_out() class BackdoorServer(StreamServer): """ Provide a backdoor to a program for debugging purposes. .. warning:: This backdoor provides no authentication and makes no attempt to limit what remote users can do. Anyone that can access the server can take any action that the running python process can. Thus, while you may bind to any interface, for security purposes it is recommended that you bind to one only accessible to the local machine, e.g., 127.0.0.1/localhost. Basic usage:: from gevent.backdoor import BackdoorServer server = BackdoorServer(('127.0.0.1', 5001), banner="Hello from gevent backdoor!", locals={'foo': "From defined scope!"}) server.serve_forever() In a another terminal, connect with...:: $ telnet 127.0.0.1 5001 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Hello from gevent backdoor! >> print(foo) From defined scope! """ def __init__(self, listener, locals=None, banner=None, **server_args): """ :keyword locals: If given, a dictionary of "builtin" values that will be available at the top-level. :keyword banner: If geven, a string that will be printed to each connecting user. """ StreamServer.__init__(self, listener, spawn=_Greenlet_stdreplace.spawn, **server_args) _locals = {'__doc__': None, '__name__': '__console__'} if locals: _locals.update(locals) self.locals = _locals self.banner = banner self.stderr = sys.stderr def _create_interactive_locals(self): # Create and return a *new* locals dictionary based on self.locals, # and set any new entries in it. (InteractiveConsole does not # copy its locals value) _locals = self.locals.copy() # __builtins__ may either be the __builtin__ module or # __builtin__.__dict__; in the latter case typing # locals() at the backdoor prompt spews out lots of # useless stuff try: import __builtin__ _locals["__builtins__"] = __builtin__ except ImportError: import builtins _locals["builtins"] = builtins _locals['__builtins__'] = builtins return _locals def handle(self, conn, address): """ Interact with one remote user. .. versionchanged:: 1.1b2 Each connection gets its own ``locals`` dictionary. Previously they were shared in a potentially unsafe manner. """ fobj = conn.makefile(mode="rw") fobj = _fileobject(conn, fobj, self.stderr) getcurrent()._fileobj = fobj getcurrent().switch_in() try: console = InteractiveConsole(self._create_interactive_locals()) console.interact(banner=self.banner) except SystemExit: # raised by quit() if hasattr(sys, 'exc_clear'): # py2 sys.exc_clear() finally: conn.close() fobj.close() class _fileobject(object): """ A file-like object that wraps the result of socket.makefile (composition instead of inheritance lets us work identically under CPython and PyPy). We write directly to the socket, avoiding the buffering that the text-oriented makefile would want to do (otherwise we'd be at the mercy of waiting on a flush() to get called for the remote user to see data); this beats putting the file in binary mode and translating everywhere with a non-default encoding. """ def __init__(self, sock, fobj, stderr): self._sock = sock self._fobj = fobj self.stderr = stderr def __getattr__(self, name): return getattr(self._fobj, name) def write(self, data): if not isinstance(data, bytes): data = data.encode('utf-8') self._sock.sendall(data) def isatty(self): return True def flush(self): pass def readline(self, *a): try: return self._fobj.readline(*a).replace("\r\n", "\n") except UnicodeError: # Typically, under python 3, a ^C on the other end return '' if __name__ == '__main__': if not sys.argv[1:]: print('USAGE: %s PORT [banner]' % sys.argv[0]) else: BackdoorServer(('127.0.0.1', int(sys.argv[1])), banner=(sys.argv[2] if len(sys.argv) > 2 else None), locals={'hello': 'world'}).serve_forever() gevent-1.1.0/gevent/baseserver.py0000644000076500000000000003404412666555342017547 0ustar jmaddenwheel00000000000000"""Base class for implementing servers""" # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. import sys import _socket import errno from gevent.greenlet import Greenlet from gevent.event import Event from gevent.hub import string_types, integer_types, get_hub, xrange __all__ = ['BaseServer'] # We define a helper function to handle closing the socket in # do_handle; We'd like to bind it to a kwarg to avoid *any* lookups at # all, but that's incompatible with the calling convention of # do_handle. On CPython, this is ~20% faster than creating and calling # a closure and ~10% faster than using a @staticmethod. (In theory, we # could create a closure only once in set_handle, to wrap self._handle, # but this is safer from a backwards compat standpoint.) # we also avoid unpacking the *args tuple when calling/spawning this object # for a tiny improvement (benchmark shows a wash) def _handle_and_close_when_done(handle, close, args_tuple): try: return handle(*args_tuple) finally: close(*args_tuple) class BaseServer(object): """ An abstract base class that implements some common functionality for the servers in gevent. :param listener: Either be an address that the server should bind on or a :class:`gevent.socket.socket` instance that is already bound (and put into listening mode in case of TCP socket). :keyword handle: If given, the request handler. The request handler can be defined in a few ways. Most commonly, subclasses will implement a ``handle`` method as an instance method. Alternatively, a function can be passed as the ``handle`` argument to the constructor. In either case, the handler can later be changed by calling :meth:`set_handle`. When the request handler returns, the socket used for the request will be closed. :keyword spawn: If provided, is called to create a new greenlet to run the handler. By default, :func:`gevent.spawn` is used (meaning there is no artificial limit on the number of concurrent requests). Possible values for *spawn*: - a :class:`gevent.pool.Pool` instance -- ``handle`` will be executed using :meth:`gevent.pool.Pool.spawn` only if the pool is not full. While it is full, no new connections are accepted; - :func:`gevent.spawn_raw` -- ``handle`` will be executed in a raw greenlet which has a little less overhead then :class:`gevent.Greenlet` instances spawned by default; - ``None`` -- ``handle`` will be executed right away, in the :class:`Hub` greenlet. ``handle`` cannot use any blocking functions as it would mean switching to the :class:`Hub`. - an integer -- a shortcut for ``gevent.pool.Pool(integer)`` .. versionchanged:: 1.1a1 When the *handle* function returns from processing a connection, the client socket will be closed. This resolves the non-deterministic closing of the socket, fixing ResourceWarnings under Python 3 and PyPy. """ #: the number of seconds to sleep in case there was an error in accept() call #: for consecutive errors the delay will double until it reaches max_delay #: when accept() finally succeeds the delay will be reset to min_delay again min_delay = 0.01 max_delay = 1 #: Sets the maximum number of consecutive accepts that a process may perform on #: a single wake up. High values give higher priority to high connection rates, #: while lower values give higher priority to already established connections. #: Default is 100. Note, that in case of multiple working processes on the same #: listening value, it should be set to a lower value. (pywsgi.WSGIServer sets it #: to 1 when environ["wsgi.multiprocess"] is true) max_accept = 100 _spawn = Greenlet.spawn #: the default timeout that we wait for the client connections to close in stop() stop_timeout = 1 fatal_errors = (errno.EBADF, errno.EINVAL, errno.ENOTSOCK) def __init__(self, listener, handle=None, spawn='default'): self._stop_event = Event() self._stop_event.set() self._watcher = None self._timer = None self.pool = None try: self.set_listener(listener) self.set_spawn(spawn) self.set_handle(handle) self.delay = self.min_delay self.loop = get_hub().loop if self.max_accept < 1: raise ValueError('max_accept must be positive int: %r' % (self.max_accept, )) except: self.close() raise def set_listener(self, listener): if hasattr(listener, 'accept'): if hasattr(listener, 'do_handshake'): raise TypeError('Expected a regular socket, not SSLSocket: %r' % (listener, )) self.family = listener.family self.address = listener.getsockname() self.socket = listener else: self.family, self.address = parse_address(listener) def set_spawn(self, spawn): if spawn == 'default': self.pool = None self._spawn = self._spawn elif hasattr(spawn, 'spawn'): self.pool = spawn self._spawn = spawn.spawn elif isinstance(spawn, integer_types): from gevent.pool import Pool self.pool = Pool(spawn) self._spawn = self.pool.spawn else: self.pool = None self._spawn = spawn if hasattr(self.pool, 'full'): self.full = self.pool.full if self.pool is not None: self.pool._semaphore.rawlink(self._start_accepting_if_started) def set_handle(self, handle): if handle is not None: self.handle = handle if hasattr(self, 'handle'): self._handle = self.handle else: raise TypeError("'handle' must be provided") def _start_accepting_if_started(self, _event=None): if self.started: self.start_accepting() def start_accepting(self): if self._watcher is None: # just stop watcher without creating a new one? self._watcher = self.loop.io(self.socket.fileno(), 1) self._watcher.start(self._do_read) def stop_accepting(self): if self._watcher is not None: self._watcher.stop() self._watcher = None if self._timer is not None: self._timer.stop() self._timer = None def do_handle(self, *args): spawn = self._spawn handle = self._handle close = self.do_close try: if spawn is None: _handle_and_close_when_done(handle, close, args) else: spawn(_handle_and_close_when_done, handle, close, args) except: close(*args) raise def do_close(self, *args): pass def _do_read(self): for _ in xrange(self.max_accept): if self.full(): self.stop_accepting() return try: args = self.do_read() self.delay = self.min_delay if not args: return except: self.loop.handle_error(self, *sys.exc_info()) ex = sys.exc_info()[1] if self.is_fatal_error(ex): self.close() sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex))) return if self.delay >= 0: self.stop_accepting() self._timer = self.loop.timer(self.delay) self._timer.start(self._start_accepting_if_started) self.delay = min(self.max_delay, self.delay * 2) break else: try: self.do_handle(*args) except: self.loop.handle_error((args[1:], self), *sys.exc_info()) if self.delay >= 0: self.stop_accepting() self._timer = self.loop.timer(self.delay) self._timer.start(self._start_accepting_if_started) self.delay = min(self.max_delay, self.delay * 2) break def full(self): return False def __repr__(self): return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo()) def __str__(self): return '<%s %s>' % (type(self).__name__, self._formatinfo()) def _formatinfo(self): if hasattr(self, 'socket'): try: fileno = self.socket.fileno() except Exception as ex: fileno = str(ex) result = 'fileno=%s ' % fileno else: result = '' try: if isinstance(self.address, tuple) and len(self.address) == 2: result += 'address=%s:%s' % self.address else: result += 'address=%s' % (self.address, ) except Exception as ex: result += str(ex) or '' handle = self.__dict__.get('handle') if handle is not None: fself = getattr(handle, '__self__', None) try: if fself is self: # Checks the __self__ of the handle in case it is a bound # method of self to prevent recursivly defined reprs. handle_repr = '' % ( self.__class__.__name__, handle.__name__, ) else: handle_repr = repr(handle) result += ' handle=' + handle_repr except Exception as ex: result += str(ex) or '' return result @property def server_host(self): """IP address that the server is bound to (string).""" if isinstance(self.address, tuple): return self.address[0] @property def server_port(self): """Port that the server is bound to (an integer).""" if isinstance(self.address, tuple): return self.address[1] def init_socket(self): """If the user initialized the server with an address rather than socket, then this function will create a socket, bind it and put it into listening mode. It is not supposed to be called by the user, it is called by :meth:`start` before starting the accept loop.""" pass @property def started(self): return not self._stop_event.is_set() def start(self): """Start accepting the connections. If an address was provided in the constructor, then also create a socket, bind it and put it into the listening mode. """ self.init_socket() self._stop_event.clear() try: self.start_accepting() except: self.close() raise def close(self): """Close the listener socket and stop accepting.""" self._stop_event.set() try: self.stop_accepting() finally: try: self.socket.close() except Exception: pass finally: self.__dict__.pop('socket', None) self.__dict__.pop('handle', None) self.__dict__.pop('_handle', None) self.__dict__.pop('_spawn', None) self.__dict__.pop('full', None) if self.pool is not None: self.pool._semaphore.unlink(self._start_accepting_if_started) @property def closed(self): return not hasattr(self, 'socket') def stop(self, timeout=None): """ Stop accepting the connections and close the listening socket. If the server uses a pool to spawn the requests, then :meth:`stop` also waits for all the handlers to exit. If there are still handlers executing after *timeout* has expired (default 1 second, :attr:`stop_timeout`), then the currently running handlers in the pool are killed. If the server does not use a pool, then this merely stops accepting connections; any spawned greenlets that are handling requests continue running until they naturally complete. """ self.close() if timeout is None: timeout = self.stop_timeout if self.pool: self.pool.join(timeout=timeout) self.pool.kill(block=True, timeout=1) def serve_forever(self, stop_timeout=None): """Start the server if it hasn't been already started and wait until it's stopped.""" # add test that serve_forever exists on stop() if not self.started: self.start() try: self._stop_event.wait() finally: Greenlet.spawn(self.stop, timeout=stop_timeout).join() def is_fatal_error(self, ex): return isinstance(ex, _socket.error) and ex.args[0] in self.fatal_errors def _extract_family(host): if host.startswith('[') and host.endswith(']'): host = host[1:-1] return _socket.AF_INET6, host return _socket.AF_INET, host def _parse_address(address): if isinstance(address, tuple): if ':' in address[0]: return _socket.AF_INET6, address return _socket.AF_INET, address elif isinstance(address, string_types): if ':' in address: host, port = address.rsplit(':', 1) family, host = _extract_family(host) if host == '*': host = '' return family, (host, int(port)) else: return _socket.AF_INET, ('', int(address)) elif isinstance(address, integer_types): return _socket.AF_INET, ('', int(address)) else: raise TypeError('Expected tuple or string, got %s' % type(address)) def parse_address(address): try: return _parse_address(address) except ValueError as ex: raise ValueError('Failed to parse address %r: %s' % (address, ex)) gevent-1.1.0/gevent/builtins.py0000644000076500000000000001053012666555342017231 0ustar jmaddenwheel00000000000000# Copyright (c) 2015 gevent contributors. See LICENSE for details. """gevent friendly implementations of builtin functions.""" from __future__ import absolute_import import imp # deprecated since 3.4; issues PendingDeprecationWarning in 3.5 import sys import weakref from gevent.lock import RLock # Normally we'd have the "expected" case inside the try # (Python 3, because Python 3 is the way forward). But # under Python 2, the popular `future` library *also* provides # a `builtins` module---which lacks the __import__ attribute. # So we test for the old, deprecated version first try: # Py2 import __builtin__ as builtins _allowed_module_name_types = (basestring,) __target__ = '__builtin__' except ImportError: import builtins _allowed_module_name_types = (str,) __target__ = 'builtins' _import = builtins.__import__ # We need to protect imports both across threads and across greenlets. # And the order matters. Note that under 3.4, the global import lock # and imp module are deprecated. It seems that in all Py3 versions, a # module lock is used such that this fix is not necessary. # We emulate the per-module locking system under Python 2 in order to # avoid issues acquiring locks in multiple-level-deep imports # that attempt to use the gevent blocking API at runtime; using one lock # could lead to a LoopExit error as a greenlet attempts to block on it while # it's already held by the main greenlet (issue #798). # We base this approach on a simplification of what `importlib._boonstrap` # does; notably, we don't check for deadlocks _g_import_locks = {} # name -> wref of RLock __lock_imports = True def __module_lock(name): # Return the lock for the given module, creating it if necessary. # It will be removed when no longer needed. # Nothing in this function yields, so we're multi-greenlet safe # (But not multi-threading safe.) # XXX: What about on PyPy, where the GC is asynchronous (not ref-counting)? # (Does it stop-the-world first?) lock = None try: lock = _g_import_locks[name]() except KeyError: pass if lock is None: lock = RLock() def cb(_): # We've seen a KeyError on PyPy on RPi2 _g_import_locks.pop(name, None) _g_import_locks[name] = weakref.ref(lock, cb) return lock def __import__(*args, **kwargs): """ __import__(name, globals=None, locals=None, fromlist=(), level=0) -> object Normally python protects imports against concurrency by doing some locking at the C level (at least, it does that in CPython). This function just wraps the normal __import__ functionality in a recursive lock, ensuring that we're protected against greenlet import concurrency as well. """ if len(args) > 0 and not issubclass(type(args[0]), _allowed_module_name_types): # if a builtin has been acquired as a bound instance method, # python knows not to pass 'self' when the method is called. # No such protection exists for monkey-patched builtins, # however, so this is necessary. args = args[1:] if not __lock_imports: return _import(*args, **kwargs) module_lock = __module_lock(args[0]) # Get a lock for the module name imp.acquire_lock() try: module_lock.acquire() try: result = _import(*args, **kwargs) finally: module_lock.release() finally: imp.release_lock() return result def _unlock_imports(): """ Internal function, called when gevent needs to perform imports lazily, but does not know the state of the system. It may be impossible to take the import lock because there are no other running greenlets, for example. This causes a monkey-patched __import__ to avoid taking any locks. until the corresponding call to lock_imports. This should only be done for limited amounts of time and when the set of imports is statically known to be "safe". """ global __lock_imports # This could easily become a list that we push/pop from or an integer # we increment if we need to do this recursively, but we shouldn't get # that complex. __lock_imports = False def _lock_imports(): global __lock_imports __lock_imports = True if sys.version_info[:2] >= (3, 3): __implements__ = [] else: __implements__ = ['__import__'] __all__ = __implements__ gevent-1.1.0/gevent/callbacks.c0000644000076500000000000001372412666555342017121 0ustar jmaddenwheel00000000000000/* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */ #ifdef Py_PYTHON_H static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context) { PyThreadState *tstate; PyObject *type, *value, *traceback, *result; tstate = PyThreadState_GET(); type = tstate->curexc_type; if (!type) return; value = tstate->curexc_value; traceback = tstate->curexc_traceback; if (!value) value = Py_None; if (!traceback) traceback = Py_None; Py_INCREF(type); Py_INCREF(value); Py_INCREF(traceback); PyErr_Clear(); result = ((struct __pyx_vtabstruct_6gevent_8corecext_loop *)loop->__pyx_vtab)->handle_error(loop, context, type, value, traceback, 0); if (result) { Py_DECREF(result); } else { PyErr_Print(); PyErr_Clear(); } Py_DECREF(type); Py_DECREF(value); Py_DECREF(traceback); } static CYTHON_INLINE void gevent_check_signals(struct PyGeventLoopObject* loop) { if (!ev_is_default_loop(loop->_ptr)) { /* only reporting signals on the default loop */ return; } PyErr_CheckSignals(); if (PyErr_Occurred()) gevent_handle_error(loop, Py_None); } #define GET_OBJECT(PY_TYPE, EV_PTR, MEMBER) \ ((struct PY_TYPE *)(((char *)EV_PTR) - offsetof(struct PY_TYPE, MEMBER))) #ifdef WITH_THREAD #define GIL_DECLARE PyGILState_STATE ___save #define GIL_ENSURE ___save = PyGILState_Ensure(); #define GIL_RELEASE PyGILState_Release(___save); #else #define GIL_DECLARE #define GIL_ENSURE #define GIL_RELEASE #endif static void gevent_stop(PyObject* watcher, struct PyGeventLoopObject* loop) { PyObject *result, *method; int error; error = 1; method = PyObject_GetAttrString(watcher, "stop"); if (method) { result = PyObject_Call(method, __pyx_empty_tuple, NULL); if (result) { Py_DECREF(result); error = 0; } Py_DECREF(method); } if (error) { gevent_handle_error(loop, watcher); } } static void gevent_callback(struct PyGeventLoopObject* loop, PyObject* callback, PyObject* args, PyObject* watcher, void *c_watcher, int revents) { GIL_DECLARE; PyObject *result, *py_events; long length; py_events = 0; GIL_ENSURE; Py_INCREF(loop); Py_INCREF(callback); Py_INCREF(args); Py_INCREF(watcher); gevent_check_signals(loop); if (args == Py_None) { args = __pyx_empty_tuple; } length = PyTuple_Size(args); if (length < 0) { gevent_handle_error(loop, watcher); goto end; } if (length > 0 && PyTuple_GET_ITEM(args, 0) == GEVENT_CORE_EVENTS) { py_events = PyInt_FromLong(revents); if (!py_events) { gevent_handle_error(loop, watcher); goto end; } PyTuple_SET_ITEM(args, 0, py_events); } else { py_events = NULL; } result = PyObject_Call(callback, args, NULL); if (result) { Py_DECREF(result); } else { gevent_handle_error(loop, watcher); if (revents & (EV_READ|EV_WRITE)) { /* io watcher: not stopping it may cause the failing callback to be called repeatedly */ gevent_stop(watcher, loop); goto end; } } if (!ev_is_active(c_watcher)) { /* Watcher was stopped, maybe by libev. Let's call stop() to clean up * 'callback' and 'args' properties, do Py_DECREF() and ev_ref() if necessary. * BTW, we don't need to check for EV_ERROR, because libev stops the watcher in that case. */ gevent_stop(watcher, loop); } end: if (py_events) { Py_DECREF(py_events); PyTuple_SET_ITEM(args, 0, GEVENT_CORE_EVENTS); } Py_DECREF(watcher); Py_DECREF(args); Py_DECREF(callback); Py_DECREF(loop); GIL_RELEASE; } static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb) { /* no need for GIL here because it is only called from run_callbacks which already has GIL */ PyObject *result, *callback, *args; if (!loop || !cb) return; callback = cb->callback; args = cb->args; if (!callback || !args) return; if (callback == Py_None || args == Py_None) return; Py_INCREF(loop); Py_INCREF(callback); Py_INCREF(args); Py_INCREF(Py_None); Py_DECREF(cb->callback); cb->callback = Py_None; result = PyObject_Call(callback, args, NULL); if (result) { Py_DECREF(result); } else { gevent_handle_error(loop, (PyObject*)cb); } Py_INCREF(Py_None); Py_DECREF(cb->args); cb->args = Py_None; Py_DECREF(callback); Py_DECREF(args); Py_DECREF(loop); } #undef DEFINE_CALLBACK #define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ static void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \ struct PyGevent##WATCHER_TYPE##Object* watcher = GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \ gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \ } DEFINE_CALLBACKS static void gevent_run_callbacks(struct ev_loop *_loop, void *watcher, int revents) { struct PyGeventLoopObject* loop; PyObject *result; GIL_DECLARE; GIL_ENSURE; loop = GET_OBJECT(PyGeventLoopObject, watcher, _prepare); Py_INCREF(loop); gevent_check_signals(loop); result = ((struct __pyx_vtabstruct_6gevent_8corecext_loop *)loop->__pyx_vtab)->_run_callbacks(loop); if (result) { Py_DECREF(result); } else { PyErr_Print(); PyErr_Clear(); } Py_DECREF(loop); GIL_RELEASE; } #if defined(_WIN32) static void gevent_periodic_signal_check(struct ev_loop *_loop, void *watcher, int revents) { GIL_DECLARE; GIL_ENSURE; gevent_check_signals(GET_OBJECT(PyGeventLoopObject, watcher, _periodic_signal_checker)); GIL_RELEASE; } #endif /* _WIN32 */ #endif /* Py_PYTHON_H */ gevent-1.1.0/gevent/callbacks.h0000644000076500000000000000231512666555342017120 0ustar jmaddenwheel00000000000000#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ static void gevent_callback_##WATCHER_LC(struct ev_loop *, void *, int); #define DEFINE_CALLBACKS0 \ DEFINE_CALLBACK(io, IO); \ DEFINE_CALLBACK(timer, Timer); \ DEFINE_CALLBACK(signal, Signal); \ DEFINE_CALLBACK(idle, Idle); \ DEFINE_CALLBACK(prepare, Prepare); \ DEFINE_CALLBACK(check, Check); \ DEFINE_CALLBACK(fork, Fork); \ DEFINE_CALLBACK(async, Async); \ DEFINE_CALLBACK(stat, Stat); #ifndef _WIN32 #define DEFINE_CALLBACKS \ DEFINE_CALLBACKS0 \ DEFINE_CALLBACK(child, Child) #else #define DEFINE_CALLBACKS DEFINE_CALLBACKS0 #endif DEFINE_CALLBACKS static void gevent_run_callbacks(struct ev_loop *, void *, int); struct PyGeventLoopObject; static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context); struct PyGeventCallbackObject; static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb); #if defined(_WIN32) static void gevent_periodic_signal_check(struct ev_loop *, void *, int); #endif static void gevent_noop(struct ev_loop *_loop, void *watcher, int revents) { } gevent-1.1.0/gevent/cares.pxd0000644000076500000000000000532212666555342016643 0ustar jmaddenwheel00000000000000cdef extern from "ares.h": struct ares_options: int flags void* sock_state_cb void* sock_state_cb_data int timeout int tries int ndots unsigned short udp_port unsigned short tcp_port char **domains int ndomains char* lookups int ARES_OPT_FLAGS int ARES_OPT_SOCK_STATE_CB int ARES_OPT_TIMEOUTMS int ARES_OPT_TRIES int ARES_OPT_NDOTS int ARES_OPT_TCP_PORT int ARES_OPT_UDP_PORT int ARES_OPT_SERVERS int ARES_OPT_DOMAINS int ARES_OPT_LOOKUPS int ARES_FLAG_USEVC int ARES_FLAG_PRIMARY int ARES_FLAG_IGNTC int ARES_FLAG_NORECURSE int ARES_FLAG_STAYOPEN int ARES_FLAG_NOSEARCH int ARES_FLAG_NOALIASES int ARES_FLAG_NOCHECKRESP int ARES_LIB_INIT_ALL int ARES_SOCKET_BAD int ARES_SUCCESS int ARES_ENODATA int ARES_EFORMERR int ARES_ESERVFAIL int ARES_ENOTFOUND int ARES_ENOTIMP int ARES_EREFUSED int ARES_EBADQUERY int ARES_EBADNAME int ARES_EBADFAMILY int ARES_EBADRESP int ARES_ECONNREFUSED int ARES_ETIMEOUT int ARES_EOF int ARES_EFILE int ARES_ENOMEM int ARES_EDESTRUCTION int ARES_EBADSTR int ARES_EBADFLAGS int ARES_ENONAME int ARES_EBADHINTS int ARES_ENOTINITIALIZED int ARES_ELOADIPHLPAPI int ARES_EADDRGETNETWORKPARAMS int ARES_ECANCELLED int ARES_NI_NOFQDN int ARES_NI_NUMERICHOST int ARES_NI_NAMEREQD int ARES_NI_NUMERICSERV int ARES_NI_DGRAM int ARES_NI_TCP int ARES_NI_UDP int ARES_NI_SCTP int ARES_NI_DCCP int ARES_NI_NUMERICSCOPE int ARES_NI_LOOKUPHOST int ARES_NI_LOOKUPSERVICE int ares_library_init(int flags) void ares_library_cleanup() int ares_init_options(void *channelptr, ares_options *options, int) int ares_init(void *channelptr) void ares_destroy(void *channelptr) void ares_gethostbyname(void* channel, char *name, int family, void* callback, void *arg) void ares_gethostbyaddr(void* channel, void *addr, int addrlen, int family, void* callback, void *arg) void ares_process_fd(void* channel, int read_fd, int write_fd) char* ares_strerror(int code) void ares_cancel(void* channel) void ares_getnameinfo(void* channel, void* sa, int salen, int flags, void* callback, void *arg) struct in_addr: pass struct ares_in6_addr: pass struct addr_union: in_addr addr4 ares_in6_addr addr6 struct ares_addr_node: ares_addr_node *next int family addr_union addr int ares_set_servers(void* channel, ares_addr_node *servers) cdef extern from "cares_pton.h": int ares_inet_pton(int af, char *src, void *dst) gevent-1.1.0/gevent/cares_ntop.h0000644000076500000000000000023112666555342017331 0ustar jmaddenwheel00000000000000#ifdef CARES_EMBED #include "ares_setup.h" #include "inet_ntop.h" #else #include #define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z) #endif gevent-1.1.0/gevent/cares_pton.h0000644000076500000000000000032412666555342017334 0ustar jmaddenwheel00000000000000#ifdef CARES_EMBED #include "ares_setup.h" #include "inet_net_pton.h" #else #include #define ares_inet_pton(x,y,z) inet_pton(x,y,z) #define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) #endif gevent-1.1.0/gevent/core.py0000644000076500000000000000077312666555342016340 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2015 Denis Bilenko and gevent contributors. See LICENSE for details. from __future__ import absolute_import import os try: if os.environ.get('GEVENT_CORE_CFFI_ONLY'): raise ImportError("Not attempting corecext") from gevent import corecext as _core except ImportError: # CFFI/PyPy from gevent import corecffi as _core for item in dir(_core): if item.startswith('__'): continue globals()[item] = getattr(_core, item) __all__ = _core.__all__ gevent-1.1.0/gevent/corecext.ppyx0000644000076500000000000011275212666555342017575 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. cimport cython cimport libev from python cimport * # Work around lack of absolute_import in Cython # Note for PY3: not doing so will leave reference to locals() on import # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) sys = __import__('sys', level=0) os = __import__('os', level=0) traceback = __import__('traceback', level=0) signalmodule = __import__('signal', level=0) __all__ = ['get_version', 'get_header_version', 'supported_backends', 'recommended_backends', 'embeddable_backends', 'time', 'loop'] cdef tuple integer_types if sys.version_info[0] >= 3: integer_types = int, else: integer_types = (int, long) cdef extern from "callbacks.h": void gevent_callback_io(libev.ev_loop, void*, int) void gevent_callback_timer(libev.ev_loop, void*, int) void gevent_callback_signal(libev.ev_loop, void*, int) void gevent_callback_idle(libev.ev_loop, void*, int) void gevent_callback_prepare(libev.ev_loop, void*, int) void gevent_callback_check(libev.ev_loop, void*, int) void gevent_callback_fork(libev.ev_loop, void*, int) void gevent_callback_async(libev.ev_loop, void*, int) void gevent_callback_child(libev.ev_loop, void*, int) void gevent_callback_stat(libev.ev_loop, void*, int) void gevent_run_callbacks(libev.ev_loop, void*, int) void gevent_periodic_signal_check(libev.ev_loop, void*, int) void gevent_call(loop, callback) void gevent_noop(libev.ev_loop, void*, int) cdef extern from *: int errno cdef extern from "stathelper.c": object _pystat_fromstructstat(void*) UNDEF = libev.EV_UNDEF NONE = libev.EV_NONE READ = libev.EV_READ WRITE = libev.EV_WRITE TIMER = libev.EV_TIMER PERIODIC = libev.EV_PERIODIC SIGNAL = libev.EV_SIGNAL CHILD = libev.EV_CHILD STAT = libev.EV_STAT IDLE = libev.EV_IDLE PREPARE = libev.EV_PREPARE CHECK = libev.EV_CHECK EMBED = libev.EV_EMBED FORK = libev.EV_FORK CLEANUP = libev.EV_CLEANUP ASYNC = libev.EV_ASYNC CUSTOM = libev.EV_CUSTOM ERROR = libev.EV_ERROR READWRITE = libev.EV_READ | libev.EV_WRITE MINPRI = libev.EV_MINPRI MAXPRI = libev.EV_MAXPRI BACKEND_PORT = libev.EVBACKEND_PORT BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE BACKEND_EPOLL = libev.EVBACKEND_EPOLL BACKEND_POLL = libev.EVBACKEND_POLL BACKEND_SELECT = libev.EVBACKEND_SELECT FORKCHECK = libev.EVFLAG_FORKCHECK NOINOTIFY = libev.EVFLAG_NOINOTIFY SIGNALFD = libev.EVFLAG_SIGNALFD NOSIGMASK = libev.EVFLAG_NOSIGMASK @cython.internal cdef class _EVENTSType: def __repr__(self): return 'gevent.core.EVENTS' cdef public object GEVENT_CORE_EVENTS = _EVENTSType() EVENTS = GEVENT_CORE_EVENTS def get_version(): return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) def get_header_version(): return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) # This list backends in the order they are actually tried by libev _flags = [(libev.EVBACKEND_PORT, 'port'), (libev.EVBACKEND_KQUEUE, 'kqueue'), (libev.EVBACKEND_EPOLL, 'epoll'), (libev.EVBACKEND_POLL, 'poll'), (libev.EVBACKEND_SELECT, 'select'), (libev.EVFLAG_NOENV, 'noenv'), (libev.EVFLAG_FORKCHECK, 'forkcheck'), (libev.EVFLAG_NOINOTIFY, 'noinotify'), (libev.EVFLAG_SIGNALFD, 'signalfd'), (libev.EVFLAG_NOSIGMASK, 'nosigmask')] _flags_str2int = dict((string, flag) for (flag, string) in _flags) _events = [(libev.EV_READ, 'READ'), (libev.EV_WRITE, 'WRITE'), (libev.EV__IOFDSET, '_IOFDSET'), (libev.EV_PERIODIC, 'PERIODIC'), (libev.EV_SIGNAL, 'SIGNAL'), (libev.EV_CHILD, 'CHILD'), (libev.EV_STAT, 'STAT'), (libev.EV_IDLE, 'IDLE'), (libev.EV_PREPARE, 'PREPARE'), (libev.EV_CHECK, 'CHECK'), (libev.EV_EMBED, 'EMBED'), (libev.EV_FORK, 'FORK'), (libev.EV_CLEANUP, 'CLEANUP'), (libev.EV_ASYNC, 'ASYNC'), (libev.EV_CUSTOM, 'CUSTOM'), (libev.EV_ERROR, 'ERROR')] cpdef _flags_to_list(unsigned int flags): cdef list result = [] for code, value in _flags: if flags & code: result.append(value) flags &= ~code if not flags: break if flags: result.append(flags) return result if sys.version_info[0] >= 3: basestring = (bytes, str) else: basestring = __builtins__.basestring cpdef unsigned int _flags_to_int(object flags) except? -1: # Note, that order does not matter, libev has its own predefined order if not flags: return 0 if isinstance(flags, integer_types): return flags cdef unsigned int result = 0 try: if isinstance(flags, basestring): flags = flags.split(',') for value in flags: value = value.strip().lower() if value: result |= _flags_str2int[value] except KeyError as ex: raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) return result cdef str _str_hex(object flag): if isinstance(flag, integer_types): return hex(flag) return str(flag) cpdef _check_flags(unsigned int flags): cdef list as_list flags &= libev.EVBACKEND_MASK if not flags: return if not (flags & libev.EVBACKEND_ALL): raise ValueError('Invalid value for backend: 0x%x' % flags) if not (flags & libev.ev_supported_backends()): as_list = [_str_hex(x) for x in _flags_to_list(flags)] raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) cpdef _events_to_str(int events): cdef list result = [] cdef int c_flag for (flag, string) in _events: c_flag = flag if events & c_flag: result.append(string) events = events & (~c_flag) if not events: break if events: result.append(hex(events)) return '|'.join(result) def supported_backends(): return _flags_to_list(libev.ev_supported_backends()) def recommended_backends(): return _flags_to_list(libev.ev_recommended_backends()) def embeddable_backends(): return _flags_to_list(libev.ev_embeddable_backends()) def time(): return libev.ev_time() #define LOOP_PROPERTY(NAME) property NAME: \ \ def __get__(self): \ CHECK_LOOP3(self) \ return self._ptr.NAME cdef bint _default_loop_destroyed = False #define CHECK_LOOP2(LOOP) \ if not LOOP._ptr: \ raise ValueError('operation on destroyed loop') #define CHECK_LOOP3(LOOP) \ if not LOOP._ptr: \ raise ValueError('operation on destroyed loop') cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: cdef libev.ev_loop* _ptr cdef public object error_handler cdef libev.ev_prepare _prepare cdef public list _callbacks cdef libev.ev_timer _timer0 #ifdef _WIN32 cdef libev.ev_timer _periodic_signal_checker #endif def __init__(self, object flags=None, object default=None, size_t ptr=0): cdef unsigned int c_flags cdef object old_handler = None libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) #ifdef _WIN32 libev.ev_timer_init(&self._periodic_signal_checker, gevent_periodic_signal_check, 0.3, 0.3) #endif libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) if ptr: self._ptr = ptr else: c_flags = _flags_to_int(flags) _check_flags(c_flags) c_flags |= libev.EVFLAG_NOENV c_flags |= libev.EVFLAG_FORKCHECK if default is None: default = True if _default_loop_destroyed: default = False if default: self._ptr = libev.gevent_ev_default_loop(c_flags) if not self._ptr: raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) #ifdef _WIN32 libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) libev.ev_unref(self._ptr) #endif else: self._ptr = libev.ev_loop_new(c_flags) if not self._ptr: raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) if default or __SYSERR_CALLBACK is None: set_syserr_cb(self._handle_syserr) libev.ev_prepare_start(self._ptr, &self._prepare) libev.ev_unref(self._ptr) self._callbacks = [] cdef _run_callbacks(self): cdef callback cb cdef object callbacks cdef int count = 1000 libev.ev_timer_stop(self._ptr, &self._timer0) while self._callbacks and count > 0: callbacks = self._callbacks self._callbacks = [] for cb in callbacks: libev.ev_unref(self._ptr) gevent_call(self, cb) count -= 1 if self._callbacks: libev.ev_timer_start(self._ptr, &self._timer0) def _stop_watchers(self): if libev.ev_is_active(&self._prepare): libev.ev_ref(self._ptr) libev.ev_prepare_stop(self._ptr, &self._prepare) #ifdef _WIN32 if libev.ev_is_active(&self._periodic_signal_checker): libev.ev_ref(self._ptr) libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) #endif def destroy(self): global _default_loop_destroyed if self._ptr: self._stop_watchers() if __SYSERR_CALLBACK == self._handle_syserr: set_syserr_cb(None) if libev.ev_is_default_loop(self._ptr): _default_loop_destroyed = True libev.ev_loop_destroy(self._ptr) self._ptr = NULL def __dealloc__(self): if self._ptr: self._stop_watchers() if not libev.ev_is_default_loop(self._ptr): libev.ev_loop_destroy(self._ptr) self._ptr = NULL property ptr: def __get__(self): return self._ptr property WatcherType: def __get__(self): return watcher property MAXPRI: def __get__(self): return libev.EV_MAXPRI property MINPRI: def __get__(self): return libev.EV_MINPRI def _handle_syserr(self, message, errno): if sys.version_info[0] >= 3: message = message.decode() self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) cpdef handle_error(self, context, type, value, tb): cdef object handle_error cdef object error_handler = self.error_handler if error_handler is not None: # we do want to do getattr every time so that setting Hub.handle_error property just works handle_error = getattr(error_handler, 'handle_error', error_handler) handle_error(context, type, value, tb) else: self._default_handle_error(context, type, value, tb) cpdef _default_handle_error(self, context, type, value, tb): # note: Hub sets its own error handler so this is not used by gevent # this is here to make core.loop usable without the rest of gevent traceback.print_exception(type, value, tb) if self._ptr: libev.ev_break(self._ptr, libev.EVBREAK_ONE) def run(self, nowait=False, once=False): CHECK_LOOP2(self) cdef unsigned int flags = 0 if nowait: flags |= libev.EVRUN_NOWAIT if once: flags |= libev.EVRUN_ONCE with nogil: libev.ev_run(self._ptr, flags) def reinit(self): if self._ptr: libev.ev_loop_fork(self._ptr) def ref(self): CHECK_LOOP2(self) libev.ev_ref(self._ptr) def unref(self): CHECK_LOOP2(self) libev.ev_unref(self._ptr) def break_(self, int how=libev.EVBREAK_ONE): CHECK_LOOP2(self) libev.ev_break(self._ptr, how) def verify(self): CHECK_LOOP2(self) libev.ev_verify(self._ptr) def now(self): CHECK_LOOP2(self) return libev.ev_now(self._ptr) def update(self): CHECK_LOOP2(self) libev.ev_now_update(self._ptr) def __repr__(self): return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) property default: def __get__(self): CHECK_LOOP3(self) return True if libev.ev_is_default_loop(self._ptr) else False property iteration: def __get__(self): CHECK_LOOP3(self) return libev.ev_iteration(self._ptr) property depth: def __get__(self): CHECK_LOOP3(self) return libev.ev_depth(self._ptr) property backend_int: def __get__(self): CHECK_LOOP3(self) return libev.ev_backend(self._ptr) property backend: def __get__(self): CHECK_LOOP3(self) cdef unsigned int backend = libev.ev_backend(self._ptr) for key, value in _flags: if key == backend: return value return backend property pendingcnt: def __get__(self): CHECK_LOOP3(self) return libev.ev_pending_count(self._ptr) #ifdef _WIN32 def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): return io(self, fd, events, ref, priority) #else def io(self, int fd, int events, ref=True, priority=None): return io(self, fd, events, ref, priority) #endif def timer(self, double after, double repeat=0.0, ref=True, priority=None): return timer(self, after, repeat, ref, priority) def signal(self, int signum, ref=True, priority=None): return signal(self, signum, ref, priority) def idle(self, ref=True, priority=None): return idle(self, ref, priority) def prepare(self, ref=True, priority=None): return prepare(self, ref, priority) def check(self, ref=True, priority=None): return check(self, ref, priority) def fork(self, ref=True, priority=None): return fork(self, ref, priority) def async(self, ref=True, priority=None): return async(self, ref, priority) #ifdef _WIN32 #else def child(self, int pid, bint trace=0, ref=True): return child(self, pid, trace, ref) def install_sigchld(self): libev.gevent_install_sigchld_handler() #endif def stat(self, str path, float interval=0.0, ref=True, priority=None): return stat(self, path, interval, ref, priority) def run_callback(self, func, *args): CHECK_LOOP2(self) cdef callback cb = callback(func, args) self._callbacks.append(cb) libev.ev_ref(self._ptr) return cb def _format(self): if not self._ptr: return 'destroyed' cdef object msg = self.backend if self.default: msg += ' default' msg += ' pending=%s' % self.pendingcnt #ifdef LIBEV_EMBED msg += self._format_details() #endif return msg #ifdef LIBEV_EMBED def _format_details(self): cdef str msg = '' cdef object fileno = self.fileno() cdef object sigfd = None cdef object activecnt = None try: sigfd = self.sigfd except AttributeError: sigfd = None try: activecnt = self.activecnt except AttributeError: pass if activecnt is not None: msg += ' ref=' + repr(activecnt) if fileno is not None: msg += ' fileno=' + repr(fileno) if sigfd is not None and sigfd != -1: msg += ' sigfd=' + repr(sigfd) return msg def fileno(self): cdef int fd if self._ptr: fd = self._ptr.backend_fd if fd >= 0: return fd LOOP_PROPERTY(activecnt) LOOP_PROPERTY(sig_pending) #if EV_USE_SIGNALFD LOOP_PROPERTY(sigfd) #endif property origflags: def __get__(self): CHECK_LOOP3(self) return _flags_to_list(self._ptr.origflags) property origflags_int: def __get__(self): CHECK_LOOP3(self) return self._ptr.origflags #endif cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: cdef public object callback cdef public tuple args def __init__(self, callback, args): self.callback = callback self.args = args def stop(self): self.callback = None self.args = None # Note, that __nonzero__ and pending are different # nonzero is used in contexts where we need to know whether to schedule another callback, # so it's true if it's pending or currently running # 'pending' has the same meaning as libev watchers: it is cleared before entering callback def __nonzero__(self): # it's nonzero if it's pending or currently executing return self.args is not None property pending: def __get__(self): return self.callback is not None def __repr__(self): if Py_ReprEnter(self) != 0: return "<...>" try: format = self._format() result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) if self.callback is None and self.args is None: result += " stopped" return result + ">" finally: Py_ReprLeave(self) def _format(self): return '' #define PYTHON_INCREF if not self._flags & 1: \ Py_INCREF(self) \ self._flags |= 1 #define LIBEV_UNREF if self._flags & 6 == 4: \ libev.ev_unref(self.loop._ptr) \ self._flags |= 2 # about readonly _flags attribute: # bit #1 set if object owns Python reference to itself (Py_INCREF was called and we must call Py_DECREF later) # bit #2 set if ev_unref() was called and we must call ev_ref() later # bit #3 set if user wants to call ev_unref() before start() #define WATCHER_BASE(TYPE) \ cdef public loop loop \ cdef object _callback \ cdef public tuple args \ cdef readonly int _flags \ cdef libev.ev_##TYPE _watcher \ \ property ref: \ \ def __get__(self): \ return False if self._flags & 4 else True \ \ def __set__(self, object value): \ CHECK_LOOP3(self.loop) \ if value: \ if not self._flags & 4: \ return # ref is already True \ if self._flags & 2: # ev_unref was called, undo \ libev.ev_ref(self.loop._ptr) \ self._flags &= ~6 # do not want unref, no outstanding unref \ else: \ if self._flags & 4: \ return # ref is already False \ self._flags |= 4 \ if not self._flags & 2 and libev.ev_is_active(&self._watcher): \ libev.ev_unref(self.loop._ptr) \ self._flags |= 2 \ \ property callback: \ \ def __get__(self): \ return self._callback \ \ def __set__(self, object callback): \ if not PyCallable_Check(callback) and callback is not None: \ raise TypeError("Expected callable, not %r" % (callback, )) \ self._callback = callback \ \ def stop(self): \ CHECK_LOOP2(self.loop) \ if self._flags & 2: \ libev.ev_ref(self.loop._ptr) \ self._flags &= ~2 \ libev.ev_##TYPE##_stop(self.loop._ptr, &self._watcher) \ self._callback = None \ self.args = None \ if self._flags & 1: \ Py_DECREF(self) \ self._flags &= ~1 \ \ property priority: \ \ def __get__(self): \ return libev.ev_priority(&self._watcher) \ \ def __set__(self, int priority): \ if libev.ev_is_active(&self._watcher): \ raise AttributeError("Cannot set priority of an active watcher") \ libev.ev_set_priority(&self._watcher, priority) \ \ def feed(self, int revents, object callback, *args): \ CHECK_LOOP2(self.loop) \ self.callback = callback \ self.args = args \ LIBEV_UNREF \ libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \ PYTHON_INCREF #define ACTIVE property active: \ \ def __get__(self): \ return True if libev.ev_is_active(&self._watcher) else False #define START(TYPE) def start(self, object callback, *args): \ CHECK_LOOP2(self.loop) \ if callback is None: \ raise TypeError('callback must be callable, not None') \ self.callback = callback \ self.args = args \ LIBEV_UNREF \ libev.ev_##TYPE##_start(self.loop._ptr, &self._watcher) \ PYTHON_INCREF #define PENDING \ property pending: \ \ def __get__(self): \ return True if libev.ev_is_pending(&self._watcher) else False #define WATCHER(TYPE) WATCHER_BASE(TYPE) \ \ START(TYPE) \ \ ACTIVE \ \ PENDING #define COMMA , #define INIT(TYPE, ARGS_INITIALIZERS, ARGS) \ def __init__(self, loop loop ARGS_INITIALIZERS, ref=True, priority=None): \ libev.ev_##TYPE##_init(&self._watcher, gevent_callback_##TYPE ARGS) \ self.loop = loop \ if ref: \ self._flags = 0 \ else: \ self._flags = 4 \ if priority is not None: \ libev.ev_set_priority(&self._watcher, priority) cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: """Abstract base class for all the watchers""" def __repr__(self): if Py_ReprEnter(self) != 0: return "<...>" try: format = self._format() result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) if self.active: result += " active" if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) return result + ">" finally: Py_ReprLeave(self) def _format(self): return '' cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: WATCHER_BASE(io) def start(self, object callback, *args, pass_events=False): CHECK_LOOP2(self.loop) if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback if pass_events: self.args = (GEVENT_CORE_EVENTS, ) + args else: self.args = args LIBEV_UNREF libev.ev_io_start(self.loop._ptr, &self._watcher) PYTHON_INCREF ACTIVE PENDING #ifdef _WIN32 def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): raise ValueError('illegal event mask: %r' % events) cdef int vfd = libev.vfd_open(fd) libev.vfd_free(self._watcher.fd) libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) #else def __init__(self, loop loop, int fd, int events, ref=True, priority=None): if fd < 0: raise ValueError('fd must be non-negative: %r' % fd) if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): raise ValueError('illegal event mask: %r' % events) libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) #endif property fd: def __get__(self): return libev.vfd_get(self._watcher.fd) def __set__(self, long fd): if libev.ev_is_active(&self._watcher): raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") cdef int vfd = libev.vfd_open(fd) libev.vfd_free(self._watcher.fd) libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, self._watcher.events) property events: def __get__(self): return self._watcher.events def __set__(self, int events): if libev.ev_is_active(&self._watcher): raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) property events_str: def __get__(self): return _events_to_str(self._watcher.events) def _format(self): return ' fd=%s events=%s' % (self.fd, self.events_str) #ifdef _WIN32 def __cinit__(self): self._watcher.fd = -1; def __dealloc__(self): libev.vfd_free(self._watcher.fd) #endif cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: WATCHER_BASE(timer) def start(self, object callback, *args, update=True): CHECK_LOOP2(self.loop) if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args LIBEV_UNREF if update: libev.ev_now_update(self.loop._ptr) libev.ev_timer_start(self.loop._ptr, &self._watcher) PYTHON_INCREF ACTIVE PENDING def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): if repeat < 0.0: raise ValueError("repeat must be positive or zero: %r" % repeat) libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) property at: def __get__(self): return self._watcher.at # QQQ: add 'after' and 'repeat' properties? def again(self, object callback, *args, update=True): CHECK_LOOP2(self.loop) self.callback = callback self.args = args LIBEV_UNREF if update: libev.ev_now_update(self.loop._ptr) libev.ev_timer_again(self.loop._ptr, &self._watcher) PYTHON_INCREF cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: WATCHER(signal) def __init__(self, loop loop, int signalnum, ref=True, priority=None): if signalnum < 1 or signalnum >= signalmodule.NSIG: raise ValueError('illegal signal number: %r' % signalnum) # still possible to crash on one of libev's asserts: # 1) "libev: ev_signal_start called with illegal signal number" # EV_NSIG might be different from signal.NSIG on some platforms # 2) "libev: a signal must not be attached to two different loops" # we probably could check that in LIBEV_EMBED mode, but not in general libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: WATCHER(idle) INIT(idle,,) cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: WATCHER(prepare) INIT(prepare,,) cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: WATCHER(check) INIT(check,,) cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: WATCHER(fork) INIT(fork,,) cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: WATCHER_BASE(async) START(async) ACTIVE property pending: def __get__(self): return True if libev.ev_async_pending(&self._watcher) else False INIT(async,,) def send(self): CHECK_LOOP2(self.loop) libev.ev_async_send(self.loop._ptr, &self._watcher) #ifdef _WIN32 #else cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: WATCHER(child) def __init__(self, loop loop, int pid, bint trace=0, ref=True): if not loop.default: raise TypeError('child watchers are only available on the default loop') libev.gevent_install_sigchld_handler() libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 def _format(self): return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) property pid: def __get__(self): return self._watcher.pid property rpid: def __get__(self): return self._watcher.rpid def __set__(self, int value): self._watcher.rpid = value property rstatus: def __get__(self): return self._watcher.rstatus def __set__(self, int value): self._watcher.rstatus = value #endif cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: WATCHER(stat) cdef readonly str path cdef readonly bytes _paths def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): self.path = path cdef bytes paths if isinstance(path, unicode): # the famous Python3 filesystem encoding debacle hits us here. Can we do better? # We must keep a reference to the encoded string so that its bytes don't get freed # and overwritten, leading to strange errors from libev ("no such file or directory") paths = (path).encode(sys.getfilesystemencoding()) self._paths = paths else: paths = path self._paths = paths libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) property attr: def __get__(self): if not self._watcher.attr.st_nlink: return return _pystat_fromstructstat(&self._watcher.attr) property prev: def __get__(self): if not self._watcher.prev.st_nlink: return return _pystat_fromstructstat(&self._watcher.prev) property interval: def __get__(self): return self._watcher.interval __SYSERR_CALLBACK = None cdef void _syserr_cb(char* msg) with gil: try: __SYSERR_CALLBACK(msg, errno) except: set_syserr_cb(None) print_exc = getattr(traceback, 'print_exc', None) if print_exc is not None: print_exc() cpdef set_syserr_cb(callback): global __SYSERR_CALLBACK if callback is None: libev.ev_set_syserr_cb(NULL) __SYSERR_CALLBACK = None elif callable(callback): libev.ev_set_syserr_cb(_syserr_cb) __SYSERR_CALLBACK = callback else: raise TypeError('Expected callable or None, got %r' % (callback, )) #ifdef LIBEV_EMBED LIBEV_EMBED = True EV_USE_FLOOR = libev.EV_USE_FLOOR EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL EV_USE_REALTIME = libev.EV_USE_REALTIME EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP EV_USE_INOTIFY = libev.EV_USE_INOTIFY EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD EV_USE_EVENTFD = libev.EV_USE_EVENTFD EV_USE_4HEAP = libev.EV_USE_4HEAP #else LIBEV_EMBED = False #endif gevent-1.1.0/gevent/corecext.pyx0000644000076500000000000020063412666555431017411 0ustar jmaddenwheel00000000000000# Generated by cythonpp.py on 2016-03-05 07:11:05 # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. cimport cython cimport libev from python cimport * # Work around lack of absolute_import in Cython # Note for PY3: not doing so will leave reference to locals() on import # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) sys = __import__('sys', level=0) os = __import__('os', level=0) traceback = __import__('traceback', level=0) signalmodule = __import__('signal', level=0) __all__ = ['get_version', 'get_header_version', 'supported_backends', 'recommended_backends', 'embeddable_backends', 'time', 'loop'] cdef tuple integer_types if sys.version_info[0] >= 3: integer_types = int, else: integer_types = (int, long) cdef extern from "callbacks.h": void gevent_callback_io(libev.ev_loop, void*, int) void gevent_callback_timer(libev.ev_loop, void*, int) void gevent_callback_signal(libev.ev_loop, void*, int) void gevent_callback_idle(libev.ev_loop, void*, int) void gevent_callback_prepare(libev.ev_loop, void*, int) void gevent_callback_check(libev.ev_loop, void*, int) void gevent_callback_fork(libev.ev_loop, void*, int) void gevent_callback_async(libev.ev_loop, void*, int) void gevent_callback_child(libev.ev_loop, void*, int) void gevent_callback_stat(libev.ev_loop, void*, int) void gevent_run_callbacks(libev.ev_loop, void*, int) void gevent_periodic_signal_check(libev.ev_loop, void*, int) void gevent_call(loop, callback) void gevent_noop(libev.ev_loop, void*, int) cdef extern from *: int errno cdef extern from "stathelper.c": object _pystat_fromstructstat(void*) UNDEF = libev.EV_UNDEF NONE = libev.EV_NONE READ = libev.EV_READ WRITE = libev.EV_WRITE TIMER = libev.EV_TIMER PERIODIC = libev.EV_PERIODIC SIGNAL = libev.EV_SIGNAL CHILD = libev.EV_CHILD STAT = libev.EV_STAT IDLE = libev.EV_IDLE PREPARE = libev.EV_PREPARE CHECK = libev.EV_CHECK EMBED = libev.EV_EMBED FORK = libev.EV_FORK CLEANUP = libev.EV_CLEANUP ASYNC = libev.EV_ASYNC CUSTOM = libev.EV_CUSTOM ERROR = libev.EV_ERROR READWRITE = libev.EV_READ | libev.EV_WRITE MINPRI = libev.EV_MINPRI MAXPRI = libev.EV_MAXPRI BACKEND_PORT = libev.EVBACKEND_PORT BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE BACKEND_EPOLL = libev.EVBACKEND_EPOLL BACKEND_POLL = libev.EVBACKEND_POLL BACKEND_SELECT = libev.EVBACKEND_SELECT FORKCHECK = libev.EVFLAG_FORKCHECK NOINOTIFY = libev.EVFLAG_NOINOTIFY SIGNALFD = libev.EVFLAG_SIGNALFD NOSIGMASK = libev.EVFLAG_NOSIGMASK @cython.internal cdef class _EVENTSType: def __repr__(self): return 'gevent.core.EVENTS' cdef public object GEVENT_CORE_EVENTS = _EVENTSType() EVENTS = GEVENT_CORE_EVENTS def get_version(): return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) def get_header_version(): return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) # This list backends in the order they are actually tried by libev _flags = [(libev.EVBACKEND_PORT, 'port'), (libev.EVBACKEND_KQUEUE, 'kqueue'), (libev.EVBACKEND_EPOLL, 'epoll'), (libev.EVBACKEND_POLL, 'poll'), (libev.EVBACKEND_SELECT, 'select'), (libev.EVFLAG_NOENV, 'noenv'), (libev.EVFLAG_FORKCHECK, 'forkcheck'), (libev.EVFLAG_NOINOTIFY, 'noinotify'), (libev.EVFLAG_SIGNALFD, 'signalfd'), (libev.EVFLAG_NOSIGMASK, 'nosigmask')] _flags_str2int = dict((string, flag) for (flag, string) in _flags) _events = [(libev.EV_READ, 'READ'), (libev.EV_WRITE, 'WRITE'), (libev.EV__IOFDSET, '_IOFDSET'), (libev.EV_PERIODIC, 'PERIODIC'), (libev.EV_SIGNAL, 'SIGNAL'), (libev.EV_CHILD, 'CHILD'), (libev.EV_STAT, 'STAT'), (libev.EV_IDLE, 'IDLE'), (libev.EV_PREPARE, 'PREPARE'), (libev.EV_CHECK, 'CHECK'), (libev.EV_EMBED, 'EMBED'), (libev.EV_FORK, 'FORK'), (libev.EV_CLEANUP, 'CLEANUP'), (libev.EV_ASYNC, 'ASYNC'), (libev.EV_CUSTOM, 'CUSTOM'), (libev.EV_ERROR, 'ERROR')] cpdef _flags_to_list(unsigned int flags): cdef list result = [] for code, value in _flags: if flags & code: result.append(value) flags &= ~code if not flags: break if flags: result.append(flags) return result if sys.version_info[0] >= 3: basestring = (bytes, str) else: basestring = __builtins__.basestring cpdef unsigned int _flags_to_int(object flags) except? -1: # Note, that order does not matter, libev has its own predefined order if not flags: return 0 if isinstance(flags, integer_types): return flags cdef unsigned int result = 0 try: if isinstance(flags, basestring): flags = flags.split(',') for value in flags: value = value.strip().lower() if value: result |= _flags_str2int[value] except KeyError as ex: raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) return result cdef str _str_hex(object flag): if isinstance(flag, integer_types): return hex(flag) return str(flag) cpdef _check_flags(unsigned int flags): cdef list as_list flags &= libev.EVBACKEND_MASK if not flags: return if not (flags & libev.EVBACKEND_ALL): raise ValueError('Invalid value for backend: 0x%x' % flags) if not (flags & libev.ev_supported_backends()): as_list = [_str_hex(x) for x in _flags_to_list(flags)] raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) cpdef _events_to_str(int events): cdef list result = [] cdef int c_flag for (flag, string) in _events: c_flag = flag if events & c_flag: result.append(string) events = events & (~c_flag) if not events: break if events: result.append(hex(events)) return '|'.join(result) def supported_backends(): return _flags_to_list(libev.ev_supported_backends()) def recommended_backends(): return _flags_to_list(libev.ev_recommended_backends()) def embeddable_backends(): return _flags_to_list(libev.ev_embeddable_backends()) def time(): return libev.ev_time() cdef bint _default_loop_destroyed = False cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: cdef libev.ev_loop* _ptr cdef public object error_handler cdef libev.ev_prepare _prepare cdef public list _callbacks cdef libev.ev_timer _timer0 #ifdef _WIN32 cdef libev.ev_timer _periodic_signal_checker #endif def __init__(self, object flags=None, object default=None, size_t ptr=0): cdef unsigned int c_flags cdef object old_handler = None libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) #ifdef _WIN32 libev.ev_timer_init(&self._periodic_signal_checker, gevent_periodic_signal_check, 0.3, 0.3) #endif libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) if ptr: self._ptr = ptr else: c_flags = _flags_to_int(flags) _check_flags(c_flags) c_flags |= libev.EVFLAG_NOENV c_flags |= libev.EVFLAG_FORKCHECK if default is None: default = True if _default_loop_destroyed: default = False if default: self._ptr = libev.gevent_ev_default_loop(c_flags) if not self._ptr: raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) #ifdef _WIN32 libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) libev.ev_unref(self._ptr) #endif else: self._ptr = libev.ev_loop_new(c_flags) if not self._ptr: raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) if default or __SYSERR_CALLBACK is None: set_syserr_cb(self._handle_syserr) libev.ev_prepare_start(self._ptr, &self._prepare) libev.ev_unref(self._ptr) self._callbacks = [] cdef _run_callbacks(self): cdef callback cb cdef object callbacks cdef int count = 1000 libev.ev_timer_stop(self._ptr, &self._timer0) while self._callbacks and count > 0: callbacks = self._callbacks self._callbacks = [] for cb in callbacks: libev.ev_unref(self._ptr) gevent_call(self, cb) count -= 1 if self._callbacks: libev.ev_timer_start(self._ptr, &self._timer0) def _stop_watchers(self): if libev.ev_is_active(&self._prepare): libev.ev_ref(self._ptr) libev.ev_prepare_stop(self._ptr, &self._prepare) #ifdef _WIN32 if libev.ev_is_active(&self._periodic_signal_checker): libev.ev_ref(self._ptr) libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) #endif def destroy(self): global _default_loop_destroyed if self._ptr: self._stop_watchers() if __SYSERR_CALLBACK == self._handle_syserr: set_syserr_cb(None) if libev.ev_is_default_loop(self._ptr): _default_loop_destroyed = True libev.ev_loop_destroy(self._ptr) self._ptr = NULL def __dealloc__(self): if self._ptr: self._stop_watchers() if not libev.ev_is_default_loop(self._ptr): libev.ev_loop_destroy(self._ptr) self._ptr = NULL property ptr: def __get__(self): return self._ptr property WatcherType: def __get__(self): return watcher property MAXPRI: def __get__(self): return libev.EV_MAXPRI property MINPRI: def __get__(self): return libev.EV_MINPRI def _handle_syserr(self, message, errno): if sys.version_info[0] >= 3: message = message.decode() self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) cpdef handle_error(self, context, type, value, tb): cdef object handle_error cdef object error_handler = self.error_handler if error_handler is not None: # we do want to do getattr every time so that setting Hub.handle_error property just works handle_error = getattr(error_handler, 'handle_error', error_handler) handle_error(context, type, value, tb) else: self._default_handle_error(context, type, value, tb) cpdef _default_handle_error(self, context, type, value, tb): # note: Hub sets its own error handler so this is not used by gevent # this is here to make core.loop usable without the rest of gevent traceback.print_exception(type, value, tb) if self._ptr: libev.ev_break(self._ptr, libev.EVBREAK_ONE) def run(self, nowait=False, once=False): if not self._ptr: raise ValueError('operation on destroyed loop') cdef unsigned int flags = 0 if nowait: flags |= libev.EVRUN_NOWAIT if once: flags |= libev.EVRUN_ONCE with nogil: libev.ev_run(self._ptr, flags) def reinit(self): if self._ptr: libev.ev_loop_fork(self._ptr) def ref(self): if not self._ptr: raise ValueError('operation on destroyed loop') libev.ev_ref(self._ptr) def unref(self): if not self._ptr: raise ValueError('operation on destroyed loop') libev.ev_unref(self._ptr) def break_(self, int how=libev.EVBREAK_ONE): if not self._ptr: raise ValueError('operation on destroyed loop') libev.ev_break(self._ptr, how) def verify(self): if not self._ptr: raise ValueError('operation on destroyed loop') libev.ev_verify(self._ptr) def now(self): if not self._ptr: raise ValueError('operation on destroyed loop') return libev.ev_now(self._ptr) def update(self): if not self._ptr: raise ValueError('operation on destroyed loop') libev.ev_now_update(self._ptr) def __repr__(self): return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) property default: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return True if libev.ev_is_default_loop(self._ptr) else False property iteration: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return libev.ev_iteration(self._ptr) property depth: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return libev.ev_depth(self._ptr) property backend_int: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return libev.ev_backend(self._ptr) property backend: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') cdef unsigned int backend = libev.ev_backend(self._ptr) for key, value in _flags: if key == backend: return value return backend property pendingcnt: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return libev.ev_pending_count(self._ptr) #ifdef _WIN32 def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): return io(self, fd, events, ref, priority) #else def io(self, int fd, int events, ref=True, priority=None): return io(self, fd, events, ref, priority) #endif def timer(self, double after, double repeat=0.0, ref=True, priority=None): return timer(self, after, repeat, ref, priority) def signal(self, int signum, ref=True, priority=None): return signal(self, signum, ref, priority) def idle(self, ref=True, priority=None): return idle(self, ref, priority) def prepare(self, ref=True, priority=None): return prepare(self, ref, priority) def check(self, ref=True, priority=None): return check(self, ref, priority) def fork(self, ref=True, priority=None): return fork(self, ref, priority) def async(self, ref=True, priority=None): return async(self, ref, priority) #ifdef _WIN32 #else def child(self, int pid, bint trace=0, ref=True): return child(self, pid, trace, ref) def install_sigchld(self): libev.gevent_install_sigchld_handler() #endif def stat(self, str path, float interval=0.0, ref=True, priority=None): return stat(self, path, interval, ref, priority) def run_callback(self, func, *args): if not self._ptr: raise ValueError('operation on destroyed loop') cdef callback cb = callback(func, args) self._callbacks.append(cb) libev.ev_ref(self._ptr) return cb def _format(self): if not self._ptr: return 'destroyed' cdef object msg = self.backend if self.default: msg += ' default' msg += ' pending=%s' % self.pendingcnt #ifdef LIBEV_EMBED msg += self._format_details() #endif return msg #ifdef LIBEV_EMBED def _format_details(self): cdef str msg = '' cdef object fileno = self.fileno() cdef object sigfd = None cdef object activecnt = None try: sigfd = self.sigfd except AttributeError: sigfd = None try: activecnt = self.activecnt except AttributeError: pass if activecnt is not None: msg += ' ref=' + repr(activecnt) if fileno is not None: msg += ' fileno=' + repr(fileno) if sigfd is not None and sigfd != -1: msg += ' sigfd=' + repr(sigfd) return msg def fileno(self): cdef int fd if self._ptr: fd = self._ptr.backend_fd if fd >= 0: return fd property activecnt: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return self._ptr.activecnt property sig_pending: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return self._ptr.sig_pending #if EV_USE_SIGNALFD property sigfd: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return self._ptr.sigfd #endif property origflags: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return _flags_to_list(self._ptr.origflags) property origflags_int: def __get__(self): if not self._ptr: raise ValueError('operation on destroyed loop') return self._ptr.origflags #endif cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: cdef public object callback cdef public tuple args def __init__(self, callback, args): self.callback = callback self.args = args def stop(self): self.callback = None self.args = None # Note, that __nonzero__ and pending are different # nonzero is used in contexts where we need to know whether to schedule another callback, # so it's true if it's pending or currently running # 'pending' has the same meaning as libev watchers: it is cleared before entering callback def __nonzero__(self): # it's nonzero if it's pending or currently executing return self.args is not None property pending: def __get__(self): return self.callback is not None def __repr__(self): if Py_ReprEnter(self) != 0: return "<...>" try: format = self._format() result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) if self.callback is None and self.args is None: result += " stopped" return result + ">" finally: Py_ReprLeave(self) def _format(self): return '' # about readonly _flags attribute: # bit #1 set if object owns Python reference to itself (Py_INCREF was called and we must call Py_DECREF later) # bit #2 set if ev_unref() was called and we must call ev_ref() later # bit #3 set if user wants to call ev_unref() before start() cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: """Abstract base class for all the watchers""" def __repr__(self): if Py_ReprEnter(self) != 0: return "<...>" try: format = self._format() result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) if self.active: result += " active" if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) return result + ">" finally: Py_ReprLeave(self) def _format(self): return '' cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_io _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_io_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args, pass_events=False): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback if pass_events: self.args = (GEVENT_CORE_EVENTS, ) + args else: self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_io_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False #ifdef _WIN32 def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): raise ValueError('illegal event mask: %r' % events) cdef int vfd = libev.vfd_open(fd) libev.vfd_free(self._watcher.fd) libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) #else def __init__(self, loop loop, int fd, int events, ref=True, priority=None): if fd < 0: raise ValueError('fd must be non-negative: %r' % fd) if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): raise ValueError('illegal event mask: %r' % events) libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) #endif property fd: def __get__(self): return libev.vfd_get(self._watcher.fd) def __set__(self, long fd): if libev.ev_is_active(&self._watcher): raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") cdef int vfd = libev.vfd_open(fd) libev.vfd_free(self._watcher.fd) libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, self._watcher.events) property events: def __get__(self): return self._watcher.events def __set__(self, int events): if libev.ev_is_active(&self._watcher): raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) property events_str: def __get__(self): return _events_to_str(self._watcher.events) def _format(self): return ' fd=%s events=%s' % (self.fd, self.events_str) #ifdef _WIN32 def __cinit__(self): self._watcher.fd = -1; def __dealloc__(self): libev.vfd_free(self._watcher.fd) #endif cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_timer _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_timer_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args, update=True): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 if update: libev.ev_now_update(self.loop._ptr) libev.ev_timer_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): if repeat < 0.0: raise ValueError("repeat must be positive or zero: %r" % repeat) libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) property at: def __get__(self): return self._watcher.at # QQQ: add 'after' and 'repeat' properties? def again(self, object callback, *args, update=True): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 if update: libev.ev_now_update(self.loop._ptr) libev.ev_timer_again(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_signal _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_signal_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_signal_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop, int signalnum, ref=True, priority=None): if signalnum < 1 or signalnum >= signalmodule.NSIG: raise ValueError('illegal signal number: %r' % signalnum) # still possible to crash on one of libev's asserts: # 1) "libev: ev_signal_start called with illegal signal number" # EV_NSIG might be different from signal.NSIG on some platforms # 2) "libev: a signal must not be attached to two different loops" # we probably could check that in LIBEV_EMBED mode, but not in general libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_idle _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_idle_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_idle_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop , ref=True, priority=None): libev.ev_idle_init(&self._watcher, gevent_callback_idle ) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_prepare _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_prepare_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_prepare_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop , ref=True, priority=None): libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_check _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_check_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_check_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop , ref=True, priority=None): libev.ev_check_init(&self._watcher, gevent_callback_check ) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_fork _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_fork_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_fork_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop , ref=True, priority=None): libev.ev_fork_init(&self._watcher, gevent_callback_fork ) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_async _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_async_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_async_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_async_pending(&self._watcher) else False def __init__(self, loop loop , ref=True, priority=None): libev.ev_async_init(&self._watcher, gevent_callback_async ) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) def send(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') libev.ev_async_send(self.loop._ptr, &self._watcher) #ifdef _WIN32 #else cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_child _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_child_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_child_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False def __init__(self, loop loop, int pid, bint trace=0, ref=True): if not loop.default: raise TypeError('child watchers are only available on the default loop') libev.gevent_install_sigchld_handler() libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 def _format(self): return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) property pid: def __get__(self): return self._watcher.pid property rpid: def __get__(self): return self._watcher.rpid def __set__(self, int value): self._watcher.rpid = value property rstatus: def __get__(self): return self._watcher.rstatus def __set__(self, int value): self._watcher.rstatus = value #endif cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: cdef public loop loop cdef object _callback cdef public tuple args cdef readonly int _flags cdef libev.ev_stat _watcher property ref: def __get__(self): return False if self._flags & 4 else True def __set__(self, object value): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo libev.ev_ref(self.loop._ptr) self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(&self._watcher): libev.ev_unref(self.loop._ptr) self._flags |= 2 property callback: def __get__(self): return self._callback def __set__(self, object callback): if not PyCallable_Check(callback) and callback is not None: raise TypeError("Expected callable, not %r" % (callback, )) self._callback = callback def stop(self): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if self._flags & 2: libev.ev_ref(self.loop._ptr) self._flags &= ~2 libev.ev_stat_stop(self.loop._ptr, &self._watcher) self._callback = None self.args = None if self._flags & 1: Py_DECREF(self) self._flags &= ~1 property priority: def __get__(self): return libev.ev_priority(&self._watcher) def __set__(self, int priority): if libev.ev_is_active(&self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(&self._watcher, priority) def feed(self, int revents, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 def start(self, object callback, *args): if not self.loop._ptr: raise ValueError('operation on destroyed loop') if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args if self._flags & 6 == 4: libev.ev_unref(self.loop._ptr) self._flags |= 2 libev.ev_stat_start(self.loop._ptr, &self._watcher) if not self._flags & 1: Py_INCREF(self) self._flags |= 1 property active: def __get__(self): return True if libev.ev_is_active(&self._watcher) else False property pending: def __get__(self): return True if libev.ev_is_pending(&self._watcher) else False cdef readonly str path cdef readonly bytes _paths def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): self.path = path cdef bytes paths if isinstance(path, unicode): # the famous Python3 filesystem encoding debacle hits us here. Can we do better? # We must keep a reference to the encoded string so that its bytes don't get freed # and overwritten, leading to strange errors from libev ("no such file or directory") paths = (path).encode(sys.getfilesystemencoding()) self._paths = paths else: paths = path self._paths = paths libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) self.loop = loop if ref: self._flags = 0 else: self._flags = 4 if priority is not None: libev.ev_set_priority(&self._watcher, priority) property attr: def __get__(self): if not self._watcher.attr.st_nlink: return return _pystat_fromstructstat(&self._watcher.attr) property prev: def __get__(self): if not self._watcher.prev.st_nlink: return return _pystat_fromstructstat(&self._watcher.prev) property interval: def __get__(self): return self._watcher.interval __SYSERR_CALLBACK = None cdef void _syserr_cb(char* msg) with gil: try: __SYSERR_CALLBACK(msg, errno) except: set_syserr_cb(None) print_exc = getattr(traceback, 'print_exc', None) if print_exc is not None: print_exc() cpdef set_syserr_cb(callback): global __SYSERR_CALLBACK if callback is None: libev.ev_set_syserr_cb(NULL) __SYSERR_CALLBACK = None elif callable(callback): libev.ev_set_syserr_cb(_syserr_cb) __SYSERR_CALLBACK = callback else: raise TypeError('Expected callable or None, got %r' % (callback, )) #ifdef LIBEV_EMBED LIBEV_EMBED = True EV_USE_FLOOR = libev.EV_USE_FLOOR EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL EV_USE_REALTIME = libev.EV_USE_REALTIME EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP EV_USE_INOTIFY = libev.EV_USE_INOTIFY EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD EV_USE_EVENTFD = libev.EV_USE_EVENTFD EV_USE_4HEAP = libev.EV_USE_4HEAP #else LIBEV_EMBED = False #endif gevent-1.1.0/gevent/corecffi.py0000644000076500000000000011247212666555342017170 0ustar jmaddenwheel00000000000000# pylint: disable=too-many-lines, protected-access, redefined-outer-name from __future__ import absolute_import, print_function import sys import os import traceback import signal as signalmodule __all__ = ['get_version', 'get_header_version', 'supported_backends', 'recommended_backends', 'embeddable_backends', 'time', 'loop'] try: import gevent._corecffi except ImportError: traceback.print_exc() # Not built yet import gevent._corecffi_build gevent._corecffi_build.ffi.compile() import gevent._corecffi ffi = gevent._corecffi.ffi libev = gevent._corecffi.lib if hasattr(libev, 'vfd_open'): # Must be on windows assert sys.platform.startswith("win"), "vfd functions only needed on windows" vfd_open = libev.vfd_open vfd_free = libev.vfd_free vfd_get = libev.vfd_get else: vfd_open = vfd_free = vfd_get = lambda fd: fd ##### ## NOTE on Windows: # The C implementation does several things specially for Windows; # a possibly incomplete list is: # # - the loop runs a periodic signal checker; # - the io watcher constructor is different and it has a destructor; # - the child watcher is not defined # # The CFFI implementation does none of these things, and so # is possibly NOT FUNCTIONALLY CORRECT on Win32 ##### ##### ## Note on CFFI objects, callbacks and the lifecycle of watcher objects # # Each subclass of `watcher` allocates a C structure of the # appropriate type e.g., struct gevent_ev_io and holds this pointer in # its `_gwatcher` attribute. When that watcher instance is garbage # collected, then the C structure is also freed. The C structure is # passed to libev from the watcher's start() method and then to the # appropriate C callback function, e.g., _gevent_ev_io_callback, which # passes it back to python's _python_callback where we need the # watcher instance. Therefore, as long as that callback is active (the # watcher is started), the watcher instance must not be allowed to get # GC'd---any access at the C level or even the FFI level to the freed # memory could crash the process. # # However, the typical idiom calls for writing something like this: # loop.io(fd, python_cb).start() # thus forgetting the newly created watcher subclass and allowing it to be immediately # GC'd. To combat this, when the watcher is started, it places itself into the loop's # `_keepaliveset`, and it only removes itself when the watcher's `stop()` method is called. # Often, this is the *only* reference keeping the watcher object, and hence its C structure, # alive. # # This is slightly complicated by the fact that the python-level # callback, called from the C callback, could choose to manually stop # the watcher. When we return to the C level callback, we now have an # invalid pointer, and attempting to pass it back to Python (e.g., to # handle an error) could crash. Hence, _python_callback, # _gevent_io_callback, and _python_handle_error cooperate to make sure # that the watcher instance stays in the loops `_keepaliveset` while # the C code could be running---and if it gets removed, to not call back # to Python again. # See also https://github.com/gevent/gevent/issues/676 #### @ffi.callback("int(void* handle, int revents)") def _python_callback(handle, revents): """ Returns an integer having one of three values: - -1 An exception occurred during the callback and you must call :func:`_python_handle_error` to deal with it. The Python watcher object will have the exception tuple saved in ``_exc_info``. - 0 Everything went according to plan. You should check to see if the libev watcher is still active, and call :func:`_python_stop` if so. This will clean up the memory. - 1 Everything went according to plan, but the watcher has already been stopped. Its memory may no longer be valid. """ try: # Even dereferencing the handle needs to be inside the try/except; # if we don't return normally (e.g., a signal) then we wind up going # to the 'onerror' handler, which # is not what we want; that can permanently wedge the loop depending # on which callback was executing watcher = ffi.from_handle(handle) args = watcher.args if args is None: # Legacy behaviour from corecext: convert None into () # See test__core_watcher.py args = _NOARGS if len(args) > 0 and args[0] == GEVENT_CORE_EVENTS: args = (revents, ) + args[1:] watcher.callback(*args) except: watcher._exc_info = sys.exc_info() # Depending on when the exception happened, the watcher # may or may not have been stopped. We need to make sure its # memory stays valid so we can stop it at the ev level if needed. watcher.loop._keepaliveset.add(watcher) return -1 else: if watcher in watcher.loop._keepaliveset: # It didn't stop itself return 0 return 1 # It stopped itself libev.python_callback = _python_callback @ffi.callback("void(void* handle, int revents)") def _python_handle_error(handle, revents): try: watcher = ffi.from_handle(handle) exc_info = watcher._exc_info del watcher._exc_info watcher.loop.handle_error(watcher, *exc_info) finally: # XXX Since we're here on an error condition, and we # made sure that the watcher object was put in loop._keepaliveset, # what about not stopping the watcher? Looks like a possible # memory leak? if revents & (libev.EV_READ | libev.EV_WRITE): try: watcher.stop() except: watcher.loop.handle_error(watcher, *sys.exc_info()) return libev.python_handle_error = _python_handle_error @ffi.callback("void(void* handle)") def _python_stop(handle): watcher = ffi.from_handle(handle) watcher.stop() libev.python_stop = _python_stop UNDEF = libev.EV_UNDEF NONE = libev.EV_NONE READ = libev.EV_READ WRITE = libev.EV_WRITE TIMER = libev.EV_TIMER PERIODIC = libev.EV_PERIODIC SIGNAL = libev.EV_SIGNAL CHILD = libev.EV_CHILD STAT = libev.EV_STAT IDLE = libev.EV_IDLE PREPARE = libev.EV_PREPARE CHECK = libev.EV_CHECK EMBED = libev.EV_EMBED FORK = libev.EV_FORK CLEANUP = libev.EV_CLEANUP ASYNC = libev.EV_ASYNC CUSTOM = libev.EV_CUSTOM ERROR = libev.EV_ERROR READWRITE = libev.EV_READ | libev.EV_WRITE MINPRI = libev.EV_MINPRI MAXPRI = libev.EV_MAXPRI BACKEND_PORT = libev.EVBACKEND_PORT BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE BACKEND_EPOLL = libev.EVBACKEND_EPOLL BACKEND_POLL = libev.EVBACKEND_POLL BACKEND_SELECT = libev.EVBACKEND_SELECT FORKCHECK = libev.EVFLAG_FORKCHECK NOINOTIFY = libev.EVFLAG_NOINOTIFY SIGNALFD = libev.EVFLAG_SIGNALFD NOSIGMASK = libev.EVFLAG_NOSIGMASK class _EVENTSType(object): def __repr__(self): return 'gevent.core.EVENTS' EVENTS = GEVENT_CORE_EVENTS = _EVENTSType() def get_version(): return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) def get_header_version(): return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) _flags = [(libev.EVBACKEND_PORT, 'port'), (libev.EVBACKEND_KQUEUE, 'kqueue'), (libev.EVBACKEND_EPOLL, 'epoll'), (libev.EVBACKEND_POLL, 'poll'), (libev.EVBACKEND_SELECT, 'select'), (libev.EVFLAG_NOENV, 'noenv'), (libev.EVFLAG_FORKCHECK, 'forkcheck'), (libev.EVFLAG_SIGNALFD, 'signalfd'), (libev.EVFLAG_NOSIGMASK, 'nosigmask')] _flags_str2int = dict((string, flag) for (flag, string) in _flags) _events = [(libev.EV_READ, 'READ'), (libev.EV_WRITE, 'WRITE'), (libev.EV__IOFDSET, '_IOFDSET'), (libev.EV_PERIODIC, 'PERIODIC'), (libev.EV_SIGNAL, 'SIGNAL'), (libev.EV_CHILD, 'CHILD'), (libev.EV_STAT, 'STAT'), (libev.EV_IDLE, 'IDLE'), (libev.EV_PREPARE, 'PREPARE'), (libev.EV_CHECK, 'CHECK'), (libev.EV_EMBED, 'EMBED'), (libev.EV_FORK, 'FORK'), (libev.EV_CLEANUP, 'CLEANUP'), (libev.EV_ASYNC, 'ASYNC'), (libev.EV_CUSTOM, 'CUSTOM'), (libev.EV_ERROR, 'ERROR')] def _flags_to_list(flags): result = [] for code, value in _flags: if flags & code: result.append(value) flags &= ~code if not flags: break if flags: result.append(flags) return result if sys.version_info[0] >= 3: basestring = (bytes, str) integer_types = int, else: import __builtin__ basestring = __builtin__.basestring integer_types = (int, __builtin__.long) def _flags_to_int(flags): # Note, that order does not matter, libev has its own predefined order if not flags: return 0 if isinstance(flags, integer_types): return flags result = 0 try: if isinstance(flags, basestring): flags = flags.split(',') for value in flags: value = value.strip().lower() if value: result |= _flags_str2int[value] except KeyError as ex: raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) return result def _str_hex(flag): if isinstance(flag, integer_types): return hex(flag) return str(flag) def _check_flags(flags): as_list = [] flags &= libev.EVBACKEND_MASK if not flags: return if not (flags & libev.EVBACKEND_ALL): raise ValueError('Invalid value for backend: 0x%x' % flags) if not (flags & libev.ev_supported_backends()): as_list = [_str_hex(x) for x in _flags_to_list(flags)] raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) def _events_to_str(events): result = [] for (flag, string) in _events: c_flag = flag if events & c_flag: result.append(string) events = events & (~c_flag) if not events: break if events: result.append(hex(events)) return '|'.join(result) def supported_backends(): return _flags_to_list(libev.ev_supported_backends()) def recommended_backends(): return _flags_to_list(libev.ev_recommended_backends()) def embeddable_backends(): return _flags_to_list(libev.ev_embeddable_backends()) def time(): return libev.ev_time() _default_loop_destroyed = False def _loop_callback(*args, **kwargs): return ffi.callback(*args, **kwargs) class loop(object): error_handler = None def __init__(self, flags=None, default=None): self._in_callback = False self._callbacks = [] # self._check is a watcher that runs in each iteration of the # mainloop, just after the blocking call self._check = ffi.new("struct ev_check *") self._check_callback_ffi = _loop_callback("void(*)(struct ev_loop *, void*, int)", self._check_callback, onerror=self._check_callback_handle_error) libev.ev_check_init(self._check, self._check_callback_ffi) # self._prepare is a watcher that runs in each iteration of the mainloop, # just before the blocking call self._prepare = ffi.new("struct ev_prepare *") self._prepare_callback_ffi = _loop_callback("void(*)(struct ev_loop *, void*, int)", self._run_callbacks, onerror=self._check_callback_handle_error) libev.ev_prepare_init(self._prepare, self._prepare_callback_ffi) # A timer we start and stop on demand. If we have callbacks, # too many to run in one iteration of _run_callbacks, we turn this # on so as to have the next iteration of the run loop return to us # as quickly as possible. # TODO: There may be a more efficient way to do this using ev_timer_again; # see the "ev_timer" section of the ev manpage (http://linux.die.net/man/3/ev) self._timer0 = ffi.new("struct ev_timer *") libev.ev_timer_init(self._timer0, libev.gevent_noop, 0.0, 0.0) # TODO: We may be able to do something nicer and use the existing python_callback # combined with onerror and the class check/timer/prepare to simplify things # and unify our handling c_flags = _flags_to_int(flags) _check_flags(c_flags) c_flags |= libev.EVFLAG_NOENV c_flags |= libev.EVFLAG_FORKCHECK if default is None: default = True if _default_loop_destroyed: default = False if default: self._ptr = libev.gevent_ev_default_loop(c_flags) if not self._ptr: raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) else: self._ptr = libev.ev_loop_new(c_flags) if not self._ptr: raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) if default or globals()["__SYSERR_CALLBACK"] is None: set_syserr_cb(self._handle_syserr) libev.ev_prepare_start(self._ptr, self._prepare) self.unref() libev.ev_check_start(self._ptr, self._check) self.unref() self._keepaliveset = set() def _check_callback_handle_error(self, t, v, tb): # None as the context argument causes the exception to be raised # in the main greenlet. self.handle_error(None, t, v, tb) def _check_callback(self, *args): # If we have the onerror callback, this is a no-op; all the real # work to rethrow the exception is done by the onerror callback pass def _run_callbacks(self, evloop, _, revents): count = 1000 libev.ev_timer_stop(self._ptr, self._timer0) while self._callbacks and count > 0: callbacks = self._callbacks self._callbacks = [] for cb in callbacks: self.unref() callback = cb.callback args = cb.args if callback is None or args is None: # it's been stopped continue cb.callback = None try: callback(*args) except: # If we allow an exception to escape this method (while we are running the ev callback), # then CFFI will print the error and libev will continue executing. # There are two problems with this. The first is that the code after # the loop won't run. The second is that any remaining callbacks scheduled # for this loop iteration will be silently dropped; they won't run, but they'll # also not be *stopped* (which is not a huge deal unless you're looking for # consistency or checking the boolean/pending status; the loop doesn't keep # a reference to them like it does to watchers...*UNLESS* the callback itself had # a reference to a watcher; then I don't know what would happen, it depends on # the state of the watcher---a leak or crash is not totally inconceivable). # The Cython implementation in core.ppyx uses gevent_call from callbacks.c # to run the callback, which uses gevent_handle_error to handle any errors the # Python callback raises...it unconditionally simply prints any error raised # by loop.handle_error and clears it, so callback handling continues. # We take a similar approach (but are extra careful about printing) try: self.handle_error(cb, *sys.exc_info()) except: try: print("Exception while handling another error", file=sys.stderr) traceback.print_exc() except: pass # Nothing we can do here finally: # Note, this must be reset here, because cb.args is used as a flag in callback class, cb.args = None count -= 1 if self._callbacks: libev.ev_timer_start(self._ptr, self._timer0) def _stop_aux_watchers(self): if libev.ev_is_active(self._prepare): self.ref() libev.ev_prepare_stop(self._ptr, self._prepare) if libev.ev_is_active(self._check): self.ref() libev.ev_check_stop(self._ptr, self._check) def destroy(self): global _default_loop_destroyed if self._ptr: self._stop_aux_watchers() if globals()["__SYSERR_CALLBACK"] == self._handle_syserr: set_syserr_cb(None) if libev.ev_is_default_loop(self._ptr): _default_loop_destroyed = True libev.ev_loop_destroy(self._ptr) self._ptr = ffi.NULL @property def ptr(self): return self._ptr @property def WatcherType(self): return watcher @property def MAXPRI(self): return libev.EV_MAXPRI @property def MINPRI(self): return libev.EV_MINPRI def _handle_syserr(self, message, errno): try: errno = os.strerror(errno) except: traceback.print_exc() try: message = '%s: %s' % (message, errno) except: traceback.print_exc() self.handle_error(None, SystemError, SystemError(message), None) def handle_error(self, context, type, value, tb): handle_error = None error_handler = self.error_handler if error_handler is not None: # we do want to do getattr every time so that setting Hub.handle_error property just works handle_error = getattr(error_handler, 'handle_error', error_handler) handle_error(context, type, value, tb) else: self._default_handle_error(context, type, value, tb) def _default_handle_error(self, context, type, value, tb): # note: Hub sets its own error handler so this is not used by gevent # this is here to make core.loop usable without the rest of gevent traceback.print_exception(type, value, tb) libev.ev_break(self._ptr, libev.EVBREAK_ONE) def run(self, nowait=False, once=False): flags = 0 if nowait: flags |= libev.EVRUN_NOWAIT if once: flags |= libev.EVRUN_ONCE libev.ev_run(self._ptr, flags) def reinit(self): libev.ev_loop_fork(self._ptr) def ref(self): libev.ev_ref(self._ptr) def unref(self): libev.ev_unref(self._ptr) def break_(self, how=libev.EVBREAK_ONE): libev.ev_break(self._ptr, how) def verify(self): libev.ev_verify(self._ptr) def now(self): return libev.ev_now(self._ptr) def update(self): libev.ev_now_update(self._ptr) def __repr__(self): return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) @property def default(self): return True if libev.ev_is_default_loop(self._ptr) else False @property def iteration(self): return libev.ev_iteration(self._ptr) @property def depth(self): return libev.ev_depth(self._ptr) @property def backend_int(self): return libev.ev_backend(self._ptr) @property def backend(self): backend = libev.ev_backend(self._ptr) for key, value in _flags: if key == backend: return value return backend @property def pendingcnt(self): return libev.ev_pending_count(self._ptr) def io(self, fd, events, ref=True, priority=None): return io(self, fd, events, ref, priority) def timer(self, after, repeat=0.0, ref=True, priority=None): return timer(self, after, repeat, ref, priority) def signal(self, signum, ref=True, priority=None): return signal(self, signum, ref, priority) def idle(self, ref=True, priority=None): return idle(self, ref, priority) def prepare(self, ref=True, priority=None): return prepare(self, ref, priority) def check(self, ref=True, priority=None): return check(self, ref, priority) def fork(self, ref=True, priority=None): return fork(self, ref, priority) def async(self, ref=True, priority=None): return async(self, ref, priority) if sys.platform != "win32": def child(self, pid, trace=0, ref=True): return child(self, pid, trace, ref) def install_sigchld(self): libev.gevent_install_sigchld_handler() def stat(self, path, interval=0.0, ref=True, priority=None): return stat(self, path, interval, ref, priority) def callback(self, priority=None): return callback(self, priority) def run_callback(self, func, *args): cb = callback(func, args) self._callbacks.append(cb) self.ref() return cb def _format(self): if not self._ptr: return 'destroyed' msg = self.backend if self.default: msg += ' default' msg += ' pending=%s' % self.pendingcnt msg += self._format_details() return msg def _format_details(self): msg = '' fileno = self.fileno() try: activecnt = self.activecnt except AttributeError: activecnt = None if activecnt is not None: msg += ' ref=' + repr(activecnt) if fileno is not None: msg += ' fileno=' + repr(fileno) #if sigfd is not None and sigfd != -1: # msg += ' sigfd=' + repr(sigfd) return msg def fileno(self): if self._ptr: fd = self._ptr.backend_fd if fd >= 0: return fd @property def activecnt(self): if not self._ptr: raise ValueError('operation on destroyed loop') return self._ptr.activecnt # For times when *args is captured but often not passed (empty), # we can avoid keeping the new tuple that was created for *args # around by using a constant. _NOARGS = () class callback(object): __slots__ = ('callback', 'args') def __init__(self, callback, args): self.callback = callback self.args = args or _NOARGS def stop(self): self.callback = None self.args = None # Note, that __nonzero__ and pending are different # nonzero is used in contexts where we need to know whether to schedule another callback, # so it's true if it's pending or currently running # 'pending' has the same meaning as libev watchers: it is cleared before entering callback def __nonzero__(self): # it's nonzero if it's pending or currently executing return self.args is not None __bool__ = __nonzero__ @property def pending(self): return self.callback is not None def _format(self): return '' def __repr__(self): result = "<%s at 0x%x" % (self.__class__.__name__, id(self)) if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) if self.callback is None and self.args is None: result += " stopped" return result + ">" class watcher(object): def __init__(self, _loop, ref=True, priority=None, args=_NOARGS): self.loop = _loop if ref: self._flags = 0 else: self._flags = 4 self._args = None self._callback = None self._handle = ffi.new_handle(self) self._watcher = ffi.new(self._watcher_struct_pointer_type) self._watcher.data = self._handle if priority is not None: libev.ev_set_priority(self._watcher, priority) self._watcher_init(self._watcher, self._watcher_callback, *args) # A string identifying the type of libev object we watch, e.g., 'ev_io' # This should be a class attribute. _watcher_type = None # A class attribute that is the callback on the libev object that init's the C struct, # e.g., libev.ev_io_init. If None, will be set by _init_subclasses. _watcher_init = None # A class attribute that is the callback on the libev object that starts the C watcher, # e.g., libev.ev_io_start. If None, will be set by _init_subclasses. _watcher_start = None # A class attribute that is the callback on the libev object that stops the C watcher, # e.g., libev.ev_io_stop. If None, will be set by _init_subclasses. _watcher_stop = None # A cffi ctype object identifying the struct pointer we create. # This is a class attribute set based on the _watcher_type _watcher_struct_pointer_type = None # The attribute of the libev object identifying the custom # callback function for this type of watcher. This is a class # attribute set based on the _watcher_type in _init_subclasses. _watcher_callback = None @classmethod def _init_subclasses(cls): for subclass in cls.__subclasses__(): watcher_type = subclass._watcher_type subclass._watcher_struct_pointer_type = ffi.typeof('struct ' + watcher_type + '*') subclass._watcher_callback = ffi.addressof(libev, '_gevent_generic_callback') for name in 'start', 'stop', 'init': ev_name = watcher_type + '_' + name watcher_name = '_watcher' + '_' + name if getattr(subclass, watcher_name) is None: setattr(subclass, watcher_name, getattr(libev, ev_name)) # this is not needed, since we keep alive the watcher while it's started #def __del__(self): # self._watcher_stop(self.loop._ptr, self._watcher) def __repr__(self): formats = self._format() result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), formats) if self.pending: result += " pending" if self.callback is not None: result += " callback=%r" % (self.callback, ) if self.args is not None: result += " args=%r" % (self.args, ) if self.callback is None and self.args is None: result += " stopped" result += " handle=%s" % (self._watcher.data) return result + ">" def _format(self): return '' def _libev_unref(self): if self._flags & 6 == 4: self.loop.unref() self._flags |= 2 def _get_ref(self): return False if self._flags & 4 else True def _set_ref(self, value): if value: if not self._flags & 4: return # ref is already True if self._flags & 2: # ev_unref was called, undo self.loop.ref() self._flags &= ~6 # do not want unref, no outstanding unref else: if self._flags & 4: return # ref is already False self._flags |= 4 if not self._flags & 2 and libev.ev_is_active(self._watcher): self.loop.unref() self._flags |= 2 ref = property(_get_ref, _set_ref) def _get_callback(self): return self._callback def _set_callback(self, cb): if not callable(cb) and cb is not None: raise TypeError("Expected callable, not %r" % (cb, )) self._callback = cb callback = property(_get_callback, _set_callback) def _get_args(self): return self._args def _set_args(self, args): if not isinstance(args, tuple) and args is not None: raise TypeError("args must be a tuple or None") self._args = args args = property(_get_args, _set_args) def start(self, callback, *args): if callback is None: raise TypeError('callback must be callable, not None') self.callback = callback self.args = args or _NOARGS self._libev_unref() self.loop._keepaliveset.add(self) self._watcher_start(self.loop._ptr, self._watcher) def stop(self): if self._flags & 2: self.loop.ref() self._flags &= ~2 self._watcher_stop(self.loop._ptr, self._watcher) self.loop._keepaliveset.discard(self) self._callback = None self.args = None def _get_priority(self): return libev.ev_priority(self._watcher) def _set_priority(self, priority): if libev.ev_is_active(self._watcher): raise AttributeError("Cannot set priority of an active watcher") libev.ev_set_priority(self._watcher, priority) priority = property(_get_priority, _set_priority) def feed(self, revents, callback, *args): self.callback = callback self.args = args or _NOARGS if self._flags & 6 == 4: self.loop.unref() self._flags |= 2 libev.ev_feed_event(self.loop._ptr, self._watcher, revents) if not self._flags & 1: # Py_INCREF(self) self._flags |= 1 @property def active(self): return True if libev.ev_is_active(self._watcher) else False @property def pending(self): return True if libev.ev_is_pending(self._watcher) else False class io(watcher): _watcher_type = 'ev_io' def __init__(self, loop, fd, events, ref=True, priority=None): # XXX: Win32: Need to vfd_open the fd and free the old one? # XXX: Win32: Need a destructor to free the old fd? if fd < 0: raise ValueError('fd must be non-negative: %r' % fd) if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): raise ValueError('illegal event mask: %r' % events) watcher.__init__(self, loop, ref=ref, priority=priority, args=(fd, events)) def start(self, callback, *args, **kwargs): args = args or _NOARGS if kwargs.get('pass_events'): args = (GEVENT_CORE_EVENTS, ) + args watcher.start(self, callback, *args) def _get_fd(self): return vfd_get(self._watcher.fd) def _set_fd(self, fd): if libev.ev_is_active(self._watcher): raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") vfd = vfd_open(fd) vfd_free(self._watcher.fd) self._watcher_init(self._watcher, self._watcher_callback, vfd, self._watcher.events) fd = property(_get_fd, _set_fd) def _get_events(self): return self._watcher.events def _set_events(self, events): if libev.ev_is_active(self._watcher): raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") self._watcher_init(self._watcher, self._watcher_callback, self._watcher.fd, events) events = property(_get_events, _set_events) @property def events_str(self): return _events_to_str(self._watcher.events) def _format(self): return ' fd=%s events=%s' % (self.fd, self.events_str) class timer(watcher): _watcher_type = 'ev_timer' def __init__(self, loop, after=0.0, repeat=0.0, ref=True, priority=None): if repeat < 0.0: raise ValueError("repeat must be positive or zero: %r" % repeat) watcher.__init__(self, loop, ref=ref, priority=priority, args=(after, repeat)) def start(self, callback, *args, **kw): update = kw.get("update", True) if update: # Quoth the libev doc: "This is a costly operation and is # usually done automatically within ev_run(). This # function is rarely useful, but when some event callback # runs for a very long time without entering the event # loop, updating libev's idea of the current time is a # good idea." # So do we really need to default to true? libev.ev_now_update(self.loop._ptr) watcher.start(self, callback, *args) @property def at(self): return self._watcher.at def again(self, callback, *args, **kw): # Exactly the same as start(), just with a different initializer # function self._watcher_start = libev.ev_timer_again try: self.start(callback, *args, **kw) finally: del self._watcher_start class signal(watcher): _watcher_type = 'ev_signal' def __init__(self, loop, signalnum, ref=True, priority=None): if signalnum < 1 or signalnum >= signalmodule.NSIG: raise ValueError('illegal signal number: %r' % signalnum) # still possible to crash on one of libev's asserts: # 1) "libev: ev_signal_start called with illegal signal number" # EV_NSIG might be different from signal.NSIG on some platforms # 2) "libev: a signal must not be attached to two different loops" # we probably could check that in LIBEV_EMBED mode, but not in general watcher.__init__(self, loop, ref=ref, priority=priority, args=(signalnum, )) class idle(watcher): _watcher_type = 'ev_idle' class prepare(watcher): _watcher_type = 'ev_prepare' class check(watcher): _watcher_type = 'ev_check' class fork(watcher): _watcher_type = 'ev_fork' class async(watcher): _watcher_type = 'ev_async' def send(self): libev.ev_async_send(self.loop._ptr, self._watcher) @property def pending(self): return True if libev.ev_async_pending(self._watcher) else False class child(watcher): _watcher_type = 'ev_child' def __init__(self, loop, pid, trace=0, ref=True): if not loop.default: raise TypeError('child watchers are only available on the default loop') loop.install_sigchld() watcher.__init__(self, loop, ref=ref, args=(pid, trace)) def _format(self): return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) @property def pid(self): return self._watcher.pid @property def rpid(self, ): return self._watcher.rpid @rpid.setter def rpid(self, value): self._watcher.rpid = value @property def rstatus(self): return self._watcher.rstatus @rstatus.setter def rstatus(self, value): self._watcher.rstatus = value class stat(watcher): _watcher_type = 'ev_stat' @staticmethod def _encode_path(path): if isinstance(path, bytes): return path # encode for the filesystem. Not all systems (e.g., Unix) # will have an encoding specified encoding = sys.getfilesystemencoding() or 'utf-8' try: path = path.encode(encoding, 'surrogateescape') except LookupError: # Can't encode it, and the error handler doesn't # exist. Probably on Python 2 with an astral character. # Not sure how to handle this. raise UnicodeEncodeError("Can't encode path to filesystem encoding") return path def __init__(self, _loop, path, interval=0.0, ref=True, priority=None): # Store the encoded path in the same attribute that corecext does self._paths = self._encode_path(path) # Keep the original path to avoid re-encoding, especially on Python 3 self._path = path # Although CFFI would automatically convert a bytes object into a char* when # calling ev_stat_init(..., char*, ...), on PyPy the char* pointer is not # guaranteed to live past the function call. On CPython, only with a constant/interned # bytes object is the pointer guaranteed to last path the function call. (And since # Python 3 is pretty much guaranteed to produce a newly-encoded bytes object above, thats # rarely the case). Therefore, we must keep a reference to the produced cdata object # so that the struct ev_stat_watcher's `path` pointer doesn't become invalid/deallocated self._cpath = ffi.new('char[]', self._paths) watcher.__init__(self, _loop, ref=ref, priority=priority, args=(self._cpath, interval)) @property def path(self): return self._path @property def attr(self): if not self._watcher.attr.st_nlink: return return self._watcher.attr @property def prev(self): if not self._watcher.prev.st_nlink: return return self._watcher.prev @property def interval(self): return self._watcher.interval # All watcher subclasses must be declared above. Now we do some # initialization; this is not only a minor optimization, it protects # against later runtime typos and attribute errors watcher._init_subclasses() def _syserr_cb(msg): try: msg = ffi.string(msg) __SYSERR_CALLBACK(msg, ffi.errno) except: set_syserr_cb(None) raise # let cffi print the traceback _syserr_cb._cb = ffi.callback("void(*)(char *msg)", _syserr_cb) def set_syserr_cb(callback): global __SYSERR_CALLBACK if callback is None: libev.ev_set_syserr_cb(ffi.NULL) __SYSERR_CALLBACK = None elif callable(callback): libev.ev_set_syserr_cb(_syserr_cb._cb) __SYSERR_CALLBACK = callback else: raise TypeError('Expected callable or None, got %r' % (callback, )) __SYSERR_CALLBACK = None LIBEV_EMBED = True gevent-1.1.0/gevent/coros.py0000644000076500000000000000037312666555342016531 0ustar jmaddenwheel00000000000000# This module definitely remains in 1.0.x, probably in versions after that too. import warnings warnings.warn('gevent.coros has been renamed to gevent.lock', DeprecationWarning, stacklevel=2) from gevent.lock import * from gevent.lock import __all__ gevent-1.1.0/gevent/dnshelper.c0000644000076500000000000000770112666555342017164 0ustar jmaddenwheel00000000000000/* Copyright (c) 2011 Denis Bilenko. See LICENSE for details. */ #include "Python.h" #ifdef CARES_EMBED #include "ares_setup.h" #endif #ifdef HAVE_NETDB_H #include #endif #include "ares.h" #include "cares_ntop.h" #include "cares_pton.h" #if PY_VERSION_HEX < 0x02060000 #define PyUnicode_FromString PyString_FromString #elif PY_MAJOR_VERSION < 3 #define PyUnicode_FromString PyBytes_FromString #endif static PyObject* _socket_error = 0; static PyObject* get_socket_object(PyObject** pobject, const char* name) { if (!*pobject) { PyObject* _socket; _socket = PyImport_ImportModule("_socket"); if (_socket) { *pobject = PyObject_GetAttrString(_socket, name); if (!*pobject) { PyErr_WriteUnraisable(Py_None); } Py_DECREF(_socket); } else { PyErr_WriteUnraisable(Py_None); } if (!*pobject) { *pobject = PyExc_IOError; } } return *pobject; } static int gevent_append_addr(PyObject* list, int family, void* src, char* tmpbuf, size_t tmpsize) { int status = -1; PyObject* tmp; if (ares_inet_ntop(family, src, tmpbuf, tmpsize)) { tmp = PyUnicode_FromString(tmpbuf); if (tmp) { status = PyList_Append(list, tmp); Py_DECREF(tmp); } } return status; } static PyObject* parse_h_name(struct hostent *h) { return PyUnicode_FromString(h->h_name); } static PyObject* parse_h_aliases(struct hostent *h) { char **pch; PyObject *result = NULL; PyObject *tmp; result = PyList_New(0); if (result && h->h_aliases) { for (pch = h->h_aliases; *pch != NULL; pch++) { if (*pch != h->h_name && strcmp(*pch, h->h_name)) { int status; tmp = PyUnicode_FromString(*pch); if (tmp == NULL) { break; } status = PyList_Append(result, tmp); Py_DECREF(tmp); if (status) { break; } } } } return result; } static PyObject * parse_h_addr_list(struct hostent *h) { char **pch; PyObject *result = NULL; result = PyList_New(0); if (result) { switch (h->h_addrtype) { case AF_INET: { char tmpbuf[sizeof "255.255.255.255"]; for (pch = h->h_addr_list; *pch != NULL; pch++) { if (gevent_append_addr(result, AF_INET, *pch, tmpbuf, sizeof(tmpbuf))) { break; } } break; } case AF_INET6: { char tmpbuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; for (pch = h->h_addr_list; *pch != NULL; pch++) { if (gevent_append_addr(result, AF_INET6, *pch, tmpbuf, sizeof(tmpbuf))) { break; } } break; } default: PyErr_SetString(get_socket_object(&_socket_error, "error"), "unsupported address family"); Py_DECREF(result); result = NULL; } } return result; } static int gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, struct sockaddr_in6* sa6) { if ( ares_inet_pton(AF_INET, hostp, &((struct sockaddr_in*)sa6)->sin_addr.s_addr) > 0 ) { ((struct sockaddr_in*)sa6)->sin_family = AF_INET; ((struct sockaddr_in*)sa6)->sin_port = htons(port); return sizeof(struct sockaddr_in); } else if ( ares_inet_pton(AF_INET6, hostp, &sa6->sin6_addr.s6_addr) > 0 ) { sa6->sin6_family = AF_INET6; sa6->sin6_port = htons(port); sa6->sin6_flowinfo = flowinfo; sa6->sin6_scope_id = scope_id; return sizeof(struct sockaddr_in6); } return -1; } gevent-1.1.0/gevent/event.py0000644000076500000000000004117012666555342016525 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2016 Denis Bilenko, gevent contributors. See LICENSE for details. """Basic synchronization primitives: Event and AsyncResult""" from __future__ import print_function import sys from gevent.hub import get_hub, getcurrent, _NONE, reraise from gevent.hub import InvalidSwitchError from gevent.timeout import Timeout from gevent._tblib import dump_traceback, load_traceback __all__ = ['Event', 'AsyncResult'] class _AbstractLinkable(object): # Encapsulates the standard parts of the linking and notifying protocol # common to both repeatable events and one-time events (AsyncResolt). _notifier = None def __init__(self): # Also previously, AsyncResult maintained the order of notifications, but Event # did not; this implementation does not. (Event also only call callbacks one # time (set), but AsyncResult permitted duplicates.) # HOWEVER, gevent.queue.Queue does guarantee the order of getters relative # to putters. Some existing documentation out on the net likes to refer to # gevent as "deterministic", such that running the same program twice will # produce results in the same order (so long as I/O isn't involved). This could # be an argument to maintain order. (One easy way to do that while guaranteeing # uniqueness would be with a 2.7+ OrderedDict.) self._links = set() self.hub = get_hub() def ready(self): # Instances must define this raise NotImplementedError() def _check_and_notify(self): # If this object is ready to be notified, begin the process. if self.ready(): if self._links and not self._notifier: self._notifier = self.hub.loop.run_callback(self._notify_links) def rawlink(self, callback): """ Register a callback to call when this object is ready. *callback* will be called in the :class:`Hub `, so it must not use blocking gevent API. *callback* will be passed one argument: this instance. """ if not callable(callback): raise TypeError('Expected callable: %r' % (callback, )) self._links.add(callback) self._check_and_notify() def unlink(self, callback): """Remove the callback set by :meth:`rawlink`""" try: self._links.remove(callback) except KeyError: pass def _notify_links(self): # Actually call the notification callbacks. Those callbacks in todo that are # still in _links are called. This method is careful to avoid iterating # over self._links, because links could be added or removed while this # method runs. For the same reason, we loop, checking for new items in # _links. # We don't need to capture self._links as todo when establishing # this callback; any links removed between now and then are handled # by the `if` below; any links added are also grabbed todo = set(self._links) done = set() while todo: for link in todo: # check that link was not notified yet and was not removed by the client # We have to do this here, and not as part of the 'for' statement because # a previous link(self) call might have altered self._links if link in self._links: try: link(self) except: self.hub.handle_error((link, self), *sys.exc_info()) # Mark everything done done.update(todo) # Anything extra now in self._links but not yet done, loop # again for todo = self._links - done def _wait_core(self, timeout, catch=Timeout): # The core of the wait implementation, handling # switching and linking. If *catch* is set to (), # a timeout that elapses will be allowed to be raised. # Returns a true value if the wait succeeded without timing out. switch = getcurrent().switch self.rawlink(switch) try: timer = Timeout._start_new_or_dummy(timeout) try: try: result = self.hub.switch() if result is not self: # pragma: no cover raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, )) return True except catch as ex: if ex is not timer: raise # test_set_and_clear and test_timeout in test_threading # rely on the exact return values, not just truthish-ness return False finally: timer.cancel() finally: self.unlink(switch) def _wait_return_value(self, waited, wait_success): return None def _wait(self, timeout=None): if self.ready(): return self._wait_return_value(False, False) gotit = self._wait_core(timeout) return self._wait_return_value(True, gotit) class Event(_AbstractLinkable): """A synchronization primitive that allows one greenlet to wake up one or more others. It has the same interface as :class:`threading.Event` but works across greenlets. An event object manages an internal flag that can be set to true with the :meth:`set` method and reset to false with the :meth:`clear` method. The :meth:`wait` method blocks until the flag is true. .. note:: The order and timing in which waiting greenlets are awakened is not determined. As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets (those not waiting to be awakened) may run between the current greenlet yielding and the waiting greenlets being awakened. These details may change in the future. """ _flag = False def __str__(self): return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links)) def is_set(self): """Return true if and only if the internal flag is true.""" return self._flag isSet = is_set # makes it a better drop-in replacement for threading.Event ready = is_set # makes it compatible with AsyncResult and Greenlet (for example in wait()) def set(self): """ Set the internal flag to true. All greenlets waiting for it to become true are awakened in some order at some time in the future. Greenlets that call :meth:`wait` once the flag is true will not block at all (until :meth:`clear` is called). """ self._flag = True self._check_and_notify() def clear(self): """ Reset the internal flag to false. Subsequently, threads calling :meth:`wait` will block until :meth:`set` is called to set the internal flag to true again. """ self._flag = False def _wait_return_value(self, waited, gotit): # To avoid the race condition outlined in http://bugs.python.org/issue13502, # if we had to wait, then we need to return whether or not # the condition got changed. Otherwise we simply echo # the current state of the flag (which should be true) if not waited: flag = self._flag assert flag, "if we didn't wait we should already be set" return flag return gotit def wait(self, timeout=None): """ Block until the internal flag is true. If the internal flag is true on entry, return immediately. Otherwise, block until another thread (greenlet) calls :meth:`set` to set the flag to true, or until the optional timeout occurs. When the *timeout* argument is present and not ``None``, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). :return: This method returns true if and only if the internal flag has been set to true, either before the wait call or after the wait starts, so it will always return ``True`` except if a timeout is given and the operation times out. .. versionchanged:: 1.1 The return value represents the flag during the elapsed wait, not just after it elapses. This solves a race condition if one greenlet sets and then clears the flag without switching, while other greenlets are waiting. When the waiters wake up, this will return True; previously, they would still wake up, but the return value would be False. This is most noticeable when the *timeout* is present. """ return self._wait(timeout) def _reset_internal_locks(self): # pragma: no cover # for compatibility with threading.Event (only in case of patch_all(Event=True), by default Event is not patched) # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",) # in ignored pass class AsyncResult(_AbstractLinkable): """A one-time event that stores a value or an exception. Like :class:`Event` it wakes up all the waiters when :meth:`set` or :meth:`set_exception` is called. Waiters may receive the passed value or exception by calling :meth:`get` instead of :meth:`wait`. An :class:`AsyncResult` instance cannot be reset. To pass a value call :meth:`set`. Calls to :meth:`get` (those that are currently blocking as well as those made in the future) will return the value: >>> result = AsyncResult() >>> result.set(100) >>> result.get() 100 To pass an exception call :meth:`set_exception`. This will cause :meth:`get` to raise that exception: >>> result = AsyncResult() >>> result.set_exception(RuntimeError('failure')) >>> result.get() Traceback (most recent call last): ... RuntimeError: failure :class:`AsyncResult` implements :meth:`__call__` and thus can be used as :meth:`link` target: >>> import gevent >>> result = AsyncResult() >>> gevent.spawn(lambda : 1/0).link(result) >>> try: ... result.get() ... except ZeroDivisionError: ... print('ZeroDivisionError') ZeroDivisionError .. note:: The order and timing in which waiting greenlets are awakened is not determined. As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets (those not waiting to be awakened) may run between the current greenlet yielding and the waiting greenlets being awakened. These details may change in the future. .. versionchanged:: 1.1 The exact order in which waiting greenlets are awakened is not the same as in 1.0. .. versionchanged:: 1.1 Callbacks :meth:`linked ` to this object are required to be hashable, and duplicates are merged. """ _value = _NONE _exc_info = () _notifier = None @property def _exception(self): return self._exc_info[1] if self._exc_info else _NONE @property def value(self): """ Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise, ``None`` """ return self._value if self._value is not _NONE else None @property def exc_info(self): """ The three-tuple of exception information if :meth:`set_exception` was called. """ if self._exc_info: return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2])) return () def __str__(self): result = '<%s ' % (self.__class__.__name__, ) if self.value is not None or self._exception is not _NONE: result += 'value=%r ' % self.value if self._exception is not None and self._exception is not _NONE: result += 'exception=%r ' % self._exception if self._exception is _NONE: result += 'unset ' return result + ' _links[%s]>' % len(self._links) def ready(self): """Return true if and only if it holds a value or an exception""" return self._exc_info or self._value is not _NONE def successful(self): """Return true if and only if it is ready and holds a value""" return self._value is not _NONE @property def exception(self): """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called. Otherwise ``None``.""" if self._exc_info: return self._exc_info[1] def set(self, value=None): """Store the value and wake up any waiters. All greenlets blocking on :meth:`get` or :meth:`wait` are awakened. Subsequent calls to :meth:`wait` and :meth:`get` will not block at all. """ self._value = value self._check_and_notify() def set_exception(self, exception, exc_info=None): """Store the exception and wake up any waiters. All greenlets blocking on :meth:`get` or :meth:`wait` are awakened. Subsequent calls to :meth:`wait` and :meth:`get` will not block at all. :keyword tuple exc_info: If given, a standard three-tuple of type, value, :class:`traceback` as returned by :func:`sys.exc_info`. This will be used when the exception is re-raised to propagate the correct traceback. """ if exc_info: self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2])) else: self._exc_info = (type(exception), exception, dump_traceback(None)) self._check_and_notify() def _raise_exception(self): reraise(*self.exc_info) def get(self, block=True, timeout=None): """Return the stored value or raise the exception. If this instance already holds a value or an exception, return or raise it immediatelly. Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or until the optional timeout occurs. When the *timeout* argument is present and not ``None``, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). If the *timeout* elapses, the *Timeout* exception will be raised. :keyword bool block: If set to ``False`` and this instance is not ready, immediately raise a :class:`Timeout` exception. """ if self._value is not _NONE: return self._value if self._exc_info: return self._raise_exception() if not block: # Not ready and not blocking, so immediately timeout raise Timeout() # Wait, raising a timeout that elapses self._wait_core(timeout, ()) # by definition we are now ready return self.get(block=False) def get_nowait(self): """ Return the value or raise the exception without blocking. If this object is not yet :meth:`ready `, raise :class:`gevent.Timeout` immediately. """ return self.get(block=False) def _wait_return_value(self, waited, gotit): # Always return the value. Since this is a one-shot event, # no race condition should reset it. return self.value def wait(self, timeout=None): """Block until the instance is ready. If this instance already holds a value, it is returned immediately. If this instance already holds an exception, ``None`` is returned immediately. Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` (at which point either the value or ``None`` will be returned, respectively), or until the optional timeout expires (at which point ``None`` will also be returned). When the *timeout* argument is present and not ``None``, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). .. note:: If a timeout is given and expires, ``None`` will be returned (no timeout exception will be raised). """ return self._wait(timeout) # link protocol def __call__(self, source): if source.successful(): self.set(source.value) else: self.set_exception(source.exception, getattr(source, 'exc_info', None)) gevent-1.1.0/gevent/fileobject.py0000644000076500000000000001710712666555342017515 0ustar jmaddenwheel00000000000000""" Wrappers to make file-like objects cooperative. .. class:: FileObject The main entry point to the file-like gevent-compatible behaviour. It will be defined to be the best available implementation. There are two main implementations of ``FileObject``. On all systems, there is :class:`FileObjectThread` which uses the built-in native threadpool to avoid blocking the entire interpreter. On UNIX systems (those that support the :mod:`fcntl` module), there is also :class:`FileObjectPosix` which uses native non-blocking semantics. A third class, :class:`FileObjectBlock`, is simply a wrapper that executes everything synchronously (and so is not gevent-compatible). It is provided for testing and debugging purposes. Configuration ============= You may change the default value for ``FileObject`` using the ``GEVENT_FILE`` environment variable. Set it to ``posix``, ``thread``, or ``block`` to choose from :class:`FileObjectPosix`, :class:`FileObjectThread` and :class:`FileObjectBlock`, respectively. You may also set it to the fully qualified class name of another object that implements the file interface to use one of your own objects. .. note:: The environment variable must be set at the time this module is first imported. Classes ======= """ from __future__ import absolute_import import sys import os from gevent._fileobjectcommon import FileObjectClosed from gevent.hub import get_hub from gevent.hub import integer_types from gevent.hub import reraise from gevent.lock import Semaphore, DummySemaphore PYPY = hasattr(sys, 'pypy_version_info') if hasattr(sys, 'exc_clear'): def _exc_clear(): sys.exc_clear() else: def _exc_clear(): return __all__ = ['FileObjectPosix', 'FileObjectThread', 'FileObject'] try: from fcntl import fcntl except ImportError: __all__.remove("FileObjectPosix") else: del fcntl from gevent._fileobjectposix import FileObjectPosix class FileObjectThread(object): """ A file-like object wrapping another file-like object, performing all blocking operations on that object in a background thread. """ def __init__(self, fobj, *args, **kwargs): """ :param fobj: The underlying file-like object to wrap, or an integer fileno that will be pass to :func:`os.fdopen` along with everything in *args*. :keyword bool lock: If True (the default) then all operations will be performed one-by-one. Note that this does not guarantee that, if using this file object from multiple threads/greenlets, operations will be performed in any particular order, only that no two operations will be attempted at the same time. You can also pass your own :class:`gevent.lock.Semaphore` to synchronize file operations with an external resource. :keyword bool close: If True (the default) then when this object is closed, the underlying object is closed as well. """ self._close = kwargs.pop('close', True) self.threadpool = kwargs.pop('threadpool', None) self.lock = kwargs.pop('lock', True) if kwargs: raise TypeError('Unexpected arguments: %r' % kwargs.keys()) if self.lock is True: self.lock = Semaphore() elif not self.lock: self.lock = DummySemaphore() if not hasattr(self.lock, '__enter__'): raise TypeError('Expected a Semaphore or boolean, got %r' % type(self.lock)) if isinstance(fobj, integer_types): if not self._close: # we cannot do this, since fdopen object will close the descriptor raise TypeError('FileObjectThread does not support close=False') fobj = os.fdopen(fobj, *args) self.io = fobj if self.threadpool is None: self.threadpool = get_hub().threadpool def _apply(self, func, args=None, kwargs=None): with self.lock: return self.threadpool.apply(func, args, kwargs) def close(self): """ .. versionchanged:: 1.1b1 The file object is closed using the threadpool. Note that whether or not this action is synchronous or asynchronous is not documented. """ fobj = self.io if fobj is None: return self.io = None try: self.flush(_fobj=fobj) finally: if self._close: # Note that we're not using self._apply; older code # did fobj.close() without going through the threadpool at all, # so acquiring the lock could potentially introduce deadlocks # that weren't present before. Avoiding the lock doesn't make # the existing race condition any worse. # We wrap the close in an exception handler and re-raise directly # to avoid the (common, expected) IOError from being logged def close(): try: fobj.close() except: return sys.exc_info() exc_info = self.threadpool.apply(close) if exc_info: reraise(*exc_info) def flush(self, _fobj=None): if _fobj is not None: fobj = _fobj else: fobj = self.io if fobj is None: raise FileObjectClosed return self._apply(fobj.flush) def __repr__(self): return '<%s _fobj=%r threadpool=%r>' % (self.__class__.__name__, self.io, self.threadpool) def __getattr__(self, item): if self.io is None: if item == 'closed': return True raise FileObjectClosed return getattr(self.io, item) def __iter__(self): return self def next(self): line = self.readline() if line: return line raise StopIteration __next__ = next def _wraps(method): def x(self, *args, **kwargs): fobj = self.io if fobj is None: raise FileObjectClosed return self._apply(getattr(fobj, method), args, kwargs) x.__name__ = method return x for method in ('read', 'readinto', 'readline', 'readlines', 'write', 'writelines', 'xreadlines'): locals()[method] = _wraps(method) del method del _wraps try: FileObject = FileObjectPosix except NameError: FileObject = FileObjectThread class FileObjectBlock(object): def __init__(self, fobj, *args, **kwargs): self._close = kwargs.pop('close', True) if kwargs: raise TypeError('Unexpected arguments: %r' % kwargs.keys()) if isinstance(fobj, integer_types): if not self._close: # we cannot do this, since fdopen object will close the descriptor raise TypeError('FileObjectBlock does not support close=False') fobj = os.fdopen(fobj, *args) self.io = fobj def __repr__(self): return '<%s %r>' % (self.io, ) def __getattr__(self, item): assert item != '_fobj' if self.io is None: raise FileObjectClosed return getattr(self.io, item) config = os.environ.get('GEVENT_FILE') if config: klass = {'thread': 'gevent.fileobject.FileObjectThread', 'posix': 'gevent.fileobject.FileObjectPosix', 'block': 'gevent.fileobject.FileObjectBlock'}.get(config, config) if klass.startswith('gevent.fileobject.'): FileObject = globals()[klass.split('.', 2)[-1]] else: from gevent.hub import _import FileObject = _import(klass) del klass gevent-1.1.0/gevent/gevent._semaphore.c0000644000076500000000000113434612666555432020620 0ustar jmaddenwheel00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__gevent___semaphore #define __PYX_HAVE_API__gevent___semaphore #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "gevent/_semaphore.py", "gevent/_semaphore.pxd", }; /*--- Type declarations ---*/ struct __pyx_obj_6gevent_10_semaphore_Semaphore; struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore; struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait; struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire; /* "gevent/_semaphore.pxd":15 * cpdef _notify_links(self) * cdef _do_wait(self, object timeout) * cpdef int wait(self, object timeout=*) except -1000 # <<<<<<<<<<<<<< * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 * cpdef __enter__(self) */ struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait { int __pyx_n; PyObject *timeout; }; /* "gevent/_semaphore.pxd":16 * cdef _do_wait(self, object timeout) * cpdef int wait(self, object timeout=*) except -1000 * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 # <<<<<<<<<<<<<< * cpdef __enter__(self) * cpdef __exit__(self, object t, object v, object tb) */ struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire { int __pyx_n; int blocking; PyObject *timeout; }; /* "gevent/_semaphore.pxd":1 * cdef class Semaphore: # <<<<<<<<<<<<<< * cdef public int counter * cdef readonly object _links */ struct __pyx_obj_6gevent_10_semaphore_Semaphore { PyObject_HEAD struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *__pyx_vtab; int counter; PyObject *_links; PyObject *_notifier; int _dirty; PyObject *__weakref__; }; /* "gevent/_semaphore.pxd":20 * cpdef __exit__(self, object t, object v, object tb) * * cdef class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<< * cdef readonly int _initial_value * */ struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore { struct __pyx_obj_6gevent_10_semaphore_Semaphore __pyx_base; int _initial_value; }; /* "gevent/_semaphore.py":9 * * * class Semaphore(object): # <<<<<<<<<<<<<< * """ * Semaphore(value=1) -> Semaphore */ struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore { int (*locked)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); int (*release)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); PyObject *(*rawlink)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch); PyObject *(*unlink)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch); PyObject *(*_start_notify)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); PyObject *(*_notify_links)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); PyObject *(*_do_wait)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *); int (*wait)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args); int (*acquire)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args); PyObject *(*__pyx___enter__)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); PyObject *(*__pyx___exit__)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *__pyx_vtabptr_6gevent_10_semaphore_Semaphore; /* "gevent/_semaphore.py":246 * * * class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<< * """ * BoundedSemaphore(value=1) -> BoundedSemaphore */ struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore { struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore __pyx_base; }; static struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore *__pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) #else #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); static int __Pyx_SetVtable(PyObject *dict, void *vtable); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static int __pyx_f_6gevent_10_semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args); /* proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/ static int __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from 'gevent._semaphore' */ static PyTypeObject *__pyx_ptype_6gevent_10_semaphore_Semaphore = 0; static PyTypeObject *__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore = 0; #define __Pyx_MODULE_NAME "gevent._semaphore" int __pyx_module_is_main_gevent___semaphore = 0; /* Implementation of 'gevent._semaphore' */ static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_TypeError; static PyObject *__pyx_builtin_AttributeError; static char __pyx_k_t[] = "t"; static char __pyx_k_v[] = "v"; static char __pyx_k_tb[] = "tb"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_sys[] = "sys"; static char __pyx_k_exit[] = "__exit__"; static char __pyx_k_init[] = "__init__"; static char __pyx_k_loop[] = "loop"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_name[] = "__name__"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_wait[] = "wait"; static char __pyx_k_class[] = "__class__"; static char __pyx_k_enter[] = "__enter__"; static char __pyx_k_value[] = "value"; static char __pyx_k_append[] = "append"; static char __pyx_k_cancel[] = "cancel"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_locked[] = "locked"; static char __pyx_k_remove[] = "remove"; static char __pyx_k_switch[] = "switch"; static char __pyx_k_unlink[] = "unlink"; static char __pyx_k_Timeout[] = "Timeout"; static char __pyx_k_acquire[] = "acquire"; static char __pyx_k_get_hub[] = "get_hub"; static char __pyx_k_rawlink[] = "rawlink"; static char __pyx_k_release[] = "release"; static char __pyx_k_timeout[] = "timeout"; static char __pyx_k_blocking[] = "blocking"; static char __pyx_k_exc_info[] = "exc_info"; static char __pyx_k_Semaphore[] = "Semaphore"; static char __pyx_k_TypeError[] = "TypeError"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_getcurrent[] = "getcurrent"; static char __pyx_k_gevent_hub[] = "gevent.hub"; static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static char __pyx_k_handle_error[] = "handle_error"; static char __pyx_k_notify_links[] = "_notify_links"; static char __pyx_k_py3k_acquire[] = "_py3k_acquire"; static char __pyx_k_run_callback[] = "run_callback"; static char __pyx_k_start_notify[] = "_start_notify"; static char __pyx_k_AttributeError[] = "AttributeError"; static char __pyx_k_gevent_timeout[] = "gevent.timeout"; static char __pyx_k_BoundedSemaphore[] = "BoundedSemaphore"; static char __pyx_k_Expected_callable[] = "Expected callable:"; static char __pyx_k_OVER_RELEASE_ERROR[] = "_OVER_RELEASE_ERROR"; static char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy"; static char __pyx_k_s_counter_s__links_s[] = "<%s counter=%s _links[%s]>"; static char __pyx_k_semaphore_initial_value_must_be[] = "semaphore initial value must be >= 0"; static char __pyx_k_Invalid_switch_into_Semaphore_wa[] = "Invalid switch into Semaphore.wait/acquire(): %r"; static char __pyx_k_Semaphore_released_too_many_time[] = "Semaphore released too many times"; static PyObject *__pyx_n_s_AttributeError; static PyObject *__pyx_n_s_BoundedSemaphore; static PyObject *__pyx_kp_s_Expected_callable; static PyObject *__pyx_kp_s_Invalid_switch_into_Semaphore_wa; static PyObject *__pyx_n_s_OVER_RELEASE_ERROR; static PyObject *__pyx_n_s_Semaphore; static PyObject *__pyx_kp_s_Semaphore_released_too_many_time; static PyObject *__pyx_n_s_Timeout; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_acquire; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_append; static PyObject *__pyx_n_s_blocking; static PyObject *__pyx_n_s_cancel; static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_enter; static PyObject *__pyx_n_s_exc_info; static PyObject *__pyx_n_s_exit; static PyObject *__pyx_n_s_get_hub; static PyObject *__pyx_n_s_getcurrent; static PyObject *__pyx_n_s_gevent_hub; static PyObject *__pyx_n_s_gevent_timeout; static PyObject *__pyx_n_s_handle_error; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_locked; static PyObject *__pyx_n_s_loop; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_notify_links; static PyObject *__pyx_n_s_py3k_acquire; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_rawlink; static PyObject *__pyx_n_s_release; static PyObject *__pyx_n_s_remove; static PyObject *__pyx_n_s_run_callback; static PyObject *__pyx_kp_s_s_counter_s__links_s; static PyObject *__pyx_kp_s_semaphore_initial_value_must_be; static PyObject *__pyx_n_s_start_new_or_dummy; static PyObject *__pyx_n_s_start_notify; static PyObject *__pyx_n_s_switch; static PyObject *__pyx_n_s_sys; static PyObject *__pyx_n_s_t; static PyObject *__pyx_n_s_tb; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_timeout; static PyObject *__pyx_n_s_unlink; static PyObject *__pyx_n_s_v; static PyObject *__pyx_n_s_value; static PyObject *__pyx_n_s_wait; static int __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self); /* proto */ static PyObject *__pyx_tp_new_6gevent_10_semaphore_Semaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; /* "gevent/_semaphore.py":29 * """ * * def __init__(self, value=1): # <<<<<<<<<<<<<< * if value < 0: * raise ValueError("semaphore initial value must be >= 0") */ /* Python wrapper */ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_value = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)__pyx_int_1); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_value = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_value); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/_semaphore.py":30 * * def __init__(self, value=1): * if value < 0: # <<<<<<<<<<<<<< * raise ValueError("semaphore initial value must be >= 0") * self.counter = value */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "gevent/_semaphore.py":31 * def __init__(self, value=1): * if value < 0: * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<< * self.counter = value * self._dirty = False */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/_semaphore.py":30 * * def __init__(self, value=1): * if value < 0: # <<<<<<<<<<<<<< * raise ValueError("semaphore initial value must be >= 0") * self.counter = value */ } /* "gevent/_semaphore.py":32 * if value < 0: * raise ValueError("semaphore initial value must be >= 0") * self.counter = value # <<<<<<<<<<<<<< * self._dirty = False * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->counter = __pyx_t_3; /* "gevent/_semaphore.py":33 * raise ValueError("semaphore initial value must be >= 0") * self.counter = value * self._dirty = False # <<<<<<<<<<<<<< * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef * # readonly` or simply `cdef` attributes of type `object` can appear to leak if */ __pyx_v_self->_dirty = 0; /* "gevent/_semaphore.py":47 * # CPython ("No attribute...") * # See https://github.com/gevent/gevent/issues/660 * self._links = None # <<<<<<<<<<<<<< * self._notifier = None * # we don't want to do get_hub() here to allow defining module-level locks */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_links); __Pyx_DECREF(__pyx_v_self->_links); __pyx_v_self->_links = Py_None; /* "gevent/_semaphore.py":48 * # See https://github.com/gevent/gevent/issues/660 * self._links = None * self._notifier = None # <<<<<<<<<<<<<< * # we don't want to do get_hub() here to allow defining module-level locks * # without initializing the hub */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; /* "gevent/_semaphore.py":29 * """ * * def __init__(self, value=1): # <<<<<<<<<<<<<< * if value < 0: * raise ValueError("semaphore initial value must be >= 0") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":52 * # without initializing the hub * * def __str__(self): # <<<<<<<<<<<<<< * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) * return '<%s counter=%s _links[%s]>' % params */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_v_params = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); /* "gevent/_semaphore.py":53 * * def __str__(self): * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) # <<<<<<<<<<<<<< * return '<%s counter=%s _links[%s]>' % params * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { __pyx_t_5 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } else { __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; } __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_v_params = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; /* "gevent/_semaphore.py":54 * def __str__(self): * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) * return '<%s counter=%s _links[%s]>' % params # <<<<<<<<<<<<<< * * def locked(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_counter_s__links_s, __pyx_v_params); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "gevent/_semaphore.py":52 * # without initializing the hub * * def __str__(self): # <<<<<<<<<<<<<< * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) * return '<%s counter=%s _links[%s]>' % params */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_params); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":56 * return '<%s counter=%s _links[%s]>' % params * * def locked(self): # <<<<<<<<<<<<<< * """Return a boolean indicating whether the semaphore can be acquired. * Most useful with binary semaphores.""" */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("locked", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_locked); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked)) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":59 * """Return a boolean indicating whether the semaphore can be acquired. * Most useful with binary semaphores.""" * return self.counter <= 0 # <<<<<<<<<<<<<< * * def release(self): */ __pyx_r = (__pyx_v_self->counter <= 0); goto __pyx_L0; /* "gevent/_semaphore.py":56 * return '<%s counter=%s _links[%s]>' % params * * def locked(self): # <<<<<<<<<<<<<< * """Return a boolean indicating whether the semaphore can be acquired. * Most useful with binary semaphores.""" */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_WriteUnraisable("gevent._semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_4locked[] = "Return a boolean indicating whether the semaphore can be acquired.\n Most useful with binary semaphores."; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("locked (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("locked", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_10_semaphore_9Semaphore_locked(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":61 * return self.counter <= 0 * * def release(self): # <<<<<<<<<<<<<< * """ * Release the semaphore, notifying any waiters if needed. */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("release", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_7release)) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":65 * Release the semaphore, notifying any waiters if needed. * """ * self.counter += 1 # <<<<<<<<<<<<<< * self._start_notify() * return self.counter */ __pyx_v_self->counter = (__pyx_v_self->counter + 1); /* "gevent/_semaphore.py":66 * """ * self.counter += 1 * self._start_notify() # <<<<<<<<<<<<<< * return self.counter * */ __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_start_notify(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":67 * self.counter += 1 * self._start_notify() * return self.counter # <<<<<<<<<<<<<< * * def _start_notify(self): */ __pyx_r = __pyx_v_self->counter; goto __pyx_L0; /* "gevent/_semaphore.py":61 * return self.counter <= 0 * * def release(self): # <<<<<<<<<<<<<< * """ * Release the semaphore, notifying any waiters if needed. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_6release[] = "\n Release the semaphore, notifying any waiters if needed.\n "; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("release (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6release(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("release", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent._semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":69 * return self.counter * * def _start_notify(self): # <<<<<<<<<<<<<< * if self._links and self.counter > 0 and not self._notifier: * # We create a new self._notifier each time through the loop, */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_start_notify", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_start_notify); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":70 * * def _start_notify(self): * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<< * # We create a new self._notifier each time through the loop, * # if needed. (it has a __bool__ method that tells whether it has */ __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = ((__pyx_v_self->counter > 0) != 0); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((!__pyx_t_6) != 0); __pyx_t_5 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_5) { /* "gevent/_semaphore.py":78 * # with Cython <= 0.23.3. You must use >= 0.23.4. * # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546 * self._notifier = get_hub().loop.run_callback(self._notify_links) # <<<<<<<<<<<<<< * * def _notify_links(self): */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loop); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/_semaphore.py":70 * * def _start_notify(self): * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<< * # We create a new self._notifier each time through the loop, * # if needed. (it has a __bool__ method that tells whether it has */ } /* "gevent/_semaphore.py":69 * return self.counter * * def _start_notify(self): # <<<<<<<<<<<<<< * if self._links and self.counter > 0 and not self._notifier: * # We create a new self._notifier each time through the loop, */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gevent._semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_start_notify (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_start_notify", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":80 * self._notifier = get_hub().loop.run_callback(self._notify_links) * * def _notify_links(self): # <<<<<<<<<<<<<< * # Subclasses CANNOT override. This is a cdef method. * */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_v_notifier = NULL; PyObject *__pyx_v_link = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; Py_ssize_t __pyx_t_7; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; int __pyx_t_17; int __pyx_t_18; char const *__pyx_t_19; PyObject *__pyx_t_20 = NULL; PyObject *__pyx_t_21 = NULL; PyObject *__pyx_t_22 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_notify_links", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":89 * # no need to keep it around until that point (making it potentially climb * # into older GC generations, notably on PyPy) * notifier = self._notifier # <<<<<<<<<<<<<< * try: * while True: */ __pyx_t_1 = __pyx_v_self->_notifier; __Pyx_INCREF(__pyx_t_1); __pyx_v_notifier = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/_semaphore.py":90 * # into older GC generations, notably on PyPy) * notifier = self._notifier * try: # <<<<<<<<<<<<<< * while True: * self._dirty = False */ /*try:*/ { /* "gevent/_semaphore.py":91 * notifier = self._notifier * try: * while True: # <<<<<<<<<<<<<< * self._dirty = False * if not self._links: */ while (1) { /* "gevent/_semaphore.py":92 * try: * while True: * self._dirty = False # <<<<<<<<<<<<<< * if not self._links: * # In case we were manually unlinked before */ __pyx_v_self->_dirty = 0; /* "gevent/_semaphore.py":93 * while True: * self._dirty = False * if not self._links: # <<<<<<<<<<<<<< * # In case we were manually unlinked before * # the callback. Which shouldn't happen */ __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __pyx_t_6 = ((!__pyx_t_5) != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":96 * # In case we were manually unlinked before * # the callback. Which shouldn't happen * return # <<<<<<<<<<<<<< * for link in self._links: * if self.counter <= 0: */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L3_return; /* "gevent/_semaphore.py":93 * while True: * self._dirty = False * if not self._links: # <<<<<<<<<<<<<< * # In case we were manually unlinked before * # the callback. Which shouldn't happen */ } /* "gevent/_semaphore.py":97 * # the callback. Which shouldn't happen * return * for link in self._links: # <<<<<<<<<<<<<< * if self.counter <= 0: * return */ if (likely(PyList_CheckExact(__pyx_v_self->_links)) || PyTuple_CheckExact(__pyx_v_self->_links)) { __pyx_t_1 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_links); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_8(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L4_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":98 * return * for link in self._links: * if self.counter <= 0: # <<<<<<<<<<<<<< * return * try: */ __pyx_t_6 = ((__pyx_v_self->counter <= 0) != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":99 * for link in self._links: * if self.counter <= 0: * return # <<<<<<<<<<<<<< * try: * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3_return; /* "gevent/_semaphore.py":98 * return * for link in self._links: * if self.counter <= 0: # <<<<<<<<<<<<<< * return * try: */ } /* "gevent/_semaphore.py":100 * if self.counter <= 0: * return * try: # <<<<<<<<<<<<<< * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory * except: */ { __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); /*try:*/ { /* "gevent/_semaphore.py":101 * return * try: * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory # <<<<<<<<<<<<<< * except: * getcurrent().handle_error((link, self), *sys.exc_info()) */ __Pyx_INCREF(__pyx_v_link); __pyx_t_3 = __pyx_v_link; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L12_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L12_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_12, 0+1, ((PyObject *)__pyx_v_self)); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L12_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":100 * if self.counter <= 0: * return * try: # <<<<<<<<<<<<<< * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory * except: */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L19_try_end; __pyx_L12_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":102 * try: * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory * except: # <<<<<<<<<<<<<< * getcurrent().handle_error((link, self), *sys.exc_info()) * if self._dirty: */ /*except:*/ { __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_12); /* "gevent/_semaphore.py":103 * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory * except: * getcurrent().handle_error((link, self), *sys.exc_info()) # <<<<<<<<<<<<<< * if self._dirty: * # We mutated self._links so we need to start over */ __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (__pyx_t_14) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_link); __Pyx_GIVEREF(__pyx_v_link); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_link); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self)); __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } if (__pyx_t_15) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Add(__pyx_t_14, __pyx_t_16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L13_exception_handled; } __pyx_L14_except_error:; /* "gevent/_semaphore.py":100 * if self.counter <= 0: * return * try: # <<<<<<<<<<<<<< * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory * except: */ __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L4_error; __pyx_L13_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_L19_try_end:; } /* "gevent/_semaphore.py":104 * except: * getcurrent().handle_error((link, self), *sys.exc_info()) * if self._dirty: # <<<<<<<<<<<<<< * # We mutated self._links so we need to start over * break */ __pyx_t_6 = (__pyx_v_self->_dirty != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":106 * if self._dirty: * # We mutated self._links so we need to start over * break # <<<<<<<<<<<<<< * if not self._dirty: * return */ goto __pyx_L10_break; /* "gevent/_semaphore.py":104 * except: * getcurrent().handle_error((link, self), *sys.exc_info()) * if self._dirty: # <<<<<<<<<<<<<< * # We mutated self._links so we need to start over * break */ } /* "gevent/_semaphore.py":97 * # the callback. Which shouldn't happen * return * for link in self._links: # <<<<<<<<<<<<<< * if self.counter <= 0: * return */ } __pyx_L10_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":107 * # We mutated self._links so we need to start over * break * if not self._dirty: # <<<<<<<<<<<<<< * return * finally: */ __pyx_t_6 = ((!(__pyx_v_self->_dirty != 0)) != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":108 * break * if not self._dirty: * return # <<<<<<<<<<<<<< * finally: * # We should not have created a new notifier even if callbacks */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L3_return; /* "gevent/_semaphore.py":107 * # We mutated self._links so we need to start over * break * if not self._dirty: # <<<<<<<<<<<<<< * return * finally: */ } } } /* "gevent/_semaphore.py":113 * # released us because we loop through *all* of our links on the * # same callback while self._notifier is still true. * assert self._notifier is notifier # <<<<<<<<<<<<<< * self._notifier = None * */ /*finally:*/ { /*normal exit:*/{ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /* "gevent/_semaphore.py":114 * # same callback while self._notifier is still true. * assert self._notifier is notifier * self._notifier = None # <<<<<<<<<<<<<< * * def rawlink(self, callback): */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; goto __pyx_L5; } /*exception exit:*/{ __pyx_L4_error:; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_17 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename; { /* "gevent/_semaphore.py":113 * # released us because we loop through *all* of our links on the * # same callback while self._notifier is still true. * assert self._notifier is notifier # <<<<<<<<<<<<<< * self._notifier = None * */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L25_error;} } } #endif /* "gevent/_semaphore.py":114 * # same callback while self._notifier is still true. * assert self._notifier is notifier * self._notifier = None # <<<<<<<<<<<<<< * * def rawlink(self, callback): */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_11, __pyx_t_10, __pyx_t_9); __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19; goto __pyx_L1_error; __pyx_L25_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_22 = __pyx_r; __pyx_r = 0; /* "gevent/_semaphore.py":113 * # released us because we loop through *all* of our links on the * # same callback while self._notifier is still true. * assert self._notifier is notifier # <<<<<<<<<<<<<< * self._notifier = None * */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /* "gevent/_semaphore.py":114 * # same callback while self._notifier is still true. * assert self._notifier is notifier * self._notifier = None # <<<<<<<<<<<<<< * * def rawlink(self, callback): */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; __pyx_r = __pyx_t_22; __pyx_t_22 = 0; goto __pyx_L0; } __pyx_L5:; } /* "gevent/_semaphore.py":80 * self._notifier = get_hub().loop.run_callback(self._notify_links) * * def _notify_links(self): # <<<<<<<<<<<<<< * # Subclasses CANNOT override. This is a cdef method. * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_notifier); __Pyx_XDECREF(__pyx_v_link); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_notify_links", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":116 * self._notifier = None * * def rawlink(self, callback): # <<<<<<<<<<<<<< * """ * rawlink(callback) -> None */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("rawlink", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":128 * will not need to use it. * """ * if not callable(callback): # <<<<<<<<<<<<<< * raise TypeError('Expected callable:', callback) * if self._links is None: */ __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0); if (__pyx_t_7) { /* "gevent/_semaphore.py":129 * """ * if not callable(callback): * raise TypeError('Expected callable:', callback) # <<<<<<<<<<<<<< * if self._links is None: * self._links = [callback] */ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Expected_callable); __Pyx_GIVEREF(__pyx_kp_s_Expected_callable); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_Expected_callable); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_callback); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/_semaphore.py":128 * will not need to use it. * """ * if not callable(callback): # <<<<<<<<<<<<<< * raise TypeError('Expected callable:', callback) * if self._links is None: */ } /* "gevent/_semaphore.py":130 * if not callable(callback): * raise TypeError('Expected callable:', callback) * if self._links is None: # <<<<<<<<<<<<<< * self._links = [callback] * else: */ __pyx_t_7 = (__pyx_v_self->_links == Py_None); __pyx_t_6 = (__pyx_t_7 != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":131 * raise TypeError('Expected callable:', callback) * if self._links is None: * self._links = [callback] # <<<<<<<<<<<<<< * else: * self._links.append(callback) */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->_links); __Pyx_DECREF(__pyx_v_self->_links); __pyx_v_self->_links = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/_semaphore.py":130 * if not callable(callback): * raise TypeError('Expected callable:', callback) * if self._links is None: # <<<<<<<<<<<<<< * self._links = [callback] * else: */ goto __pyx_L4; } /* "gevent/_semaphore.py":133 * self._links = [callback] * else: * self._links.append(callback) # <<<<<<<<<<<<<< * self._dirty = True * */ /*else*/ { __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L4:; /* "gevent/_semaphore.py":134 * else: * self._links.append(callback) * self._dirty = True # <<<<<<<<<<<<<< * * def unlink(self, callback): */ __pyx_v_self->_dirty = 1; /* "gevent/_semaphore.py":116 * self._notifier = None * * def rawlink(self, callback): # <<<<<<<<<<<<<< * """ * rawlink(callback) -> None */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent._semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_12rawlink[] = "\n rawlink(callback) -> None\n\n Register a callback to call when a counter is more than zero.\n\n *callback* will be called in the :class:`Hub `, so it must not use blocking gevent API.\n *callback* will be passed one argument: this instance.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code\n will not need to use it.\n "; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rawlink (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("rawlink", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":136 * self._dirty = True * * def unlink(self, callback): # <<<<<<<<<<<<<< * """ * unlink(callback) -> None */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("unlink", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":145 * code will not need to use it. * """ * try: # <<<<<<<<<<<<<< * self._links.remove(callback) * self._dirty = True */ { __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { /* "gevent/_semaphore.py":146 * """ * try: * self._links.remove(callback) # <<<<<<<<<<<<<< * self._dirty = True * except (ValueError, AttributeError): */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_links, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_callback); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":147 * try: * self._links.remove(callback) * self._dirty = True # <<<<<<<<<<<<<< * except (ValueError, AttributeError): * pass */ __pyx_v_self->_dirty = 1; /* "gevent/_semaphore.py":145 * code will not need to use it. * """ * try: # <<<<<<<<<<<<<< * self._links.remove(callback) * self._dirty = True */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":148 * self._links.remove(callback) * self._dirty = True * except (ValueError, AttributeError): # <<<<<<<<<<<<<< * pass * if not self._links: */ __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_ValueError) || PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_9) { PyErr_Restore(0,0,0); goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* "gevent/_semaphore.py":145 * code will not need to use it. * """ * try: # <<<<<<<<<<<<<< * self._links.remove(callback) * self._dirty = True */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L10_try_end:; } /* "gevent/_semaphore.py":150 * except (ValueError, AttributeError): * pass * if not self._links: # <<<<<<<<<<<<<< * self._links = None * # TODO: Cancel a notifier if there are no links? */ __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_11 = ((!__pyx_t_10) != 0); if (__pyx_t_11) { /* "gevent/_semaphore.py":151 * pass * if not self._links: * self._links = None # <<<<<<<<<<<<<< * # TODO: Cancel a notifier if there are no links? * */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_links); __Pyx_DECREF(__pyx_v_self->_links); __pyx_v_self->_links = Py_None; /* "gevent/_semaphore.py":150 * except (ValueError, AttributeError): * pass * if not self._links: # <<<<<<<<<<<<<< * self._links = None * # TODO: Cancel a notifier if there are no links? */ } /* "gevent/_semaphore.py":136 * self._dirty = True * * def unlink(self, callback): # <<<<<<<<<<<<<< * """ * unlink(callback) -> None */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent._semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_14unlink[] = "\n unlink(callback) -> None\n\n Remove the callback set by :meth:`rawlink`.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most\n code will not need to use it.\n "; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unlink (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("unlink", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_unlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":154 * # TODO: Cancel a notifier if there are no links? * * def _do_wait(self, timeout): # <<<<<<<<<<<<<< * """ * Wait for up to *timeout* seconds to expire. If timeout */ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) { PyObject *__pyx_v_switch = NULL; PyObject *__pyx_v_timer = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; char const *__pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; char const *__pyx_t_16; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_do_wait", 0); /* "gevent/_semaphore.py":160 * Raises timeout if a different timer expires. * """ * switch = getcurrent().switch # <<<<<<<<<<<<<< * self.rawlink(switch) * try: */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_switch = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/_semaphore.py":161 * """ * switch = getcurrent().switch * self.rawlink(switch) # <<<<<<<<<<<<<< * try: * timer = Timeout._start_new_or_dummy(timeout) */ __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":162 * switch = getcurrent().switch * self.rawlink(switch) * try: # <<<<<<<<<<<<<< * timer = Timeout._start_new_or_dummy(timeout) * try: */ /*try:*/ { /* "gevent/_semaphore.py":163 * self.rawlink(switch) * try: * timer = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<< * try: * try: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_INCREF(__pyx_v_timeout); __Pyx_GIVEREF(__pyx_v_timeout); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_timer = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/_semaphore.py":164 * try: * timer = Timeout._start_new_or_dummy(timeout) * try: # <<<<<<<<<<<<<< * try: * result = get_hub().switch() */ /*try:*/ { /* "gevent/_semaphore.py":165 * timer = Timeout._start_new_or_dummy(timeout) * try: * try: # <<<<<<<<<<<<<< * result = get_hub().switch() * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) */ { __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); /*try:*/ { /* "gevent/_semaphore.py":166 * try: * try: * result = get_hub().switch() # <<<<<<<<<<<<<< * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) * except Timeout as ex: */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_1) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_switch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_result = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/_semaphore.py":167 * try: * result = get_hub().switch() * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) # <<<<<<<<<<<<<< * except Timeout as ex: * if ex is not timer: */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_8 = (__pyx_v_result == ((PyObject *)__pyx_v_self)); if (unlikely(!(__pyx_t_8 != 0))) { __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_result); __Pyx_GIVEREF(__pyx_v_result); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_result); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } } #endif /* "gevent/_semaphore.py":165 * timer = Timeout._start_new_or_dummy(timeout) * try: * try: # <<<<<<<<<<<<<< * result = get_hub().switch() * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L16_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "gevent/_semaphore.py":168 * result = get_hub().switch() * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) * except Timeout as ex: # <<<<<<<<<<<<<< * if ex is not timer: * raise */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PyErr_ExceptionMatches(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_9) { __Pyx_AddTraceback("gevent._semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_v_ex = __pyx_t_2; /* "gevent/_semaphore.py":169 * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) * except Timeout as ex: * if ex is not timer: # <<<<<<<<<<<<<< * raise * return ex */ __pyx_t_8 = (__pyx_v_ex != __pyx_v_timer); __pyx_t_10 = (__pyx_t_8 != 0); if (__pyx_t_10) { /* "gevent/_semaphore.py":170 * except Timeout as ex: * if ex is not timer: * raise # <<<<<<<<<<<<<< * return ex * finally: */ __Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ErrRestore(__pyx_t_4, __pyx_t_2, __pyx_t_3); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;} /* "gevent/_semaphore.py":169 * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) * except Timeout as ex: * if ex is not timer: # <<<<<<<<<<<<<< * raise * return ex */ } /* "gevent/_semaphore.py":171 * if ex is not timer: * raise * return ex # <<<<<<<<<<<<<< * finally: * timer.cancel() */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_ex); __pyx_r = __pyx_v_ex; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L12_except_return; } goto __pyx_L11_except_error; __pyx_L11_except_error:; /* "gevent/_semaphore.py":165 * timer = Timeout._start_new_or_dummy(timeout) * try: * try: # <<<<<<<<<<<<<< * result = get_hub().switch() * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L7_error; __pyx_L12_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L6_return; __pyx_L16_try_end:; } } /* "gevent/_semaphore.py":173 * return ex * finally: * timer.cancel() # <<<<<<<<<<<<<< * finally: * self.unlink(switch) */ /*finally:*/ { /*normal exit:*/{ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8; } /*exception exit:*/{ __pyx_L7_error:; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_9 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L21_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L21_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L21_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_6, __pyx_t_5); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12; goto __pyx_L4_error; __pyx_L21_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; goto __pyx_L4_error; } __pyx_L6_return: { __pyx_t_15 = __pyx_r; __pyx_r = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_15; __pyx_t_15 = 0; goto __pyx_L3_return; } __pyx_L8:; } } /* "gevent/_semaphore.py":175 * timer.cancel() * finally: * self.unlink(switch) # <<<<<<<<<<<<<< * * def wait(self, timeout=None): */ /*finally:*/ { /*normal exit:*/{ __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L5; } /*exception exit:*/{ __pyx_L4_error:; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __pyx_t_11 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L23_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13); __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_16; goto __pyx_L1_error; __pyx_L23_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_7 = __pyx_r; __pyx_r = 0; __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0; } __pyx_L5:; } /* "gevent/_semaphore.py":154 * # TODO: Cancel a notifier if there are no links? * * def _do_wait(self, timeout): # <<<<<<<<<<<<<< * """ * Wait for up to *timeout* seconds to expire. If timeout */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_switch); __Pyx_XDECREF(__pyx_v_timer); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":177 * self.unlink(switch) * * def wait(self, timeout=None): # <<<<<<<<<<<<<< * """ * wait(timeout=None) -> int */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args) { PyObject *__pyx_v_timeout = ((PyObject *)Py_None); int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("wait", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_timeout = __pyx_optional_args->timeout; } } /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait)) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_timeout); __Pyx_GIVEREF(__pyx_v_timeout); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_6; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":192 * before blocking. * """ * if self.counter > 0: # <<<<<<<<<<<<<< * return self.counter * */ __pyx_t_7 = ((__pyx_v_self->counter > 0) != 0); if (__pyx_t_7) { /* "gevent/_semaphore.py":193 * """ * if self.counter > 0: * return self.counter # <<<<<<<<<<<<<< * * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout */ __pyx_r = __pyx_v_self->counter; goto __pyx_L0; /* "gevent/_semaphore.py":192 * before blocking. * """ * if self.counter > 0: # <<<<<<<<<<<<<< * return self.counter * */ } /* "gevent/_semaphore.py":195 * return self.counter * * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout # <<<<<<<<<<<<<< * return self.counter * */ __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":196 * * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout * return self.counter # <<<<<<<<<<<<<< * * def acquire(self, blocking=True, timeout=None): */ __pyx_r = __pyx_v_self->counter; goto __pyx_L0; /* "gevent/_semaphore.py":177 * self.unlink(switch) * * def wait(self, timeout=None): # <<<<<<<<<<<<<< * """ * wait(timeout=None) -> int */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_16wait[] = "\n wait(timeout=None) -> int\n\n Wait until it is possible to acquire this semaphore, or until the optional\n *timeout* elapses.\n\n .. caution:: If this semaphore was initialized with a size of 0,\n this method will block forever if no timeout is given.\n\n :keyword float timeout: If given, specifies the maximum amount of seconds\n this method will block.\n :return: A number indicating how many times the semaphore can be acquired\n before blocking.\n "; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_timeout = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wait (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_timeout = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_timeout); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("wait", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.timeout = __pyx_v_timeout; __pyx_t_1 = __pyx_vtabptr_6gevent_10_semaphore_Semaphore->wait(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":198 * return self.counter * * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< * """ * acquire(blocking=True, timeout=None) -> bool */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6gevent_10_semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args) { int __pyx_v_blocking = ((int)1); PyObject *__pyx_v_timeout = ((PyObject *)Py_None); int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("acquire", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_blocking = __pyx_optional_args->blocking; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_timeout = __pyx_optional_args->timeout; } } } __Pyx_INCREF(__pyx_v_timeout); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire)) { __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_blocking); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_v_timeout); __Pyx_GIVEREF(__pyx_v_timeout); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_timeout); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_8; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":219 * raise a ``Timeout`` exception, if some other caller had already started a timer.) * """ * if self.counter > 0: # <<<<<<<<<<<<<< * self.counter -= 1 * return True */ __pyx_t_8 = ((__pyx_v_self->counter > 0) != 0); if (__pyx_t_8) { /* "gevent/_semaphore.py":220 * """ * if self.counter > 0: * self.counter -= 1 # <<<<<<<<<<<<<< * return True * */ __pyx_v_self->counter = (__pyx_v_self->counter - 1); /* "gevent/_semaphore.py":221 * if self.counter > 0: * self.counter -= 1 * return True # <<<<<<<<<<<<<< * * if not blocking: */ __pyx_r = 1; goto __pyx_L0; /* "gevent/_semaphore.py":219 * raise a ``Timeout`` exception, if some other caller had already started a timer.) * """ * if self.counter > 0: # <<<<<<<<<<<<<< * self.counter -= 1 * return True */ } /* "gevent/_semaphore.py":223 * return True * * if not blocking: # <<<<<<<<<<<<<< * return False * */ __pyx_t_8 = ((!(__pyx_v_blocking != 0)) != 0); if (__pyx_t_8) { /* "gevent/_semaphore.py":224 * * if not blocking: * return False # <<<<<<<<<<<<<< * * timeout = self._do_wait(timeout) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/_semaphore.py":223 * return True * * if not blocking: # <<<<<<<<<<<<<< * return False * */ } /* "gevent/_semaphore.py":226 * return False * * timeout = self._do_wait(timeout) # <<<<<<<<<<<<<< * if timeout is not None: * # Our timer expired. */ __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":227 * * timeout = self._do_wait(timeout) * if timeout is not None: # <<<<<<<<<<<<<< * # Our timer expired. * return False */ __pyx_t_8 = (__pyx_v_timeout != Py_None); __pyx_t_9 = (__pyx_t_8 != 0); if (__pyx_t_9) { /* "gevent/_semaphore.py":229 * if timeout is not None: * # Our timer expired. * return False # <<<<<<<<<<<<<< * * # Neither our timer no another one expired, so we blocked until */ __pyx_r = 0; goto __pyx_L0; /* "gevent/_semaphore.py":227 * * timeout = self._do_wait(timeout) * if timeout is not None: # <<<<<<<<<<<<<< * # Our timer expired. * return False */ } /* "gevent/_semaphore.py":233 * # Neither our timer no another one expired, so we blocked until * # awoke. Therefore, the counter is ours * self.counter -= 1 # <<<<<<<<<<<<<< * assert self.counter >= 0 * return True */ __pyx_v_self->counter = (__pyx_v_self->counter - 1); /* "gevent/_semaphore.py":234 * # awoke. Therefore, the counter is ours * self.counter -= 1 * assert self.counter >= 0 # <<<<<<<<<<<<<< * return True * */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->counter >= 0) != 0))) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /* "gevent/_semaphore.py":235 * self.counter -= 1 * assert self.counter >= 0 * return True # <<<<<<<<<<<<<< * * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython */ __pyx_r = 1; goto __pyx_L0; /* "gevent/_semaphore.py":198 * return self.counter * * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< * """ * acquire(blocking=True, timeout=None) -> bool */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; __Pyx_XDECREF(__pyx_v_timeout); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6gevent_10_semaphore_9Semaphore_18acquire[] = "\n acquire(blocking=True, timeout=None) -> bool\n\n Acquire the semaphore.\n\n .. caution:: If this semaphore was initialized with a size of 0,\n this method will block forever (unless a timeout is given or blocking is\n set to false).\n\n :keyword bool blocking: If True (the default), this function will block\n until the semaphore is acquired.\n :keyword float timeout: If given, specifies the maximum amount of seconds\n this method will block.\n :return: A boolean indicating whether the semaphore was acquired.\n If ``blocking`` is True and ``timeout`` is None (the default), then\n (so long as this semaphore was initialized with a size greater than 0)\n this will always return True. If a timeout was given, and it expired before\n the semaphore was acquired, False will be returned. (Note that this can still\n raise a ``Timeout`` exception, if some other caller had already started a timer.)\n "; static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_blocking; PyObject *__pyx_v_timeout = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("acquire (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,&__pyx_n_s_timeout,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_blocking); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } if (values[0]) { __pyx_v_blocking = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_blocking = ((int)1); } __pyx_v_timeout = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_blocking, __pyx_v_timeout); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("acquire", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 2; __pyx_t_2.blocking = __pyx_v_blocking; __pyx_t_2.timeout = __pyx_v_timeout; __pyx_t_1 = __pyx_vtabptr_6gevent_10_semaphore_Semaphore->acquire(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":239 * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython * * def __enter__(self): # <<<<<<<<<<<<<< * self.acquire() * */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__enter__", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":240 * * def __enter__(self): * self.acquire() # <<<<<<<<<<<<<< * * def __exit__(self, t, v, tb): */ __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->acquire(__pyx_v_self, 0, NULL); if (unlikely(__pyx_t_5 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/_semaphore.py":239 * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython * * def __enter__(self): # <<<<<<<<<<<<<< * self.acquire() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__enter__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore___enter__(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":242 * self.acquire() * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * self.release() * */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__exit__", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_t); __Pyx_GIVEREF(__pyx_v_t); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_t); __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_v); __Pyx_INCREF(__pyx_v_tb); __Pyx_GIVEREF(__pyx_v_tb); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":243 * * def __exit__(self, t, v, tb): * self.release() # <<<<<<<<<<<<<< * * */ __pyx_t_7 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->release(__pyx_v_self, 0); if (unlikely(__pyx_t_7 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/_semaphore.py":242 * self.acquire() * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * self.release() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_t = 0; PyObject *__pyx_v_v = 0; PyObject *__pyx_v_tb = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_t = values[0]; __pyx_v_v = values[1]; __pyx_v_tb = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__exit__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore___exit__(__pyx_v_self, __pyx_v_t, __pyx_v_v, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.pxd":2 * cdef class Semaphore: * cdef public int counter # <<<<<<<<<<<<<< * cdef readonly object _links * cdef readonly object _notifier */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore.counter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->counter = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore.counter.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.pxd":3 * cdef class Semaphore: * cdef public int counter * cdef readonly object _links # <<<<<<<<<<<<<< * cdef readonly object _notifier * cdef public int _dirty */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_links); __pyx_r = __pyx_v_self->_links; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.pxd":4 * cdef public int counter * cdef readonly object _links * cdef readonly object _notifier # <<<<<<<<<<<<<< * cdef public int _dirty * cdef object __weakref__ */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_notifier); __pyx_r = __pyx_v_self->_notifier; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.pxd":5 * cdef readonly object _links * cdef readonly object _notifier * cdef public int _dirty # <<<<<<<<<<<<<< * cdef object __weakref__ * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_dirty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.Semaphore._dirty.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->_dirty = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent._semaphore.Semaphore._dirty.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":262 * _OVER_RELEASE_ERROR = ValueError * * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< * Semaphore.__init__(self, *args, **kwargs) * self._initial_value = self.counter */ /* Python wrapper */ static int __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_v_kwargs = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1; if (unlikely(__pyx_kwds)) { __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1; __Pyx_GOTREF(__pyx_v_kwargs); } else { __pyx_v_kwargs = NULL; } __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/_semaphore.py":263 * * def __init__(self, *args, **kwargs): * Semaphore.__init__(self, *args, **kwargs) # <<<<<<<<<<<<<< * self._initial_value = self.counter * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":264 * def __init__(self, *args, **kwargs): * Semaphore.__init__(self, *args, **kwargs) * self._initial_value = self.counter # <<<<<<<<<<<<<< * * def release(self): */ __pyx_t_4 = __pyx_v_self->__pyx_base.counter; __pyx_v_self->_initial_value = __pyx_t_4; /* "gevent/_semaphore.py":262 * _OVER_RELEASE_ERROR = ValueError * * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< * Semaphore.__init__(self, *args, **kwargs) * self._initial_value = self.counter */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.py":266 * self._initial_value = self.counter * * def release(self): # <<<<<<<<<<<<<< * if self.counter >= self._initial_value: * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") */ static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static int __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("release", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release)) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/_semaphore.py":267 * * def release(self): * if self.counter >= self._initial_value: # <<<<<<<<<<<<<< * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") * return Semaphore.release(self) */ __pyx_t_6 = ((__pyx_v_self->__pyx_base.counter >= __pyx_v_self->_initial_value) != 0); if (__pyx_t_6) { /* "gevent/_semaphore.py":268 * def release(self): * if self.counter >= self._initial_value: * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<< * return Semaphore.release(self) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_OVER_RELEASE_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/_semaphore.py":267 * * def release(self): * if self.counter >= self._initial_value: # <<<<<<<<<<<<<< * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") * return Semaphore.release(self) */ } /* "gevent/_semaphore.py":269 * if self.counter >= self._initial_value: * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") * return Semaphore.release(self) # <<<<<<<<<<<<<< */ __pyx_t_5 = __pyx_f_6gevent_10_semaphore_9Semaphore_release(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), 1); if (unlikely(__pyx_t_5 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_t_5; goto __pyx_L0; /* "gevent/_semaphore.py":266 * self._initial_value = self.counter * * def release(self): # <<<<<<<<<<<<<< * if self.counter >= self._initial_value: * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("release (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("release", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == -1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/_semaphore.pxd":21 * * cdef class BoundedSemaphore(Semaphore): * cdef readonly int _initial_value # <<<<<<<<<<<<<< * * cpdef int release(self) except -1000 */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_initial_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore._initial_value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore __pyx_vtable_6gevent_10_semaphore_Semaphore; static PyObject *__pyx_tp_new_6gevent_10_semaphore_Semaphore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_6gevent_10_semaphore_Semaphore *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o); p->__pyx_vtab = __pyx_vtabptr_6gevent_10_semaphore_Semaphore; p->_links = Py_None; Py_INCREF(Py_None); p->_notifier = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore(PyObject *o) { struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); if (p->__weakref__) PyObject_ClearWeakRefs(o); Py_CLEAR(p->_links); Py_CLEAR(p->_notifier); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_6gevent_10_semaphore_Semaphore(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; if (p->_links) { e = (*v)(p->_links, a); if (e) return e; } if (p->_notifier) { e = (*v)(p->_notifier, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_10_semaphore_Semaphore(PyObject *o) { PyObject* tmp; struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; tmp = ((PyObject*)p->_links); p->_links = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_notifier); p->_notifier = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore_counter(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(o); } static int __pyx_setprop_6gevent_10_semaphore_9Semaphore_counter(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__links(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(o); } static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__notifier(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(o); } static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__dirty(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(o); } static int __pyx_setprop_6gevent_10_semaphore_9Semaphore__dirty(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyMethodDef __pyx_methods_6gevent_10_semaphore_Semaphore[] = { {"locked", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked, METH_NOARGS, __pyx_doc_6gevent_10_semaphore_9Semaphore_4locked}, {"release", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_7release, METH_NOARGS, __pyx_doc_6gevent_10_semaphore_9Semaphore_6release}, {"_start_notify", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify, METH_NOARGS, 0}, {"_notify_links", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links, METH_NOARGS, 0}, {"rawlink", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink, METH_O, __pyx_doc_6gevent_10_semaphore_9Semaphore_12rawlink}, {"unlink", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink, METH_O, __pyx_doc_6gevent_10_semaphore_9Semaphore_14unlink}, {"wait", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_10_semaphore_9Semaphore_16wait}, {"acquire", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_10_semaphore_9Semaphore_18acquire}, {"__enter__", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__, METH_NOARGS, 0}, {"__exit__", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_10_semaphore_Semaphore[] = { {(char *)"counter", __pyx_getprop_6gevent_10_semaphore_9Semaphore_counter, __pyx_setprop_6gevent_10_semaphore_9Semaphore_counter, 0, 0}, {(char *)"_links", __pyx_getprop_6gevent_10_semaphore_9Semaphore__links, 0, 0, 0}, {(char *)"_notifier", __pyx_getprop_6gevent_10_semaphore_9Semaphore__notifier, 0, 0, 0}, {(char *)"_dirty", __pyx_getprop_6gevent_10_semaphore_9Semaphore__dirty, __pyx_setprop_6gevent_10_semaphore_9Semaphore__dirty, 0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_6gevent_10_semaphore_Semaphore = { PyVarObject_HEAD_INIT(0, 0) "gevent._semaphore.Semaphore", /*tp_name*/ sizeof(struct __pyx_obj_6gevent_10_semaphore_Semaphore), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ __pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "\n Semaphore(value=1) -> Semaphore\n\n A semaphore manages a counter representing the number of release()\n calls minus the number of acquire() calls, plus an initial value.\n The acquire() method blocks if necessary until it can return\n without making the counter negative.\n\n If not given, ``value`` defaults to 1.\n\n The semaphore is a context manager and can be used in ``with`` statements.\n\n This Semaphore's ``__exit__`` method does not call the trace function\n on CPython, but does under PyPy.\n\n .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents\n some classes of bugs.\n ", /*tp_doc*/ __pyx_tp_traverse_6gevent_10_semaphore_Semaphore, /*tp_traverse*/ __pyx_tp_clear_6gevent_10_semaphore_Semaphore, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_10_semaphore_Semaphore, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_10_semaphore_Semaphore, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_10_semaphore_Semaphore, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore; static PyObject *__pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *p; PyObject *o = __pyx_tp_new_6gevent_10_semaphore_Semaphore(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore*)__pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore; return o; } static PyObject *__pyx_getprop_6gevent_10_semaphore_16BoundedSemaphore__initial_value(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_10_semaphore_BoundedSemaphore[] = { {"release", (PyCFunction)__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_10_semaphore_BoundedSemaphore[] = { {(char *)"_initial_value", __pyx_getprop_6gevent_10_semaphore_16BoundedSemaphore__initial_value, 0, 0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_6gevent_10_semaphore_BoundedSemaphore = { PyVarObject_HEAD_INIT(0, 0) "gevent._semaphore.BoundedSemaphore", /*tp_name*/ sizeof(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__, /*tp_str*/ #else 0, /*tp_str*/ #endif 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "\n BoundedSemaphore(value=1) -> BoundedSemaphore\n\n A bounded semaphore checks to make sure its current value doesn't\n exceed its initial value. If it does, :class:`ValueError` is\n raised. In most situations semaphores are used to guard resources\n with limited capacity. If the semaphore is released too many times\n it's a sign of a bug.\n\n If not given, *value* defaults to 1.\n ", /*tp_doc*/ __pyx_tp_traverse_6gevent_10_semaphore_Semaphore, /*tp_traverse*/ __pyx_tp_clear_6gevent_10_semaphore_Semaphore, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_10_semaphore_BoundedSemaphore, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_10_semaphore_BoundedSemaphore, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "_semaphore", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, {&__pyx_n_s_BoundedSemaphore, __pyx_k_BoundedSemaphore, sizeof(__pyx_k_BoundedSemaphore), 0, 0, 1, 1}, {&__pyx_kp_s_Expected_callable, __pyx_k_Expected_callable, sizeof(__pyx_k_Expected_callable), 0, 0, 1, 0}, {&__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_k_Invalid_switch_into_Semaphore_wa, sizeof(__pyx_k_Invalid_switch_into_Semaphore_wa), 0, 0, 1, 0}, {&__pyx_n_s_OVER_RELEASE_ERROR, __pyx_k_OVER_RELEASE_ERROR, sizeof(__pyx_k_OVER_RELEASE_ERROR), 0, 0, 1, 1}, {&__pyx_n_s_Semaphore, __pyx_k_Semaphore, sizeof(__pyx_k_Semaphore), 0, 0, 1, 1}, {&__pyx_kp_s_Semaphore_released_too_many_time, __pyx_k_Semaphore_released_too_many_time, sizeof(__pyx_k_Semaphore_released_too_many_time), 0, 0, 1, 0}, {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1}, {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1}, {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1}, {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, {&__pyx_n_s_get_hub, __pyx_k_get_hub, sizeof(__pyx_k_get_hub), 0, 0, 1, 1}, {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1}, {&__pyx_n_s_gevent_hub, __pyx_k_gevent_hub, sizeof(__pyx_k_gevent_hub), 0, 0, 1, 1}, {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1}, {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_locked, __pyx_k_locked, sizeof(__pyx_k_locked), 0, 0, 1, 1}, {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_notify_links, __pyx_k_notify_links, sizeof(__pyx_k_notify_links), 0, 0, 1, 1}, {&__pyx_n_s_py3k_acquire, __pyx_k_py3k_acquire, sizeof(__pyx_k_py3k_acquire), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1}, {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1}, {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1}, {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1}, {&__pyx_kp_s_s_counter_s__links_s, __pyx_k_s_counter_s__links_s, sizeof(__pyx_k_s_counter_s__links_s), 0, 0, 1, 0}, {&__pyx_kp_s_semaphore_initial_value_must_be, __pyx_k_semaphore_initial_value_must_be, sizeof(__pyx_k_semaphore_initial_value_must_be), 0, 0, 1, 0}, {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1}, {&__pyx_n_s_start_notify, __pyx_k_start_notify, sizeof(__pyx_k_start_notify), 0, 0, 1, 1}, {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1}, {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1}, {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1}, {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1}, {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "gevent/_semaphore.py":31 * def __init__(self, value=1): * if value < 0: * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<< * self.counter = value * self._dirty = False */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_semaphore_initial_value_must_be); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "gevent/_semaphore.py":268 * def release(self): * if self.counter >= self._initial_value: * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<< * return Semaphore.release(self) */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Semaphore_released_too_many_time); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC init_semaphore(void); /*proto*/ PyMODINIT_FUNC init_semaphore(void) #else PyMODINIT_FUNC PyInit__semaphore(void); /*proto*/ PyMODINIT_FUNC PyInit__semaphore(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__semaphore(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("_semaphore", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_gevent___semaphore) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "gevent._semaphore")) { if (unlikely(PyDict_SetItemString(modules, "gevent._semaphore", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ __pyx_vtabptr_6gevent_10_semaphore_Semaphore = &__pyx_vtable_6gevent_10_semaphore_Semaphore; __pyx_vtable_6gevent_10_semaphore_Semaphore.locked = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_locked; __pyx_vtable_6gevent_10_semaphore_Semaphore.release = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_release; __pyx_vtable_6gevent_10_semaphore_Semaphore.rawlink = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink; __pyx_vtable_6gevent_10_semaphore_Semaphore.unlink = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_unlink; __pyx_vtable_6gevent_10_semaphore_Semaphore._start_notify = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify; __pyx_vtable_6gevent_10_semaphore_Semaphore._notify_links = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links; __pyx_vtable_6gevent_10_semaphore_Semaphore._do_wait = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *))__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait; __pyx_vtable_6gevent_10_semaphore_Semaphore.wait = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args))__pyx_f_6gevent_10_semaphore_9Semaphore_wait; __pyx_vtable_6gevent_10_semaphore_Semaphore.acquire = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args))__pyx_f_6gevent_10_semaphore_9Semaphore_acquire; __pyx_vtable_6gevent_10_semaphore_Semaphore.__pyx___enter__ = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore___enter__; __pyx_vtable_6gevent_10_semaphore_Semaphore.__pyx___exit__ = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore___exit__; if (PyType_Ready(&__pyx_type_6gevent_10_semaphore_Semaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_6gevent_10_semaphore_Semaphore.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_6gevent_10_semaphore_Semaphore.tp_dict, __pyx_vtabptr_6gevent_10_semaphore_Semaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "Semaphore", (PyObject *)&__pyx_type_6gevent_10_semaphore_Semaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_type_6gevent_10_semaphore_Semaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_10_semaphore_Semaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_10_semaphore_Semaphore, __weakref__); __pyx_ptype_6gevent_10_semaphore_Semaphore = &__pyx_type_6gevent_10_semaphore_Semaphore; __pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore = &__pyx_vtable_6gevent_10_semaphore_BoundedSemaphore; __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore.__pyx_base = *__pyx_vtabptr_6gevent_10_semaphore_Semaphore; __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore.__pyx_base.release = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release; __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_base = __pyx_ptype_6gevent_10_semaphore_Semaphore; if (PyType_Ready(&__pyx_type_6gevent_10_semaphore_BoundedSemaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_dict, __pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "BoundedSemaphore", (PyObject *)&__pyx_type_6gevent_10_semaphore_BoundedSemaphore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore, __pyx_base.__weakref__); __pyx_ptype_6gevent_10_semaphore_BoundedSemaphore = &__pyx_type_6gevent_10_semaphore_BoundedSemaphore; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "gevent/_semaphore.py":1 * import sys # <<<<<<<<<<<<<< * from gevent.hub import get_hub, getcurrent * from gevent.timeout import Timeout */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":2 * import sys * from gevent.hub import get_hub, getcurrent # <<<<<<<<<<<<<< * from gevent.timeout import Timeout * */ __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_hub); __Pyx_GIVEREF(__pyx_n_s_get_hub); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_hub); __Pyx_INCREF(__pyx_n_s_getcurrent); __Pyx_GIVEREF(__pyx_n_s_getcurrent); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_getcurrent); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_hub, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_hub); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_getcurrent, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/_semaphore.py":3 * import sys * from gevent.hub import get_hub, getcurrent * from gevent.timeout import Timeout # <<<<<<<<<<<<<< * * */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Timeout); __Pyx_GIVEREF(__pyx_n_s_Timeout); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Timeout); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timeout, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":6 * * * __all__ = ['Semaphore', 'BoundedSemaphore'] # <<<<<<<<<<<<<< * * */ __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Semaphore); __Pyx_GIVEREF(__pyx_n_s_Semaphore); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Semaphore); __Pyx_INCREF(__pyx_n_s_BoundedSemaphore); __Pyx_GIVEREF(__pyx_n_s_BoundedSemaphore); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_BoundedSemaphore); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/_semaphore.py":237 * return True * * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython # <<<<<<<<<<<<<< * * def __enter__(self): */ __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore, __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_py3k_acquire, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); /* "gevent/_semaphore.py":260 * * #: For monkey-patching, allow changing the class of error we raise * _OVER_RELEASE_ERROR = ValueError # <<<<<<<<<<<<<< * * def __init__(self, *args, **kwargs): */ if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyType_Modified(__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore); /* "gevent/_semaphore.py":1 * import sys # <<<<<<<<<<<<<< * from gevent.hub import get_hub, getcurrent * from gevent.timeout import Timeout */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init gevent._semaphore", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init gevent._semaphore"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else PyErr_GetExcInfo(type, value, tb); #endif } static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(type, value, tb); #endif } static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_COMPILING_IN_CPYTHON tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #else PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { PyObject *method, *result = NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto bad; #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyMethod_Check(method))) { PyObject *self = PyMethod_GET_SELF(method); if (likely(self)) { PyObject *args; PyObject *function = PyMethod_GET_FUNCTION(method); args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); Py_INCREF(function); Py_DECREF(method); method = NULL; result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); return result; } } #endif result = __Pyx_PyObject_CallOneArg(method, arg); bad: Py_XDECREF(method); return result; } static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { if (likely(PyList_CheckExact(L))) { if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; } else { PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); if (unlikely(!retval)) return -1; Py_DECREF(retval); } return 0; } static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { PyObject *result; result = __Pyx_PyObject_GetAttrStr(nmspace, name); if (!result) result = __Pyx_GetModuleGlobalName(name); return result; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ gevent-1.1.0/gevent/gevent.ares.c0000644000076500000000000211202712666555432017421 0ustar jmaddenwheel00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__gevent__ares #define __PYX_HAVE_API__gevent__ares #include "ares.h" #include "cares_pton.h" #include "frameobject.h" #include "dnshelper.c" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "gevent/ares.pyx", }; /*--- Type declarations ---*/ struct __pyx_obj_6gevent_4ares_result; struct PyGeventAresChannelObject; struct __pyx_opt_args_6gevent_4ares__convert_cares_flags; /* "gevent/ares.pyx":137 * * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< * if _cares_flag_map is None: * _prepare_cares_flag_map() */ struct __pyx_opt_args_6gevent_4ares__convert_cares_flags { int __pyx_n; int __pyx_default; }; /* "gevent/ares.pyx":164 * * * cdef class result: # <<<<<<<<<<<<<< * cdef public object value * cdef public object exception */ struct __pyx_obj_6gevent_4ares_result { PyObject_HEAD PyObject *value; PyObject *exception; }; /* "gevent/ares.pyx":245 * * * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: # <<<<<<<<<<<<<< * * cdef public object loop */ struct PyGeventAresChannelObject { PyObject_HEAD struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtab; PyObject *loop; struct ares_channeldata *channel; PyObject *_watchers; PyObject *_timer; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type; struct __pyx_vtabstruct_6gevent_4ares_channel { PyObject *(*_sock_state_callback)(struct PyGeventAresChannelObject *, int, int, int); PyObject *(*_getnameinfo)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtabptr_6gevent_4ares_channel; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE int __Pyx_IterFinish(void); static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); static double __Pyx__PyObject_AsDouble(PyObject* obj); #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_AsDouble(obj)\ (likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\ likely(PyInt_CheckExact(obj)) ?\ PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj)) #else #define __Pyx_PyObject_AsDouble(obj)\ ((likely(PyFloat_CheckExact(obj))) ?\ PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) #endif #define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0) static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); static int __Pyx_SetVtable(PyObject *dict, void *vtable); static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); #define __Pyx_CyFunction_USED 1 #include #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { PyCFunctionObject func; #if PY_VERSION_HEX < 0x030500A0 PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; void *defaults; int defaults_pyobjects; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(void); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write); /* proto*/ static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from 'gevent.cares' */ /* Module declarations from 'gevent.python' */ /* Module declarations from 'gevent.ares' */ static PyTypeObject *__pyx_ptype_6gevent_4ares_result = 0; static PyTypeObject *__pyx_ptype_6gevent_4ares_channel = 0; static PyObject *__pyx_v_6gevent_4ares_string_types = 0; static PyObject *__pyx_v_6gevent_4ares_text_type = 0; static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void); /*proto*/ static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args); /*proto*/ static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *, int __pyx_skip_dispatch); /*proto*/ static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *, int, int, int); /*proto*/ static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *, int, int, struct hostent *); /*proto*/ static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *, int, int, char *, char *); /*proto*/ #define __Pyx_MODULE_NAME "gevent.ares" int __pyx_module_is_main_gevent__ares = 0; /* Implementation of 'gevent.ares' */ static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_id; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_TypeError; static char __pyx_k__2[] = ","; static char __pyx_k_fd[] = "fd"; static char __pyx_k_id[] = "id"; static char __pyx_k_io[] = "io"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_cls[] = "cls"; static char __pyx_k_doc[] = "__doc__"; static char __pyx_k_get[] = "get"; static char __pyx_k_new[] = "__new__"; static char __pyx_k_pop[] = "pop"; static char __pyx_k_s_r[] = "%s(%r)"; static char __pyx_k_s_s[] = "%s: %s"; static char __pyx_k_sys[] = "sys"; static char __pyx_k_addr[] = "addr"; static char __pyx_k_loop[] = "loop"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_name[] = "__name__"; static char __pyx_k_self[] = "self"; static char __pyx_k_stop[] = "stop"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_again[] = "again"; static char __pyx_k_ascii[] = "ascii"; static char __pyx_k_class[] = "__class__"; static char __pyx_k_flags[] = "flags"; static char __pyx_k_ndots[] = "ndots"; static char __pyx_k_si_ii[] = "si|ii"; static char __pyx_k_split[] = "split"; static char __pyx_k_start[] = "start"; static char __pyx_k_timer[] = "timer"; static char __pyx_k_tries[] = "tries"; static char __pyx_k_value[] = "value"; static char __pyx_k_encode[] = "encode"; static char __pyx_k_events[] = "events"; static char __pyx_k_family[] = "family"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_module[] = "__module__"; static char __pyx_k_name_2[] = "name"; static char __pyx_k_socket[] = "_socket"; static char __pyx_k_TIMEOUT[] = "TIMEOUT"; static char __pyx_k_channel[] = "channel"; static char __pyx_k_default[] = "default"; static char __pyx_k_destroy[] = "destroy"; static char __pyx_k_prepare[] = "__prepare__"; static char __pyx_k_servers[] = "servers"; static char __pyx_k_timeout[] = "timeout"; static char __pyx_k_unicode[] = "unicode"; static char __pyx_k_watcher[] = "watcher"; static char __pyx_k_ARES_EOF[] = "ARES_EOF"; static char __pyx_k_NI_DGRAM[] = "NI_DGRAM"; static char __pyx_k_builtins[] = "__builtins__"; static char __pyx_k_callback[] = "callback"; static char __pyx_k_exc_info[] = "exc_info"; static char __pyx_k_gaierror[] = "gaierror"; static char __pyx_k_iterable[] = "iterable"; static char __pyx_k_on_timer[] = "_on_timer"; static char __pyx_k_qualname[] = "__qualname__"; static char __pyx_k_sockaddr[] = "sockaddr"; static char __pyx_k_tcp_port[] = "tcp_port"; static char __pyx_k_udp_port[] = "udp_port"; static char __pyx_k_InvalidIP[] = "InvalidIP"; static char __pyx_k_NI_NOFQDN[] = "NI_NOFQDN"; static char __pyx_k_TypeError[] = "TypeError"; static char __pyx_k_exception[] = "exception"; static char __pyx_k_metaclass[] = "__metaclass__"; static char __pyx_k_ARES_EFILE[] = "ARES_EFILE"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_basestring[] = "basestring"; static char __pyx_k_getnewargs[] = "__getnewargs__"; static char __pyx_k_process_fd[] = "_process_fd"; static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static char __pyx_k_ARES_ENOMEM[] = "ARES_ENOMEM"; static char __pyx_k_MemoryError[] = "MemoryError"; static char __pyx_k_NI_NAMEREQD[] = "NI_NAMEREQD"; static char __pyx_k_ares_errors[] = "_ares_errors"; static char __pyx_k_getnameinfo[] = "_getnameinfo"; static char __pyx_k_gevent_ares[] = "gevent.ares"; static char __pyx_k_pass_events[] = "pass_events"; static char __pyx_k_set_servers[] = "set_servers"; static char __pyx_k_ARES_EBADSTR[] = "ARES_EBADSTR"; static char __pyx_k_ARES_ENODATA[] = "ARES_ENODATA"; static char __pyx_k_ARES_ENONAME[] = "ARES_ENONAME"; static char __pyx_k_ARES_ENOTIMP[] = "ARES_ENOTIMP"; static char __pyx_k_ARES_SUCCESS[] = "ARES_SUCCESS"; static char __pyx_k_handle_error[] = "handle_error"; static char __pyx_k_version_info[] = "version_info"; static char __pyx_k_ARES_EBADNAME[] = "ARES_EBADNAME"; static char __pyx_k_ARES_EBADRESP[] = "ARES_EBADRESP"; static char __pyx_k_ARES_EFORMERR[] = "ARES_EFORMERR"; static char __pyx_k_ARES_EREFUSED[] = "ARES_EREFUSED"; static char __pyx_k_ARES_ETIMEOUT[] = "ARES_ETIMEOUT"; static char __pyx_k_s_exception_r[] = "%s(exception=%r)"; static char __pyx_k_ARES_EBADFLAGS[] = "ARES_EBADFLAGS"; static char __pyx_k_ARES_EBADHINTS[] = "ARES_EBADHINTS"; static char __pyx_k_ARES_EBADQUERY[] = "ARES_EBADQUERY"; static char __pyx_k_ARES_ENOTFOUND[] = "ARES_ENOTFOUND"; static char __pyx_k_ARES_ESERVFAIL[] = "ARES_ESERVFAIL"; static char __pyx_k_NI_NUMERICHOST[] = "NI_NUMERICHOST"; static char __pyx_k_NI_NUMERICSERV[] = "NI_NUMERICSERV"; static char __pyx_k_cares_flag_map[] = "_cares_flag_map"; static char __pyx_k_ARES_EBADFAMILY[] = "ARES_EBADFAMILY"; static char __pyx_k_ARES_ECANCELLED[] = "ARES_ECANCELLED"; static char __pyx_k_ARES_FLAG_IGNTC[] = "ARES_FLAG_IGNTC"; static char __pyx_k_ARES_FLAG_USEVC[] = "ARES_FLAG_USEVC"; static char __pyx_k_ares_host_result[] = "ares_host_result"; static char __pyx_k_ARES_ECONNREFUSED[] = "ARES_ECONNREFUSED"; static char __pyx_k_ARES_EDESTRUCTION[] = "ARES_EDESTRUCTION"; static char __pyx_k_ARES_FLAG_PRIMARY[] = "ARES_FLAG_PRIMARY"; static char __pyx_k_ARES_ELOADIPHLPAPI[] = "ARES_ELOADIPHLPAPI"; static char __pyx_k_ARES_FLAG_NOSEARCH[] = "ARES_FLAG_NOSEARCH"; static char __pyx_k_ARES_FLAG_STAYOPEN[] = "ARES_FLAG_STAYOPEN"; static char __pyx_k_ARES_FLAG_NOALIASES[] = "ARES_FLAG_NOALIASES"; static char __pyx_k_ARES_FLAG_NORECURSE[] = "ARES_FLAG_NORECURSE"; static char __pyx_k_ARES_ENOTINITIALIZED[] = "ARES_ENOTINITIALIZED"; static char __pyx_k_ARES_FLAG_NOCHECKRESP[] = "ARES_FLAG_NOCHECKRESP"; static char __pyx_k_s_value_r_exception_r[] = "%s(value=%r, exception=%r)"; static char __pyx_k_ares_host_result___new[] = "ares_host_result.__new__"; static char __pyx_k_expected_a_tuple_got_r[] = "expected a tuple, got %r"; static char __pyx_k_Invalid_value_for_port_r[] = "Invalid value for port: %r"; static char __pyx_k_ARES_EADDRGETNETWORKPARAMS[] = "ARES_EADDRGETNETWORKPARAMS"; static char __pyx_k_Bad_value_for_ai_flags_0x_x[] = "Bad value for ai_flags: 0x%x"; static char __pyx_k_ares_host_result___getnewargs[] = "ares_host_result.__getnewargs__"; static char __pyx_k_s_at_0x_x__timer_r__watchers_s[] = "<%s at 0x%x _timer=%r _watchers[%s]>"; static char __pyx_k_private_tmp_gevent_python2_7_ge[] = "/private/tmp/gevent/python2.7/gevent/gevent/ares.pyx"; static char __pyx_k_this_ares_channel_has_been_destr[] = "this ares channel has been destroyed"; static PyObject *__pyx_n_s_ARES_EADDRGETNETWORKPARAMS; static PyObject *__pyx_n_s_ARES_EBADFAMILY; static PyObject *__pyx_n_s_ARES_EBADFLAGS; static PyObject *__pyx_n_s_ARES_EBADHINTS; static PyObject *__pyx_n_s_ARES_EBADNAME; static PyObject *__pyx_n_s_ARES_EBADQUERY; static PyObject *__pyx_n_s_ARES_EBADRESP; static PyObject *__pyx_n_s_ARES_EBADSTR; static PyObject *__pyx_n_s_ARES_ECANCELLED; static PyObject *__pyx_n_s_ARES_ECONNREFUSED; static PyObject *__pyx_n_s_ARES_EDESTRUCTION; static PyObject *__pyx_n_s_ARES_EFILE; static PyObject *__pyx_n_s_ARES_EFORMERR; static PyObject *__pyx_n_s_ARES_ELOADIPHLPAPI; static PyObject *__pyx_n_s_ARES_ENODATA; static PyObject *__pyx_n_s_ARES_ENOMEM; static PyObject *__pyx_n_s_ARES_ENONAME; static PyObject *__pyx_n_s_ARES_ENOTFOUND; static PyObject *__pyx_n_s_ARES_ENOTIMP; static PyObject *__pyx_n_s_ARES_ENOTINITIALIZED; static PyObject *__pyx_n_s_ARES_EOF; static PyObject *__pyx_n_s_ARES_EREFUSED; static PyObject *__pyx_n_s_ARES_ESERVFAIL; static PyObject *__pyx_n_s_ARES_ETIMEOUT; static PyObject *__pyx_n_s_ARES_FLAG_IGNTC; static PyObject *__pyx_n_s_ARES_FLAG_NOALIASES; static PyObject *__pyx_n_s_ARES_FLAG_NOCHECKRESP; static PyObject *__pyx_n_s_ARES_FLAG_NORECURSE; static PyObject *__pyx_n_s_ARES_FLAG_NOSEARCH; static PyObject *__pyx_n_s_ARES_FLAG_PRIMARY; static PyObject *__pyx_n_s_ARES_FLAG_STAYOPEN; static PyObject *__pyx_n_s_ARES_FLAG_USEVC; static PyObject *__pyx_n_s_ARES_SUCCESS; static PyObject *__pyx_kp_s_Bad_value_for_ai_flags_0x_x; static PyObject *__pyx_n_s_InvalidIP; static PyObject *__pyx_kp_s_Invalid_value_for_port_r; static PyObject *__pyx_n_s_MemoryError; static PyObject *__pyx_n_s_NI_DGRAM; static PyObject *__pyx_n_s_NI_NAMEREQD; static PyObject *__pyx_n_s_NI_NOFQDN; static PyObject *__pyx_n_s_NI_NUMERICHOST; static PyObject *__pyx_n_s_NI_NUMERICSERV; static PyObject *__pyx_n_s_TIMEOUT; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_kp_s__2; static PyObject *__pyx_n_s_addr; static PyObject *__pyx_n_s_again; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_ares_errors; static PyObject *__pyx_n_s_ares_host_result; static PyObject *__pyx_n_s_ares_host_result___getnewargs; static PyObject *__pyx_n_s_ares_host_result___new; static PyObject *__pyx_n_s_ascii; static PyObject *__pyx_n_s_basestring; static PyObject *__pyx_n_s_builtins; static PyObject *__pyx_n_s_callback; static PyObject *__pyx_n_s_cares_flag_map; static PyObject *__pyx_n_s_channel; static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_cls; static PyObject *__pyx_n_s_default; static PyObject *__pyx_n_s_destroy; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_events; static PyObject *__pyx_n_s_exc_info; static PyObject *__pyx_n_s_exception; static PyObject *__pyx_kp_s_expected_a_tuple_got_r; static PyObject *__pyx_n_s_family; static PyObject *__pyx_n_s_fd; static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_gaierror; static PyObject *__pyx_n_s_get; static PyObject *__pyx_n_s_getnameinfo; static PyObject *__pyx_n_s_getnewargs; static PyObject *__pyx_n_s_gevent_ares; static PyObject *__pyx_n_s_handle_error; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_io; static PyObject *__pyx_n_s_iterable; static PyObject *__pyx_n_s_loop; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_name_2; static PyObject *__pyx_n_s_ndots; static PyObject *__pyx_n_s_new; static PyObject *__pyx_n_s_on_timer; static PyObject *__pyx_n_s_pass_events; static PyObject *__pyx_n_s_pop; static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_kp_s_private_tmp_gevent_python2_7_ge; static PyObject *__pyx_n_s_process_fd; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_kp_s_s_at_0x_x__timer_r__watchers_s; static PyObject *__pyx_kp_s_s_exception_r; static PyObject *__pyx_kp_s_s_r; static PyObject *__pyx_kp_s_s_s; static PyObject *__pyx_kp_s_s_value_r_exception_r; static PyObject *__pyx_n_s_self; static PyObject *__pyx_n_s_servers; static PyObject *__pyx_n_s_set_servers; static PyObject *__pyx_n_s_sockaddr; static PyObject *__pyx_n_s_socket; static PyObject *__pyx_n_s_split; static PyObject *__pyx_n_s_start; static PyObject *__pyx_n_s_stop; static PyObject *__pyx_n_s_sys; static PyObject *__pyx_n_s_tcp_port; static PyObject *__pyx_n_s_test; static PyObject *__pyx_kp_s_this_ares_channel_has_been_destr; static PyObject *__pyx_n_s_timeout; static PyObject *__pyx_n_s_timer; static PyObject *__pyx_n_s_tries; static PyObject *__pyx_n_s_udp_port; static PyObject *__pyx_n_s_unicode; static PyObject *__pyx_n_s_value; static PyObject *__pyx_n_s_version_info; static PyObject *__pyx_n_s_watcher; static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code); /* proto */ static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_int_3; static PyObject *__pyx_int_4; static PyObject *__pyx_int_8; static PyObject *__pyx_int_16; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_int_neg_8; static int __pyx_k_; static int __pyx_k__5; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__8; static PyObject *__pyx_codeobj__7; static PyObject *__pyx_codeobj__9; /* "gevent/ares.pyx":126 * * * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<< * global _cares_flag_map * import _socket */ static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void) { PyObject *__pyx_v__socket = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_prepare_cares_flag_map", 0); /* "gevent/ares.pyx":128 * cdef _prepare_cares_flag_map(): * global _cares_flag_map * import _socket # <<<<<<<<<<<<<< * _cares_flag_map = [ * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v__socket = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/ares.pyx":130 * import _socket * _cares_flag_map = [ * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), # <<<<<<<<<<<<<< * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), */ __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICHOST, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NUMERICHOST); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; /* "gevent/ares.pyx":131 * _cares_flag_map = [ * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), # <<<<<<<<<<<<<< * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), */ __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICSERV, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NUMERICSERV); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_1 = 0; /* "gevent/ares.pyx":132 * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), # <<<<<<<<<<<<<< * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] */ __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NOFQDN, __pyx_int_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NOFQDN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; /* "gevent/ares.pyx":133 * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), # <<<<<<<<<<<<<< * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] * */ __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NAMEREQD, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NAMEREQD); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_1 = 0; /* "gevent/ares.pyx":134 * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] # <<<<<<<<<<<<<< * * */ __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_DGRAM, __pyx_int_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_DGRAM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; /* "gevent/ares.pyx":129 * global _cares_flag_map * import _socket * _cares_flag_map = [ # <<<<<<<<<<<<<< * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), */ __pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":126 * * * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<< * global _cares_flag_map * import _socket */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.ares._prepare_cares_flag_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v__socket); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":137 * * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< * if _cares_flag_map is None: * _prepare_cares_flag_map() */ static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args) { int __pyx_v_default = __pyx_k_; PyObject *__pyx_v_socket_flag = NULL; PyObject *__pyx_v_cares_flag = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; PyObject *(*__pyx_t_6)(PyObject *); PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *(*__pyx_t_10)(PyObject *); int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_convert_cares_flags", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default = __pyx_optional_args->__pyx_default; } } /* "gevent/ares.pyx":138 * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): * if _cares_flag_map is None: # <<<<<<<<<<<<<< * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_t_1 == Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "gevent/ares.pyx":139 * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): * if _cares_flag_map is None: * _prepare_cares_flag_map() # <<<<<<<<<<<<<< * for socket_flag, cares_flag in _cares_flag_map: * if socket_flag & flags: */ __pyx_t_1 = __pyx_f_6gevent_4ares__prepare_cares_flag_map(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":138 * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): * if _cares_flag_map is None: # <<<<<<<<<<<<<< * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: */ } /* "gevent/ares.pyx":140 * if _cares_flag_map is None: * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<< * if socket_flag & flags: * default |= cares_flag */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_8 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_socket_flag, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_cares_flag, __pyx_t_8); __pyx_t_8 = 0; /* "gevent/ares.pyx":141 * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: * if socket_flag & flags: # <<<<<<<<<<<<<< * default |= cares_flag * flags &= ~socket_flag */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = PyNumber_And(__pyx_v_socket_flag, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_3) { /* "gevent/ares.pyx":142 * for socket_flag, cares_flag in _cares_flag_map: * if socket_flag & flags: * default |= cares_flag # <<<<<<<<<<<<<< * flags &= ~socket_flag * if not flags: */ __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = PyNumber_InPlaceOr(__pyx_t_8, __pyx_v_cares_flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_default = __pyx_t_11; /* "gevent/ares.pyx":143 * if socket_flag & flags: * default |= cares_flag * flags &= ~socket_flag # <<<<<<<<<<<<<< * if not flags: * return default */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = PyNumber_Invert(__pyx_v_socket_flag); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyNumber_InPlaceAnd(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_flags = __pyx_t_11; /* "gevent/ares.pyx":141 * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: * if socket_flag & flags: # <<<<<<<<<<<<<< * default |= cares_flag * flags &= ~socket_flag */ } /* "gevent/ares.pyx":144 * default |= cares_flag * flags &= ~socket_flag * if not flags: # <<<<<<<<<<<<<< * return default * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) */ __pyx_t_3 = ((!(__pyx_v_flags != 0)) != 0); if (__pyx_t_3) { /* "gevent/ares.pyx":145 * flags &= ~socket_flag * if not flags: * return default # <<<<<<<<<<<<<< * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) * */ __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0; /* "gevent/ares.pyx":144 * default |= cares_flag * flags &= ~socket_flag * if not flags: # <<<<<<<<<<<<<< * return default * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) */ } /* "gevent/ares.pyx":140 * if _cares_flag_map is None: * _prepare_cares_flag_map() * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<< * if socket_flag & flags: * default |= cares_flag */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "gevent/ares.pyx":146 * if not flags: * return default * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) # <<<<<<<<<<<<<< * * */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_int_neg_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":137 * * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< * if _cares_flag_map is None: * _prepare_cares_flag_map() */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_socket_flag); __Pyx_XDECREF(__pyx_v_cares_flag); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_flags; int __pyx_v_default; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_convert_cares_flags (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_convert_cares_flags") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_flags = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} if (values[1]) { __pyx_v_default = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_default == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_default = __pyx_k_; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_convert_cares_flags", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares__convert_cares_flags(__pyx_self, __pyx_v_flags, __pyx_v_default); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; struct __pyx_opt_args_6gevent_4ares__convert_cares_flags __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_convert_cares_flags", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.__pyx_default = __pyx_v_default; __pyx_t_1 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":149 * * * cpdef strerror(code): # <<<<<<<<<<<<<< * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) * */ static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/ static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *__pyx_v_code, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("strerror", 0); /* "gevent/ares.pyx":150 * * cpdef strerror(code): * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_errors); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_code); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_code); __Pyx_GIVEREF(__pyx_v_code); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_code); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_6) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L3_bool_binop_done; } __Pyx_INCREF(__pyx_v_code); __pyx_t_1 = __pyx_v_code; __pyx_L3_bool_binop_done:; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_code); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyBytes_FromString(ares_strerror(__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/ares.pyx":149 * * * cpdef strerror(code): # <<<<<<<<<<<<<< * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("strerror (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_2strerror(__pyx_self, ((PyObject *)__pyx_v_code)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("strerror", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_4ares_strerror(__pyx_v_code, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":157 * * * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<< * if not data: * return */ static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *__pyx_v_data, int __pyx_v_s, int __pyx_v_read, int __pyx_v_write) { struct PyGeventAresChannelObject *__pyx_v_ch = 0; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gevent_sock_state_callback", 0); /* "gevent/ares.pyx":158 * * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): * if not data: # <<<<<<<<<<<<<< * return * cdef channel ch = data */ __pyx_t_1 = ((!(__pyx_v_data != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":159 * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): * if not data: * return # <<<<<<<<<<<<<< * cdef channel ch = data * ch._sock_state_callback(s, read, write) */ goto __pyx_L0; /* "gevent/ares.pyx":158 * * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): * if not data: # <<<<<<<<<<<<<< * return * cdef channel ch = data */ } /* "gevent/ares.pyx":160 * if not data: * return * cdef channel ch = data # <<<<<<<<<<<<<< * ch._sock_state_callback(s, read, write) * */ __pyx_t_2 = ((PyObject *)__pyx_v_data); __Pyx_INCREF(__pyx_t_2); __pyx_v_ch = ((struct PyGeventAresChannelObject *)__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":161 * return * cdef channel ch = data * ch._sock_state_callback(s, read, write) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_ch->__pyx_vtab)->_sock_state_callback(__pyx_v_ch, __pyx_v_s, __pyx_v_read, __pyx_v_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":157 * * * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<< * if not data: * return */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("gevent.ares.gevent_sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_ch); __Pyx_RefNannyFinishContext(); } /* "gevent/ares.pyx":168 * cdef public object exception * * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<< * self.value = value * self.exception = exception */ /* Python wrapper */ static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_value = 0; PyObject *__pyx_v_exception = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_exception,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_exception); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_value = values[0]; __pyx_v_exception = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.result.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_6result___init__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), __pyx_v_value, __pyx_v_exception); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/ares.pyx":169 * * def __init__(self, object value=None, object exception=None): * self.value = value # <<<<<<<<<<<<<< * self.exception = exception * */ __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->value); __Pyx_DECREF(__pyx_v_self->value); __pyx_v_self->value = __pyx_v_value; /* "gevent/ares.pyx":170 * def __init__(self, object value=None, object exception=None): * self.value = value * self.exception = exception # <<<<<<<<<<<<<< * * def __repr__(self): */ __Pyx_INCREF(__pyx_v_exception); __Pyx_GIVEREF(__pyx_v_exception); __Pyx_GOTREF(__pyx_v_self->exception); __Pyx_DECREF(__pyx_v_self->exception); __pyx_v_self->exception = __pyx_v_exception; /* "gevent/ares.pyx":168 * cdef public object exception * * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<< * self.value = value * self.exception = exception */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":172 * self.exception = exception * * def __repr__(self): # <<<<<<<<<<<<<< * if self.exception is None: * return '%s(%r)' % (self.__class__.__name__, self.value) */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_2__repr__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/ares.pyx":173 * * def __repr__(self): * if self.exception is None: # <<<<<<<<<<<<<< * return '%s(%r)' % (self.__class__.__name__, self.value) * elif self.value is None: */ __pyx_t_1 = (__pyx_v_self->exception == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":174 * def __repr__(self): * if self.exception is None: * return '%s(%r)' % (self.__class__.__name__, self.value) # <<<<<<<<<<<<<< * elif self.value is None: * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_INCREF(__pyx_v_self->value); __Pyx_GIVEREF(__pyx_v_self->value); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "gevent/ares.pyx":173 * * def __repr__(self): * if self.exception is None: # <<<<<<<<<<<<<< * return '%s(%r)' % (self.__class__.__name__, self.value) * elif self.value is None: */ } /* "gevent/ares.pyx":175 * if self.exception is None: * return '%s(%r)' % (self.__class__.__name__, self.value) * elif self.value is None: # <<<<<<<<<<<<<< * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) * else: */ __pyx_t_2 = (__pyx_v_self->value == Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":176 * return '%s(%r)' % (self.__class__.__name__, self.value) * elif self.value is None: * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) # <<<<<<<<<<<<<< * else: * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_INCREF(__pyx_v_self->exception); __Pyx_GIVEREF(__pyx_v_self->exception); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->exception); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_exception_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "gevent/ares.pyx":175 * if self.exception is None: * return '%s(%r)' % (self.__class__.__name__, self.value) * elif self.value is None: # <<<<<<<<<<<<<< * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) * else: */ } /* "gevent/ares.pyx":178 * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) * else: * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) # <<<<<<<<<<<<<< * # add repr_recursive precaution * */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_INCREF(__pyx_v_self->value); __Pyx_GIVEREF(__pyx_v_self->value); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value); __Pyx_INCREF(__pyx_v_self->exception); __Pyx_GIVEREF(__pyx_v_self->exception); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->exception); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_value_r_exception_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; } /* "gevent/ares.pyx":172 * self.exception = exception * * def __repr__(self): # <<<<<<<<<<<<<< * if self.exception is None: * return '%s(%r)' % (self.__class__.__name__, self.value) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.ares.result.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":181 * # add repr_recursive precaution * * def successful(self): # <<<<<<<<<<<<<< * return self.exception is None * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("successful (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_4successful(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("successful", 0); /* "gevent/ares.pyx":182 * * def successful(self): * return self.exception is None # <<<<<<<<<<<<<< * * def get(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = (__pyx_v_self->exception == Py_None); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/ares.pyx":181 * # add repr_recursive precaution * * def successful(self): # <<<<<<<<<<<<<< * return self.exception is None * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.ares.result.successful", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":184 * return self.exception is None * * def get(self): # <<<<<<<<<<<<<< * if self.exception is not None: * raise self.exception */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_6get(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get", 0); /* "gevent/ares.pyx":185 * * def get(self): * if self.exception is not None: # <<<<<<<<<<<<<< * raise self.exception * return self.value */ __pyx_t_1 = (__pyx_v_self->exception != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":186 * def get(self): * if self.exception is not None: * raise self.exception # <<<<<<<<<<<<<< * return self.value * */ __Pyx_Raise(__pyx_v_self->exception, 0, 0, 0); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":185 * * def get(self): * if self.exception is not None: # <<<<<<<<<<<<<< * raise self.exception * return self.value */ } /* "gevent/ares.pyx":187 * if self.exception is not None: * raise self.exception * return self.value # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->value); __pyx_r = __pyx_v_self->value; goto __pyx_L0; /* "gevent/ares.pyx":184 * return self.exception is None * * def get(self): # <<<<<<<<<<<<<< * if self.exception is not None: * raise self.exception */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("gevent.ares.result.get", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":165 * * cdef class result: * cdef public object value # <<<<<<<<<<<<<< * cdef public object exception * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_5value___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->value); __pyx_r = __pyx_v_self->value; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->value); __Pyx_DECREF(__pyx_v_self->value); __pyx_v_self->value = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->value); __Pyx_DECREF(__pyx_v_self->value); __pyx_v_self->value = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":166 * cdef class result: * cdef public object value * cdef public object exception # <<<<<<<<<<<<<< * * def __init__(self, object value=None, object exception=None): */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->exception); __pyx_r = __pyx_v_self->exception; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->exception); __Pyx_DECREF(__pyx_v_self->exception); __pyx_v_self->exception = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->exception); __Pyx_DECREF(__pyx_v_self->exception); __pyx_v_self->exception = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":192 * class ares_host_result(tuple): * * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< * cdef object self = tuple.__new__(cls, iterable) * self.family = family */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_1__new__ = {"__new__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_1__new__, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_cls = 0; PyObject *__pyx_v_family = 0; PyObject *__pyx_v_iterable = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__new__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_family,&__pyx_n_s_iterable,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_iterable)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_cls = values[0]; __pyx_v_family = values[1]; __pyx_v_iterable = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result___new__(__pyx_self, __pyx_v_cls, __pyx_v_family, __pyx_v_iterable); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable) { PyObject *__pyx_v_self = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__new__", 0); /* "gevent/ares.pyx":193 * * def __new__(cls, family, iterable): * cdef object self = tuple.__new__(cls, iterable) # <<<<<<<<<<<<<< * self.family = family * return self */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_cls); __Pyx_GIVEREF(__pyx_v_cls); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_cls); __Pyx_INCREF(__pyx_v_iterable); __Pyx_GIVEREF(__pyx_v_iterable); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_iterable); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/ares.pyx":194 * def __new__(cls, family, iterable): * cdef object self = tuple.__new__(cls, iterable) * self.family = family # <<<<<<<<<<<<<< * return self * */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":195 * cdef object self = tuple.__new__(cls, iterable) * self.family = family * return self # <<<<<<<<<<<<<< * * def __getnewargs__(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self); __pyx_r = __pyx_v_self; goto __pyx_L0; /* "gevent/ares.pyx":192 * class ares_host_result(tuple): * * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< * cdef object self = tuple.__new__(cls, iterable) * self.family = family */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_self); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":197 * return self * * def __getnewargs__(self): # <<<<<<<<<<<<<< * return (self.family, tuple(self)) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__ = {"__getnewargs__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__, METH_O, 0}; static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getnewargs__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getnewargs__", 0); /* "gevent/ares.pyx":198 * * def __getnewargs__(self): * return (self.family, tuple(self)) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_family); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_Tuple(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "gevent/ares.pyx":197 * return self * * def __getnewargs__(self): # <<<<<<<<<<<<<< * return (self.family, tuple(self)) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.ares.ares_host_result.__getnewargs__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":201 * * * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<< * cdef channel channel * cdef object callback */ static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, struct hostent *__pyx_v_host) { struct PyGeventAresChannelObject *__pyx_v_channel = 0; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_host_result = 0; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; Py_ssize_t __pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gevent_ares_host_callback", 0); /* "gevent/ares.pyx":204 * cdef channel channel * cdef object callback * channel, callback = arg # <<<<<<<<<<<<<< * Py_DECREF(arg) * cdef object host_result */ __pyx_t_1 = ((PyObject *)__pyx_v_arg); __Pyx_INCREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2); __pyx_t_2 = 0; __pyx_v_callback = __pyx_t_3; __pyx_t_3 = 0; /* "gevent/ares.pyx":205 * cdef object callback * channel, callback = arg * Py_DECREF(arg) # <<<<<<<<<<<<<< * cdef object host_result * try: */ Py_DECREF(((PyObject*)__pyx_v_arg)); /* "gevent/ares.pyx":207 * Py_DECREF(arg) * cdef object host_result * try: # <<<<<<<<<<<<<< * if status or not host: * callback(result(None, gaierror(status, strerror(status)))) */ { __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "gevent/ares.pyx":208 * cdef object host_result * try: * if status or not host: # <<<<<<<<<<<<<< * callback(result(None, gaierror(status, strerror(status)))) * else: */ __pyx_t_8 = (__pyx_v_status != 0); if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L12_bool_binop_done; } __pyx_t_8 = ((!(__pyx_v_host != 0)) != 0); __pyx_t_7 = __pyx_t_8; __pyx_L12_bool_binop_done:; if (__pyx_t_7) { /* "gevent/ares.pyx":209 * try: * if status or not host: * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<< * else: * try: */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_12 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_12 = 1; } } __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11); __pyx_t_9 = 0; __pyx_t_11 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_callback); __pyx_t_2 = __pyx_v_callback; __pyx_t_13 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_13) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":208 * cdef object host_result * try: * if status or not host: # <<<<<<<<<<<<<< * callback(result(None, gaierror(status, strerror(status)))) * else: */ goto __pyx_L11; } /* "gevent/ares.pyx":211 * callback(result(None, gaierror(status, strerror(status)))) * else: * try: # <<<<<<<<<<<<<< * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) * except: */ /*else*/ { { __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); /*try:*/ { /* "gevent/ares.pyx":212 * else: * try: * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) # <<<<<<<<<<<<<< * except: * callback(result(None, sys.exc_info()[1])) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_host_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_host->h_addrtype); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = parse_h_name(__pyx_v_host); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = parse_h_aliases(__pyx_v_host); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = parse_h_addr_list(__pyx_v_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9); __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_12 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_12 = 1; } } __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10); __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L14_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_host_result = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/ares.pyx":211 * callback(result(None, gaierror(status, strerror(status)))) * else: * try: # <<<<<<<<<<<<<< * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) * except: */ } /* "gevent/ares.pyx":216 * callback(result(None, sys.exc_info()[1])) * else: * callback(result(host_result)) # <<<<<<<<<<<<<< * except: * channel.loop.handle_error(callback, *sys.exc_info()) */ /*else:*/ { __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_host_result); __Pyx_GIVEREF(__pyx_v_host_result); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_host_result); __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_callback); __pyx_t_2 = __pyx_v_callback; __pyx_t_10 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_10) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L21_try_end; __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":213 * try: * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) * except: # <<<<<<<<<<<<<< * callback(result(None, sys.exc_info()[1])) * else: */ /*except:*/ { __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_11); /* "gevent/ares.pyx":214 * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) * except: * callback(result(None, sys.exc_info()[1])) # <<<<<<<<<<<<<< * else: * callback(result(host_result)) */ __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_9) { __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} } __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_10, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_10, 0, Py_None); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_v_callback); __pyx_t_10 = __pyx_v_callback; __pyx_t_9 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } if (!__pyx_t_9) { __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_13); } else { __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L15_exception_handled; } __pyx_L16_except_error:; /* "gevent/ares.pyx":211 * callback(result(None, gaierror(status, strerror(status)))) * else: * try: # <<<<<<<<<<<<<< * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) * except: */ __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L3_error; __pyx_L15_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_L21_try_end:; } } __pyx_L11:; /* "gevent/ares.pyx":207 * Py_DECREF(arg) * cdef object host_result * try: # <<<<<<<<<<<<<< * if status or not host: * callback(result(None, gaierror(status, strerror(status)))) */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; /* "gevent/ares.pyx":217 * else: * callback(result(host_result)) * except: # <<<<<<<<<<<<<< * channel.loop.handle_error(callback, *sys.exc_info()) * */ /*except:*/ { __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); /* "gevent/ares.pyx":218 * callback(result(host_result)) * except: * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<< * * */ __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_callback); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (__pyx_t_3) { __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_17 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} } __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PySequence_Tuple(__pyx_t_17); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L4_exception_handled; } __pyx_L5_except_error:; /* "gevent/ares.pyx":207 * Py_DECREF(arg) * cdef object host_result * try: # <<<<<<<<<<<<<< * if status or not host: * callback(result(None, gaierror(status, strerror(status)))) */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L10_try_end:; } /* "gevent/ares.pyx":201 * * * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<< * cdef channel channel * cdef object callback */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_17); __Pyx_WriteUnraisable("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_channel); __Pyx_XDECREF(__pyx_v_callback); __Pyx_XDECREF(__pyx_v_host_result); __Pyx_RefNannyFinishContext(); } /* "gevent/ares.pyx":221 * * * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<< * cdef channel channel * cdef object callback */ static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, char *__pyx_v_c_node, char *__pyx_v_c_service) { struct PyGeventAresChannelObject *__pyx_v_channel = 0; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_node = 0; PyObject *__pyx_v_service = 0; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; Py_ssize_t __pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gevent_ares_nameinfo_callback", 0); /* "gevent/ares.pyx":224 * cdef channel channel * cdef object callback * channel, callback = arg # <<<<<<<<<<<<<< * Py_DECREF(arg) * cdef object node */ __pyx_t_1 = ((PyObject *)__pyx_v_arg); __Pyx_INCREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2); __pyx_t_2 = 0; __pyx_v_callback = __pyx_t_3; __pyx_t_3 = 0; /* "gevent/ares.pyx":225 * cdef object callback * channel, callback = arg * Py_DECREF(arg) # <<<<<<<<<<<<<< * cdef object node * cdef object service */ Py_DECREF(((PyObject*)__pyx_v_arg)); /* "gevent/ares.pyx":228 * cdef object node * cdef object service * try: # <<<<<<<<<<<<<< * if status: * callback(result(None, gaierror(status, strerror(status)))) */ { __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "gevent/ares.pyx":229 * cdef object service * try: * if status: # <<<<<<<<<<<<<< * callback(result(None, gaierror(status, strerror(status)))) * else: */ __pyx_t_7 = (__pyx_v_status != 0); if (__pyx_t_7) { /* "gevent/ares.pyx":230 * try: * if status: * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<< * else: * if c_node: */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_11 = 1; } } __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_10 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_callback); __pyx_t_2 = __pyx_v_callback; __pyx_t_12 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_12) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":229 * cdef object service * try: * if status: # <<<<<<<<<<<<<< * callback(result(None, gaierror(status, strerror(status)))) * else: */ goto __pyx_L11; } /* "gevent/ares.pyx":232 * callback(result(None, gaierror(status, strerror(status)))) * else: * if c_node: # <<<<<<<<<<<<<< * node = PyUnicode_FromString(c_node) * else: */ /*else*/ { __pyx_t_7 = (__pyx_v_c_node != 0); if (__pyx_t_7) { /* "gevent/ares.pyx":233 * else: * if c_node: * node = PyUnicode_FromString(c_node) # <<<<<<<<<<<<<< * else: * node = None */ __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_node); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_node = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/ares.pyx":232 * callback(result(None, gaierror(status, strerror(status)))) * else: * if c_node: # <<<<<<<<<<<<<< * node = PyUnicode_FromString(c_node) * else: */ goto __pyx_L12; } /* "gevent/ares.pyx":235 * node = PyUnicode_FromString(c_node) * else: * node = None # <<<<<<<<<<<<<< * if c_service: * service = PyUnicode_FromString(c_service) */ /*else*/ { __Pyx_INCREF(Py_None); __pyx_v_node = Py_None; } __pyx_L12:; /* "gevent/ares.pyx":236 * else: * node = None * if c_service: # <<<<<<<<<<<<<< * service = PyUnicode_FromString(c_service) * else: */ __pyx_t_7 = (__pyx_v_c_service != 0); if (__pyx_t_7) { /* "gevent/ares.pyx":237 * node = None * if c_service: * service = PyUnicode_FromString(c_service) # <<<<<<<<<<<<<< * else: * service = None */ __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_service); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_service = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/ares.pyx":236 * else: * node = None * if c_service: # <<<<<<<<<<<<<< * service = PyUnicode_FromString(c_service) * else: */ goto __pyx_L13; } /* "gevent/ares.pyx":239 * service = PyUnicode_FromString(c_service) * else: * service = None # <<<<<<<<<<<<<< * callback(result((node, service))) * except: */ /*else*/ { __Pyx_INCREF(Py_None); __pyx_v_service = Py_None; } __pyx_L13:; /* "gevent/ares.pyx":240 * else: * service = None * callback(result((node, service))) # <<<<<<<<<<<<<< * except: * channel.loop.handle_error(callback, *sys.exc_info()) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_node); __Pyx_GIVEREF(__pyx_v_node); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_node); __Pyx_INCREF(__pyx_v_service); __Pyx_GIVEREF(__pyx_v_service); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_service); __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_v_callback); __pyx_t_10 = __pyx_v_callback; __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L11:; /* "gevent/ares.pyx":228 * cdef object node * cdef object service * try: # <<<<<<<<<<<<<< * if status: * callback(result(None, gaierror(status, strerror(status)))) */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":241 * service = None * callback(result((node, service))) * except: # <<<<<<<<<<<<<< * channel.loop.handle_error(callback, *sys.exc_info()) * */ /*except:*/ { __Pyx_AddTraceback("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_12); /* "gevent/ares.pyx":242 * callback(result((node, service))) * except: * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback); __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (__pyx_t_9) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PySequence_Tuple(__pyx_t_8); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L4_exception_handled; } __pyx_L5_except_error:; /* "gevent/ares.pyx":228 * cdef object node * cdef object service * try: # <<<<<<<<<<<<<< * if status: * callback(result(None, gaierror(status, strerror(status)))) */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L10_try_end:; } /* "gevent/ares.pyx":221 * * * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<< * cdef channel channel * cdef object callback */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_WriteUnraisable("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_channel); __Pyx_XDECREF(__pyx_v_callback); __Pyx_XDECREF(__pyx_v_node); __Pyx_XDECREF(__pyx_v_service); __Pyx_RefNannyFinishContext(); } /* "gevent/ares.pyx":252 * cdef public object _timer * * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< * udp_port=None, tcp_port=None, servers=None): * cdef ares_channeldata* channel = NULL */ /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_loop = 0; PyObject *__pyx_v_flags = 0; PyObject *__pyx_v_timeout = 0; PyObject *__pyx_v_tries = 0; PyObject *__pyx_v_ndots = 0; PyObject *__pyx_v_udp_port = 0; PyObject *__pyx_v_tcp_port = 0; PyObject *__pyx_v_servers = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_flags,&__pyx_n_s_timeout,&__pyx_n_s_tries,&__pyx_n_s_ndots,&__pyx_n_s_udp_port,&__pyx_n_s_tcp_port,&__pyx_n_s_servers,0}; PyObject* values[8] = {0,0,0,0,0,0,0,0}; values[1] = ((PyObject *)Py_None); values[2] = ((PyObject *)Py_None); values[3] = ((PyObject *)Py_None); values[4] = ((PyObject *)Py_None); /* "gevent/ares.pyx":253 * * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, * udp_port=None, tcp_port=None, servers=None): # <<<<<<<<<<<<<< * cdef ares_channeldata* channel = NULL * cdef cares.ares_options options */ values[5] = ((PyObject *)Py_None); values[6] = ((PyObject *)Py_None); values[7] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tries); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndots); if (value) { values[4] = value; kw_args--; } } case 5: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_udp_port); if (value) { values[5] = value; kw_args--; } } case 6: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tcp_port); if (value) { values[6] = value; kw_args--; } } case 7: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers); if (value) { values[7] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = values[0]; __pyx_v_flags = values[1]; __pyx_v_timeout = values[2]; __pyx_v_tries = values[3]; __pyx_v_ndots = values[4]; __pyx_v_udp_port = values[5]; __pyx_v_tcp_port = values[6]; __pyx_v_servers = values[7]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_7channel___init__(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_flags, __pyx_v_timeout, __pyx_v_tries, __pyx_v_ndots, __pyx_v_udp_port, __pyx_v_tcp_port, __pyx_v_servers); /* "gevent/ares.pyx":252 * cdef public object _timer * * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< * udp_port=None, tcp_port=None, servers=None): * cdef ares_channeldata* channel = NULL */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers) { struct ares_channeldata *__pyx_v_channel; struct ares_options __pyx_v_options; int __pyx_v_optmask; int __pyx_v_result; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; double __pyx_t_5; unsigned short __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; Py_ssize_t __pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/ares.pyx":254 * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, * udp_port=None, tcp_port=None, servers=None): * cdef ares_channeldata* channel = NULL # <<<<<<<<<<<<<< * cdef cares.ares_options options * memset(&options, 0, sizeof(cares.ares_options)) */ __pyx_v_channel = NULL; /* "gevent/ares.pyx":256 * cdef ares_channeldata* channel = NULL * cdef cares.ares_options options * memset(&options, 0, sizeof(cares.ares_options)) # <<<<<<<<<<<<<< * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB * options.sock_state_cb = gevent_sock_state_callback */ memset((&__pyx_v_options), 0, (sizeof(struct ares_options))); /* "gevent/ares.pyx":257 * cdef cares.ares_options options * memset(&options, 0, sizeof(cares.ares_options)) * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB # <<<<<<<<<<<<<< * options.sock_state_cb = gevent_sock_state_callback * options.sock_state_cb_data = self */ __pyx_v_optmask = ARES_OPT_SOCK_STATE_CB; /* "gevent/ares.pyx":258 * memset(&options, 0, sizeof(cares.ares_options)) * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB * options.sock_state_cb = gevent_sock_state_callback # <<<<<<<<<<<<<< * options.sock_state_cb_data = self * if flags is not None: */ __pyx_v_options.sock_state_cb = ((void *)__pyx_f_6gevent_4ares_gevent_sock_state_callback); /* "gevent/ares.pyx":259 * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB * options.sock_state_cb = gevent_sock_state_callback * options.sock_state_cb_data = self # <<<<<<<<<<<<<< * if flags is not None: * options.flags = int(flags) */ __pyx_v_options.sock_state_cb_data = ((void *)__pyx_v_self); /* "gevent/ares.pyx":260 * options.sock_state_cb = gevent_sock_state_callback * options.sock_state_cb_data = self * if flags is not None: # <<<<<<<<<<<<<< * options.flags = int(flags) * optmask |= cares.ARES_OPT_FLAGS */ __pyx_t_1 = (__pyx_v_flags != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":261 * options.sock_state_cb_data = self * if flags is not None: * options.flags = int(flags) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_FLAGS * if timeout is not None: */ __pyx_t_3 = PyNumber_Int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_options.flags = __pyx_t_4; /* "gevent/ares.pyx":262 * if flags is not None: * options.flags = int(flags) * optmask |= cares.ARES_OPT_FLAGS # <<<<<<<<<<<<<< * if timeout is not None: * options.timeout = int(float(timeout) * 1000) */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_FLAGS); /* "gevent/ares.pyx":260 * options.sock_state_cb = gevent_sock_state_callback * options.sock_state_cb_data = self * if flags is not None: # <<<<<<<<<<<<<< * options.flags = int(flags) * optmask |= cares.ARES_OPT_FLAGS */ } /* "gevent/ares.pyx":263 * options.flags = int(flags) * optmask |= cares.ARES_OPT_FLAGS * if timeout is not None: # <<<<<<<<<<<<<< * options.timeout = int(float(timeout) * 1000) * optmask |= cares.ARES_OPT_TIMEOUTMS */ __pyx_t_2 = (__pyx_v_timeout != Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":264 * optmask |= cares.ARES_OPT_FLAGS * if timeout is not None: * options.timeout = int(float(timeout) * 1000) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_TIMEOUTMS * if tries is not None: */ __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_timeout); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_options.timeout = ((int)(__pyx_t_5 * 1000.0)); /* "gevent/ares.pyx":265 * if timeout is not None: * options.timeout = int(float(timeout) * 1000) * optmask |= cares.ARES_OPT_TIMEOUTMS # <<<<<<<<<<<<<< * if tries is not None: * options.tries = int(tries) */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TIMEOUTMS); /* "gevent/ares.pyx":263 * options.flags = int(flags) * optmask |= cares.ARES_OPT_FLAGS * if timeout is not None: # <<<<<<<<<<<<<< * options.timeout = int(float(timeout) * 1000) * optmask |= cares.ARES_OPT_TIMEOUTMS */ } /* "gevent/ares.pyx":266 * options.timeout = int(float(timeout) * 1000) * optmask |= cares.ARES_OPT_TIMEOUTMS * if tries is not None: # <<<<<<<<<<<<<< * options.tries = int(tries) * optmask |= cares.ARES_OPT_TRIES */ __pyx_t_1 = (__pyx_v_tries != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":267 * optmask |= cares.ARES_OPT_TIMEOUTMS * if tries is not None: * options.tries = int(tries) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_TRIES * if ndots is not None: */ __pyx_t_3 = PyNumber_Int(__pyx_v_tries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_options.tries = __pyx_t_4; /* "gevent/ares.pyx":268 * if tries is not None: * options.tries = int(tries) * optmask |= cares.ARES_OPT_TRIES # <<<<<<<<<<<<<< * if ndots is not None: * options.ndots = int(ndots) */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TRIES); /* "gevent/ares.pyx":266 * options.timeout = int(float(timeout) * 1000) * optmask |= cares.ARES_OPT_TIMEOUTMS * if tries is not None: # <<<<<<<<<<<<<< * options.tries = int(tries) * optmask |= cares.ARES_OPT_TRIES */ } /* "gevent/ares.pyx":269 * options.tries = int(tries) * optmask |= cares.ARES_OPT_TRIES * if ndots is not None: # <<<<<<<<<<<<<< * options.ndots = int(ndots) * optmask |= cares.ARES_OPT_NDOTS */ __pyx_t_2 = (__pyx_v_ndots != Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":270 * optmask |= cares.ARES_OPT_TRIES * if ndots is not None: * options.ndots = int(ndots) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_NDOTS * if udp_port is not None: */ __pyx_t_3 = PyNumber_Int(__pyx_v_ndots); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_options.ndots = __pyx_t_4; /* "gevent/ares.pyx":271 * if ndots is not None: * options.ndots = int(ndots) * optmask |= cares.ARES_OPT_NDOTS # <<<<<<<<<<<<<< * if udp_port is not None: * options.udp_port = int(udp_port) */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_NDOTS); /* "gevent/ares.pyx":269 * options.tries = int(tries) * optmask |= cares.ARES_OPT_TRIES * if ndots is not None: # <<<<<<<<<<<<<< * options.ndots = int(ndots) * optmask |= cares.ARES_OPT_NDOTS */ } /* "gevent/ares.pyx":272 * options.ndots = int(ndots) * optmask |= cares.ARES_OPT_NDOTS * if udp_port is not None: # <<<<<<<<<<<<<< * options.udp_port = int(udp_port) * optmask |= cares.ARES_OPT_UDP_PORT */ __pyx_t_1 = (__pyx_v_udp_port != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":273 * optmask |= cares.ARES_OPT_NDOTS * if udp_port is not None: * options.udp_port = int(udp_port) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_UDP_PORT * if tcp_port is not None: */ __pyx_t_3 = PyNumber_Int(__pyx_v_udp_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_options.udp_port = __pyx_t_6; /* "gevent/ares.pyx":274 * if udp_port is not None: * options.udp_port = int(udp_port) * optmask |= cares.ARES_OPT_UDP_PORT # <<<<<<<<<<<<<< * if tcp_port is not None: * options.tcp_port = int(tcp_port) */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_UDP_PORT); /* "gevent/ares.pyx":272 * options.ndots = int(ndots) * optmask |= cares.ARES_OPT_NDOTS * if udp_port is not None: # <<<<<<<<<<<<<< * options.udp_port = int(udp_port) * optmask |= cares.ARES_OPT_UDP_PORT */ } /* "gevent/ares.pyx":275 * options.udp_port = int(udp_port) * optmask |= cares.ARES_OPT_UDP_PORT * if tcp_port is not None: # <<<<<<<<<<<<<< * options.tcp_port = int(tcp_port) * optmask |= cares.ARES_OPT_TCP_PORT */ __pyx_t_2 = (__pyx_v_tcp_port != Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":276 * optmask |= cares.ARES_OPT_UDP_PORT * if tcp_port is not None: * options.tcp_port = int(tcp_port) # <<<<<<<<<<<<<< * optmask |= cares.ARES_OPT_TCP_PORT * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? */ __pyx_t_3 = PyNumber_Int(__pyx_v_tcp_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_options.tcp_port = __pyx_t_6; /* "gevent/ares.pyx":277 * if tcp_port is not None: * options.tcp_port = int(tcp_port) * optmask |= cares.ARES_OPT_TCP_PORT # <<<<<<<<<<<<<< * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? * if result: */ __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TCP_PORT); /* "gevent/ares.pyx":275 * options.udp_port = int(udp_port) * optmask |= cares.ARES_OPT_UDP_PORT * if tcp_port is not None: # <<<<<<<<<<<<<< * options.tcp_port = int(tcp_port) * optmask |= cares.ARES_OPT_TCP_PORT */ } /* "gevent/ares.pyx":278 * options.tcp_port = int(tcp_port) * optmask |= cares.ARES_OPT_TCP_PORT * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? # <<<<<<<<<<<<<< * if result: * raise gaierror(result, strerror(result)) */ __pyx_v_result = ares_library_init(ARES_LIB_INIT_ALL); /* "gevent/ares.pyx":279 * optmask |= cares.ARES_OPT_TCP_PORT * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? * if result: # <<<<<<<<<<<<<< * raise gaierror(result, strerror(result)) * result = cares.ares_init_options(&channel, &options, optmask) */ __pyx_t_1 = (__pyx_v_result != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":280 * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? * if result: * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<< * result = cares.ares_init_options(&channel, &options, optmask) * if result: */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_10 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":279 * optmask |= cares.ARES_OPT_TCP_PORT * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? * if result: # <<<<<<<<<<<<<< * raise gaierror(result, strerror(result)) * result = cares.ares_init_options(&channel, &options, optmask) */ } /* "gevent/ares.pyx":281 * if result: * raise gaierror(result, strerror(result)) * result = cares.ares_init_options(&channel, &options, optmask) # <<<<<<<<<<<<<< * if result: * raise gaierror(result, strerror(result)) */ __pyx_v_result = ares_init_options((&__pyx_v_channel), (&__pyx_v_options), __pyx_v_optmask); /* "gevent/ares.pyx":282 * raise gaierror(result, strerror(result)) * result = cares.ares_init_options(&channel, &options, optmask) * if result: # <<<<<<<<<<<<<< * raise gaierror(result, strerror(result)) * self._timer = loop.timer(TIMEOUT, TIMEOUT) */ __pyx_t_1 = (__pyx_v_result != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":283 * result = cares.ares_init_options(&channel, &options, optmask) * if result: * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<< * self._timer = loop.timer(TIMEOUT, TIMEOUT) * self._watchers = {} */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_11 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_8); __pyx_t_12 = 0; __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":282 * raise gaierror(result, strerror(result)) * result = cares.ares_init_options(&channel, &options, optmask) * if result: # <<<<<<<<<<<<<< * raise gaierror(result, strerror(result)) * self._timer = loop.timer(TIMEOUT, TIMEOUT) */ } /* "gevent/ares.pyx":284 * if result: * raise gaierror(result, strerror(result)) * self._timer = loop.timer(TIMEOUT, TIMEOUT) # <<<<<<<<<<<<<< * self._watchers = {} * self.channel = channel */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_timer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = NULL; __pyx_t_11 = 0; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_8); __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_timer); __Pyx_DECREF(__pyx_v_self->_timer); __pyx_v_self->_timer = __pyx_t_3; __pyx_t_3 = 0; /* "gevent/ares.pyx":285 * raise gaierror(result, strerror(result)) * self._timer = loop.timer(TIMEOUT, TIMEOUT) * self._watchers = {} # <<<<<<<<<<<<<< * self.channel = channel * try: */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_watchers); __Pyx_DECREF(__pyx_v_self->_watchers); __pyx_v_self->_watchers = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":286 * self._timer = loop.timer(TIMEOUT, TIMEOUT) * self._watchers = {} * self.channel = channel # <<<<<<<<<<<<<< * try: * if servers is not None: */ __pyx_v_self->channel = __pyx_v_channel; /* "gevent/ares.pyx":287 * self._watchers = {} * self.channel = channel * try: # <<<<<<<<<<<<<< * if servers is not None: * self.set_servers(servers) */ { __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); /*try:*/ { /* "gevent/ares.pyx":288 * self.channel = channel * try: * if servers is not None: # <<<<<<<<<<<<<< * self.set_servers(servers) * self.loop = loop */ __pyx_t_1 = (__pyx_v_servers != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/ares.pyx":289 * try: * if servers is not None: * self.set_servers(servers) # <<<<<<<<<<<<<< * self.loop = loop * except: */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_servers); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L11_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_10) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_servers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L11_error;} __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L11_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL; __Pyx_INCREF(__pyx_v_servers); __Pyx_GIVEREF(__pyx_v_servers); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_servers); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L11_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":288 * self.channel = channel * try: * if servers is not None: # <<<<<<<<<<<<<< * self.set_servers(servers) * self.loop = loop */ } /* "gevent/ares.pyx":290 * if servers is not None: * self.set_servers(servers) * self.loop = loop # <<<<<<<<<<<<<< * except: * self.destroy() */ __Pyx_INCREF(__pyx_v_loop); __Pyx_GIVEREF(__pyx_v_loop); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(__pyx_v_self->loop); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/ares.pyx":287 * self._watchers = {} * self.channel = channel * try: # <<<<<<<<<<<<<< * if servers is not None: * self.set_servers(servers) */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L18_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":291 * self.set_servers(servers) * self.loop = loop * except: # <<<<<<<<<<<<<< * self.destroy() * raise */ /*except:*/ { __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_7, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_8); /* "gevent/ares.pyx":292 * self.loop = loop * except: * self.destroy() # <<<<<<<<<<<<<< * raise * */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (__pyx_t_12) { __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;} } __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "gevent/ares.pyx":293 * except: * self.destroy() * raise # <<<<<<<<<<<<<< * * def __repr__(self): */ __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ErrRestore(__pyx_t_3, __pyx_t_7, __pyx_t_8); __pyx_t_3 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;} } __pyx_L13_except_error:; /* "gevent/ares.pyx":287 * self._watchers = {} * self.channel = channel * try: # <<<<<<<<<<<<<< * if servers is not None: * self.set_servers(servers) */ __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L18_try_end:; } /* "gevent/ares.pyx":252 * cdef public object _timer * * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< * udp_port=None, tcp_port=None, servers=None): * cdef ares_channeldata* channel = NULL */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":295 * raise * * def __repr__(self): # <<<<<<<<<<<<<< * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_2__repr__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_v_args = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/ares.pyx":296 * * def __repr__(self): * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) # <<<<<<<<<<<<<< * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_v_self->_watchers; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = PyDict_Size(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); __Pyx_INCREF(__pyx_v_self->_timer); __Pyx_GIVEREF(__pyx_v_self->_timer); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->_timer); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_v_args = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; /* "gevent/ares.pyx":297 * def __repr__(self): * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args # <<<<<<<<<<<<<< * * def destroy(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_v_args); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "gevent/ares.pyx":295 * raise * * def __repr__(self): # <<<<<<<<<<<<<< * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.ares.channel.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":299 * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args * * def destroy(self): # <<<<<<<<<<<<<< * if self.channel: * # XXX ares_library_cleanup? */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("destroy (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_4destroy(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("destroy", 0); /* "gevent/ares.pyx":300 * * def destroy(self): * if self.channel: # <<<<<<<<<<<<<< * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) */ __pyx_t_1 = (__pyx_v_self->channel != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":302 * if self.channel: * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<< * self.channel = NULL * self._watchers.clear() */ ares_destroy(__pyx_v_self->channel); /* "gevent/ares.pyx":303 * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) * self.channel = NULL # <<<<<<<<<<<<<< * self._watchers.clear() * self._timer.stop() */ __pyx_v_self->channel = NULL; /* "gevent/ares.pyx":304 * cares.ares_destroy(self.channel) * self.channel = NULL * self._watchers.clear() # <<<<<<<<<<<<<< * self._timer.stop() * self.loop = None */ if (unlikely(__pyx_v_self->_watchers == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "clear"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = __Pyx_PyDict_Clear(__pyx_v_self->_watchers); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":305 * self.channel = NULL * self._watchers.clear() * self._timer.stop() # <<<<<<<<<<<<<< * self.loop = None * */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":306 * self._watchers.clear() * self._timer.stop() * self.loop = None # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(__pyx_v_self->loop); __pyx_v_self->loop = Py_None; /* "gevent/ares.pyx":300 * * def destroy(self): * if self.channel: # <<<<<<<<<<<<<< * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) */ } /* "gevent/ares.pyx":299 * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args * * def destroy(self): # <<<<<<<<<<<<<< * if self.channel: * # XXX ares_library_cleanup? */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.ares.channel.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":308 * self.loop = None * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self.channel: * # XXX ares_library_cleanup? */ /* Python wrapper */ static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6gevent_4ares_7channel_6__dealloc__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "gevent/ares.pyx":309 * * def __dealloc__(self): * if self.channel: # <<<<<<<<<<<<<< * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) */ __pyx_t_1 = (__pyx_v_self->channel != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":311 * if self.channel: * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<< * self.channel = NULL * */ ares_destroy(__pyx_v_self->channel); /* "gevent/ares.pyx":312 * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) * self.channel = NULL # <<<<<<<<<<<<<< * * def set_servers(self, servers=None): */ __pyx_v_self->channel = NULL; /* "gevent/ares.pyx":309 * * def __dealloc__(self): * if self.channel: # <<<<<<<<<<<<<< * # XXX ares_library_cleanup? * cares.ares_destroy(self.channel) */ } /* "gevent/ares.pyx":308 * self.loop = None * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self.channel: * # XXX ares_library_cleanup? */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "gevent/ares.pyx":314 * self.channel = NULL * * def set_servers(self, servers=None): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_servers = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_servers (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_servers,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_servers") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_servers = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("set_servers", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_7channel_8set_servers(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_servers); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers) { int __pyx_v_length; CYTHON_UNUSED int __pyx_v_result; int __pyx_v_index; char *__pyx_v_string; struct ares_addr_node *__pyx_v_c_servers; PyObject *__pyx_v_server = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *(*__pyx_t_9)(PyObject *); char *__pyx_t_10; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_servers", 0); __Pyx_INCREF(__pyx_v_servers); /* "gevent/ares.pyx":315 * * def set_servers(self, servers=None): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * if not servers: */ __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":316 * def set_servers(self, servers=None): * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< * if not servers: * servers = [] */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":315 * * def set_servers(self, servers=None): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * if not servers: */ } /* "gevent/ares.pyx":317 * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * if not servers: # <<<<<<<<<<<<<< * servers = [] * if isinstance(servers, string_types): */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_servers); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = ((!__pyx_t_1) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":318 * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * if not servers: * servers = [] # <<<<<<<<<<<<<< * if isinstance(servers, string_types): * servers = servers.split(',') */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":317 * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * if not servers: # <<<<<<<<<<<<<< * servers = [] * if isinstance(servers, string_types): */ } /* "gevent/ares.pyx":319 * if not servers: * servers = [] * if isinstance(servers, string_types): # <<<<<<<<<<<<<< * servers = servers.split(',') * cdef int length = len(servers) */ __pyx_t_2 = __pyx_v_6gevent_4ares_string_types; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = PyObject_IsInstance(__pyx_v_servers, __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = (__pyx_t_8 != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":320 * servers = [] * if isinstance(servers, string_types): * servers = servers.split(',') # <<<<<<<<<<<<<< * cdef int length = len(servers) * cdef int result, index */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_servers, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":319 * if not servers: * servers = [] * if isinstance(servers, string_types): # <<<<<<<<<<<<<< * servers = servers.split(',') * cdef int length = len(servers) */ } /* "gevent/ares.pyx":321 * if isinstance(servers, string_types): * servers = servers.split(',') * cdef int length = len(servers) # <<<<<<<<<<<<<< * cdef int result, index * cdef char* string */ __pyx_t_6 = PyObject_Length(__pyx_v_servers); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_length = __pyx_t_6; /* "gevent/ares.pyx":325 * cdef char* string * cdef cares.ares_addr_node* c_servers * if length <= 0: # <<<<<<<<<<<<<< * result = cares.ares_set_servers(self.channel, NULL) * else: */ __pyx_t_1 = ((__pyx_v_length <= 0) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":326 * cdef cares.ares_addr_node* c_servers * if length <= 0: * result = cares.ares_set_servers(self.channel, NULL) # <<<<<<<<<<<<<< * else: * c_servers = malloc(sizeof(cares.ares_addr_node) * length) */ __pyx_v_result = ares_set_servers(__pyx_v_self->channel, NULL); /* "gevent/ares.pyx":325 * cdef char* string * cdef cares.ares_addr_node* c_servers * if length <= 0: # <<<<<<<<<<<<<< * result = cares.ares_set_servers(self.channel, NULL) * else: */ goto __pyx_L6; } /* "gevent/ares.pyx":328 * result = cares.ares_set_servers(self.channel, NULL) * else: * c_servers = malloc(sizeof(cares.ares_addr_node) * length) # <<<<<<<<<<<<<< * if not c_servers: * raise MemoryError */ /*else*/ { __pyx_v_c_servers = ((struct ares_addr_node *)malloc(((sizeof(struct ares_addr_node)) * __pyx_v_length))); /* "gevent/ares.pyx":329 * else: * c_servers = malloc(sizeof(cares.ares_addr_node) * length) * if not c_servers: # <<<<<<<<<<<<<< * raise MemoryError * try: */ __pyx_t_1 = ((!(__pyx_v_c_servers != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":330 * c_servers = malloc(sizeof(cares.ares_addr_node) * length) * if not c_servers: * raise MemoryError # <<<<<<<<<<<<<< * try: * index = 0 */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":329 * else: * c_servers = malloc(sizeof(cares.ares_addr_node) * length) * if not c_servers: # <<<<<<<<<<<<<< * raise MemoryError * try: */ } /* "gevent/ares.pyx":331 * if not c_servers: * raise MemoryError * try: # <<<<<<<<<<<<<< * index = 0 * for server in servers: */ /*try:*/ { /* "gevent/ares.pyx":332 * raise MemoryError * try: * index = 0 # <<<<<<<<<<<<<< * for server in servers: * if isinstance(server, unicode): */ __pyx_v_index = 0; /* "gevent/ares.pyx":333 * try: * index = 0 * for server in servers: # <<<<<<<<<<<<<< * if isinstance(server, unicode): * server = server.encode('ascii') */ if (likely(PyList_CheckExact(__pyx_v_servers)) || PyTuple_CheckExact(__pyx_v_servers)) { __pyx_t_3 = __pyx_v_servers; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_9 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_servers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_server, __pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":334 * index = 0 * for server in servers: * if isinstance(server, unicode): # <<<<<<<<<<<<<< * server = server.encode('ascii') * string = server */ __pyx_t_1 = PyUnicode_Check(__pyx_v_server); __pyx_t_8 = (__pyx_t_1 != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":335 * for server in servers: * if isinstance(server, unicode): * server = server.encode('ascii') # <<<<<<<<<<<<<< * string = server * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_server, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_server, __pyx_t_7); __pyx_t_7 = 0; /* "gevent/ares.pyx":334 * index = 0 * for server in servers: * if isinstance(server, unicode): # <<<<<<<<<<<<<< * server = server.encode('ascii') * string = server */ } /* "gevent/ares.pyx":336 * if isinstance(server, unicode): * server = server.encode('ascii') * string = server # <<<<<<<<<<<<<< * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET */ __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_server); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __pyx_v_string = ((char *)__pyx_t_10); /* "gevent/ares.pyx":337 * server = server.encode('ascii') * string = server * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< * c_servers[index].family = AF_INET * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: */ __pyx_t_8 = ((ares_inet_pton(AF_INET, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":338 * string = server * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET # <<<<<<<<<<<<<< * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET6 */ (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET; /* "gevent/ares.pyx":337 * server = server.encode('ascii') * string = server * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< * c_servers[index].family = AF_INET * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: */ goto __pyx_L14; } /* "gevent/ares.pyx":339 * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< * c_servers[index].family = AF_INET6 * else: */ __pyx_t_8 = ((ares_inet_pton(AF_INET6, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":340 * c_servers[index].family = AF_INET * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET6 # <<<<<<<<<<<<<< * else: * raise InvalidIP(repr(string)) */ (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET6; /* "gevent/ares.pyx":339 * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: * c_servers[index].family = AF_INET * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< * c_servers[index].family = AF_INET6 * else: */ goto __pyx_L14; } /* "gevent/ares.pyx":342 * c_servers[index].family = AF_INET6 * else: * raise InvalidIP(repr(string)) # <<<<<<<<<<<<<< * c_servers[index].next = &c_servers[index] + 1 * index += 1 */ /*else*/ { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_string); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_Repr(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_7); } else { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L9_error;} } __pyx_L14:; /* "gevent/ares.pyx":343 * else: * raise InvalidIP(repr(string)) * c_servers[index].next = &c_servers[index] + 1 # <<<<<<<<<<<<<< * index += 1 * if index >= length: */ (__pyx_v_c_servers[__pyx_v_index]).next = ((&(__pyx_v_c_servers[__pyx_v_index])) + 1); /* "gevent/ares.pyx":344 * raise InvalidIP(repr(string)) * c_servers[index].next = &c_servers[index] + 1 * index += 1 # <<<<<<<<<<<<<< * if index >= length: * break */ __pyx_v_index = (__pyx_v_index + 1); /* "gevent/ares.pyx":345 * c_servers[index].next = &c_servers[index] + 1 * index += 1 * if index >= length: # <<<<<<<<<<<<<< * break * c_servers[length - 1].next = NULL */ __pyx_t_8 = ((__pyx_v_index >= __pyx_v_length) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":346 * index += 1 * if index >= length: * break # <<<<<<<<<<<<<< * c_servers[length - 1].next = NULL * index = cares.ares_set_servers(self.channel, c_servers) */ goto __pyx_L12_break; /* "gevent/ares.pyx":345 * c_servers[index].next = &c_servers[index] + 1 * index += 1 * if index >= length: # <<<<<<<<<<<<<< * break * c_servers[length - 1].next = NULL */ } /* "gevent/ares.pyx":333 * try: * index = 0 * for server in servers: # <<<<<<<<<<<<<< * if isinstance(server, unicode): * server = server.encode('ascii') */ } __pyx_L12_break:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":347 * if index >= length: * break * c_servers[length - 1].next = NULL # <<<<<<<<<<<<<< * index = cares.ares_set_servers(self.channel, c_servers) * if index: */ (__pyx_v_c_servers[(__pyx_v_length - 1)]).next = NULL; /* "gevent/ares.pyx":348 * break * c_servers[length - 1].next = NULL * index = cares.ares_set_servers(self.channel, c_servers) # <<<<<<<<<<<<<< * if index: * raise ValueError(strerror(index)) */ __pyx_v_index = ares_set_servers(__pyx_v_self->channel, __pyx_v_c_servers); /* "gevent/ares.pyx":349 * c_servers[length - 1].next = NULL * index = cares.ares_set_servers(self.channel, c_servers) * if index: # <<<<<<<<<<<<<< * raise ValueError(strerror(index)) * finally: */ __pyx_t_8 = (__pyx_v_index != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":350 * index = cares.ares_set_servers(self.channel, c_servers) * if index: * raise ValueError(strerror(index)) # <<<<<<<<<<<<<< * finally: * free(c_servers) */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __pyx_f_6gevent_4ares_strerror(__pyx_t_3, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L9_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L9_error;} /* "gevent/ares.pyx":349 * c_servers[length - 1].next = NULL * index = cares.ares_set_servers(self.channel, c_servers) * if index: # <<<<<<<<<<<<<< * raise ValueError(strerror(index)) * finally: */ } } /* "gevent/ares.pyx":352 * raise ValueError(strerror(index)) * finally: * free(c_servers) # <<<<<<<<<<<<<< * * # this crashes c-ares */ /*finally:*/ { /*normal exit:*/{ free(__pyx_v_c_servers); goto __pyx_L10; } /*exception exit:*/{ __pyx_L9_error:; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_12 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { free(__pyx_v_c_servers); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L10:; } } __pyx_L6:; /* "gevent/ares.pyx":314 * self.channel = NULL * * def set_servers(self, servers=None): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_server); __Pyx_XDECREF(__pyx_v_servers); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":358 * # cares.ares_cancel(self.channel) * * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<< * if not self.channel: * return */ static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write) { PyObject *__pyx_v_watcher = 0; int __pyx_v_events; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; Py_ssize_t __pyx_t_8; PyObject *__pyx_t_9 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_sock_state_callback", 0); /* "gevent/ares.pyx":359 * * cdef _sock_state_callback(self, int socket, int read, int write): * if not self.channel: # <<<<<<<<<<<<<< * return * cdef object watcher = self._watchers.get(socket) */ __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":360 * cdef _sock_state_callback(self, int socket, int read, int write): * if not self.channel: * return # <<<<<<<<<<<<<< * cdef object watcher = self._watchers.get(socket) * cdef int events = 0 */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/ares.pyx":359 * * cdef _sock_state_callback(self, int socket, int read, int write): * if not self.channel: # <<<<<<<<<<<<<< * return * cdef object watcher = self._watchers.get(socket) */ } /* "gevent/ares.pyx":361 * if not self.channel: * return * cdef object watcher = self._watchers.get(socket) # <<<<<<<<<<<<<< * cdef int events = 0 * if read: */ if (unlikely(__pyx_v_self->_watchers == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->_watchers, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_watcher = __pyx_t_3; __pyx_t_3 = 0; /* "gevent/ares.pyx":362 * return * cdef object watcher = self._watchers.get(socket) * cdef int events = 0 # <<<<<<<<<<<<<< * if read: * events |= EV_READ */ __pyx_v_events = 0; /* "gevent/ares.pyx":363 * cdef object watcher = self._watchers.get(socket) * cdef int events = 0 * if read: # <<<<<<<<<<<<<< * events |= EV_READ * if write: */ __pyx_t_1 = (__pyx_v_read != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":364 * cdef int events = 0 * if read: * events |= EV_READ # <<<<<<<<<<<<<< * if write: * events |= EV_WRITE */ __pyx_v_events = (__pyx_v_events | 1); /* "gevent/ares.pyx":363 * cdef object watcher = self._watchers.get(socket) * cdef int events = 0 * if read: # <<<<<<<<<<<<<< * events |= EV_READ * if write: */ } /* "gevent/ares.pyx":365 * if read: * events |= EV_READ * if write: # <<<<<<<<<<<<<< * events |= EV_WRITE * if watcher is None: */ __pyx_t_1 = (__pyx_v_write != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":366 * events |= EV_READ * if write: * events |= EV_WRITE # <<<<<<<<<<<<<< * if watcher is None: * if not events: */ __pyx_v_events = (__pyx_v_events | 2); /* "gevent/ares.pyx":365 * if read: * events |= EV_READ * if write: # <<<<<<<<<<<<<< * events |= EV_WRITE * if watcher is None: */ } /* "gevent/ares.pyx":367 * if write: * events |= EV_WRITE * if watcher is None: # <<<<<<<<<<<<<< * if not events: * return */ __pyx_t_1 = (__pyx_v_watcher == Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* "gevent/ares.pyx":368 * events |= EV_WRITE * if watcher is None: * if not events: # <<<<<<<<<<<<<< * return * watcher = self.loop.io(socket, events) */ __pyx_t_4 = ((!(__pyx_v_events != 0)) != 0); if (__pyx_t_4) { /* "gevent/ares.pyx":369 * if watcher is None: * if not events: * return # <<<<<<<<<<<<<< * watcher = self.loop.io(socket, events) * self._watchers[socket] = watcher */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/ares.pyx":368 * events |= EV_WRITE * if watcher is None: * if not events: # <<<<<<<<<<<<<< * return * watcher = self.loop.io(socket, events) */ } /* "gevent/ares.pyx":370 * if not events: * return * watcher = self.loop.io(socket, events) # <<<<<<<<<<<<<< * self._watchers[socket] = watcher * elif events: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_8 = 1; } } __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_watcher, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":371 * return * watcher = self.loop.io(socket, events) * self._watchers[socket] = watcher # <<<<<<<<<<<<<< * elif events: * if watcher.events == events: */ if (unlikely(__pyx_v_self->_watchers == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (unlikely(PyDict_SetItem(__pyx_v_self->_watchers, __pyx_t_3, __pyx_v_watcher) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":367 * if write: * events |= EV_WRITE * if watcher is None: # <<<<<<<<<<<<<< * if not events: * return */ goto __pyx_L6; } /* "gevent/ares.pyx":372 * watcher = self.loop.io(socket, events) * self._watchers[socket] = watcher * elif events: # <<<<<<<<<<<<<< * if watcher.events == events: * return */ __pyx_t_4 = (__pyx_v_events != 0); if (__pyx_t_4) { /* "gevent/ares.pyx":373 * self._watchers[socket] = watcher * elif events: * if watcher.events == events: # <<<<<<<<<<<<<< * return * watcher.stop() */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_4) { /* "gevent/ares.pyx":374 * elif events: * if watcher.events == events: * return # <<<<<<<<<<<<<< * watcher.stop() * watcher.events = events */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/ares.pyx":373 * self._watchers[socket] = watcher * elif events: * if watcher.events == events: # <<<<<<<<<<<<<< * return * watcher.stop() */ } /* "gevent/ares.pyx":375 * if watcher.events == events: * return * watcher.stop() # <<<<<<<<<<<<<< * watcher.events = events * else: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "gevent/ares.pyx":376 * return * watcher.stop() * watcher.events = events # <<<<<<<<<<<<<< * else: * watcher.stop() */ __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); if (__Pyx_PyObject_SetAttrStr(__pyx_v_watcher, __pyx_n_s_events, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "gevent/ares.pyx":372 * watcher = self.loop.io(socket, events) * self._watchers[socket] = watcher * elif events: # <<<<<<<<<<<<<< * if watcher.events == events: * return */ goto __pyx_L6; } /* "gevent/ares.pyx":378 * watcher.events = events * else: * watcher.stop() # <<<<<<<<<<<<<< * self._watchers.pop(socket, None) * if not self._watchers: */ /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "gevent/ares.pyx":379 * else: * watcher.stop() * self._watchers.pop(socket, None) # <<<<<<<<<<<<<< * if not self._watchers: * self._timer.stop() */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_watchers, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_8 = 0; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_8 = 1; } } __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_t_3); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, Py_None); __pyx_t_3 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "gevent/ares.pyx":380 * watcher.stop() * self._watchers.pop(socket, None) * if not self._watchers: # <<<<<<<<<<<<<< * self._timer.stop() * return */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_watchers); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = ((!__pyx_t_4) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":381 * self._watchers.pop(socket, None) * if not self._watchers: * self._timer.stop() # <<<<<<<<<<<<<< * return * watcher.start(self._process_fd, watcher, pass_events=True) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "gevent/ares.pyx":380 * watcher.stop() * self._watchers.pop(socket, None) * if not self._watchers: # <<<<<<<<<<<<<< * self._timer.stop() * return */ } /* "gevent/ares.pyx":382 * if not self._watchers: * self._timer.stop() * return # <<<<<<<<<<<<<< * watcher.start(self._process_fd, watcher, pass_events=True) * self._timer.again(self._on_timer) */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; } __pyx_L6:; /* "gevent/ares.pyx":383 * self._timer.stop() * return * watcher.start(self._process_fd, watcher, pass_events=True) # <<<<<<<<<<<<<< * self._timer.again(self._on_timer) * */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_process_fd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_INCREF(__pyx_v_watcher); __Pyx_GIVEREF(__pyx_v_watcher); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_watcher); __pyx_t_2 = 0; __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pass_events, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":384 * return * watcher.start(self._process_fd, watcher, pass_events=True) * self._timer.again(self._on_timer) # <<<<<<<<<<<<<< * * def _on_timer(self): */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_again); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timer); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_9) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/ares.pyx":358 * # cares.ares_cancel(self.channel) * * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<< * if not self.channel: * return */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gevent.ares.channel._sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_watcher); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":386 * self._timer.again(self._on_timer) * * def _on_timer(self): # <<<<<<<<<<<<<< * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_on_timer (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_10_on_timer(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_on_timer", 0); /* "gevent/ares.pyx":387 * * def _on_timer(self): * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) # <<<<<<<<<<<<<< * * def _process_fd(self, int events, object watcher): */ ares_process_fd(__pyx_v_self->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); /* "gevent/ares.pyx":386 * self._timer.again(self._on_timer) * * def _on_timer(self): # <<<<<<<<<<<<<< * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":389 * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) * * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<< * if not self.channel: * return */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_events; PyObject *__pyx_v_watcher = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_process_fd (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_events,&__pyx_n_s_watcher,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_process_fd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_events = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_watcher = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_7channel_12_process_fd(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_events, __pyx_v_watcher); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher) { int __pyx_v_read_fd; int __pyx_v_write_fd; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_process_fd", 0); /* "gevent/ares.pyx":390 * * def _process_fd(self, int events, object watcher): * if not self.channel: # <<<<<<<<<<<<<< * return * cdef int read_fd = watcher.fd */ __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":391 * def _process_fd(self, int events, object watcher): * if not self.channel: * return # <<<<<<<<<<<<<< * cdef int read_fd = watcher.fd * cdef int write_fd = read_fd */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/ares.pyx":390 * * def _process_fd(self, int events, object watcher): * if not self.channel: # <<<<<<<<<<<<<< * return * cdef int read_fd = watcher.fd */ } /* "gevent/ares.pyx":392 * if not self.channel: * return * cdef int read_fd = watcher.fd # <<<<<<<<<<<<<< * cdef int write_fd = read_fd * if not (events & EV_READ): */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_fd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_read_fd = __pyx_t_3; /* "gevent/ares.pyx":393 * return * cdef int read_fd = watcher.fd * cdef int write_fd = read_fd # <<<<<<<<<<<<<< * if not (events & EV_READ): * read_fd = cares.ARES_SOCKET_BAD */ __pyx_v_write_fd = __pyx_v_read_fd; /* "gevent/ares.pyx":394 * cdef int read_fd = watcher.fd * cdef int write_fd = read_fd * if not (events & EV_READ): # <<<<<<<<<<<<<< * read_fd = cares.ARES_SOCKET_BAD * if not (events & EV_WRITE): */ __pyx_t_1 = ((!((__pyx_v_events & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":395 * cdef int write_fd = read_fd * if not (events & EV_READ): * read_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<< * if not (events & EV_WRITE): * write_fd = cares.ARES_SOCKET_BAD */ __pyx_v_read_fd = ARES_SOCKET_BAD; /* "gevent/ares.pyx":394 * cdef int read_fd = watcher.fd * cdef int write_fd = read_fd * if not (events & EV_READ): # <<<<<<<<<<<<<< * read_fd = cares.ARES_SOCKET_BAD * if not (events & EV_WRITE): */ } /* "gevent/ares.pyx":396 * if not (events & EV_READ): * read_fd = cares.ARES_SOCKET_BAD * if not (events & EV_WRITE): # <<<<<<<<<<<<<< * write_fd = cares.ARES_SOCKET_BAD * cares.ares_process_fd(self.channel, read_fd, write_fd) */ __pyx_t_1 = ((!((__pyx_v_events & 2) != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":397 * read_fd = cares.ARES_SOCKET_BAD * if not (events & EV_WRITE): * write_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<< * cares.ares_process_fd(self.channel, read_fd, write_fd) * */ __pyx_v_write_fd = ARES_SOCKET_BAD; /* "gevent/ares.pyx":396 * if not (events & EV_READ): * read_fd = cares.ARES_SOCKET_BAD * if not (events & EV_WRITE): # <<<<<<<<<<<<<< * write_fd = cares.ARES_SOCKET_BAD * cares.ares_process_fd(self.channel, read_fd, write_fd) */ } /* "gevent/ares.pyx":398 * if not (events & EV_WRITE): * write_fd = cares.ARES_SOCKET_BAD * cares.ares_process_fd(self.channel, read_fd, write_fd) # <<<<<<<<<<<<<< * * def gethostbyname(self, object callback, char* name, int family=AF_INET): */ ares_process_fd(__pyx_v_self->channel, __pyx_v_read_fd, __pyx_v_write_fd); /* "gevent/ares.pyx":389 * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) * * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<< * if not self.channel: * return */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":400 * cares.ares_process_fd(self.channel, read_fd, write_fd) * * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; char *__pyx_v_name; int __pyx_v_family; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("gethostbyname (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_name_2,&__pyx_n_s_family,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyname") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_callback = values[0]; __pyx_v_name = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} if (values[2]) { __pyx_v_family = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_family == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_family = __pyx_k__5; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_7channel_14gethostbyname(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_name, __pyx_v_family); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family) { PyObject *__pyx_v_arg = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gethostbyname", 0); /* "gevent/ares.pyx":401 * * def gethostbyname(self, object callback, char* name, int family=AF_INET): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * # note that for file lookups still AF_INET can be returned for AF_INET6 request */ __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":402 * def gethostbyname(self, object callback, char* name, int family=AF_INET): * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< * # note that for file lookups still AF_INET can be returned for AF_INET6 request * cdef object arg = (self, callback) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":401 * * def gethostbyname(self, object callback, char* name, int family=AF_INET): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * # note that for file lookups still AF_INET can be returned for AF_INET6 request */ } /* "gevent/ares.pyx":404 * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * # note that for file lookups still AF_INET can be returned for AF_INET6 request * cdef object arg = (self, callback) # <<<<<<<<<<<<<< * Py_INCREF(arg) * cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); __pyx_v_arg = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/ares.pyx":405 * # note that for file lookups still AF_INET can be returned for AF_INET6 request * cdef object arg = (self, callback) * Py_INCREF(arg) # <<<<<<<<<<<<<< * cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) * */ Py_INCREF(((PyObject*)__pyx_v_arg)); /* "gevent/ares.pyx":406 * cdef object arg = (self, callback) * Py_INCREF(arg) * cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) # <<<<<<<<<<<<<< * * def gethostbyaddr(self, object callback, char* addr): */ ares_gethostbyname(__pyx_v_self->channel, __pyx_v_name, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg)); /* "gevent/ares.pyx":400 * cares.ares_process_fd(self.channel, read_fd, write_fd) * * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":408 * cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) * * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; char *__pyx_v_addr; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("gethostbyaddr (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_addr,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyaddr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_callback = values[0]; __pyx_v_addr = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_addr) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_addr); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr) { char __pyx_v_addr_packed[16]; int __pyx_v_family; int __pyx_v_length; PyObject *__pyx_v_arg = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gethostbyaddr", 0); /* "gevent/ares.pyx":409 * * def gethostbyaddr(self, object callback, char* addr): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * # will guess the family */ __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":410 * def gethostbyaddr(self, object callback, char* addr): * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< * # will guess the family * cdef char addr_packed[16] */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":409 * * def gethostbyaddr(self, object callback, char* addr): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * # will guess the family */ } /* "gevent/ares.pyx":415 * cdef int family * cdef int length * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<< * family = AF_INET * length = 4 */ __pyx_t_1 = ((ares_inet_pton(AF_INET, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":416 * cdef int length * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: * family = AF_INET # <<<<<<<<<<<<<< * length = 4 * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: */ __pyx_v_family = AF_INET; /* "gevent/ares.pyx":417 * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: * family = AF_INET * length = 4 # <<<<<<<<<<<<<< * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: * family = AF_INET6 */ __pyx_v_length = 4; /* "gevent/ares.pyx":415 * cdef int family * cdef int length * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<< * family = AF_INET * length = 4 */ goto __pyx_L4; } /* "gevent/ares.pyx":418 * family = AF_INET * length = 4 * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<< * family = AF_INET6 * length = 16 */ __pyx_t_1 = ((ares_inet_pton(AF_INET6, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0); if (__pyx_t_1) { /* "gevent/ares.pyx":419 * length = 4 * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: * family = AF_INET6 # <<<<<<<<<<<<<< * length = 16 * else: */ __pyx_v_family = AF_INET6; /* "gevent/ares.pyx":420 * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: * family = AF_INET6 * length = 16 # <<<<<<<<<<<<<< * else: * raise InvalidIP(repr(addr)) */ __pyx_v_length = 16; /* "gevent/ares.pyx":418 * family = AF_INET * length = 4 * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<< * family = AF_INET6 * length = 16 */ goto __pyx_L4; } /* "gevent/ares.pyx":422 * length = 16 * else: * raise InvalidIP(repr(addr)) # <<<<<<<<<<<<<< * cdef object arg = (self, callback) * Py_INCREF(arg) */ /*else*/ { __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_addr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_7) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L4:; /* "gevent/ares.pyx":423 * else: * raise InvalidIP(repr(addr)) * cdef object arg = (self, callback) # <<<<<<<<<<<<<< * Py_INCREF(arg) * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); __pyx_v_arg = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/ares.pyx":424 * raise InvalidIP(repr(addr)) * cdef object arg = (self, callback) * Py_INCREF(arg) # <<<<<<<<<<<<<< * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) * */ Py_INCREF(((PyObject*)__pyx_v_arg)); /* "gevent/ares.pyx":425 * cdef object arg = (self, callback) * Py_INCREF(arg) * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) # <<<<<<<<<<<<<< * * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): */ ares_gethostbyaddr(__pyx_v_self->channel, __pyx_v_addr_packed, __pyx_v_length, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg)); /* "gevent/ares.pyx":408 * cares.ares_gethostbyname(self.channel, name, family, gevent_ares_host_callback, arg) * * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":427 * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) * * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch) { char *__pyx_v_hostp; int __pyx_v_port; int __pyx_v_flowinfo; int __pyx_v_scope_id; struct sockaddr_in6 __pyx_v_sa6; int __pyx_v_length; PyObject *__pyx_v_arg = 0; struct sockaddr *__pyx_v_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_getnameinfo", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getnameinfo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_callback); __Pyx_INCREF(__pyx_v_sockaddr); __Pyx_GIVEREF(__pyx_v_sockaddr); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_sockaddr); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/ares.pyx":428 * * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * cdef char* hostp = NULL */ __pyx_t_8 = ((!(__pyx_v_self->channel != 0)) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":429 * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< * cdef char* hostp = NULL * cdef int port = 0 */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":428 * * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): * if not self.channel: # <<<<<<<<<<<<<< * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * cdef char* hostp = NULL */ } /* "gevent/ares.pyx":430 * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * cdef char* hostp = NULL # <<<<<<<<<<<<<< * cdef int port = 0 * cdef int flowinfo = 0 */ __pyx_v_hostp = NULL; /* "gevent/ares.pyx":431 * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') * cdef char* hostp = NULL * cdef int port = 0 # <<<<<<<<<<<<<< * cdef int flowinfo = 0 * cdef int scope_id = 0 */ __pyx_v_port = 0; /* "gevent/ares.pyx":432 * cdef char* hostp = NULL * cdef int port = 0 * cdef int flowinfo = 0 # <<<<<<<<<<<<<< * cdef int scope_id = 0 * cdef sockaddr_in6 sa6 */ __pyx_v_flowinfo = 0; /* "gevent/ares.pyx":433 * cdef int port = 0 * cdef int flowinfo = 0 * cdef int scope_id = 0 # <<<<<<<<<<<<<< * cdef sockaddr_in6 sa6 * if not PyTuple_Check(sockaddr): */ __pyx_v_scope_id = 0; /* "gevent/ares.pyx":435 * cdef int scope_id = 0 * cdef sockaddr_in6 sa6 * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<< * raise TypeError('expected a tuple, got %r' % (sockaddr, )) * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) */ __pyx_t_8 = ((!(PyTuple_Check(__pyx_v_sockaddr) != 0)) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":436 * cdef sockaddr_in6 sa6 * if not PyTuple_Check(sockaddr): * raise TypeError('expected a tuple, got %r' % (sockaddr, )) # <<<<<<<<<<<<<< * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) * if port < 0 or port > 65535: */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_sockaddr); __Pyx_GIVEREF(__pyx_v_sockaddr); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sockaddr); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_expected_a_tuple_got_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":435 * cdef int scope_id = 0 * cdef sockaddr_in6 sa6 * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<< * raise TypeError('expected a tuple, got %r' % (sockaddr, )) * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) */ } /* "gevent/ares.pyx":437 * if not PyTuple_Check(sockaddr): * raise TypeError('expected a tuple, got %r' % (sockaddr, )) * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) # <<<<<<<<<<<<<< * if port < 0 or port > 65535: * raise gaierror(-8, 'Invalid value for port: %r' % port) */ __pyx_t_9 = PyArg_ParseTuple(__pyx_v_sockaddr, __pyx_k_si_ii, (&__pyx_v_hostp), (&__pyx_v_port), (&__pyx_v_flowinfo), (&__pyx_v_scope_id)); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":438 * raise TypeError('expected a tuple, got %r' % (sockaddr, )) * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) * if port < 0 or port > 65535: # <<<<<<<<<<<<<< * raise gaierror(-8, 'Invalid value for port: %r' % port) * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) */ __pyx_t_10 = ((__pyx_v_port < 0) != 0); if (!__pyx_t_10) { } else { __pyx_t_8 = __pyx_t_10; goto __pyx_L6_bool_binop_done; } __pyx_t_10 = ((__pyx_v_port > 0xFFFF) != 0); __pyx_t_8 = __pyx_t_10; __pyx_L6_bool_binop_done:; if (__pyx_t_8) { /* "gevent/ares.pyx":439 * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) * if port < 0 or port > 65535: * raise gaierror(-8, 'Invalid value for port: %r' % port) # <<<<<<<<<<<<<< * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) * if length <= 0: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_port_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_int_neg_8); __Pyx_GIVEREF(__pyx_int_neg_8); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_int_neg_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":438 * raise TypeError('expected a tuple, got %r' % (sockaddr, )) * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) * if port < 0 or port > 65535: # <<<<<<<<<<<<<< * raise gaierror(-8, 'Invalid value for port: %r' % port) * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) */ } /* "gevent/ares.pyx":440 * if port < 0 or port > 65535: * raise gaierror(-8, 'Invalid value for port: %r' % port) * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) # <<<<<<<<<<<<<< * if length <= 0: * raise InvalidIP(repr(hostp)) */ __pyx_v_length = gevent_make_sockaddr(__pyx_v_hostp, __pyx_v_port, __pyx_v_flowinfo, __pyx_v_scope_id, (&__pyx_v_sa6)); /* "gevent/ares.pyx":441 * raise gaierror(-8, 'Invalid value for port: %r' % port) * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) * if length <= 0: # <<<<<<<<<<<<<< * raise InvalidIP(repr(hostp)) * cdef object arg = (self, callback) */ __pyx_t_8 = ((__pyx_v_length <= 0) != 0); if (__pyx_t_8) { /* "gevent/ares.pyx":442 * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) * if length <= 0: * raise InvalidIP(repr(hostp)) # <<<<<<<<<<<<<< * cdef object arg = (self, callback) * Py_INCREF(arg) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_hostp); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_7) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":441 * raise gaierror(-8, 'Invalid value for port: %r' % port) * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) * if length <= 0: # <<<<<<<<<<<<<< * raise InvalidIP(repr(hostp)) * cdef object arg = (self, callback) */ } /* "gevent/ares.pyx":443 * if length <= 0: * raise InvalidIP(repr(hostp)) * cdef object arg = (self, callback) # <<<<<<<<<<<<<< * Py_INCREF(arg) * cdef sockaddr_t* x = &sa6 */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); __pyx_v_arg = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/ares.pyx":444 * raise InvalidIP(repr(hostp)) * cdef object arg = (self, callback) * Py_INCREF(arg) # <<<<<<<<<<<<<< * cdef sockaddr_t* x = &sa6 * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) */ Py_INCREF(((PyObject*)__pyx_v_arg)); /* "gevent/ares.pyx":445 * cdef object arg = (self, callback) * Py_INCREF(arg) * cdef sockaddr_t* x = &sa6 # <<<<<<<<<<<<<< * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) * */ __pyx_v_x = ((struct sockaddr *)(&__pyx_v_sa6)); /* "gevent/ares.pyx":446 * Py_INCREF(arg) * cdef sockaddr_t* x = &sa6 * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) # <<<<<<<<<<<<<< * * def getnameinfo(self, object callback, tuple sockaddr, int flags): */ ares_getnameinfo(__pyx_v_self->channel, __pyx_v_x, __pyx_v_length, __pyx_v_flags, ((void *)__pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback), ((void *)__pyx_v_arg)); /* "gevent/ares.pyx":427 * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, gevent_ares_host_callback, arg) * * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_sockaddr = 0; int __pyx_v_flags; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_getnameinfo (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getnameinfo") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_callback = values[0]; __pyx_v_sockaddr = ((PyObject*)values[1]); __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_4ares_7channel_18_getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_getnameinfo", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_4ares_7channel__getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":448 * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) * * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< * return self._getnameinfo(callback, sockaddr, _convert_cares_flags(flags)) */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_sockaddr = 0; int __pyx_v_flags; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("getnameinfo (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getnameinfo") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_callback = values[0]; __pyx_v_sockaddr = ((PyObject*)values[1]); __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_4ares_7channel_20getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("getnameinfo", 0); /* "gevent/ares.pyx":449 * * def getnameinfo(self, object callback, tuple sockaddr, int flags): * return self._getnameinfo(callback, sockaddr, _convert_cares_flags(flags)) # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_self->__pyx_vtab)->_getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/ares.pyx":448 * cares.ares_getnameinfo(self.channel, x, length, flags, gevent_ares_nameinfo_callback, arg) * * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< * return self._getnameinfo(callback, sockaddr, _convert_cares_flags(flags)) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":247 * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: * * cdef public object loop # <<<<<<<<<<<<<< * cdef ares_channeldata* channel * cdef public dict _watchers */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->loop); __pyx_r = __pyx_v_self->loop; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(__pyx_v_self->loop); __pyx_v_self->loop = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(__pyx_v_self->loop); __pyx_v_self->loop = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":249 * cdef public object loop * cdef ares_channeldata* channel * cdef public dict _watchers # <<<<<<<<<<<<<< * cdef public object _timer * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_watchers); __pyx_r = __pyx_v_self->_watchers; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->_watchers); __Pyx_DECREF(__pyx_v_self->_watchers); __pyx_v_self->_watchers = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.ares.channel._watchers.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_watchers); __Pyx_DECREF(__pyx_v_self->_watchers); __pyx_v_self->_watchers = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/ares.pyx":250 * cdef ares_channeldata* channel * cdef public dict _watchers * cdef public object _timer # <<<<<<<<<<<<<< * * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_timer); __pyx_r = __pyx_v_self->_timer; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->_timer); __Pyx_DECREF(__pyx_v_self->_timer); __pyx_v_self->_timer = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_timer); __Pyx_DECREF(__pyx_v_self->_timer); __pyx_v_self->_timer = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_6gevent_4ares_result *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_6gevent_4ares_result *)o); p->value = Py_None; Py_INCREF(Py_None); p->exception = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_4ares_result(PyObject *o) { struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->value); Py_CLEAR(p->exception); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_6gevent_4ares_result(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; if (p->value) { e = (*v)(p->value, a); if (e) return e; } if (p->exception) { e = (*v)(p->exception, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_4ares_result(PyObject *o) { PyObject* tmp; struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; tmp = ((PyObject*)p->value); p->value = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->exception); p->exception = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_4ares_6result_value(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_4ares_6result_5value_1__get__(o); } static int __pyx_setprop_6gevent_4ares_6result_value(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_4ares_6result_5value_3__set__(o, v); } else { return __pyx_pw_6gevent_4ares_6result_5value_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_4ares_6result_exception(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_4ares_6result_9exception_1__get__(o); } static int __pyx_setprop_6gevent_4ares_6result_exception(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_4ares_6result_9exception_3__set__(o, v); } else { return __pyx_pw_6gevent_4ares_6result_9exception_5__del__(o); } } static PyMethodDef __pyx_methods_6gevent_4ares_result[] = { {"successful", (PyCFunction)__pyx_pw_6gevent_4ares_6result_5successful, METH_NOARGS, 0}, {"get", (PyCFunction)__pyx_pw_6gevent_4ares_6result_7get, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_4ares_result[] = { {(char *)"value", __pyx_getprop_6gevent_4ares_6result_value, __pyx_setprop_6gevent_4ares_6result_value, 0, 0}, {(char *)"exception", __pyx_getprop_6gevent_4ares_6result_exception, __pyx_setprop_6gevent_4ares_6result_exception, 0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_6gevent_4ares_result = { PyVarObject_HEAD_INIT(0, 0) "gevent.ares.result", /*tp_name*/ sizeof(struct __pyx_obj_6gevent_4ares_result), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_4ares_result, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_4ares_6result_3__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_4ares_result, /*tp_traverse*/ __pyx_tp_clear_6gevent_4ares_result, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_4ares_result, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_4ares_result, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_4ares_6result_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_4ares_result, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_6gevent_4ares_channel __pyx_vtable_6gevent_4ares_channel; static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct PyGeventAresChannelObject *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct PyGeventAresChannelObject *)o); p->__pyx_vtab = __pyx_vtabptr_6gevent_4ares_channel; p->loop = Py_None; Py_INCREF(Py_None); p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_timer = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_4ares_channel(PyObject *o) { struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_6gevent_4ares_7channel_7__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->loop); Py_CLEAR(p->_watchers); Py_CLEAR(p->_timer); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_6gevent_4ares_channel(PyObject *o, visitproc v, void *a) { int e; struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; if (p->loop) { e = (*v)(p->loop, a); if (e) return e; } if (p->_watchers) { e = (*v)(p->_watchers, a); if (e) return e; } if (p->_timer) { e = (*v)(p->_timer, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_4ares_channel(PyObject *o) { PyObject* tmp; struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; tmp = ((PyObject*)p->loop); p->loop = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_watchers); p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_timer); p->_timer = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_4ares_7channel_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_4ares_7channel_4loop_1__get__(o); } static int __pyx_setprop_6gevent_4ares_7channel_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_4ares_7channel__watchers(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(o); } static int __pyx_setprop_6gevent_4ares_7channel__watchers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(o, v); } else { return __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_4ares_7channel__timer(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(o); } static int __pyx_setprop_6gevent_4ares_7channel__timer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(o, v); } else { return __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(o); } } static PyMethodDef __pyx_methods_6gevent_4ares_channel[] = { {"destroy", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_5destroy, METH_NOARGS, 0}, {"set_servers", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_9set_servers, METH_VARARGS|METH_KEYWORDS, 0}, {"_on_timer", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_11_on_timer, METH_NOARGS, 0}, {"_process_fd", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_13_process_fd, METH_VARARGS|METH_KEYWORDS, 0}, {"gethostbyname", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_15gethostbyname, METH_VARARGS|METH_KEYWORDS, 0}, {"gethostbyaddr", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr, METH_VARARGS|METH_KEYWORDS, 0}, {"_getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo, METH_VARARGS|METH_KEYWORDS, 0}, {"getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_21getnameinfo, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_4ares_channel[] = { {(char *)"loop", __pyx_getprop_6gevent_4ares_7channel_loop, __pyx_setprop_6gevent_4ares_7channel_loop, 0, 0}, {(char *)"_watchers", __pyx_getprop_6gevent_4ares_7channel__watchers, __pyx_setprop_6gevent_4ares_7channel__watchers, 0, 0}, {(char *)"_timer", __pyx_getprop_6gevent_4ares_7channel__timer, __pyx_setprop_6gevent_4ares_7channel__timer, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.ares.channel", /*tp_name*/ sizeof(struct PyGeventAresChannelObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_4ares_channel, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_4ares_7channel_3__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_4ares_channel, /*tp_traverse*/ __pyx_tp_clear_6gevent_4ares_channel, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_4ares_channel, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_4ares_channel, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_4ares_7channel_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_4ares_channel, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {"_convert_cares_flags", (PyCFunction)__pyx_pw_6gevent_4ares_1_convert_cares_flags, METH_VARARGS|METH_KEYWORDS, 0}, {"strerror", (PyCFunction)__pyx_pw_6gevent_4ares_3strerror, METH_O, 0}, {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "ares", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_k_ARES_EADDRGETNETWORKPARAMS, sizeof(__pyx_k_ARES_EADDRGETNETWORKPARAMS), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADFAMILY, __pyx_k_ARES_EBADFAMILY, sizeof(__pyx_k_ARES_EBADFAMILY), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADFLAGS, __pyx_k_ARES_EBADFLAGS, sizeof(__pyx_k_ARES_EBADFLAGS), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADHINTS, __pyx_k_ARES_EBADHINTS, sizeof(__pyx_k_ARES_EBADHINTS), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADNAME, __pyx_k_ARES_EBADNAME, sizeof(__pyx_k_ARES_EBADNAME), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADQUERY, __pyx_k_ARES_EBADQUERY, sizeof(__pyx_k_ARES_EBADQUERY), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADRESP, __pyx_k_ARES_EBADRESP, sizeof(__pyx_k_ARES_EBADRESP), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EBADSTR, __pyx_k_ARES_EBADSTR, sizeof(__pyx_k_ARES_EBADSTR), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ECANCELLED, __pyx_k_ARES_ECANCELLED, sizeof(__pyx_k_ARES_ECANCELLED), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ECONNREFUSED, __pyx_k_ARES_ECONNREFUSED, sizeof(__pyx_k_ARES_ECONNREFUSED), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EDESTRUCTION, __pyx_k_ARES_EDESTRUCTION, sizeof(__pyx_k_ARES_EDESTRUCTION), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EFILE, __pyx_k_ARES_EFILE, sizeof(__pyx_k_ARES_EFILE), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EFORMERR, __pyx_k_ARES_EFORMERR, sizeof(__pyx_k_ARES_EFORMERR), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_k_ARES_ELOADIPHLPAPI, sizeof(__pyx_k_ARES_ELOADIPHLPAPI), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENODATA, __pyx_k_ARES_ENODATA, sizeof(__pyx_k_ARES_ENODATA), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENOMEM, __pyx_k_ARES_ENOMEM, sizeof(__pyx_k_ARES_ENOMEM), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENONAME, __pyx_k_ARES_ENONAME, sizeof(__pyx_k_ARES_ENONAME), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENOTFOUND, __pyx_k_ARES_ENOTFOUND, sizeof(__pyx_k_ARES_ENOTFOUND), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENOTIMP, __pyx_k_ARES_ENOTIMP, sizeof(__pyx_k_ARES_ENOTIMP), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ENOTINITIALIZED, __pyx_k_ARES_ENOTINITIALIZED, sizeof(__pyx_k_ARES_ENOTINITIALIZED), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EOF, __pyx_k_ARES_EOF, sizeof(__pyx_k_ARES_EOF), 0, 0, 1, 1}, {&__pyx_n_s_ARES_EREFUSED, __pyx_k_ARES_EREFUSED, sizeof(__pyx_k_ARES_EREFUSED), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ESERVFAIL, __pyx_k_ARES_ESERVFAIL, sizeof(__pyx_k_ARES_ESERVFAIL), 0, 0, 1, 1}, {&__pyx_n_s_ARES_ETIMEOUT, __pyx_k_ARES_ETIMEOUT, sizeof(__pyx_k_ARES_ETIMEOUT), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_IGNTC, __pyx_k_ARES_FLAG_IGNTC, sizeof(__pyx_k_ARES_FLAG_IGNTC), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_NOALIASES, __pyx_k_ARES_FLAG_NOALIASES, sizeof(__pyx_k_ARES_FLAG_NOALIASES), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_k_ARES_FLAG_NOCHECKRESP, sizeof(__pyx_k_ARES_FLAG_NOCHECKRESP), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_NORECURSE, __pyx_k_ARES_FLAG_NORECURSE, sizeof(__pyx_k_ARES_FLAG_NORECURSE), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_k_ARES_FLAG_NOSEARCH, sizeof(__pyx_k_ARES_FLAG_NOSEARCH), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_PRIMARY, __pyx_k_ARES_FLAG_PRIMARY, sizeof(__pyx_k_ARES_FLAG_PRIMARY), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_k_ARES_FLAG_STAYOPEN, sizeof(__pyx_k_ARES_FLAG_STAYOPEN), 0, 0, 1, 1}, {&__pyx_n_s_ARES_FLAG_USEVC, __pyx_k_ARES_FLAG_USEVC, sizeof(__pyx_k_ARES_FLAG_USEVC), 0, 0, 1, 1}, {&__pyx_n_s_ARES_SUCCESS, __pyx_k_ARES_SUCCESS, sizeof(__pyx_k_ARES_SUCCESS), 0, 0, 1, 1}, {&__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_k_Bad_value_for_ai_flags_0x_x, sizeof(__pyx_k_Bad_value_for_ai_flags_0x_x), 0, 0, 1, 0}, {&__pyx_n_s_InvalidIP, __pyx_k_InvalidIP, sizeof(__pyx_k_InvalidIP), 0, 0, 1, 1}, {&__pyx_kp_s_Invalid_value_for_port_r, __pyx_k_Invalid_value_for_port_r, sizeof(__pyx_k_Invalid_value_for_port_r), 0, 0, 1, 0}, {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, {&__pyx_n_s_NI_DGRAM, __pyx_k_NI_DGRAM, sizeof(__pyx_k_NI_DGRAM), 0, 0, 1, 1}, {&__pyx_n_s_NI_NAMEREQD, __pyx_k_NI_NAMEREQD, sizeof(__pyx_k_NI_NAMEREQD), 0, 0, 1, 1}, {&__pyx_n_s_NI_NOFQDN, __pyx_k_NI_NOFQDN, sizeof(__pyx_k_NI_NOFQDN), 0, 0, 1, 1}, {&__pyx_n_s_NI_NUMERICHOST, __pyx_k_NI_NUMERICHOST, sizeof(__pyx_k_NI_NUMERICHOST), 0, 0, 1, 1}, {&__pyx_n_s_NI_NUMERICSERV, __pyx_k_NI_NUMERICSERV, sizeof(__pyx_k_NI_NUMERICSERV), 0, 0, 1, 1}, {&__pyx_n_s_TIMEOUT, __pyx_k_TIMEOUT, sizeof(__pyx_k_TIMEOUT), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1}, {&__pyx_n_s_again, __pyx_k_again, sizeof(__pyx_k_again), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_ares_errors, __pyx_k_ares_errors, sizeof(__pyx_k_ares_errors), 0, 0, 1, 1}, {&__pyx_n_s_ares_host_result, __pyx_k_ares_host_result, sizeof(__pyx_k_ares_host_result), 0, 0, 1, 1}, {&__pyx_n_s_ares_host_result___getnewargs, __pyx_k_ares_host_result___getnewargs, sizeof(__pyx_k_ares_host_result___getnewargs), 0, 0, 1, 1}, {&__pyx_n_s_ares_host_result___new, __pyx_k_ares_host_result___new, sizeof(__pyx_k_ares_host_result___new), 0, 0, 1, 1}, {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1}, {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1}, {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1}, {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1}, {&__pyx_n_s_cares_flag_map, __pyx_k_cares_flag_map, sizeof(__pyx_k_cares_flag_map), 0, 0, 1, 1}, {&__pyx_n_s_channel, __pyx_k_channel, sizeof(__pyx_k_channel), 0, 0, 1, 1}, {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1}, {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1}, {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1}, {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1}, {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1}, {&__pyx_kp_s_expected_a_tuple_got_r, __pyx_k_expected_a_tuple_got_r, sizeof(__pyx_k_expected_a_tuple_got_r), 0, 0, 1, 0}, {&__pyx_n_s_family, __pyx_k_family, sizeof(__pyx_k_family), 0, 0, 1, 1}, {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, {&__pyx_n_s_gaierror, __pyx_k_gaierror, sizeof(__pyx_k_gaierror), 0, 0, 1, 1}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_getnameinfo, __pyx_k_getnameinfo, sizeof(__pyx_k_getnameinfo), 0, 0, 1, 1}, {&__pyx_n_s_getnewargs, __pyx_k_getnewargs, sizeof(__pyx_k_getnewargs), 0, 0, 1, 1}, {&__pyx_n_s_gevent_ares, __pyx_k_gevent_ares, sizeof(__pyx_k_gevent_ares), 0, 0, 1, 1}, {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1}, {&__pyx_n_s_iterable, __pyx_k_iterable, sizeof(__pyx_k_iterable), 0, 0, 1, 1}, {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_n_s_ndots, __pyx_k_ndots, sizeof(__pyx_k_ndots), 0, 0, 1, 1}, {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, {&__pyx_n_s_on_timer, __pyx_k_on_timer, sizeof(__pyx_k_on_timer), 0, 0, 1, 1}, {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1}, {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_k_private_tmp_gevent_python2_7_ge, sizeof(__pyx_k_private_tmp_gevent_python2_7_ge), 0, 0, 1, 0}, {&__pyx_n_s_process_fd, __pyx_k_process_fd, sizeof(__pyx_k_process_fd), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_k_s_at_0x_x__timer_r__watchers_s, sizeof(__pyx_k_s_at_0x_x__timer_r__watchers_s), 0, 0, 1, 0}, {&__pyx_kp_s_s_exception_r, __pyx_k_s_exception_r, sizeof(__pyx_k_s_exception_r), 0, 0, 1, 0}, {&__pyx_kp_s_s_r, __pyx_k_s_r, sizeof(__pyx_k_s_r), 0, 0, 1, 0}, {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0}, {&__pyx_kp_s_s_value_r_exception_r, __pyx_k_s_value_r_exception_r, sizeof(__pyx_k_s_value_r_exception_r), 0, 0, 1, 0}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, {&__pyx_n_s_servers, __pyx_k_servers, sizeof(__pyx_k_servers), 0, 0, 1, 1}, {&__pyx_n_s_set_servers, __pyx_k_set_servers, sizeof(__pyx_k_set_servers), 0, 0, 1, 1}, {&__pyx_n_s_sockaddr, __pyx_k_sockaddr, sizeof(__pyx_k_sockaddr), 0, 0, 1, 1}, {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1}, {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_tcp_port, __pyx_k_tcp_port, sizeof(__pyx_k_tcp_port), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_kp_s_this_ares_channel_has_been_destr, __pyx_k_this_ares_channel_has_been_destr, sizeof(__pyx_k_this_ares_channel_has_been_destr), 0, 0, 1, 0}, {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1}, {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1}, {&__pyx_n_s_tries, __pyx_k_tries, sizeof(__pyx_k_tries), 0, 0, 1, 1}, {&__pyx_n_s_udp_port, __pyx_k_udp_port, sizeof(__pyx_k_udp_port), 0, 0, 1, 1}, {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1}, {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, {&__pyx_n_s_watcher, __pyx_k_watcher, sizeof(__pyx_k_watcher), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "gevent/ares.pyx":320 * servers = [] * if isinstance(servers, string_types): * servers = servers.split(',') # <<<<<<<<<<<<<< * cdef int length = len(servers) * cdef int result, index */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s__2); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "gevent/ares.pyx":335 * for server in servers: * if isinstance(server, unicode): * server = server.encode('ascii') # <<<<<<<<<<<<<< * string = server * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "gevent/ares.pyx":192 * class ares_host_result(tuple): * * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< * cdef object self = tuple.__new__(cls, iterable) * self.family = family */ __pyx_tuple__6 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_family, __pyx_n_s_iterable, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_new, 192, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":197 * return self * * def __getnewargs__(self): # <<<<<<<<<<<<<< * return (self.family, tuple(self)) * */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_getnewargs, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initares(void); /*proto*/ PyMODINIT_FUNC initares(void) #else PyMODINIT_FUNC PyInit_ares(void); /*proto*/ PyMODINIT_FUNC PyInit_ares(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; PyObject *__pyx_t_21 = NULL; PyObject *__pyx_t_22 = NULL; PyObject *__pyx_t_23 = NULL; PyObject *__pyx_t_24 = NULL; PyObject *__pyx_t_25 = NULL; PyObject *__pyx_t_26 = NULL; PyObject *__pyx_t_27 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ares(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("ares", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_gevent__ares) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "gevent.ares")) { if (unlikely(PyDict_SetItemString(modules, "gevent.ares", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ __pyx_v_6gevent_4ares_string_types = Py_None; Py_INCREF(Py_None); __pyx_v_6gevent_4ares_text_type = Py_None; Py_INCREF(Py_None); /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_6gevent_4ares_result) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_6gevent_4ares_result.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "result", (PyObject *)&__pyx_type_6gevent_4ares_result) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_4ares_result = &__pyx_type_6gevent_4ares_result; __pyx_vtabptr_6gevent_4ares_channel = &__pyx_vtable_6gevent_4ares_channel; __pyx_vtable_6gevent_4ares_channel._sock_state_callback = (PyObject *(*)(struct PyGeventAresChannelObject *, int, int, int))__pyx_f_6gevent_4ares_7channel__sock_state_callback; __pyx_vtable_6gevent_4ares_channel._getnameinfo = (PyObject *(*)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_6gevent_4ares_7channel__getnameinfo; if (PyType_Ready(&PyGeventAresChannel_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventAresChannel_Type.tp_print = 0; if (__Pyx_SetVtable(PyGeventAresChannel_Type.tp_dict, __pyx_vtabptr_6gevent_4ares_channel) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "channel", (PyObject *)&PyGeventAresChannel_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_4ares_channel = &PyGeventAresChannel_Type; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "gevent/ares.pyx":3 * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. * cimport cares * import sys # <<<<<<<<<<<<<< * from python cimport * * from _socket import gaierror */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":5 * import sys * from python cimport * * from _socket import gaierror # <<<<<<<<<<<<<< * * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_gaierror); __Pyx_GIVEREF(__pyx_n_s_gaierror); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gaierror); __pyx_t_2 = __Pyx_Import(__pyx_n_s_socket, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_gaierror, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":8 * * * __all__ = ['channel'] # <<<<<<<<<<<<<< * * cdef object string_types */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_channel); __Pyx_GIVEREF(__pyx_n_s_channel); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_channel); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":13 * cdef object text_type * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * string_types = str, * text_type = str */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* "gevent/ares.pyx":14 * * if sys.version_info[0] >= 3: * string_types = str, # <<<<<<<<<<<<<< * text_type = str * else: */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)(&PyString_Type))); __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyString_Type))); __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types); __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":15 * if sys.version_info[0] >= 3: * string_types = str, * text_type = str # <<<<<<<<<<<<<< * else: * string_types = __builtins__.basestring, */ __Pyx_INCREF(((PyObject *)(&PyString_Type))); __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type); __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, ((PyObject *)(&PyString_Type))); __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); /* "gevent/ares.pyx":13 * cdef object text_type * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * string_types = str, * text_type = str */ goto __pyx_L2; } /* "gevent/ares.pyx":17 * text_type = str * else: * string_types = __builtins__.basestring, # <<<<<<<<<<<<<< * text_type = __builtins__.unicode * */ /*else*/ { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basestring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types); __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/ares.pyx":18 * else: * string_types = __builtins__.basestring, * text_type = __builtins__.unicode # <<<<<<<<<<<<<< * * TIMEOUT = 1 */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type); __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L2:; /* "gevent/ares.pyx":20 * text_type = __builtins__.unicode * * TIMEOUT = 1 # <<<<<<<<<<<<<< * * DEF EV_READ = 1 */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":58 * * * ARES_SUCCESS = cares.ARES_SUCCESS # <<<<<<<<<<<<<< * ARES_ENODATA = cares.ARES_ENODATA * ARES_EFORMERR = cares.ARES_EFORMERR */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_SUCCESS, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":59 * * ARES_SUCCESS = cares.ARES_SUCCESS * ARES_ENODATA = cares.ARES_ENODATA # <<<<<<<<<<<<<< * ARES_EFORMERR = cares.ARES_EFORMERR * ARES_ESERVFAIL = cares.ARES_ESERVFAIL */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENODATA, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":60 * ARES_SUCCESS = cares.ARES_SUCCESS * ARES_ENODATA = cares.ARES_ENODATA * ARES_EFORMERR = cares.ARES_EFORMERR # <<<<<<<<<<<<<< * ARES_ESERVFAIL = cares.ARES_ESERVFAIL * ARES_ENOTFOUND = cares.ARES_ENOTFOUND */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFORMERR, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":61 * ARES_ENODATA = cares.ARES_ENODATA * ARES_EFORMERR = cares.ARES_EFORMERR * ARES_ESERVFAIL = cares.ARES_ESERVFAIL # <<<<<<<<<<<<<< * ARES_ENOTFOUND = cares.ARES_ENOTFOUND * ARES_ENOTIMP = cares.ARES_ENOTIMP */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ESERVFAIL, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":62 * ARES_EFORMERR = cares.ARES_EFORMERR * ARES_ESERVFAIL = cares.ARES_ESERVFAIL * ARES_ENOTFOUND = cares.ARES_ENOTFOUND # <<<<<<<<<<<<<< * ARES_ENOTIMP = cares.ARES_ENOTIMP * ARES_EREFUSED = cares.ARES_EREFUSED */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTFOUND, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":63 * ARES_ESERVFAIL = cares.ARES_ESERVFAIL * ARES_ENOTFOUND = cares.ARES_ENOTFOUND * ARES_ENOTIMP = cares.ARES_ENOTIMP # <<<<<<<<<<<<<< * ARES_EREFUSED = cares.ARES_EREFUSED * ARES_EBADQUERY = cares.ARES_EBADQUERY */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTIMP, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":64 * ARES_ENOTFOUND = cares.ARES_ENOTFOUND * ARES_ENOTIMP = cares.ARES_ENOTIMP * ARES_EREFUSED = cares.ARES_EREFUSED # <<<<<<<<<<<<<< * ARES_EBADQUERY = cares.ARES_EBADQUERY * ARES_EBADNAME = cares.ARES_EBADNAME */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EREFUSED, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":65 * ARES_ENOTIMP = cares.ARES_ENOTIMP * ARES_EREFUSED = cares.ARES_EREFUSED * ARES_EBADQUERY = cares.ARES_EBADQUERY # <<<<<<<<<<<<<< * ARES_EBADNAME = cares.ARES_EBADNAME * ARES_EBADFAMILY = cares.ARES_EBADFAMILY */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADQUERY, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":66 * ARES_EREFUSED = cares.ARES_EREFUSED * ARES_EBADQUERY = cares.ARES_EBADQUERY * ARES_EBADNAME = cares.ARES_EBADNAME # <<<<<<<<<<<<<< * ARES_EBADFAMILY = cares.ARES_EBADFAMILY * ARES_EBADRESP = cares.ARES_EBADRESP */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADNAME, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":67 * ARES_EBADQUERY = cares.ARES_EBADQUERY * ARES_EBADNAME = cares.ARES_EBADNAME * ARES_EBADFAMILY = cares.ARES_EBADFAMILY # <<<<<<<<<<<<<< * ARES_EBADRESP = cares.ARES_EBADRESP * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFAMILY, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":68 * ARES_EBADNAME = cares.ARES_EBADNAME * ARES_EBADFAMILY = cares.ARES_EBADFAMILY * ARES_EBADRESP = cares.ARES_EBADRESP # <<<<<<<<<<<<<< * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED * ARES_ETIMEOUT = cares.ARES_ETIMEOUT */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADRESP, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":69 * ARES_EBADFAMILY = cares.ARES_EBADFAMILY * ARES_EBADRESP = cares.ARES_EBADRESP * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED # <<<<<<<<<<<<<< * ARES_ETIMEOUT = cares.ARES_ETIMEOUT * ARES_EOF = cares.ARES_EOF */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECONNREFUSED, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":70 * ARES_EBADRESP = cares.ARES_EBADRESP * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED * ARES_ETIMEOUT = cares.ARES_ETIMEOUT # <<<<<<<<<<<<<< * ARES_EOF = cares.ARES_EOF * ARES_EFILE = cares.ARES_EFILE */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ETIMEOUT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":71 * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED * ARES_ETIMEOUT = cares.ARES_ETIMEOUT * ARES_EOF = cares.ARES_EOF # <<<<<<<<<<<<<< * ARES_EFILE = cares.ARES_EFILE * ARES_ENOMEM = cares.ARES_ENOMEM */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EOF, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":72 * ARES_ETIMEOUT = cares.ARES_ETIMEOUT * ARES_EOF = cares.ARES_EOF * ARES_EFILE = cares.ARES_EFILE # <<<<<<<<<<<<<< * ARES_ENOMEM = cares.ARES_ENOMEM * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFILE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":73 * ARES_EOF = cares.ARES_EOF * ARES_EFILE = cares.ARES_EFILE * ARES_ENOMEM = cares.ARES_ENOMEM # <<<<<<<<<<<<<< * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION * ARES_EBADSTR = cares.ARES_EBADSTR */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOMEM, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":74 * ARES_EFILE = cares.ARES_EFILE * ARES_ENOMEM = cares.ARES_ENOMEM * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION # <<<<<<<<<<<<<< * ARES_EBADSTR = cares.ARES_EBADSTR * ARES_EBADFLAGS = cares.ARES_EBADFLAGS */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EDESTRUCTION, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":75 * ARES_ENOMEM = cares.ARES_ENOMEM * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION * ARES_EBADSTR = cares.ARES_EBADSTR # <<<<<<<<<<<<<< * ARES_EBADFLAGS = cares.ARES_EBADFLAGS * ARES_ENONAME = cares.ARES_ENONAME */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADSTR, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":76 * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION * ARES_EBADSTR = cares.ARES_EBADSTR * ARES_EBADFLAGS = cares.ARES_EBADFLAGS # <<<<<<<<<<<<<< * ARES_ENONAME = cares.ARES_ENONAME * ARES_EBADHINTS = cares.ARES_EBADHINTS */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFLAGS, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":77 * ARES_EBADSTR = cares.ARES_EBADSTR * ARES_EBADFLAGS = cares.ARES_EBADFLAGS * ARES_ENONAME = cares.ARES_ENONAME # <<<<<<<<<<<<<< * ARES_EBADHINTS = cares.ARES_EBADHINTS * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENONAME, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":78 * ARES_EBADFLAGS = cares.ARES_EBADFLAGS * ARES_ENONAME = cares.ARES_ENONAME * ARES_EBADHINTS = cares.ARES_EBADHINTS # <<<<<<<<<<<<<< * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADHINTS, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":79 * ARES_ENONAME = cares.ARES_ENONAME * ARES_EBADHINTS = cares.ARES_EBADHINTS * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED # <<<<<<<<<<<<<< * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTINITIALIZED, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":80 * ARES_EBADHINTS = cares.ARES_EBADHINTS * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI # <<<<<<<<<<<<<< * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS * ARES_ECANCELLED = cares.ARES_ECANCELLED */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":81 * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS # <<<<<<<<<<<<<< * ARES_ECANCELLED = cares.ARES_ECANCELLED * */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":82 * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS * ARES_ECANCELLED = cares.ARES_ECANCELLED # <<<<<<<<<<<<<< * * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECANCELLED, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":84 * ARES_ECANCELLED = cares.ARES_ECANCELLED * * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC # <<<<<<<<<<<<<< * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_USEVC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_USEVC, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":85 * * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY # <<<<<<<<<<<<<< * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_PRIMARY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_PRIMARY, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":86 * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC # <<<<<<<<<<<<<< * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_IGNTC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_IGNTC, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":87 * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE # <<<<<<<<<<<<<< * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NORECURSE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NORECURSE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":88 * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN # <<<<<<<<<<<<<< * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_STAYOPEN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":89 * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH # <<<<<<<<<<<<<< * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOSEARCH); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":90 * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES # <<<<<<<<<<<<<< * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP * */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOALIASES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOALIASES, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":91 * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOCHECKRESP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":95 * * _ares_errors = dict([ * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), # <<<<<<<<<<<<<< * (cares.ARES_ENODATA, 'ARES_ENODATA'), * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_SUCCESS); __Pyx_GIVEREF(__pyx_n_s_ARES_SUCCESS); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ARES_SUCCESS); __pyx_t_2 = 0; /* "gevent/ares.pyx":96 * _ares_errors = dict([ * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), * (cares.ARES_ENODATA, 'ARES_ENODATA'), # <<<<<<<<<<<<<< * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENODATA); __Pyx_GIVEREF(__pyx_n_s_ARES_ENODATA); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_ARES_ENODATA); __pyx_t_2 = 0; /* "gevent/ares.pyx":97 * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), * (cares.ARES_ENODATA, 'ARES_ENODATA'), * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), # <<<<<<<<<<<<<< * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EFORMERR); __Pyx_GIVEREF(__pyx_n_s_ARES_EFORMERR); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_ARES_EFORMERR); __pyx_t_2 = 0; /* "gevent/ares.pyx":98 * (cares.ARES_ENODATA, 'ARES_ENODATA'), * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), # <<<<<<<<<<<<<< * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ESERVFAIL); __Pyx_GIVEREF(__pyx_n_s_ARES_ESERVFAIL); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_ARES_ESERVFAIL); __pyx_t_2 = 0; /* "gevent/ares.pyx":99 * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), # <<<<<<<<<<<<<< * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENOTFOUND); __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTFOUND); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ARES_ENOTFOUND); __pyx_t_2 = 0; /* "gevent/ares.pyx":100 * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), # <<<<<<<<<<<<<< * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENOTIMP); __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTIMP); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_ARES_ENOTIMP); __pyx_t_2 = 0; /* "gevent/ares.pyx":101 * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), # <<<<<<<<<<<<<< * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EREFUSED); __Pyx_GIVEREF(__pyx_n_s_ARES_EREFUSED); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_ARES_EREFUSED); __pyx_t_2 = 0; /* "gevent/ares.pyx":102 * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), # <<<<<<<<<<<<<< * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADQUERY); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADQUERY); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_ARES_EBADQUERY); __pyx_t_2 = 0; /* "gevent/ares.pyx":103 * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), # <<<<<<<<<<<<<< * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADNAME); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADNAME); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_ARES_EBADNAME); __pyx_t_2 = 0; /* "gevent/ares.pyx":104 * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), # <<<<<<<<<<<<<< * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADFAMILY); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFAMILY); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_ARES_EBADFAMILY); __pyx_t_2 = 0; /* "gevent/ares.pyx":105 * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), # <<<<<<<<<<<<<< * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADRESP); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADRESP); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_ARES_EBADRESP); __pyx_t_2 = 0; /* "gevent/ares.pyx":106 * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), # <<<<<<<<<<<<<< * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), * (cares.ARES_EOF, 'ARES_EOF'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ECONNREFUSED); __Pyx_GIVEREF(__pyx_n_s_ARES_ECONNREFUSED); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_ARES_ECONNREFUSED); __pyx_t_2 = 0; /* "gevent/ares.pyx":107 * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), # <<<<<<<<<<<<<< * (cares.ARES_EOF, 'ARES_EOF'), * (cares.ARES_EFILE, 'ARES_EFILE'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ETIMEOUT); __Pyx_GIVEREF(__pyx_n_s_ARES_ETIMEOUT); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_ARES_ETIMEOUT); __pyx_t_2 = 0; /* "gevent/ares.pyx":108 * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), * (cares.ARES_EOF, 'ARES_EOF'), # <<<<<<<<<<<<<< * (cares.ARES_EFILE, 'ARES_EFILE'), * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EOF); __Pyx_GIVEREF(__pyx_n_s_ARES_EOF); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ARES_EOF); __pyx_t_2 = 0; /* "gevent/ares.pyx":109 * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), * (cares.ARES_EOF, 'ARES_EOF'), * (cares.ARES_EFILE, 'ARES_EFILE'), # <<<<<<<<<<<<<< * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EFILE); __Pyx_GIVEREF(__pyx_n_s_ARES_EFILE); PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_ARES_EFILE); __pyx_t_2 = 0; /* "gevent/ares.pyx":110 * (cares.ARES_EOF, 'ARES_EOF'), * (cares.ARES_EFILE, 'ARES_EFILE'), * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), # <<<<<<<<<<<<<< * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENOMEM); __Pyx_GIVEREF(__pyx_n_s_ARES_ENOMEM); PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ARES_ENOMEM); __pyx_t_2 = 0; /* "gevent/ares.pyx":111 * (cares.ARES_EFILE, 'ARES_EFILE'), * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), # <<<<<<<<<<<<<< * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EDESTRUCTION); __Pyx_GIVEREF(__pyx_n_s_ARES_EDESTRUCTION); PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_n_s_ARES_EDESTRUCTION); __pyx_t_2 = 0; /* "gevent/ares.pyx":112 * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), # <<<<<<<<<<<<<< * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), * (cares.ARES_ENONAME, 'ARES_ENONAME'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_20); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADSTR); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADSTR); PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_n_s_ARES_EBADSTR); __pyx_t_2 = 0; /* "gevent/ares.pyx":113 * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), # <<<<<<<<<<<<<< * (cares.ARES_ENONAME, 'ARES_ENONAME'), * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADFLAGS); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFLAGS); PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_n_s_ARES_EBADFLAGS); __pyx_t_2 = 0; /* "gevent/ares.pyx":114 * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), * (cares.ARES_ENONAME, 'ARES_ENONAME'), # <<<<<<<<<<<<<< * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_22); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENONAME); __Pyx_GIVEREF(__pyx_n_s_ARES_ENONAME); PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_n_s_ARES_ENONAME); __pyx_t_2 = 0; /* "gevent/ares.pyx":115 * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), * (cares.ARES_ENONAME, 'ARES_ENONAME'), * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), # <<<<<<<<<<<<<< * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_23); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EBADHINTS); __Pyx_GIVEREF(__pyx_n_s_ARES_EBADHINTS); PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_n_s_ARES_EBADHINTS); __pyx_t_2 = 0; /* "gevent/ares.pyx":116 * (cares.ARES_ENONAME, 'ARES_ENONAME'), * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), # <<<<<<<<<<<<<< * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_24); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ENOTINITIALIZED); __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTINITIALIZED); PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_n_s_ARES_ENOTINITIALIZED); __pyx_t_2 = 0; /* "gevent/ares.pyx":117 * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), # <<<<<<<<<<<<<< * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_25); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ELOADIPHLPAPI); __Pyx_GIVEREF(__pyx_n_s_ARES_ELOADIPHLPAPI); PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_n_s_ARES_ELOADIPHLPAPI); __pyx_t_2 = 0; /* "gevent/ares.pyx":118 * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), # <<<<<<<<<<<<<< * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) * */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_26 = PyTuple_New(2); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_26); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS); __Pyx_GIVEREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS); PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS); __pyx_t_2 = 0; /* "gevent/ares.pyx":119 * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_27); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_ARES_ECANCELLED); __Pyx_GIVEREF(__pyx_n_s_ARES_ECANCELLED); PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_n_s_ARES_ECANCELLED); __pyx_t_2 = 0; /* "gevent/ares.pyx":94 * * * _ares_errors = dict([ # <<<<<<<<<<<<<< * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), * (cares.ARES_ENODATA, 'ARES_ENODATA'), */ __pyx_t_2 = PyList_New(25); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyList_SET_ITEM(__pyx_t_2, 10, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyList_SET_ITEM(__pyx_t_2, 11, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_15); PyList_SET_ITEM(__pyx_t_2, 12, __pyx_t_15); __Pyx_GIVEREF(__pyx_t_16); PyList_SET_ITEM(__pyx_t_2, 13, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_17); PyList_SET_ITEM(__pyx_t_2, 14, __pyx_t_17); __Pyx_GIVEREF(__pyx_t_18); PyList_SET_ITEM(__pyx_t_2, 15, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_19); PyList_SET_ITEM(__pyx_t_2, 16, __pyx_t_19); __Pyx_GIVEREF(__pyx_t_20); PyList_SET_ITEM(__pyx_t_2, 17, __pyx_t_20); __Pyx_GIVEREF(__pyx_t_21); PyList_SET_ITEM(__pyx_t_2, 18, __pyx_t_21); __Pyx_GIVEREF(__pyx_t_22); PyList_SET_ITEM(__pyx_t_2, 19, __pyx_t_22); __Pyx_GIVEREF(__pyx_t_23); PyList_SET_ITEM(__pyx_t_2, 20, __pyx_t_23); __Pyx_GIVEREF(__pyx_t_24); PyList_SET_ITEM(__pyx_t_2, 21, __pyx_t_24); __Pyx_GIVEREF(__pyx_t_25); PyList_SET_ITEM(__pyx_t_2, 22, __pyx_t_25); __Pyx_GIVEREF(__pyx_t_26); PyList_SET_ITEM(__pyx_t_2, 23, __pyx_t_26); __Pyx_GIVEREF(__pyx_t_27); PyList_SET_ITEM(__pyx_t_2, 24, __pyx_t_27); __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_27); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_27, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_errors, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":123 * * # maps c-ares flag to _socket module flag * _cares_flag_map = None # <<<<<<<<<<<<<< * * */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/ares.pyx":137 * * * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< * if _cares_flag_map is None: * _prepare_cares_flag_map() */ __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE); __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE); /* "gevent/ares.pyx":153 * * * class InvalidIP(ValueError): # <<<<<<<<<<<<<< * pass * */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_builtin_ValueError); __Pyx_GIVEREF(__pyx_builtin_ValueError); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_ValueError); __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_27); __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_InvalidIP, __pyx_n_s_InvalidIP, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_26); __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_InvalidIP, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_25); if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidIP, __pyx_t_25) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":190 * * * class ares_host_result(tuple): # <<<<<<<<<<<<<< * * def __new__(cls, family, iterable): */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)(&PyTuple_Type))); __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type))); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyTuple_Type))); __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_27); __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_ares_host_result, __pyx_n_s_ares_host_result, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_26); /* "gevent/ares.pyx":192 * class ares_host_result(tuple): * * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< * cdef object self = tuple.__new__(cls, iterable) * self.family = family */ __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ares_host_result___new, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_25); if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_new, __pyx_t_25) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; /* "gevent/ares.pyx":197 * return self * * def __getnewargs__(self): # <<<<<<<<<<<<<< * return (self.family, tuple(self)) * */ __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__, 0, __pyx_n_s_ares_host_result___getnewargs, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_25); if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_getnewargs, __pyx_t_25) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; /* "gevent/ares.pyx":190 * * * class ares_host_result(tuple): # <<<<<<<<<<<<<< * * def __new__(cls, family, iterable): */ __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_ares_host_result, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_25); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_host_result, __pyx_t_25) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/ares.pyx":400 * cares.ares_process_fd(self.channel, read_fd, write_fd) * * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< * if not self.channel: * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') */ __pyx_k__5 = AF_INET; /* "gevent/ares.pyx":1 * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<< * cimport cares * import sys */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_XDECREF(__pyx_t_23); __Pyx_XDECREF(__pyx_t_24); __Pyx_XDECREF(__pyx_t_25); __Pyx_XDECREF(__pyx_t_26); __Pyx_XDECREF(__pyx_t_27); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init gevent.ares", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init gevent.ares"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r = __Pyx_GetAttr(o, n); if (unlikely(!r)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); r = d; Py_INCREF(d); } return r; bad: return NULL; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else PyErr_GetExcInfo(type, value, tb); #endif } static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(type, value, tb); #endif } static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_COMPILING_IN_CPYTHON tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (PyErr_ExceptionMatches(PyExc_OverflowError)) PyErr_Clear(); else return NULL; } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } static double __Pyx__PyObject_AsDouble(PyObject* obj) { PyObject* float_value; #if CYTHON_COMPILING_IN_PYPY float_value = PyNumber_Float(obj); if (0) goto bad; #else PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; if (likely(nb) && likely(nb->nb_float)) { float_value = nb->nb_float(obj); if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { PyErr_Format(PyExc_TypeError, "__float__ returned non-float (type %.200s)", Py_TYPE(float_value)->tp_name); Py_DECREF(float_value); goto bad; } } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { #if PY_MAJOR_VERSION >= 3 float_value = PyFloat_FromString(obj); #else float_value = PyFloat_FromString(obj, 0); #endif } else { PyObject* args = PyTuple_New(1); if (unlikely(!args)) goto bad; PyTuple_SET_ITEM(args, 0, obj); float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); PyTuple_SET_ITEM(args, 0, 0); Py_DECREF(args); } #endif if (likely(float_value)) { double value = PyFloat_AS_DOUBLE(float_value); Py_DECREF(float_value); return value; } bad: return (double)-1; } static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #else PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (unlikely(PyErr_Occurred())) return NULL; value = default_value; } Py_INCREF(value); #else if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { value = PyDict_GetItem(d, key); if (unlikely(!value)) { value = default_value; } Py_INCREF(value); } else { if (default_value == Py_None) default_value = NULL; value = PyObject_CallMethodObjArgs( d, __pyx_n_s_get, key, default_value, NULL); } #endif return value; } static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); } static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (none_allowed && obj == Py_None) return 1; else if (exact) { if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(PyObject_TypeCheck(obj, type))) return 1; } __Pyx_RaiseArgumentTypeInvalid(name, obj, type); return 0; } static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; PyObject *tmp = PyTuple_GET_ITEM(bases, i); tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs = PyTuple_Pack(2, name, bases); if (unlikely(!pargs)) { Py_DECREF(prep); return NULL; } ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); } else { if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; PyErr_Clear(); ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result, *margs; PyObject *owned_metaclass = NULL; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } margs = PyTuple_Pack(3, name, bases, dict); if (unlikely(!margs)) { result = NULL; } else { result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); } Py_XDECREF(owned_metaclass); return result; } static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); if (!fake_module) return NULL; Py_INCREF(fake_module); cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); if (cached_type) { if (!PyType_Check((PyObject*)cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", type->tp_name); goto bad; } if (cached_type->tp_basicsize != type->tp_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", type->tp_name); goto bad; } } else { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) goto bad; Py_INCREF(type); cached_type = type; } done: Py_DECREF(fake_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (unlikely(op->func_doc == NULL)) { if (op->func.m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); #else op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp = op->func_doc; if (value == NULL) { value = Py_None; } Py_INCREF(value); op->func_doc = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); #else op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) { Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = op->func_qualname; Py_INCREF(value); op->func_qualname = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) { PyObject *self; self = m->func_closure; if (self == NULL) self = Py_None; Py_INCREF(self); return self; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) { if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) { Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_COMPILING_IN_CPYTHON op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } Py_INCREF(value); tmp = op->defaults_tuple; op->defaults_tuple = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } Py_INCREF(value); tmp = op->defaults_kwdict; op->defaults_kwdict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value || value == Py_None) { value = NULL; } else if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); tmp = op->func_annotations; op->func_annotations = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(m->func.m_ml->ml_name); #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) #endif static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); if (op == NULL) return NULL; op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; op->func.m_ml = ml; op->func.m_self = (PyObject *) op; Py_XINCREF(closure); op->func_closure = closure; Py_XINCREF(module); op->func.m_module = module; op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; op->func_classobj = NULL; op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; PyObject_GC_Track(op); return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); Py_CLEAR(m->func.m_module); Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); Py_CLEAR(m->func_classobj); Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyMem_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); Py_VISIT(m->func.m_module); Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); Py_VISIT(m->func_classobj); Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { Py_INCREF(func); return func; } if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { if (type == NULL) type = (PyObject *)(Py_TYPE(obj)); return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; return __Pyx_PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("", op->func_qualname, (void *)op); #else return PyString_FromFormat("", PyString_AsString(op->func_qualname), (void *)op); #endif } #if CYTHON_COMPILING_IN_PYPY static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; PyObject *self = f->m_self; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 0)) return (*meth)(self, NULL); PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 1)) { PyObject *result, *arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; result = (*meth)(self, arg0); Py_DECREF(arg0); return result; } PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags in " "__Pyx_CyFunction_Call. METH_OLDARGS is no " "longer supported!"); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; } #else static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { return PyCFunction_Call(func, arg, kw); } #endif static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, 0, 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_Call, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_CyFunction_descr_get, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif }; static int __pyx_CyFunction_init(void) { #if !CYTHON_COMPILING_IN_PYPY __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; #endif __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); if (__pyx_CyFunctionType == NULL) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyMem_Malloc(size); if (!m->defaults) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *x) { const unsigned short neg_one = (unsigned short) -1, const_zero = (unsigned short) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned short) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(unsigned short, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (unsigned short) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned short) 0; case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, digits[0]) case 2: if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) >= 2 * PyLong_SHIFT) { return (unsigned short) (((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); } } break; case 3: if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) >= 3 * PyLong_SHIFT) { return (unsigned short) (((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); } } break; case 4: if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) >= 4 * PyLong_SHIFT) { return (unsigned short) (((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned short) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(unsigned short) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(unsigned short) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned short) 0; case -1: __PYX_VERIFY_RETURN_INT(unsigned short, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, +digits[0]) case -2: if (8 * sizeof(unsigned short) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { return (unsigned short) (((unsigned short)-1)*(((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; case 2: if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { return (unsigned short) ((((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; case -3: if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { return (unsigned short) (((unsigned short)-1)*(((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; case 3: if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { return (unsigned short) ((((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; case -4: if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) { return (unsigned short) (((unsigned short)-1)*(((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; case 4: if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) { return (unsigned short) ((((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); } } break; } #endif if (sizeof(unsigned short) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned short, long, PyLong_AsLong(x)) } else if (sizeof(unsigned short) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned short, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned short val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (unsigned short) -1; } } else { unsigned short val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned short) -1; val = __Pyx_PyInt_As_unsigned_short(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short"); return (unsigned short) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned short"); return (unsigned short) -1; } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ gevent-1.1.0/gevent/gevent.ares.h0000644000076500000000000000200712666555432017420 0ustar jmaddenwheel00000000000000/* Generated by Cython 0.23.4 */ #ifndef __PYX_HAVE__gevent__ares #define __PYX_HAVE__gevent__ares struct PyGeventAresChannelObject; /* "gevent/ares.pyx":245 * * * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: # <<<<<<<<<<<<<< * * cdef public object loop */ struct PyGeventAresChannelObject { PyObject_HEAD struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtab; PyObject *loop; struct ares_channeldata *channel; PyObject *_watchers; PyObject *_timer; }; #ifndef __PYX_HAVE_API__gevent__ares #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(_T) _T #endif __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventAresChannel_Type; #endif /* !__PYX_HAVE_API__gevent__ares */ #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initares(void); #else PyMODINIT_FUNC PyInit_ares(void); #endif #endif /* !__PYX_HAVE__gevent__ares */ gevent-1.1.0/gevent/gevent.corecext.c0000644000076500000000000757075512666555431020327 0ustar jmaddenwheel00000000000000#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* Generated by cythonpp.py on 2016-03-05 07:11:05 */ /* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__gevent__corecext #define __PYX_HAVE_API__gevent__corecext #include "libev_vfd.h" #include "libev.h" #include "frameobject.h" #include "callbacks.h" #include "stathelper.c" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "gevent/corecext.pyx", }; /*--- Type declarations ---*/ struct __pyx_obj_6gevent_8corecext__EVENTSType; struct PyGeventLoopObject; struct PyGeventCallbackObject; struct PyGeventWatcherObject; struct PyGeventIOObject; struct PyGeventTimerObject; struct PyGeventSignalObject; struct PyGeventIdleObject; struct PyGeventPrepareObject; struct PyGeventCheckObject; struct PyGeventForkObject; struct PyGeventAsyncObject; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) struct PyGeventChildObject; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) struct PyGeventStatObject; struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr; /* "gevent/corecext.pyx":90 * * @cython.internal * cdef class _EVENTSType: # <<<<<<<<<<<<<< * * def __repr__(self): */ struct __pyx_obj_6gevent_8corecext__EVENTSType { PyObject_HEAD }; /* "gevent/corecext.pyx":239 * * * cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: # <<<<<<<<<<<<<< * cdef libev.ev_loop* _ptr * cdef public object error_handler */ struct PyGeventLoopObject { PyObject_HEAD struct __pyx_vtabstruct_6gevent_8corecext_loop *__pyx_vtab; struct ev_loop *_ptr; PyObject *error_handler; struct ev_prepare _prepare; PyObject *_callbacks; struct ev_timer _timer0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) struct ev_timer _periodic_signal_checker; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type; /* "gevent/corecext.pyx":617 * * * cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: # <<<<<<<<<<<<<< * cdef public object callback * cdef public tuple args */ struct PyGeventCallbackObject { PyObject_HEAD PyObject *callback; PyObject *args; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCallback_Type; /* "gevent/corecext.pyx":685 * * * cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: # <<<<<<<<<<<<<< * """Abstract base class for all the watchers""" * */ struct PyGeventWatcherObject { PyObject_HEAD }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventWatcher_Type; /* "gevent/corecext.pyx":710 * * * cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventIOObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_io _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIO_Type; /* "gevent/corecext.pyx":895 * * * cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventTimerObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_timer _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventTimer_Type; /* "gevent/corecext.pyx":1040 * * * cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventSignalObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_signal _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventSignal_Type; /* "gevent/corecext.pyx":1165 * * * cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventIdleObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_idle _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIdle_Type; /* "gevent/corecext.pyx":1284 * * * cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventPrepareObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_prepare _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventPrepare_Type; /* "gevent/corecext.pyx":1403 * * * cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventCheckObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_check _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCheck_Type; /* "gevent/corecext.pyx":1522 * * * cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventForkObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_fork _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventFork_Type; /* "gevent/corecext.pyx":1641 * * * cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventAsyncObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_async _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAsync_Type; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":1767 * * * cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventChildObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_child _watcher; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventChild_Type; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":1912 * * * cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventStatObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_stat _watcher; PyObject *path; PyObject *_paths; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventStat_Type; /* "gevent/corecext.pyx":121 * * * _flags_str2int = dict((string, flag) for (flag, string) in _flags) # <<<<<<<<<<<<<< * * */ struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr { PyObject_HEAD PyObject *__pyx_v_flag; PyObject *__pyx_v_string; }; __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type; /* "gevent/corecext.pyx":239 * * * cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: # <<<<<<<<<<<<<< * cdef libev.ev_loop* _ptr * cdef public object error_handler */ struct __pyx_vtabstruct_6gevent_8corecext_loop { PyObject *(*_run_callbacks)(struct PyGeventLoopObject *); PyObject *(*handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); PyObject *(*_default_handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_6gevent_8corecext_loop *__pyx_vtabptr_6gevent_8corecext_loop; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE int __Pyx_IterFinish(void); static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyString_Join __Pyx_PyBytes_Join #define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v)) #else #define __Pyx_PyString_Join PyUnicode_Join #define __Pyx_PyBaseString_Join PyUnicode_Join #endif #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION < 3 #define __Pyx_PyBytes_Join _PyString_Join #else #define __Pyx_PyBytes_Join _PyBytes_Join #endif #else static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len)) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) #else #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) #endif static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); #include static int __Pyx_SetVtable(PyObject *dict, void *vtable); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static CYTHON_INLINE vfd_socket_t __Pyx_PyInt_As_vfd_socket_t(PyObject *); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static CYTHON_INLINE PyObject* __Pyx_PyInt_From_vfd_socket_t(vfd_socket_t value); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *); typedef struct { PyObject_HEAD __pyx_coroutine_body_t body; PyObject *closure; PyObject *exc_type; PyObject *exc_value; PyObject *exc_traceback; PyObject *gi_weakreflist; PyObject *classobj; PyObject *yieldfrom; PyObject *gi_name; PyObject *gi_qualname; int resume_label; char is_running; } __pyx_CoroutineObject; static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *closure, PyObject *name, PyObject *qualname); static int __Pyx_Coroutine_clear(PyObject *self); #if 1 || PY_VERSION_HEX < 0x030300B0 static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); #else #define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) #endif static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); static int __Pyx_patch_abc(void); #define __Pyx_Generator_USED static PyTypeObject *__pyx_GeneratorType = 0; #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) #define __Pyx_Generator_New(body, closure, name, qualname)\ __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname) static PyObject *__Pyx_Generator_Next(PyObject *self); static int __pyx_Generator_init(void); static int __Pyx_check_binary_version(void); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static PyObject *__pyx_f_6gevent_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self); /* proto*/ static PyObject *__pyx_f_6gevent_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_6gevent_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'gevent.libev' */ /* Module declarations from 'gevent.python' */ /* Module declarations from 'gevent.corecext' */ static PyTypeObject *__pyx_ptype_6gevent_8corecext__EVENTSType = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_loop = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_callback = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_watcher = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_io = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_timer = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_signal = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_idle = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_prepare = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_check = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_fork = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext_async = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyTypeObject *__pyx_ptype_6gevent_8corecext_child = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyTypeObject *__pyx_ptype_6gevent_8corecext_stat = 0; static PyTypeObject *__pyx_ptype_6gevent_8corecext___pyx_scope_struct__genexpr = 0; static PyObject *__pyx_v_6gevent_8corecext_integer_types = 0; __PYX_EXTERN_C DL_EXPORT(PyObject) *GEVENT_CORE_EVENTS; static int __pyx_v_6gevent_8corecext__default_loop_destroyed; static PyObject *__pyx_f_6gevent_8corecext__flags_to_list(unsigned int, int __pyx_skip_dispatch); /*proto*/ static unsigned int __pyx_f_6gevent_8corecext__flags_to_int(PyObject *, int __pyx_skip_dispatch); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__str_hex(PyObject *); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__check_flags(unsigned int, int __pyx_skip_dispatch); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__events_to_str(int, int __pyx_skip_dispatch); /*proto*/ static void __pyx_f_6gevent_8corecext__syserr_cb(char *); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext_set_syserr_cb(PyObject *, int __pyx_skip_dispatch); /*proto*/ #define __Pyx_MODULE_NAME "gevent.corecext" int __pyx_module_is_main_gevent__corecext = 0; /* Implementation of 'gevent.corecext' */ static PyObject *__pyx_builtin___import__; static PyObject *__pyx_builtin_KeyError; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_hex; static PyObject *__pyx_builtin_SystemError; static PyObject *__pyx_builtin_id; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_builtin_AttributeError; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_builtin_TypeError; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) static PyObject *__pyx_builtin_AttributeError; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_[] = ","; static char __pyx_k__3[] = ", "; static char __pyx_k__4[] = "|"; static char __pyx_k__5[] = ": "; static char __pyx_k_fd[] = "fd"; static char __pyx_k_id[] = "id"; static char __pyx_k_os[] = "os"; static char __pyx_k_tb[] = "tb"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) static char __pyx_k__21[] = "<...>"; static char __pyx_k__22[] = ">"; static char __pyx_k__23[] = ""; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k__21[] = ""; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static char __pyx_k__26[] = "<...>"; static char __pyx_k__27[] = ">"; #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static char __pyx_k__27[] = "<...>"; static char __pyx_k__28[] = ">"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_all[] = "__all__"; static char __pyx_k_hex[] = "hex"; static char __pyx_k_how[] = "how"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_pid[] = "pid"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_ptr[] = "ptr"; static char __pyx_k_ref[] = "ref"; static char __pyx_k_sys[] = "sys"; static char __pyx_k_FORK[] = "FORK"; static char __pyx_k_IDLE[] = "IDLE"; static char __pyx_k_NONE[] = "NONE"; static char __pyx_k_NSIG[] = "NSIG"; static char __pyx_k_READ[] = "READ"; static char __pyx_k_STAT[] = "STAT"; static char __pyx_k_args[] = "args"; static char __pyx_k_func[] = "func"; static char __pyx_k_join[] = "join"; static char __pyx_k_keys[] = "keys"; static char __pyx_k_loop[] = "loop"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_name[] = "__name__"; static char __pyx_k_once[] = "once"; static char __pyx_k_path[] = "path"; static char __pyx_k_poll[] = "poll"; static char __pyx_k_port[] = "port"; static char __pyx_k_send[] = "send"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_time[] = "time"; static char __pyx_k_type[] = "type"; static char __pyx_k_ASYNC[] = "ASYNC"; static char __pyx_k_CHECK[] = "CHECK"; static char __pyx_k_CHILD[] = "CHILD"; static char __pyx_k_EMBED[] = "EMBED"; static char __pyx_k_ERROR[] = "ERROR"; static char __pyx_k_TIMER[] = "TIMER"; static char __pyx_k_UNDEF[] = "UNDEF"; static char __pyx_k_WRITE[] = "WRITE"; static char __pyx_k_after[] = "after"; static char __pyx_k_class[] = "__class__"; static char __pyx_k_close[] = "close"; static char __pyx_k_epoll[] = "epoll"; static char __pyx_k_errno[] = "errno"; static char __pyx_k_flags[] = "_flags"; static char __pyx_k_level[] = "level"; static char __pyx_k_lower[] = "lower"; static char __pyx_k_noenv[] = "noenv"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_ref_2[] = " ref="; static char __pyx_k_sigfd[] = "sigfd"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_split[] = "split"; static char __pyx_k_strip[] = "strip"; static char __pyx_k_throw[] = "throw"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_trace[] = "trace"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_value[] = "value"; static char __pyx_k_CUSTOM[] = "CUSTOM"; static char __pyx_k_EVENTS[] = "EVENTS"; static char __pyx_k_MAXPRI[] = "MAXPRI"; static char __pyx_k_MINPRI[] = "MINPRI"; static char __pyx_k_SIGNAL[] = "SIGNAL"; static char __pyx_k_active[] = "active"; static char __pyx_k_args_r[] = " args=%r"; static char __pyx_k_decode[] = "decode"; static char __pyx_k_encode[] = "encode"; static char __pyx_k_events[] = "_events"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_fileno[] = "fileno"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_format[] = "_format"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_kqueue[] = "kqueue"; static char __pyx_k_nowait[] = "nowait"; static char __pyx_k_repeat[] = "repeat"; static char __pyx_k_select[] = "select"; static char __pyx_k_signal[] = "signal"; static char __pyx_k_signum[] = "signum"; static char __pyx_k_update[] = "update"; static char __pyx_k_CLEANUP[] = "CLEANUP"; static char __pyx_k_IOFDSET[] = "_IOFDSET"; static char __pyx_k_PREPARE[] = "PREPARE"; static char __pyx_k_backend[] = "backend"; static char __pyx_k_context[] = "context"; static char __pyx_k_default[] = "default"; static char __pyx_k_flags_2[] = "flags"; static char __pyx_k_genexpr[] = "genexpr"; static char __pyx_k_message[] = "message"; static char __pyx_k_pending[] = "pending"; static char __pyx_k_revents[] = "revents"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_rstatus[] = "rstatus"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_sigfd_2[] = " sigfd="; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_stopped[] = " stopped"; static char __pyx_k_KeyError[] = "KeyError"; static char __pyx_k_PERIODIC[] = "PERIODIC"; static char __pyx_k_SIGNALFD[] = "SIGNALFD"; static char __pyx_k_active_2[] = " active"; static char __pyx_k_builtins[] = "__builtins__"; static char __pyx_k_callback[] = "callback"; static char __pyx_k_events_2[] = "events"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_fileno_2[] = " fileno="; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_interval[] = "interval"; static char __pyx_k_priority[] = "priority"; static char __pyx_k_signalfd[] = "signalfd"; static char __pyx_k_strerror[] = "strerror"; static char __pyx_k_FORKCHECK[] = "FORKCHECK"; static char __pyx_k_NOINOTIFY[] = "NOINOTIFY"; static char __pyx_k_NOSIGMASK[] = "NOSIGMASK"; static char __pyx_k_READWRITE[] = "READWRITE"; static char __pyx_k_TypeError[] = "TypeError"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_activecnt[] = "activecnt"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_default_2[] = " default"; static char __pyx_k_destroyed[] = "destroyed"; static char __pyx_k_forkcheck[] = "forkcheck"; static char __pyx_k_noinotify[] = "noinotify"; static char __pyx_k_nosigmask[] = "nosigmask"; static char __pyx_k_pending_2[] = " pending"; static char __pyx_k_pending_s[] = " pending=%s"; static char __pyx_k_print_exc[] = "print_exc"; static char __pyx_k_signalnum[] = "signalnum"; static char __pyx_k_traceback[] = "traceback"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_basestring[] = "basestring"; static char __pyx_k_callback_r[] = " callback=%r"; static char __pyx_k_events_str[] = "events_str"; static char __pyx_k_pendingcnt[] = "pendingcnt"; static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static char __pyx_k_LIBEV_EMBED[] = "LIBEV_EMBED"; static char __pyx_k_SystemError[] = "SystemError"; static char __pyx_k_get_version[] = "get_version"; static char __pyx_k_libev_d_02d[] = "libev-%d.%02d"; static char __pyx_k_pass_events[] = "pass_events"; static char __pyx_k_s_at_0x_x_s[] = "<%s at 0x%x %s>"; static char __pyx_k_BACKEND_POLL[] = "BACKEND_POLL"; static char __pyx_k_BACKEND_PORT[] = "BACKEND_PORT"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_EV_USE_4HEAP[] = "EV_USE_4HEAP"; static char __pyx_k_EV_USE_FLOOR[] = "EV_USE_FLOOR"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_handle_error[] = "handle_error"; static char __pyx_k_signalmodule[] = "signalmodule"; static char __pyx_k_version_info[] = "version_info"; static char __pyx_k_BACKEND_EPOLL[] = "BACKEND_EPOLL"; static char __pyx_k_fd_s_events_s[] = " fd=%s events=%s"; static char __pyx_k_flags_str2int[] = "_flags_str2int"; static char __pyx_k_handle_syserr[] = "_handle_syserr"; static char __pyx_k_s_at_0x_x_s_2[] = "<%s at 0x%x%s"; static char __pyx_k_stop_watchers[] = "_stop_watchers"; static char __pyx_k_AttributeError[] = "AttributeError"; static char __pyx_k_BACKEND_KQUEUE[] = "BACKEND_KQUEUE"; static char __pyx_k_BACKEND_SELECT[] = "BACKEND_SELECT"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_EV_USE_EVENTFD[] = "EV_USE_EVENTFD"; static char __pyx_k_EV_USE_INOTIFY[] = "EV_USE_INOTIFY"; static char __pyx_k_format_details[] = "_format_details"; static char __pyx_k_EV_USE_REALTIME[] = "EV_USE_REALTIME"; static char __pyx_k_EV_USE_SIGNALFD[] = "EV_USE_SIGNALFD"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_SYSERR_CALLBACK[] = "__SYSERR_CALLBACK"; static char __pyx_k_gevent_corecext[] = "gevent.corecext"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_pid_r_rstatus_r[] = " pid=%r rstatus=%r"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_print_exception[] = "print_exception"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_EV_USE_MONOTONIC[] = "EV_USE_MONOTONIC"; static char __pyx_k_EV_USE_NANOSLEEP[] = "EV_USE_NANOSLEEP"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_get_header_version[] = "get_header_version"; static char __pyx_k_gevent_core_EVENTS[] = "gevent.core.EVENTS"; static char __pyx_k_supported_backends[] = "supported_backends"; static char __pyx_k_embeddable_backends[] = "embeddable_backends"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static char __pyx_k_EV_USE_CLOCK_SYSCALL[] = "EV_USE_CLOCK_SYSCALL"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_default_handle_error[] = "_default_handle_error"; static char __pyx_k_ev_loop_new_s_failed[] = "ev_loop_new(%s) failed"; static char __pyx_k_illegal_event_mask_r[] = "illegal event mask: %r"; static char __pyx_k_recommended_backends[] = "recommended_backends"; static char __pyx_k_Unsupported_backend_s[] = "Unsupported backend: %s"; static char __pyx_k_getfilesystemencoding[] = "getfilesystemencoding"; static char __pyx_k_Expected_callable_not_r[] = "Expected callable, not %r"; static char __pyx_k_illegal_signal_number_r[] = "illegal signal number: %r"; static char __pyx_k_ev_default_loop_s_failed[] = "ev_default_loop(%s) failed"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_fd_must_be_non_negative_r[] = "fd must be non-negative: %r"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static char __pyx_k_operation_on_destroyed_loop[] = "operation on destroyed loop"; static char __pyx_k_Invalid_value_for_backend_0x_x[] = "Invalid value for backend: 0x%x"; static char __pyx_k_io_watcher_attribute_events_is[] = "'io' watcher attribute 'events' is read-only while watcher is active"; static char __pyx_k_Expected_callable_or_None_got_r[] = "Expected callable or None, got %r"; static char __pyx_k_io_watcher_attribute_fd_is_read[] = "'io' watcher attribute 'fd' is read-only while watcher is active"; static char __pyx_k_private_tmp_gevent_python2_7_ge[] = "/private/tmp/gevent/python2.7/gevent/gevent/corecext.pyx"; static char __pyx_k_repeat_must_be_positive_or_zero[] = "repeat must be positive or zero: %r"; static char __pyx_k_Cannot_set_priority_of_an_active[] = "Cannot set priority of an active watcher"; static char __pyx_k_Invalid_backend_or_flag_s_Possib[] = "Invalid backend or flag: %s\nPossible values: %s"; static char __pyx_k_callback_must_be_callable_not_No[] = "callback must be callable, not None"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static char __pyx_k_child_watchers_are_only_availabl[] = "child watchers are only available on the default loop"; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_kp_s_; static PyObject *__pyx_n_s_ASYNC; static PyObject *__pyx_n_s_AttributeError; static PyObject *__pyx_n_s_BACKEND_EPOLL; static PyObject *__pyx_n_s_BACKEND_KQUEUE; static PyObject *__pyx_n_s_BACKEND_POLL; static PyObject *__pyx_n_s_BACKEND_PORT; static PyObject *__pyx_n_s_BACKEND_SELECT; static PyObject *__pyx_n_s_CHECK; static PyObject *__pyx_n_s_CHILD; static PyObject *__pyx_n_s_CLEANUP; static PyObject *__pyx_n_s_CUSTOM; static PyObject *__pyx_kp_s_Cannot_set_priority_of_an_active; static PyObject *__pyx_n_s_EMBED; static PyObject *__pyx_n_s_ERROR; static PyObject *__pyx_n_s_EVENTS; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_n_s_EV_USE_4HEAP; static PyObject *__pyx_n_s_EV_USE_CLOCK_SYSCALL; static PyObject *__pyx_n_s_EV_USE_EVENTFD; static PyObject *__pyx_n_s_EV_USE_FLOOR; static PyObject *__pyx_n_s_EV_USE_INOTIFY; static PyObject *__pyx_n_s_EV_USE_MONOTONIC; static PyObject *__pyx_n_s_EV_USE_NANOSLEEP; static PyObject *__pyx_n_s_EV_USE_REALTIME; static PyObject *__pyx_n_s_EV_USE_SIGNALFD; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_kp_s_Expected_callable_not_r; static PyObject *__pyx_kp_s_Expected_callable_or_None_got_r; static PyObject *__pyx_n_s_FORK; static PyObject *__pyx_n_s_FORKCHECK; static PyObject *__pyx_n_s_IDLE; static PyObject *__pyx_n_s_IOFDSET; static PyObject *__pyx_kp_s_Invalid_backend_or_flag_s_Possib; static PyObject *__pyx_kp_s_Invalid_value_for_backend_0x_x; static PyObject *__pyx_n_s_KeyError; static PyObject *__pyx_n_s_LIBEV_EMBED; static PyObject *__pyx_n_s_MAXPRI; static PyObject *__pyx_n_s_MINPRI; static PyObject *__pyx_n_s_NOINOTIFY; static PyObject *__pyx_n_s_NONE; static PyObject *__pyx_n_s_NOSIGMASK; static PyObject *__pyx_n_s_NSIG; static PyObject *__pyx_n_s_PERIODIC; static PyObject *__pyx_n_s_PREPARE; static PyObject *__pyx_n_s_READ; static PyObject *__pyx_n_s_READWRITE; static PyObject *__pyx_n_s_SIGNAL; static PyObject *__pyx_n_s_SIGNALFD; static PyObject *__pyx_n_s_STAT; static PyObject *__pyx_n_s_SYSERR_CALLBACK; static PyObject *__pyx_n_s_SystemError; static PyObject *__pyx_n_s_TIMER; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_UNDEF; static PyObject *__pyx_kp_s_Unsupported_backend_s; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_WRITE; static PyObject *__pyx_kp_s__21; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) static PyObject *__pyx_kp_s__22; static PyObject *__pyx_kp_s__23; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_kp_s__26; #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_kp_s__27; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_kp_s__28; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_kp_s__3; static PyObject *__pyx_kp_s__4; static PyObject *__pyx_kp_s__5; static PyObject *__pyx_n_s_active; static PyObject *__pyx_kp_s_active_2; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_n_s_activecnt; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_after; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_args; static PyObject *__pyx_kp_s_args_r; static PyObject *__pyx_n_s_backend; static PyObject *__pyx_n_s_basestring; static PyObject *__pyx_n_s_builtins; static PyObject *__pyx_n_s_callback; static PyObject *__pyx_kp_s_callback_must_be_callable_not_No; static PyObject *__pyx_kp_s_callback_r; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_kp_s_child_watchers_are_only_availabl; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_close; static PyObject *__pyx_n_s_context; static PyObject *__pyx_n_s_decode; static PyObject *__pyx_n_s_default; static PyObject *__pyx_kp_s_default_2; static PyObject *__pyx_n_s_default_handle_error; static PyObject *__pyx_n_s_destroyed; static PyObject *__pyx_n_s_embeddable_backends; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_epoll; static PyObject *__pyx_n_s_errno; static PyObject *__pyx_kp_s_ev_default_loop_s_failed; static PyObject *__pyx_kp_s_ev_loop_new_s_failed; static PyObject *__pyx_n_s_events; static PyObject *__pyx_n_s_events_2; static PyObject *__pyx_n_s_events_str; static PyObject *__pyx_n_s_fd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_kp_s_fd_must_be_non_negative_r; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_kp_s_fd_s_events_s; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_n_s_fileno; static PyObject *__pyx_kp_s_fileno_2; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_flags_2; static PyObject *__pyx_n_s_flags_str2int; static PyObject *__pyx_n_s_forkcheck; static PyObject *__pyx_n_s_format; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_n_s_format_details; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_func; static PyObject *__pyx_n_s_genexpr; static PyObject *__pyx_n_s_get_header_version; static PyObject *__pyx_n_s_get_version; static PyObject *__pyx_n_s_getfilesystemencoding; static PyObject *__pyx_kp_s_gevent_core_EVENTS; static PyObject *__pyx_n_s_gevent_corecext; static PyObject *__pyx_n_s_handle_error; static PyObject *__pyx_n_s_handle_syserr; static PyObject *__pyx_n_s_hex; static PyObject *__pyx_n_s_how; static PyObject *__pyx_n_s_id; static PyObject *__pyx_kp_s_illegal_event_mask_r; static PyObject *__pyx_kp_s_illegal_signal_number_r; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_interval; static PyObject *__pyx_kp_s_io_watcher_attribute_events_is; static PyObject *__pyx_kp_s_io_watcher_attribute_fd_is_read; static PyObject *__pyx_n_s_join; static PyObject *__pyx_n_s_keys; static PyObject *__pyx_n_s_kqueue; static PyObject *__pyx_n_s_level; static PyObject *__pyx_kp_s_libev_d_02d; static PyObject *__pyx_n_s_loop; static PyObject *__pyx_n_s_lower; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_message; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_noenv; static PyObject *__pyx_n_s_noinotify; static PyObject *__pyx_n_s_nosigmask; static PyObject *__pyx_n_s_nowait; static PyObject *__pyx_n_s_once; static PyObject *__pyx_kp_s_operation_on_destroyed_loop; static PyObject *__pyx_n_s_os; static PyObject *__pyx_n_s_pass_events; static PyObject *__pyx_n_s_path; static PyObject *__pyx_n_s_pending; static PyObject *__pyx_kp_s_pending_2; static PyObject *__pyx_kp_s_pending_s; static PyObject *__pyx_n_s_pendingcnt; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_n_s_pid; static PyObject *__pyx_kp_s_pid_r_rstatus_r; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_poll; static PyObject *__pyx_n_s_port; static PyObject *__pyx_n_s_print_exc; static PyObject *__pyx_n_s_print_exception; static PyObject *__pyx_n_s_priority; static PyObject *__pyx_kp_s_private_tmp_gevent_python2_7_ge; static PyObject *__pyx_n_s_ptr; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_recommended_backends; static PyObject *__pyx_n_s_ref; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_kp_s_ref_2; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_repeat; static PyObject *__pyx_kp_s_repeat_must_be_positive_or_zero; static PyObject *__pyx_n_s_revents; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_n_s_rstatus; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_kp_s_s_at_0x_x_s; static PyObject *__pyx_kp_s_s_at_0x_x_s_2; static PyObject *__pyx_n_s_select; static PyObject *__pyx_n_s_send; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_n_s_sigfd; static PyObject *__pyx_kp_s_sigfd_2; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_signal; static PyObject *__pyx_n_s_signalfd; static PyObject *__pyx_n_s_signalmodule; static PyObject *__pyx_n_s_signalnum; static PyObject *__pyx_n_s_signum; static PyObject *__pyx_n_s_split; static PyObject *__pyx_n_s_stop_watchers; static PyObject *__pyx_kp_s_stopped; static PyObject *__pyx_n_s_strerror; static PyObject *__pyx_n_s_strip; static PyObject *__pyx_n_s_supported_backends; static PyObject *__pyx_n_s_sys; static PyObject *__pyx_n_s_tb; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_throw; static PyObject *__pyx_n_s_time; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_n_s_trace; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_n_s_traceback; static PyObject *__pyx_n_s_type; static PyObject *__pyx_n_s_update; static PyObject *__pyx_n_s_value; static PyObject *__pyx_n_s_version_info; static PyObject *__pyx_pf_6gevent_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_8corecext__EVENTSType *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4loop___init__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, size_t __pyx_v_ptr); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_2_stop_watchers(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static void __pyx_pf_6gevent_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_28update(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_pf_6gevent_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_46async(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_52stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_54run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_56_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_58_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_60fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_pf_6gevent_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7watcher___repr__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7watcher_2_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_3ref___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_3ref_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_8callback___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_8callback_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_stop(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_8priority___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_8priority_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_2feed(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_4start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_6active___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_7pending___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static int __pyx_pf_6gevent_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static int __pyx_pf_6gevent_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_pf_6gevent_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static int __pyx_pf_6gevent_8corecext_2io_10__cinit__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static void __pyx_pf_6gevent_8corecext_2io_12__dealloc__(struct PyGeventIOObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_pf_6gevent_8corecext_2io_4loop___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_4loop_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_4loop_4__del__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_4args___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_4args_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_2io_4args_4__del__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_2io_6_flags___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_3ref___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_3ref_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_8callback___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_8callback_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_stop(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_8priority___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_8priority_2__set__(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_2feed(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_6active___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_7pending___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_6__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_8again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_4loop___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_4loop_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_4loop_4__del__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_4args___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_4args_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5timer_4args_4__del__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5timer_6_flags___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_3ref___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_3ref_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_8callback___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_8callback_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_stop(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_8priority___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_8priority_2__set__(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_2feed(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_4start(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_6active___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_7pending___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_6__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_4loop___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_4loop_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_4loop_4__del__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_4args___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_4args_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_6signal_4args_4__del__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_6signal_6_flags___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_3ref___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_3ref_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_8callback___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_8callback_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_stop(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_8priority___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_8priority_2__set__(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_2feed(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_4start(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_6active___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_7pending___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_6__init__(struct PyGeventIdleObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_4loop___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_4loop_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_4loop_4__del__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_4args___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_4args_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4idle_4args_4__del__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4idle_6_flags___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_3ref___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_3ref_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_8callback___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_8callback_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_stop(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_8priority___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_8priority_2__set__(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_2feed(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4start(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_6active___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_7pending___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_6__init__(struct PyGeventPrepareObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4loop___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_4loop_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_4loop_4__del__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4args___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_4args_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_7prepare_4args_4__del__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_7prepare_6_flags___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_3ref___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_3ref_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_8callback___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_8callback_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_stop(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_8priority___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_8priority_2__set__(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_2feed(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_4start(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_6active___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_7pending___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_6__init__(struct PyGeventCheckObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_4loop___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_4loop_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_4loop_4__del__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_4args___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_4args_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5check_4args_4__del__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5check_6_flags___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_3ref___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_3ref_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_8callback___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_8callback_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_stop(struct PyGeventForkObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_8priority___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_8priority_2__set__(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_2feed(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_4start(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_6active___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_7pending___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_6__init__(struct PyGeventForkObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_4loop___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_4loop_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_4loop_4__del__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_4args___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_4args_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4fork_4args_4__del__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4fork_6_flags___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_3ref___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_3ref_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_8callback___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_8callback_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_stop(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_8priority___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_8priority_2__set__(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_2feed(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_4start(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_6active___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_7pending___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_6__init__(struct PyGeventAsyncObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_8send(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_4loop___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_4loop_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_4loop_4__del__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_4args___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_4args_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5async_4args_4__del__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5async_6_flags___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_5child_3ref___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_3ref_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_8callback___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_8callback_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_stop(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_8priority___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_8priority_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_2feed(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_4start(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_6active___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_7pending___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_6__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_8_format(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_4loop___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_4loop_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_4loop_4__del__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_4args___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_4args_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_5child_4args_4__del__(struct PyGeventChildObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_5child_6_flags___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_pf_6gevent_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_8callback___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_8callback_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_stop(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_8priority___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_8priority_2__set__(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_2feed(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4start(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_6active___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_7pending___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_6__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4loop___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_4loop_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_4loop_4__del__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4args___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_4args_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_6gevent_8corecext_4stat_4args_4__del__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_6_flags___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6gevent_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback); /* proto */ static PyObject *__pyx_tp_new_6gevent_8corecext__EVENTSType(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_loop(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_callback(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_watcher(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext_async(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_tp_new_6gevent_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_tp_new_6gevent_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6gevent_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_3; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_int_neg_1; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static int __pyx_k__9; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__17; static PyObject *__pyx_tuple__18; static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__23; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__25; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_tuple__26; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) static PyObject *__pyx_tuple__27; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD) static PyObject *__pyx_tuple__28; #endif /* (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_tuple__29; static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__31; static PyObject *__pyx_tuple__32; static PyObject *__pyx_tuple__33; static PyObject *__pyx_tuple__34; static PyObject *__pyx_tuple__35; static PyObject *__pyx_tuple__36; static PyObject *__pyx_tuple__37; static PyObject *__pyx_tuple__38; static PyObject *__pyx_tuple__39; static PyObject *__pyx_tuple__40; static PyObject *__pyx_tuple__41; static PyObject *__pyx_tuple__42; static PyObject *__pyx_tuple__43; static PyObject *__pyx_tuple__44; static PyObject *__pyx_tuple__45; static PyObject *__pyx_tuple__46; static PyObject *__pyx_tuple__47; static PyObject *__pyx_tuple__48; static PyObject *__pyx_tuple__49; static PyObject *__pyx_tuple__50; static PyObject *__pyx_tuple__51; static PyObject *__pyx_tuple__52; static PyObject *__pyx_tuple__53; static PyObject *__pyx_tuple__54; static PyObject *__pyx_tuple__55; static PyObject *__pyx_tuple__56; static PyObject *__pyx_tuple__57; static PyObject *__pyx_tuple__58; static PyObject *__pyx_tuple__59; static PyObject *__pyx_tuple__60; static PyObject *__pyx_tuple__61; static PyObject *__pyx_tuple__62; static PyObject *__pyx_tuple__63; static PyObject *__pyx_tuple__64; static PyObject *__pyx_tuple__65; static PyObject *__pyx_tuple__66; static PyObject *__pyx_tuple__67; static PyObject *__pyx_tuple__68; static PyObject *__pyx_tuple__69; static PyObject *__pyx_tuple__70; static PyObject *__pyx_tuple__71; static PyObject *__pyx_tuple__72; static PyObject *__pyx_tuple__73; static PyObject *__pyx_tuple__74; static PyObject *__pyx_tuple__75; static PyObject *__pyx_tuple__76; static PyObject *__pyx_tuple__77; static PyObject *__pyx_tuple__78; static PyObject *__pyx_tuple__79; static PyObject *__pyx_tuple__80; static PyObject *__pyx_tuple__81; static PyObject *__pyx_tuple__82; static PyObject *__pyx_tuple__83; static PyObject *__pyx_tuple__84; static PyObject *__pyx_tuple__85; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_tuple__86; static PyObject *__pyx_tuple__87; static PyObject *__pyx_tuple__88; static PyObject *__pyx_tuple__89; #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_tuple__90; #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_tuple__91; static PyObject *__pyx_tuple__92; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_codeobj__90; #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_codeobj__91; static PyObject *__pyx_codeobj__92; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_codeobj__93; static PyObject *__pyx_codeobj__94; static PyObject *__pyx_codeobj__95; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_codeobj__96; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_tuple__93; static PyObject *__pyx_tuple__94; static PyObject *__pyx_tuple__95; static PyObject *__pyx_tuple__96; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_codeobj__97; #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_tuple__97; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_codeobj__98; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_codeobj__86; static PyObject *__pyx_codeobj__87; static PyObject *__pyx_codeobj__88; static PyObject *__pyx_codeobj__89; static PyObject *__pyx_codeobj__90; static PyObject *__pyx_codeobj__91; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_codeobj__99; static PyObject *__pyx_codeobj__100; static PyObject *__pyx_codeobj__101; static PyObject *__pyx_codeobj__102; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_codeobj__103; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_gb_6gevent_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* "gevent/corecext.pyx":121 * * * _flags_str2int = dict((string, flag) for (flag, string) in _flags) # <<<<<<<<<<<<<< * * */ static PyObject *__pyx_pf_6gevent_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self) { struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("genexpr", 0); __pyx_cur_scope = (struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)__pyx_tp_new_6gevent_8corecext___pyx_scope_struct__genexpr(__pyx_ptype_6gevent_8corecext___pyx_scope_struct__genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_cur_scope); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gevent_8corecext_24generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gevent_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope = ((struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("None", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; default: /* CPython raises the right error here */ __Pyx_RefNannyFinishContext(); return NULL; } __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = PyDict_New(); if (unlikely(!__pyx_r)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_r); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_flag); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_flag, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_string); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_string, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(PyDict_SetItem(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_string, (PyObject*)__pyx_cur_scope->__pyx_v_flag))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } PyObject *GEVENT_CORE_EVENTS = 0; /* "gevent/corecext.pyx":92 * cdef class _EVENTSType: * * def __repr__(self): # <<<<<<<<<<<<<< * return 'gevent.core.EVENTS' * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_11_EVENTSType___repr__(((struct __pyx_obj_6gevent_8corecext__EVENTSType *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_8corecext__EVENTSType *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/corecext.pyx":93 * * def __repr__(self): * return 'gevent.core.EVENTS' # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_kp_s_gevent_core_EVENTS); __pyx_r = __pyx_kp_s_gevent_core_EVENTS; goto __pyx_L0; /* "gevent/corecext.pyx":92 * cdef class _EVENTSType: * * def __repr__(self): # <<<<<<<<<<<<<< * return 'gevent.core.EVENTS' * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":100 * * * def get_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_1get_version = {"get_version", (PyCFunction)__pyx_pw_6gevent_8corecext_1get_version, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_version (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_get_version(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_version", 0); /* "gevent/corecext.pyx":101 * * def get_version(): * return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_version_major()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(ev_version_minor()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":100 * * * def get_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":104 * * * def get_header_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_3get_header_version = {"get_header_version", (PyCFunction)__pyx_pw_6gevent_8corecext_3get_header_version, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_header_version (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2get_header_version(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_header_version", 0); /* "gevent/corecext.pyx":105 * * def get_header_version(): * return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(EV_VERSION_MAJOR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(EV_VERSION_MINOR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":104 * * * def get_header_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.get_header_version", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":142 * * * cpdef _flags_to_list(unsigned int flags): # <<<<<<<<<<<<<< * cdef list result = [] * for code, value in _flags: */ static PyObject *__pyx_pw_6gevent_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__flags_to_list(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_result = 0; PyObject *__pyx_v_code = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); int __pyx_t_9; int __pyx_t_10; unsigned int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_flags_to_list", 0); /* "gevent/corecext.pyx":143 * * cpdef _flags_to_list(unsigned int flags): * cdef list result = [] # <<<<<<<<<<<<<< * for code, value in _flags: * if flags & code: */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":144 * cpdef _flags_to_list(unsigned int flags): * cdef list result = [] * for code, value in _flags: # <<<<<<<<<<<<<< * if flags & code: * result.append(value) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_code, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6); __pyx_t_6 = 0; /* "gevent/corecext.pyx":145 * cdef list result = [] * for code, value in _flags: * if flags & code: # <<<<<<<<<<<<<< * result.append(value) * flags &= ~code */ __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_code); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_9) { /* "gevent/corecext.pyx":146 * for code, value in _flags: * if flags & code: * result.append(value) # <<<<<<<<<<<<<< * flags &= ~code * if not flags: */ __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_value); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":145 * cdef list result = [] * for code, value in _flags: * if flags & code: # <<<<<<<<<<<<<< * result.append(value) * flags &= ~code */ } /* "gevent/corecext.pyx":147 * if flags & code: * result.append(value) * flags &= ~code # <<<<<<<<<<<<<< * if not flags: * break */ __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_Invert(__pyx_v_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyNumber_InPlaceAnd(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyInt_As_unsigned_int(__pyx_t_5); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_flags = __pyx_t_11; /* "gevent/corecext.pyx":148 * result.append(value) * flags &= ~code * if not flags: # <<<<<<<<<<<<<< * break * if flags: */ __pyx_t_9 = ((!(__pyx_v_flags != 0)) != 0); if (__pyx_t_9) { /* "gevent/corecext.pyx":149 * flags &= ~code * if not flags: * break # <<<<<<<<<<<<<< * if flags: * result.append(flags) */ goto __pyx_L4_break; /* "gevent/corecext.pyx":148 * result.append(value) * flags &= ~code * if not flags: # <<<<<<<<<<<<<< * break * if flags: */ } /* "gevent/corecext.pyx":144 * cpdef _flags_to_list(unsigned int flags): * cdef list result = [] * for code, value in _flags: # <<<<<<<<<<<<<< * if flags & code: * result.append(value) */ } __pyx_L4_break:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":150 * if not flags: * break * if flags: # <<<<<<<<<<<<<< * result.append(flags) * return result */ __pyx_t_9 = (__pyx_v_flags != 0); if (__pyx_t_9) { /* "gevent/corecext.pyx":151 * break * if flags: * result.append(flags) # <<<<<<<<<<<<<< * return result * */ __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":150 * if not flags: * break * if flags: # <<<<<<<<<<<<<< * result.append(flags) * return result */ } /* "gevent/corecext.pyx":152 * if flags: * result.append(flags) * return result # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; /* "gevent/corecext.pyx":142 * * * cpdef _flags_to_list(unsigned int flags): # <<<<<<<<<<<<<< * cdef list result = [] * for code, value in _flags: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_code); __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags) { unsigned int __pyx_v_flags; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_flags_to_list (wrapper)", 0); assert(__pyx_arg_flags); { __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4_flags_to_list(__pyx_self, ((unsigned int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_flags_to_list", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":161 * * * cpdef unsigned int _flags_to_int(object flags) except? -1: # <<<<<<<<<<<<<< * # Note, that order does not matter, libev has its own predefined order * if not flags: */ static PyObject *__pyx_pw_6gevent_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/ static unsigned int __pyx_f_6gevent_8corecext__flags_to_int(PyObject *__pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { unsigned int __pyx_v_result; PyObject *__pyx_v_value = NULL; PyObject *__pyx_v_ex = NULL; unsigned int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; unsigned int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; Py_ssize_t __pyx_t_9; PyObject *(*__pyx_t_10)(PyObject *); PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; int __pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; int __pyx_t_17; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_flags_to_int", 0); __Pyx_INCREF(__pyx_v_flags); /* "gevent/corecext.pyx":163 * cpdef unsigned int _flags_to_int(object flags) except? -1: * # Note, that order does not matter, libev has its own predefined order * if not flags: # <<<<<<<<<<<<<< * return 0 * if isinstance(flags, integer_types): */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_flags); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = ((!__pyx_t_1) != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":164 * # Note, that order does not matter, libev has its own predefined order * if not flags: * return 0 # <<<<<<<<<<<<<< * if isinstance(flags, integer_types): * return flags */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":163 * cpdef unsigned int _flags_to_int(object flags) except? -1: * # Note, that order does not matter, libev has its own predefined order * if not flags: # <<<<<<<<<<<<<< * return 0 * if isinstance(flags, integer_types): */ } /* "gevent/corecext.pyx":165 * if not flags: * return 0 * if isinstance(flags, integer_types): # <<<<<<<<<<<<<< * return flags * cdef unsigned int result = 0 */ __pyx_t_3 = __pyx_v_6gevent_8corecext_integer_types; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":166 * return 0 * if isinstance(flags, integer_types): * return flags # <<<<<<<<<<<<<< * cdef unsigned int result = 0 * try: */ __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_t_4; goto __pyx_L0; /* "gevent/corecext.pyx":165 * if not flags: * return 0 * if isinstance(flags, integer_types): # <<<<<<<<<<<<<< * return flags * cdef unsigned int result = 0 */ } /* "gevent/corecext.pyx":167 * if isinstance(flags, integer_types): * return flags * cdef unsigned int result = 0 # <<<<<<<<<<<<<< * try: * if isinstance(flags, basestring): */ __pyx_v_result = 0; /* "gevent/corecext.pyx":168 * return flags * cdef unsigned int result = 0 * try: # <<<<<<<<<<<<<< * if isinstance(flags, basestring): * flags = flags.split(',') */ { __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); /*try:*/ { /* "gevent/corecext.pyx":169 * cdef unsigned int result = 0 * try: * if isinstance(flags, basestring): # <<<<<<<<<<<<<< * flags = flags.split(',') * for value in flags: */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_basestring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":170 * try: * if isinstance(flags, basestring): * flags = flags.split(',') # <<<<<<<<<<<<<< * for value in flags: * value = value.strip().lower() */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_flags, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_flags, __pyx_t_8); __pyx_t_8 = 0; /* "gevent/corecext.pyx":169 * cdef unsigned int result = 0 * try: * if isinstance(flags, basestring): # <<<<<<<<<<<<<< * flags = flags.split(',') * for value in flags: */ } /* "gevent/corecext.pyx":171 * if isinstance(flags, basestring): * flags = flags.split(',') * for value in flags: # <<<<<<<<<<<<<< * value = value.strip().lower() * if value: */ if (likely(PyList_CheckExact(__pyx_v_flags)) || PyTuple_CheckExact(__pyx_v_flags)) { __pyx_t_8 = __pyx_v_flags; __Pyx_INCREF(__pyx_t_8); __pyx_t_9 = 0; __pyx_t_10 = NULL; } else { __pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_flags); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_8))) { if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":172 * flags = flags.split(',') * for value in flags: * value = value.strip().lower() # <<<<<<<<<<<<<< * if value: * result |= _flags_str2int[value] */ __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_strip); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (__pyx_t_13) { __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_lower); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (__pyx_t_11) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":173 * for value in flags: * value = value.strip().lower() * if value: # <<<<<<<<<<<<<< * result |= _flags_str2int[value] * except KeyError as ex: */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L5_error;} if (__pyx_t_2) { /* "gevent/corecext.pyx":174 * value = value.strip().lower() * if value: * result |= _flags_str2int[value] # <<<<<<<<<<<<<< * except KeyError as ex: * raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) */ __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_result); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = PyObject_GetItem(__pyx_t_12, __pyx_v_value); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L5_error;}; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_InPlaceOr(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_12); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_v_result = __pyx_t_4; /* "gevent/corecext.pyx":173 * for value in flags: * value = value.strip().lower() * if value: # <<<<<<<<<<<<<< * result |= _flags_str2int[value] * except KeyError as ex: */ } /* "gevent/corecext.pyx":171 * if isinstance(flags, basestring): * flags = flags.split(',') * for value in flags: # <<<<<<<<<<<<<< * value = value.strip().lower() * if value: */ } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "gevent/corecext.pyx":168 * return flags * cdef unsigned int result = 0 * try: # <<<<<<<<<<<<<< * if isinstance(flags, basestring): * flags = flags.split(',') */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L12_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* "gevent/corecext.pyx":175 * if value: * result |= _flags_str2int[value] * except KeyError as ex: # <<<<<<<<<<<<<< * raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) * return result */ __pyx_t_14 = PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_14) { __Pyx_AddTraceback("gevent.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_12, &__pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_12); __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __pyx_v_ex = __pyx_t_12; /* "gevent/corecext.pyx":176 * result |= _flags_str2int[value] * except KeyError as ex: * raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) # <<<<<<<<<<<<<< * return result * */ __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_keys); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } if (__pyx_t_15) { __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else { __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} } __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = PySequence_List(__pyx_t_13); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_3 = ((PyObject*)__pyx_t_16); __pyx_t_16 = 0; __pyx_t_17 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __pyx_t_16 = __Pyx_PyString_Join(__pyx_kp_s__3, __pyx_t_3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_ex); __Pyx_GIVEREF(__pyx_v_ex); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ex); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_t_3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_16, 0, 0, 0); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} } goto __pyx_L7_except_error; __pyx_L7_except_error:; /* "gevent/corecext.pyx":168 * return flags * cdef unsigned int result = 0 * try: # <<<<<<<<<<<<<< * if isinstance(flags, basestring): * flags = flags.split(',') */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L12_try_end:; } /* "gevent/corecext.pyx":177 * except KeyError as ex: * raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) * return result # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "gevent/corecext.pyx":161 * * * cpdef unsigned int _flags_to_int(object flags) except? -1: # <<<<<<<<<<<<<< * # Note, that order does not matter, libev has its own predefined order * if not flags: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("gevent.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_flags); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_flags_to_int (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6_flags_to_int(__pyx_self, ((PyObject *)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations unsigned int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_flags_to_int", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":180 * * * cdef str _str_hex(object flag): # <<<<<<<<<<<<<< * if isinstance(flag, integer_types): * return hex(flag) */ static PyObject *__pyx_f_6gevent_8corecext__str_hex(PyObject *__pyx_v_flag) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_str_hex", 0); /* "gevent/corecext.pyx":181 * * cdef str _str_hex(object flag): * if isinstance(flag, integer_types): # <<<<<<<<<<<<<< * return hex(flag) * return str(flag) */ __pyx_t_1 = __pyx_v_6gevent_8corecext_integer_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_flag, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":182 * cdef str _str_hex(object flag): * if isinstance(flag, integer_types): * return hex(flag) # <<<<<<<<<<<<<< * return str(flag) * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_flag); __Pyx_GIVEREF(__pyx_v_flag); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_flag); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":181 * * cdef str _str_hex(object flag): * if isinstance(flag, integer_types): # <<<<<<<<<<<<<< * return hex(flag) * return str(flag) */ } /* "gevent/corecext.pyx":183 * if isinstance(flag, integer_types): * return hex(flag) * return str(flag) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_flag); __Pyx_GIVEREF(__pyx_v_flag); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_flag); __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":180 * * * cdef str _str_hex(object flag): # <<<<<<<<<<<<<< * if isinstance(flag, integer_types): * return hex(flag) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext._str_hex", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":186 * * * cpdef _check_flags(unsigned int flags): # <<<<<<<<<<<<<< * cdef list as_list * flags &= libev.EVBACKEND_MASK */ static PyObject *__pyx_pw_6gevent_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__check_flags(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_as_list = 0; PyObject *__pyx_v_x = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_check_flags", 0); /* "gevent/corecext.pyx":188 * cpdef _check_flags(unsigned int flags): * cdef list as_list * flags &= libev.EVBACKEND_MASK # <<<<<<<<<<<<<< * if not flags: * return */ __pyx_v_flags = (__pyx_v_flags & EVBACKEND_MASK); /* "gevent/corecext.pyx":189 * cdef list as_list * flags &= libev.EVBACKEND_MASK * if not flags: # <<<<<<<<<<<<<< * return * if not (flags & libev.EVBACKEND_ALL): */ __pyx_t_1 = ((!(__pyx_v_flags != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":190 * flags &= libev.EVBACKEND_MASK * if not flags: * return # <<<<<<<<<<<<<< * if not (flags & libev.EVBACKEND_ALL): * raise ValueError('Invalid value for backend: 0x%x' % flags) */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/corecext.pyx":189 * cdef list as_list * flags &= libev.EVBACKEND_MASK * if not flags: # <<<<<<<<<<<<<< * return * if not (flags & libev.EVBACKEND_ALL): */ } /* "gevent/corecext.pyx":191 * if not flags: * return * if not (flags & libev.EVBACKEND_ALL): # <<<<<<<<<<<<<< * raise ValueError('Invalid value for backend: 0x%x' % flags) * if not (flags & libev.ev_supported_backends()): */ __pyx_t_1 = ((!((__pyx_v_flags & EVBACKEND_ALL) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":192 * return * if not (flags & libev.EVBACKEND_ALL): * raise ValueError('Invalid value for backend: 0x%x' % flags) # <<<<<<<<<<<<<< * if not (flags & libev.ev_supported_backends()): * as_list = [_str_hex(x) for x in _flags_to_list(flags)] */ __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":191 * if not flags: * return * if not (flags & libev.EVBACKEND_ALL): # <<<<<<<<<<<<<< * raise ValueError('Invalid value for backend: 0x%x' % flags) * if not (flags & libev.ev_supported_backends()): */ } /* "gevent/corecext.pyx":193 * if not (flags & libev.EVBACKEND_ALL): * raise ValueError('Invalid value for backend: 0x%x' % flags) * if not (flags & libev.ev_supported_backends()): # <<<<<<<<<<<<<< * as_list = [_str_hex(x) for x in _flags_to_list(flags)] * raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) */ __pyx_t_1 = ((!((__pyx_v_flags & ev_supported_backends()) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":194 * raise ValueError('Invalid value for backend: 0x%x' % flags) * if not (flags & libev.ev_supported_backends()): * as_list = [_str_hex(x) for x in _flags_to_list(flags)] # <<<<<<<<<<<<<< * raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) * */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_f_6gevent_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_f_6gevent_8corecext__str_hex(__pyx_v_x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_as_list = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":195 * if not (flags & libev.ev_supported_backends()): * as_list = [_str_hex(x) for x in _flags_to_list(flags)] * raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_as_list); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_backend_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":193 * if not (flags & libev.EVBACKEND_ALL): * raise ValueError('Invalid value for backend: 0x%x' % flags) * if not (flags & libev.ev_supported_backends()): # <<<<<<<<<<<<<< * as_list = [_str_hex(x) for x in _flags_to_list(flags)] * raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) */ } /* "gevent/corecext.pyx":186 * * * cpdef _check_flags(unsigned int flags): # <<<<<<<<<<<<<< * cdef list as_list * flags &= libev.EVBACKEND_MASK */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_as_list); __Pyx_XDECREF(__pyx_v_x); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags) { unsigned int __pyx_v_flags; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_check_flags (wrapper)", 0); assert(__pyx_arg_flags); { __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_8_check_flags(__pyx_self, ((unsigned int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_check_flags", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__check_flags(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":198 * * * cpdef _events_to_str(int events): # <<<<<<<<<<<<<< * cdef list result = [] * cdef int c_flag */ static PyObject *__pyx_pw_6gevent_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext__events_to_str(int __pyx_v_events, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_result = 0; int __pyx_v_c_flag; PyObject *__pyx_v_flag = NULL; PyObject *__pyx_v_string = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_events_to_str", 0); /* "gevent/corecext.pyx":199 * * cpdef _events_to_str(int events): * cdef list result = [] # <<<<<<<<<<<<<< * cdef int c_flag * for (flag, string) in _events: */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":201 * cdef list result = [] * cdef int c_flag * for (flag, string) in _events: # <<<<<<<<<<<<<< * c_flag = flag * if events & c_flag: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_events); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_flag, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_string, __pyx_t_6); __pyx_t_6 = 0; /* "gevent/corecext.pyx":202 * cdef int c_flag * for (flag, string) in _events: * c_flag = flag # <<<<<<<<<<<<<< * if events & c_flag: * result.append(string) */ __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_flag); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_c_flag = __pyx_t_9; /* "gevent/corecext.pyx":203 * for (flag, string) in _events: * c_flag = flag * if events & c_flag: # <<<<<<<<<<<<<< * result.append(string) * events = events & (~c_flag) */ __pyx_t_10 = ((__pyx_v_events & __pyx_v_c_flag) != 0); if (__pyx_t_10) { /* "gevent/corecext.pyx":204 * c_flag = flag * if events & c_flag: * result.append(string) # <<<<<<<<<<<<<< * events = events & (~c_flag) * if not events: */ __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_string); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":205 * if events & c_flag: * result.append(string) * events = events & (~c_flag) # <<<<<<<<<<<<<< * if not events: * break */ __pyx_v_events = (__pyx_v_events & (~__pyx_v_c_flag)); /* "gevent/corecext.pyx":203 * for (flag, string) in _events: * c_flag = flag * if events & c_flag: # <<<<<<<<<<<<<< * result.append(string) * events = events & (~c_flag) */ } /* "gevent/corecext.pyx":206 * result.append(string) * events = events & (~c_flag) * if not events: # <<<<<<<<<<<<<< * break * if events: */ __pyx_t_10 = ((!(__pyx_v_events != 0)) != 0); if (__pyx_t_10) { /* "gevent/corecext.pyx":207 * events = events & (~c_flag) * if not events: * break # <<<<<<<<<<<<<< * if events: * result.append(hex(events)) */ goto __pyx_L4_break; /* "gevent/corecext.pyx":206 * result.append(string) * events = events & (~c_flag) * if not events: # <<<<<<<<<<<<<< * break * if events: */ } /* "gevent/corecext.pyx":201 * cdef list result = [] * cdef int c_flag * for (flag, string) in _events: # <<<<<<<<<<<<<< * c_flag = flag * if events & c_flag: */ } __pyx_L4_break:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":208 * if not events: * break * if events: # <<<<<<<<<<<<<< * result.append(hex(events)) * return '|'.join(result) */ __pyx_t_10 = (__pyx_v_events != 0); if (__pyx_t_10) { /* "gevent/corecext.pyx":209 * break * if events: * result.append(hex(events)) # <<<<<<<<<<<<<< * return '|'.join(result) * */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":208 * if not events: * break * if events: # <<<<<<<<<<<<<< * result.append(hex(events)) * return '|'.join(result) */ } /* "gevent/corecext.pyx":210 * if events: * result.append(hex(events)) * return '|'.join(result) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":198 * * * cpdef _events_to_str(int events): # <<<<<<<<<<<<<< * cdef list result = [] * cdef int c_flag */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_flag); __Pyx_XDECREF(__pyx_v_string); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events) { int __pyx_v_events; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_events_to_str (wrapper)", 0); assert(__pyx_arg_events); { __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_10_events_to_str(__pyx_self, ((int)__pyx_v_events)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_events_to_str", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__events_to_str(__pyx_v_events, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":213 * * * def supported_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_supported_backends()) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_13supported_backends = {"supported_backends", (PyCFunction)__pyx_pw_6gevent_8corecext_13supported_backends, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("supported_backends (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_12supported_backends(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("supported_backends", 0); /* "gevent/corecext.pyx":214 * * def supported_backends(): * return _flags_to_list(libev.ev_supported_backends()) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__flags_to_list(ev_supported_backends(), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":213 * * * def supported_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_supported_backends()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.supported_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":217 * * * def recommended_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_recommended_backends()) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_15recommended_backends = {"recommended_backends", (PyCFunction)__pyx_pw_6gevent_8corecext_15recommended_backends, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("recommended_backends (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_14recommended_backends(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("recommended_backends", 0); /* "gevent/corecext.pyx":218 * * def recommended_backends(): * return _flags_to_list(libev.ev_recommended_backends()) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__flags_to_list(ev_recommended_backends(), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":217 * * * def recommended_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_recommended_backends()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.recommended_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":221 * * * def embeddable_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_embeddable_backends()) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_17embeddable_backends = {"embeddable_backends", (PyCFunction)__pyx_pw_6gevent_8corecext_17embeddable_backends, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("embeddable_backends (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_16embeddable_backends(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("embeddable_backends", 0); /* "gevent/corecext.pyx":222 * * def embeddable_backends(): * return _flags_to_list(libev.ev_embeddable_backends()) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__flags_to_list(ev_embeddable_backends(), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":221 * * * def embeddable_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_embeddable_backends()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.embeddable_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":225 * * * def time(): # <<<<<<<<<<<<<< * return libev.ev_time() * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_8corecext_19time = {"time", (PyCFunction)__pyx_pw_6gevent_8corecext_19time, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("time (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_18time(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("time", 0); /* "gevent/corecext.pyx":226 * * def time(): * return libev.ev_time() # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(ev_time()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":225 * * * def time(): # <<<<<<<<<<<<<< * return libev.ev_time() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.time", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":249 * * * def __init__(self, object flags=None, object default=None, size_t ptr=0): # <<<<<<<<<<<<<< * cdef unsigned int c_flags * cdef object old_handler = None */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4loop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_4loop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_flags = 0; PyObject *__pyx_v_default = 0; size_t __pyx_v_ptr; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags_2,&__pyx_n_s_default,&__pyx_n_s_ptr,0}; PyObject* values[3] = {0,0,0}; values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags_2); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ptr); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_flags = values[0]; __pyx_v_default = values[1]; if (values[2]) { __pyx_v_ptr = __Pyx_PyInt_As_size_t(values[2]); if (unlikely((__pyx_v_ptr == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_ptr = ((size_t)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop___init__(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_flags, __pyx_v_default, __pyx_v_ptr); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4loop___init__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, size_t __pyx_v_ptr) { unsigned int __pyx_v_c_flags; CYTHON_UNUSED PyObject *__pyx_v_old_handler = 0; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; unsigned int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); __Pyx_INCREF(__pyx_v_default); /* "gevent/corecext.pyx":251 * def __init__(self, object flags=None, object default=None, size_t ptr=0): * cdef unsigned int c_flags * cdef object old_handler = None # <<<<<<<<<<<<<< * libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) * */ __Pyx_INCREF(Py_None); __pyx_v_old_handler = Py_None; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":252 * cdef unsigned int c_flags * cdef object old_handler = None * libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":252 * cdef unsigned int c_flags * cdef object old_handler = None * libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) # <<<<<<<<<<<<<< * * libev.ev_timer_init(&self._periodic_signal_checker, gevent_periodic_signal_check, 0.3, 0.3) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) ev_prepare_init((&__pyx_v_self->_prepare), ((void *)gevent_run_callbacks)); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":256 * * * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) # <<<<<<<<<<<<<< * if ptr: * self._ptr = ptr */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":254 * libev.ev_prepare_init(&self._prepare, gevent_run_callbacks) * * libev.ev_timer_init(&self._periodic_signal_checker, gevent_periodic_signal_check, 0.3, 0.3) # <<<<<<<<<<<<<< * * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) */ ev_timer_init((&__pyx_v_self->_periodic_signal_checker), ((void *)gevent_periodic_signal_check), 0.3, 0.3); /* "gevent/corecext.pyx":256 * libev.ev_timer_init(&self._periodic_signal_checker, gevent_periodic_signal_check, 0.3, 0.3) * * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) # <<<<<<<<<<<<<< * if ptr: * self._ptr = ptr */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) ev_timer_init((&__pyx_v_self->_timer0), ((void *)gevent_noop), 0.0, 0.0); /* "gevent/corecext.pyx":257 * * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) * if ptr: # <<<<<<<<<<<<<< * self._ptr = ptr * else: */ __pyx_t_1 = (__pyx_v_ptr != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":258 * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) * if ptr: * self._ptr = ptr # <<<<<<<<<<<<<< * else: * c_flags = _flags_to_int(flags) */ __pyx_v_self->_ptr = ((struct ev_loop *)__pyx_v_ptr); /* "gevent/corecext.pyx":257 * * libev.ev_timer_init(&self._timer0, gevent_noop, 0.0, 0.0) * if ptr: # <<<<<<<<<<<<<< * self._ptr = ptr * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":260 * self._ptr = ptr * else: * c_flags = _flags_to_int(flags) # <<<<<<<<<<<<<< * _check_flags(c_flags) * c_flags |= libev.EVFLAG_NOENV */ /*else*/ { __pyx_t_2 = __pyx_f_6gevent_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_c_flags = __pyx_t_2; /* "gevent/corecext.pyx":261 * else: * c_flags = _flags_to_int(flags) * _check_flags(c_flags) # <<<<<<<<<<<<<< * c_flags |= libev.EVFLAG_NOENV * c_flags |= libev.EVFLAG_FORKCHECK */ __pyx_t_3 = __pyx_f_6gevent_8corecext__check_flags(__pyx_v_c_flags, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":262 * c_flags = _flags_to_int(flags) * _check_flags(c_flags) * c_flags |= libev.EVFLAG_NOENV # <<<<<<<<<<<<<< * c_flags |= libev.EVFLAG_FORKCHECK * if default is None: */ __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_NOENV); /* "gevent/corecext.pyx":263 * _check_flags(c_flags) * c_flags |= libev.EVFLAG_NOENV * c_flags |= libev.EVFLAG_FORKCHECK # <<<<<<<<<<<<<< * if default is None: * default = True */ __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_FORKCHECK); /* "gevent/corecext.pyx":264 * c_flags |= libev.EVFLAG_NOENV * c_flags |= libev.EVFLAG_FORKCHECK * if default is None: # <<<<<<<<<<<<<< * default = True * if _default_loop_destroyed: */ __pyx_t_1 = (__pyx_v_default == Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* "gevent/corecext.pyx":265 * c_flags |= libev.EVFLAG_FORKCHECK * if default is None: * default = True # <<<<<<<<<<<<<< * if _default_loop_destroyed: * default = False */ __Pyx_INCREF(Py_True); __Pyx_DECREF_SET(__pyx_v_default, Py_True); /* "gevent/corecext.pyx":266 * if default is None: * default = True * if _default_loop_destroyed: # <<<<<<<<<<<<<< * default = False * if default: */ __pyx_t_4 = (__pyx_v_6gevent_8corecext__default_loop_destroyed != 0); if (__pyx_t_4) { /* "gevent/corecext.pyx":267 * default = True * if _default_loop_destroyed: * default = False # <<<<<<<<<<<<<< * if default: * self._ptr = libev.gevent_ev_default_loop(c_flags) */ __Pyx_INCREF(Py_False); __Pyx_DECREF_SET(__pyx_v_default, Py_False); /* "gevent/corecext.pyx":266 * if default is None: * default = True * if _default_loop_destroyed: # <<<<<<<<<<<<<< * default = False * if default: */ } /* "gevent/corecext.pyx":264 * c_flags |= libev.EVFLAG_NOENV * c_flags |= libev.EVFLAG_FORKCHECK * if default is None: # <<<<<<<<<<<<<< * default = True * if _default_loop_destroyed: */ } /* "gevent/corecext.pyx":268 * if _default_loop_destroyed: * default = False * if default: # <<<<<<<<<<<<<< * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { /* "gevent/corecext.pyx":269 * default = False * if default: * self._ptr = libev.gevent_ev_default_loop(c_flags) # <<<<<<<<<<<<<< * if not self._ptr: * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) */ __pyx_v_self->_ptr = gevent_ev_default_loop(__pyx_v_c_flags); /* "gevent/corecext.pyx":270 * if default: * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: # <<<<<<<<<<<<<< * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) * */ __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_4) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":271 * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":271 * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) # <<<<<<<<<<<<<< * * libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_default_loop_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":270 * if default: * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: # <<<<<<<<<<<<<< * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) * */ } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":273 * raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) * * libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * */ ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_periodic_signal_checker)); /* "gevent/corecext.pyx":274 * * libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) * libev.ev_unref(self._ptr) # <<<<<<<<<<<<<< * * else: */ ev_unref(__pyx_v_self->_ptr); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":268 * if _default_loop_destroyed: * default = False * if default: # <<<<<<<<<<<<<< * self._ptr = libev.gevent_ev_default_loop(c_flags) * if not self._ptr: */ goto __pyx_L6; } /* "gevent/corecext.pyx":277 * * else: * self._ptr = libev.ev_loop_new(c_flags) # <<<<<<<<<<<<<< * if not self._ptr: * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) */ /*else*/ { __pyx_v_self->_ptr = ev_loop_new(__pyx_v_c_flags); /* "gevent/corecext.pyx":278 * else: * self._ptr = libev.ev_loop_new(c_flags) * if not self._ptr: # <<<<<<<<<<<<<< * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) * if default or __SYSERR_CALLBACK is None: */ __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_4) { /* "gevent/corecext.pyx":279 * self._ptr = libev.ev_loop_new(c_flags) * if not self._ptr: * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) # <<<<<<<<<<<<<< * if default or __SYSERR_CALLBACK is None: * set_syserr_cb(self._handle_syserr) */ __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_loop_new_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":278 * else: * self._ptr = libev.ev_loop_new(c_flags) * if not self._ptr: # <<<<<<<<<<<<<< * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) * if default or __SYSERR_CALLBACK is None: */ } } __pyx_L6:; /* "gevent/corecext.pyx":280 * if not self._ptr: * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) * if default or __SYSERR_CALLBACK is None: # <<<<<<<<<<<<<< * set_syserr_cb(self._handle_syserr) * libev.ev_prepare_start(self._ptr, &self._prepare) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_1) { } else { __pyx_t_4 = __pyx_t_1; goto __pyx_L10_bool_binop_done; } __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = (__pyx_t_3 == Py_None); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (__pyx_t_1 != 0); __pyx_t_4 = __pyx_t_6; __pyx_L10_bool_binop_done:; if (__pyx_t_4) { /* "gevent/corecext.pyx":281 * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) * if default or __SYSERR_CALLBACK is None: * set_syserr_cb(self._handle_syserr) # <<<<<<<<<<<<<< * libev.ev_prepare_start(self._ptr, &self._prepare) * libev.ev_unref(self._ptr) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_f_6gevent_8corecext_set_syserr_cb(__pyx_t_3, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "gevent/corecext.pyx":280 * if not self._ptr: * raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) * if default or __SYSERR_CALLBACK is None: # <<<<<<<<<<<<<< * set_syserr_cb(self._handle_syserr) * libev.ev_prepare_start(self._ptr, &self._prepare) */ } /* "gevent/corecext.pyx":282 * if default or __SYSERR_CALLBACK is None: * set_syserr_cb(self._handle_syserr) * libev.ev_prepare_start(self._ptr, &self._prepare) # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * self._callbacks = [] */ ev_prepare_start(__pyx_v_self->_ptr, (&__pyx_v_self->_prepare)); /* "gevent/corecext.pyx":283 * set_syserr_cb(self._handle_syserr) * libev.ev_prepare_start(self._ptr, &self._prepare) * libev.ev_unref(self._ptr) # <<<<<<<<<<<<<< * self._callbacks = [] * */ ev_unref(__pyx_v_self->_ptr); } __pyx_L3:; /* "gevent/corecext.pyx":284 * libev.ev_prepare_start(self._ptr, &self._prepare) * libev.ev_unref(self._ptr) * self._callbacks = [] # <<<<<<<<<<<<<< * * cdef _run_callbacks(self): */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->_callbacks); __Pyx_DECREF(__pyx_v_self->_callbacks); __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; /* "gevent/corecext.pyx":249 * * * def __init__(self, object flags=None, object default=None, size_t ptr=0): # <<<<<<<<<<<<<< * cdef unsigned int c_flags * cdef object old_handler = None */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_old_handler); __Pyx_XDECREF(__pyx_v_default); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":286 * self._callbacks = [] * * cdef _run_callbacks(self): # <<<<<<<<<<<<<< * cdef callback cb * cdef object callbacks */ static PyObject *__pyx_f_6gevent_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self) { struct PyGeventCallbackObject *__pyx_v_cb = 0; PyObject *__pyx_v_callbacks = 0; int __pyx_v_count; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_run_callbacks", 0); /* "gevent/corecext.pyx":289 * cdef callback cb * cdef object callbacks * cdef int count = 1000 # <<<<<<<<<<<<<< * libev.ev_timer_stop(self._ptr, &self._timer0) * while self._callbacks and count > 0: */ __pyx_v_count = 0x3E8; /* "gevent/corecext.pyx":290 * cdef object callbacks * cdef int count = 1000 * libev.ev_timer_stop(self._ptr, &self._timer0) # <<<<<<<<<<<<<< * while self._callbacks and count > 0: * callbacks = self._callbacks */ ev_timer_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0)); /* "gevent/corecext.pyx":291 * cdef int count = 1000 * libev.ev_timer_stop(self._ptr, &self._timer0) * while self._callbacks and count > 0: # <<<<<<<<<<<<<< * callbacks = self._callbacks * self._callbacks = [] */ while (1) { __pyx_t_2 = (__pyx_v_self->_callbacks != Py_None) && (PyList_GET_SIZE(__pyx_v_self->_callbacks) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = ((__pyx_v_count > 0) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; if (!__pyx_t_1) break; /* "gevent/corecext.pyx":292 * libev.ev_timer_stop(self._ptr, &self._timer0) * while self._callbacks and count > 0: * callbacks = self._callbacks # <<<<<<<<<<<<<< * self._callbacks = [] * for cb in callbacks: */ __pyx_t_3 = __pyx_v_self->_callbacks; __Pyx_INCREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_callbacks, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":293 * while self._callbacks and count > 0: * callbacks = self._callbacks * self._callbacks = [] # <<<<<<<<<<<<<< * for cb in callbacks: * libev.ev_unref(self._ptr) */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_callbacks); __Pyx_DECREF(__pyx_v_self->_callbacks); __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":294 * callbacks = self._callbacks * self._callbacks = [] * for cb in callbacks: # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * gevent_call(self, cb) */ if (likely(PyList_CheckExact(__pyx_v_callbacks)) || PyTuple_CheckExact(__pyx_v_callbacks)) { __pyx_t_3 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_callbacks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif } } else { __pyx_t_6 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_6); } if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6gevent_8corecext_callback))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_cb, ((struct PyGeventCallbackObject *)__pyx_t_6)); __pyx_t_6 = 0; /* "gevent/corecext.pyx":295 * self._callbacks = [] * for cb in callbacks: * libev.ev_unref(self._ptr) # <<<<<<<<<<<<<< * gevent_call(self, cb) * count -= 1 */ ev_unref(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":296 * for cb in callbacks: * libev.ev_unref(self._ptr) * gevent_call(self, cb) # <<<<<<<<<<<<<< * count -= 1 * if self._callbacks: */ gevent_call(__pyx_v_self, __pyx_v_cb); /* "gevent/corecext.pyx":297 * libev.ev_unref(self._ptr) * gevent_call(self, cb) * count -= 1 # <<<<<<<<<<<<<< * if self._callbacks: * libev.ev_timer_start(self._ptr, &self._timer0) */ __pyx_v_count = (__pyx_v_count - 1); /* "gevent/corecext.pyx":294 * callbacks = self._callbacks * self._callbacks = [] * for cb in callbacks: # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * gevent_call(self, cb) */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } /* "gevent/corecext.pyx":298 * gevent_call(self, cb) * count -= 1 * if self._callbacks: # <<<<<<<<<<<<<< * libev.ev_timer_start(self._ptr, &self._timer0) * */ __pyx_t_1 = (__pyx_v_self->_callbacks != Py_None) && (PyList_GET_SIZE(__pyx_v_self->_callbacks) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":299 * count -= 1 * if self._callbacks: * libev.ev_timer_start(self._ptr, &self._timer0) # <<<<<<<<<<<<<< * * def _stop_watchers(self): */ ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0)); /* "gevent/corecext.pyx":298 * gevent_call(self, cb) * count -= 1 * if self._callbacks: # <<<<<<<<<<<<<< * libev.ev_timer_start(self._ptr, &self._timer0) * */ } /* "gevent/corecext.pyx":286 * self._callbacks = [] * * cdef _run_callbacks(self): # <<<<<<<<<<<<<< * cdef callback cb * cdef object callbacks */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent.corecext.loop._run_callbacks", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_cb); __Pyx_XDECREF(__pyx_v_callbacks); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":301 * libev.ev_timer_start(self._ptr, &self._timer0) * * def _stop_watchers(self): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._prepare): * libev.ev_ref(self._ptr) */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_3_stop_watchers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_3_stop_watchers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_stop_watchers (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_2_stop_watchers(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_2_stop_watchers(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("_stop_watchers", 0); /* "gevent/corecext.pyx":302 * * def _stop_watchers(self): * if libev.ev_is_active(&self._prepare): # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * libev.ev_prepare_stop(self._ptr, &self._prepare) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_prepare)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":303 * def _stop_watchers(self): * if libev.ev_is_active(&self._prepare): * libev.ev_ref(self._ptr) # <<<<<<<<<<<<<< * libev.ev_prepare_stop(self._ptr, &self._prepare) * */ ev_ref(__pyx_v_self->_ptr); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":304 * if libev.ev_is_active(&self._prepare): * libev.ev_ref(self._ptr) * libev.ev_prepare_stop(self._ptr, &self._prepare) # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":304 * if libev.ev_is_active(&self._prepare): * libev.ev_ref(self._ptr) * libev.ev_prepare_stop(self._ptr, &self._prepare) # <<<<<<<<<<<<<< * * if libev.ev_is_active(&self._periodic_signal_checker): */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) ev_prepare_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_prepare)); /* "gevent/corecext.pyx":302 * * def _stop_watchers(self): * if libev.ev_is_active(&self._prepare): # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * libev.ev_prepare_stop(self._ptr, &self._prepare) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) } /* "gevent/corecext.pyx":306 * libev.ev_prepare_stop(self._ptr, &self._prepare) * * if libev.ev_is_active(&self._periodic_signal_checker): # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_periodic_signal_checker)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":307 * * if libev.ev_is_active(&self._periodic_signal_checker): * libev.ev_ref(self._ptr) # <<<<<<<<<<<<<< * libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) * */ ev_ref(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":308 * if libev.ev_is_active(&self._periodic_signal_checker): * libev.ev_ref(self._ptr) * libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) # <<<<<<<<<<<<<< * * */ ev_timer_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_periodic_signal_checker)); /* "gevent/corecext.pyx":306 * libev.ev_prepare_stop(self._ptr, &self._prepare) * * if libev.ev_is_active(&self._periodic_signal_checker): # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } /* "gevent/corecext.pyx":301 * libev.ev_timer_start(self._ptr, &self._timer0) * * def _stop_watchers(self): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._prepare): * libev.ev_ref(self._ptr) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":311 * * * def destroy(self): # <<<<<<<<<<<<<< * global _default_loop_destroyed * if self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("destroy (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_4destroy(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("destroy", 0); /* "gevent/corecext.pyx":313 * def destroy(self): * global _default_loop_destroyed * if self._ptr: # <<<<<<<<<<<<<< * self._stop_watchers() * if __SYSERR_CALLBACK == self._handle_syserr: */ __pyx_t_1 = (__pyx_v_self->_ptr != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":314 * global _default_loop_destroyed * if self._ptr: * self._stop_watchers() # <<<<<<<<<<<<<< * if __SYSERR_CALLBACK == self._handle_syserr: * set_syserr_cb(None) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop_watchers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":315 * if self._ptr: * self._stop_watchers() * if __SYSERR_CALLBACK == self._handle_syserr: # <<<<<<<<<<<<<< * set_syserr_cb(None) * if libev.ev_is_default_loop(self._ptr): */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":316 * self._stop_watchers() * if __SYSERR_CALLBACK == self._handle_syserr: * set_syserr_cb(None) # <<<<<<<<<<<<<< * if libev.ev_is_default_loop(self._ptr): * _default_loop_destroyed = True */ __pyx_t_4 = __pyx_f_6gevent_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":315 * if self._ptr: * self._stop_watchers() * if __SYSERR_CALLBACK == self._handle_syserr: # <<<<<<<<<<<<<< * set_syserr_cb(None) * if libev.ev_is_default_loop(self._ptr): */ } /* "gevent/corecext.pyx":317 * if __SYSERR_CALLBACK == self._handle_syserr: * set_syserr_cb(None) * if libev.ev_is_default_loop(self._ptr): # <<<<<<<<<<<<<< * _default_loop_destroyed = True * libev.ev_loop_destroy(self._ptr) */ __pyx_t_1 = (ev_is_default_loop(__pyx_v_self->_ptr) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":318 * set_syserr_cb(None) * if libev.ev_is_default_loop(self._ptr): * _default_loop_destroyed = True # <<<<<<<<<<<<<< * libev.ev_loop_destroy(self._ptr) * self._ptr = NULL */ __pyx_v_6gevent_8corecext__default_loop_destroyed = 1; /* "gevent/corecext.pyx":317 * if __SYSERR_CALLBACK == self._handle_syserr: * set_syserr_cb(None) * if libev.ev_is_default_loop(self._ptr): # <<<<<<<<<<<<<< * _default_loop_destroyed = True * libev.ev_loop_destroy(self._ptr) */ } /* "gevent/corecext.pyx":319 * if libev.ev_is_default_loop(self._ptr): * _default_loop_destroyed = True * libev.ev_loop_destroy(self._ptr) # <<<<<<<<<<<<<< * self._ptr = NULL * */ ev_loop_destroy(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":320 * _default_loop_destroyed = True * libev.ev_loop_destroy(self._ptr) * self._ptr = NULL # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_v_self->_ptr = NULL; /* "gevent/corecext.pyx":313 * def destroy(self): * global _default_loop_destroyed * if self._ptr: # <<<<<<<<<<<<<< * self._stop_watchers() * if __SYSERR_CALLBACK == self._handle_syserr: */ } /* "gevent/corecext.pyx":311 * * * def destroy(self): # <<<<<<<<<<<<<< * global _default_loop_destroyed * if self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext.loop.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":322 * self._ptr = NULL * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._ptr: * self._stop_watchers() */ /* Python wrapper */ static void __pyx_pw_6gevent_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6gevent_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6gevent_8corecext_4loop_6__dealloc__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_6gevent_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "gevent/corecext.pyx":323 * * def __dealloc__(self): * if self._ptr: # <<<<<<<<<<<<<< * self._stop_watchers() * if not libev.ev_is_default_loop(self._ptr): */ __pyx_t_1 = (__pyx_v_self->_ptr != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":324 * def __dealloc__(self): * if self._ptr: * self._stop_watchers() # <<<<<<<<<<<<<< * if not libev.ev_is_default_loop(self._ptr): * libev.ev_loop_destroy(self._ptr) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop_watchers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":325 * if self._ptr: * self._stop_watchers() * if not libev.ev_is_default_loop(self._ptr): # <<<<<<<<<<<<<< * libev.ev_loop_destroy(self._ptr) * self._ptr = NULL */ __pyx_t_1 = ((!(ev_is_default_loop(__pyx_v_self->_ptr) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":326 * self._stop_watchers() * if not libev.ev_is_default_loop(self._ptr): * libev.ev_loop_destroy(self._ptr) # <<<<<<<<<<<<<< * self._ptr = NULL * */ ev_loop_destroy(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":325 * if self._ptr: * self._stop_watchers() * if not libev.ev_is_default_loop(self._ptr): # <<<<<<<<<<<<<< * libev.ev_loop_destroy(self._ptr) * self._ptr = NULL */ } /* "gevent/corecext.pyx":327 * if not libev.ev_is_default_loop(self._ptr): * libev.ev_loop_destroy(self._ptr) * self._ptr = NULL # <<<<<<<<<<<<<< * * property ptr: */ __pyx_v_self->_ptr = NULL; /* "gevent/corecext.pyx":323 * * def __dealloc__(self): * if self._ptr: # <<<<<<<<<<<<<< * self._stop_watchers() * if not libev.ev_is_default_loop(self._ptr): */ } /* "gevent/corecext.pyx":322 * self._ptr = NULL * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._ptr: * self._stop_watchers() */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_WriteUnraisable("gevent.corecext.loop.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* "gevent/corecext.pyx":331 * property ptr: * * def __get__(self): # <<<<<<<<<<<<<< * return self._ptr * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_3ptr___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":332 * * def __get__(self): * return self._ptr # <<<<<<<<<<<<<< * * property WatcherType: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":331 * property ptr: * * def __get__(self): # <<<<<<<<<<<<<< * return self._ptr * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop.ptr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":336 * property WatcherType: * * def __get__(self): # <<<<<<<<<<<<<< * return watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_11WatcherType___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":337 * * def __get__(self): * return watcher # <<<<<<<<<<<<<< * * property MAXPRI: */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_8corecext_watcher)); __pyx_r = ((PyObject *)__pyx_ptype_6gevent_8corecext_watcher); goto __pyx_L0; /* "gevent/corecext.pyx":336 * property WatcherType: * * def __get__(self): # <<<<<<<<<<<<<< * return watcher * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":341 * property MAXPRI: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.EV_MAXPRI * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_6MAXPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":342 * * def __get__(self): * return libev.EV_MAXPRI # <<<<<<<<<<<<<< * * property MINPRI: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":341 * property MAXPRI: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.EV_MAXPRI * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop.MAXPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":346 * property MINPRI: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.EV_MINPRI * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_6MINPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":347 * * def __get__(self): * return libev.EV_MINPRI # <<<<<<<<<<<<<< * * def _handle_syserr(self, message, errno): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":346 * property MINPRI: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.EV_MINPRI * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop.MINPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":349 * return libev.EV_MINPRI * * def _handle_syserr(self, message, errno): # <<<<<<<<<<<<<< * if sys.version_info[0] >= 3: * message = message.decode() */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_message = 0; PyObject *__pyx_v_errno = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_handle_syserr (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_message,&__pyx_n_s_errno,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_errno)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_syserr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_message = values[0]; __pyx_v_errno = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_8_handle_syserr(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_message, __pyx_v_errno); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_handle_syserr", 0); __Pyx_INCREF(__pyx_v_message); /* "gevent/corecext.pyx":350 * * def _handle_syserr(self, message, errno): * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * message = message.decode() * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "gevent/corecext.pyx":351 * def _handle_syserr(self, message, errno): * if sys.version_info[0] >= 3: * message = message.decode() # <<<<<<<<<<<<<< * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_message, __pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":350 * * def _handle_syserr(self, message, errno): * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * message = message.decode() * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) */ } /* "gevent/corecext.pyx":352 * if sys.version_info[0] >= 3: * message = message.decode() * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) # <<<<<<<<<<<<<< * * cpdef handle_error(self, context, type, value, tb): */ __pyx_t_2 = PyNumber_Add(__pyx_v_message, __pyx_kp_s__5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strerror); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_errno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_errno); __Pyx_GIVEREF(__pyx_v_errno); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_errno); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8corecext_loop *)__pyx_v_self->__pyx_vtab)->handle_error(__pyx_v_self, Py_None, __pyx_builtin_SystemError, __pyx_t_5, Py_None, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":349 * return libev.EV_MINPRI * * def _handle_syserr(self, message, errno): # <<<<<<<<<<<<<< * if sys.version_info[0] >= 3: * message = message.decode() */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_message); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":354 * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) * * cpdef handle_error(self, context, type, value, tb): # <<<<<<<<<<<<<< * cdef object handle_error * cdef object error_handler = self.error_handler */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { PyObject *__pyx_v_handle_error = 0; PyObject *__pyx_v_error_handler = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_error", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_11handle_error)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_context); __Pyx_GIVEREF(__pyx_v_context); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); __Pyx_INCREF(__pyx_v_type); __Pyx_GIVEREF(__pyx_v_type); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); __Pyx_INCREF(__pyx_v_tb); __Pyx_GIVEREF(__pyx_v_tb); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/corecext.pyx":356 * cpdef handle_error(self, context, type, value, tb): * cdef object handle_error * cdef object error_handler = self.error_handler # <<<<<<<<<<<<<< * if error_handler is not None: * # we do want to do getattr every time so that setting Hub.handle_error property just works */ __pyx_t_1 = __pyx_v_self->error_handler; __Pyx_INCREF(__pyx_t_1); __pyx_v_error_handler = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/corecext.pyx":357 * cdef object handle_error * cdef object error_handler = self.error_handler * if error_handler is not None: # <<<<<<<<<<<<<< * # we do want to do getattr every time so that setting Hub.handle_error property just works * handle_error = getattr(error_handler, 'handle_error', error_handler) */ __pyx_t_7 = (__pyx_v_error_handler != Py_None); __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* "gevent/corecext.pyx":359 * if error_handler is not None: * # we do want to do getattr every time so that setting Hub.handle_error property just works * handle_error = getattr(error_handler, 'handle_error', error_handler) # <<<<<<<<<<<<<< * handle_error(context, type, value, tb) * else: */ __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_error_handler, __pyx_n_s_handle_error, __pyx_v_error_handler); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_handle_error = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/corecext.pyx":360 * # we do want to do getattr every time so that setting Hub.handle_error property just works * handle_error = getattr(error_handler, 'handle_error', error_handler) * handle_error(context, type, value, tb) # <<<<<<<<<<<<<< * else: * self._default_handle_error(context, type, value, tb) */ __Pyx_INCREF(__pyx_v_handle_error); __pyx_t_2 = __pyx_v_handle_error; __pyx_t_3 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_context); __Pyx_GIVEREF(__pyx_v_context); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); __Pyx_INCREF(__pyx_v_type); __Pyx_GIVEREF(__pyx_v_type); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); __Pyx_INCREF(__pyx_v_tb); __Pyx_GIVEREF(__pyx_v_tb); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":357 * cdef object handle_error * cdef object error_handler = self.error_handler * if error_handler is not None: # <<<<<<<<<<<<<< * # we do want to do getattr every time so that setting Hub.handle_error property just works * handle_error = getattr(error_handler, 'handle_error', error_handler) */ goto __pyx_L3; } /* "gevent/corecext.pyx":362 * handle_error(context, type, value, tb) * else: * self._default_handle_error(context, type, value, tb) # <<<<<<<<<<<<<< * * cpdef _default_handle_error(self, context, type, value, tb): */ /*else*/ { __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_8corecext_loop *)__pyx_v_self->__pyx_vtab)->_default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; /* "gevent/corecext.pyx":354 * self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) * * cpdef handle_error(self, context, type, value, tb): # <<<<<<<<<<<<<< * cdef object handle_error * cdef object error_handler = self.error_handler */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_handle_error); __Pyx_XDECREF(__pyx_v_error_handler); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_context = 0; PyObject *__pyx_v_type = 0; PyObject *__pyx_v_value = 0; PyObject *__pyx_v_tb = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_error (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_error") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_context = values[0]; __pyx_v_type = values[1]; __pyx_v_value = values[2]; __pyx_v_tb = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_10handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_error", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext_4loop_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":364 * self._default_handle_error(context, type, value, tb) * * cpdef _default_handle_error(self, context, type, value, tb): # <<<<<<<<<<<<<< * # note: Hub sets its own error handler so this is not used by gevent * # this is here to make core.loop usable without the rest of gevent */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_default_handle_error", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_default_handle_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_13_default_handle_error)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_context); __Pyx_GIVEREF(__pyx_v_context); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); __Pyx_INCREF(__pyx_v_type); __Pyx_GIVEREF(__pyx_v_type); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); __Pyx_INCREF(__pyx_v_tb); __Pyx_GIVEREF(__pyx_v_tb); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* "gevent/corecext.pyx":367 * # note: Hub sets its own error handler so this is not used by gevent * # this is here to make core.loop usable without the rest of gevent * traceback.print_exception(type, value, tb) # <<<<<<<<<<<<<< * if self._ptr: * libev.ev_break(self._ptr, libev.EVBREAK_ONE) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_print_exception); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_type); __Pyx_GIVEREF(__pyx_v_type); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_type); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_value); __Pyx_INCREF(__pyx_v_tb); __Pyx_GIVEREF(__pyx_v_tb); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":368 * # this is here to make core.loop usable without the rest of gevent * traceback.print_exception(type, value, tb) * if self._ptr: # <<<<<<<<<<<<<< * libev.ev_break(self._ptr, libev.EVBREAK_ONE) * */ __pyx_t_7 = (__pyx_v_self->_ptr != 0); if (__pyx_t_7) { /* "gevent/corecext.pyx":369 * traceback.print_exception(type, value, tb) * if self._ptr: * libev.ev_break(self._ptr, libev.EVBREAK_ONE) # <<<<<<<<<<<<<< * * def run(self, nowait=False, once=False): */ ev_break(__pyx_v_self->_ptr, EVBREAK_ONE); /* "gevent/corecext.pyx":368 * # this is here to make core.loop usable without the rest of gevent * traceback.print_exception(type, value, tb) * if self._ptr: # <<<<<<<<<<<<<< * libev.ev_break(self._ptr, libev.EVBREAK_ONE) * */ } /* "gevent/corecext.pyx":364 * self._default_handle_error(context, type, value, tb) * * cpdef _default_handle_error(self, context, type, value, tb): # <<<<<<<<<<<<<< * # note: Hub sets its own error handler so this is not used by gevent * # this is here to make core.loop usable without the rest of gevent */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_context = 0; PyObject *__pyx_v_type = 0; PyObject *__pyx_v_value = 0; PyObject *__pyx_v_tb = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_default_handle_error (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_default_handle_error") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_context = values[0]; __pyx_v_type = values[1]; __pyx_v_value = values[2]; __pyx_v_tb = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_12_default_handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_default_handle_error", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext_4loop__default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":371 * libev.ev_break(self._ptr, libev.EVBREAK_ONE) * * def run(self, nowait=False, once=False): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_nowait = 0; PyObject *__pyx_v_once = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("run (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nowait,&__pyx_n_s_once,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_False); values[1] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nowait); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_once); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_nowait = values[0]; __pyx_v_once = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("run", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_14run(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_nowait, __pyx_v_once); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once) { unsigned int __pyx_v_flags; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("run", 0); /* "gevent/corecext.pyx":373 * def run(self, nowait=False, once=False): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef unsigned int flags = 0 */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":374 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef unsigned int flags = 0 * if nowait: */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":373 * def run(self, nowait=False, once=False): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef unsigned int flags = 0 */ } /* "gevent/corecext.pyx":375 * if not self._ptr: * raise ValueError('operation on destroyed loop') * cdef unsigned int flags = 0 # <<<<<<<<<<<<<< * if nowait: * flags |= libev.EVRUN_NOWAIT */ __pyx_v_flags = 0; /* "gevent/corecext.pyx":376 * raise ValueError('operation on destroyed loop') * cdef unsigned int flags = 0 * if nowait: # <<<<<<<<<<<<<< * flags |= libev.EVRUN_NOWAIT * if once: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_nowait); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":377 * cdef unsigned int flags = 0 * if nowait: * flags |= libev.EVRUN_NOWAIT # <<<<<<<<<<<<<< * if once: * flags |= libev.EVRUN_ONCE */ __pyx_v_flags = (__pyx_v_flags | EVRUN_NOWAIT); /* "gevent/corecext.pyx":376 * raise ValueError('operation on destroyed loop') * cdef unsigned int flags = 0 * if nowait: # <<<<<<<<<<<<<< * flags |= libev.EVRUN_NOWAIT * if once: */ } /* "gevent/corecext.pyx":378 * if nowait: * flags |= libev.EVRUN_NOWAIT * if once: # <<<<<<<<<<<<<< * flags |= libev.EVRUN_ONCE * with nogil: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_once); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":379 * flags |= libev.EVRUN_NOWAIT * if once: * flags |= libev.EVRUN_ONCE # <<<<<<<<<<<<<< * with nogil: * libev.ev_run(self._ptr, flags) */ __pyx_v_flags = (__pyx_v_flags | EVRUN_ONCE); /* "gevent/corecext.pyx":378 * if nowait: * flags |= libev.EVRUN_NOWAIT * if once: # <<<<<<<<<<<<<< * flags |= libev.EVRUN_ONCE * with nogil: */ } /* "gevent/corecext.pyx":380 * if once: * flags |= libev.EVRUN_ONCE * with nogil: # <<<<<<<<<<<<<< * libev.ev_run(self._ptr, flags) * */ { #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS #endif /*try:*/ { /* "gevent/corecext.pyx":381 * flags |= libev.EVRUN_ONCE * with nogil: * libev.ev_run(self._ptr, flags) # <<<<<<<<<<<<<< * * def reinit(self): */ ev_run(__pyx_v_self->_ptr, __pyx_v_flags); } /* "gevent/corecext.pyx":380 * if once: * flags |= libev.EVRUN_ONCE * with nogil: # <<<<<<<<<<<<<< * libev.ev_run(self._ptr, flags) * */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD Py_BLOCK_THREADS #endif goto __pyx_L8; } __pyx_L8:; } } /* "gevent/corecext.pyx":371 * libev.ev_break(self._ptr, libev.EVBREAK_ONE) * * def run(self, nowait=False, once=False): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":383 * libev.ev_run(self._ptr, flags) * * def reinit(self): # <<<<<<<<<<<<<< * if self._ptr: * libev.ev_loop_fork(self._ptr) */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reinit (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_16reinit(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("reinit", 0); /* "gevent/corecext.pyx":384 * * def reinit(self): * if self._ptr: # <<<<<<<<<<<<<< * libev.ev_loop_fork(self._ptr) * */ __pyx_t_1 = (__pyx_v_self->_ptr != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":385 * def reinit(self): * if self._ptr: * libev.ev_loop_fork(self._ptr) # <<<<<<<<<<<<<< * * def ref(self): */ ev_loop_fork(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":384 * * def reinit(self): * if self._ptr: # <<<<<<<<<<<<<< * libev.ev_loop_fork(self._ptr) * */ } /* "gevent/corecext.pyx":383 * libev.ev_run(self._ptr, flags) * * def reinit(self): # <<<<<<<<<<<<<< * if self._ptr: * libev.ev_loop_fork(self._ptr) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":387 * libev.ev_loop_fork(self._ptr) * * def ref(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ref (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_18ref(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("ref", 0); /* "gevent/corecext.pyx":389 * def ref(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_ref(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":390 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":389 * def ref(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_ref(self._ptr) */ } /* "gevent/corecext.pyx":391 * if not self._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_ref(self._ptr) # <<<<<<<<<<<<<< * * def unref(self): */ ev_ref(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":387 * libev.ev_loop_fork(self._ptr) * * def ref(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.ref", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":393 * libev.ev_ref(self._ptr) * * def unref(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unref (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_20unref(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("unref", 0); /* "gevent/corecext.pyx":395 * def unref(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_unref(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":396 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":395 * def unref(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_unref(self._ptr) */ } /* "gevent/corecext.pyx":397 * if not self._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_unref(self._ptr) # <<<<<<<<<<<<<< * * def break_(self, int how=libev.EVBREAK_ONE): */ ev_unref(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":393 * libev.ev_ref(self._ptr) * * def unref(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.unref", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":399 * libev.ev_unref(self._ptr) * * def break_(self, int how=libev.EVBREAK_ONE): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_how; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("break_ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_how,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_how); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "break_") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } if (values[0]) { __pyx_v_how = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_how == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_how = __pyx_k__9; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("break_", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_22break_(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_how); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("break_", 0); /* "gevent/corecext.pyx":401 * def break_(self, int how=libev.EVBREAK_ONE): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_break(self._ptr, how) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":402 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_break(self._ptr, how) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":401 * def break_(self, int how=libev.EVBREAK_ONE): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_break(self._ptr, how) */ } /* "gevent/corecext.pyx":403 * if not self._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_break(self._ptr, how) # <<<<<<<<<<<<<< * * def verify(self): */ ev_break(__pyx_v_self->_ptr, __pyx_v_how); /* "gevent/corecext.pyx":399 * libev.ev_unref(self._ptr) * * def break_(self, int how=libev.EVBREAK_ONE): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":405 * libev.ev_break(self._ptr, how) * * def verify(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("verify (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_24verify(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("verify", 0); /* "gevent/corecext.pyx":407 * def verify(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_verify(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":408 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_verify(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":407 * def verify(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_verify(self._ptr) */ } /* "gevent/corecext.pyx":409 * if not self._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_verify(self._ptr) # <<<<<<<<<<<<<< * * def now(self): */ ev_verify(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":405 * libev.ev_break(self._ptr, how) * * def verify(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.verify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":411 * libev.ev_verify(self._ptr) * * def now(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("now (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_26now(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("now", 0); /* "gevent/corecext.pyx":413 * def now(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_now(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":414 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_now(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":413 * def now(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_now(self._ptr) */ } /* "gevent/corecext.pyx":415 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return libev.ev_now(self._ptr) # <<<<<<<<<<<<<< * * def update(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyFloat_FromDouble(ev_now(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":411 * libev.ev_verify(self._ptr) * * def now(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.now", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":417 * return libev.ev_now(self._ptr) * * def update(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_29update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_29update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_28update(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_28update(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("update", 0); /* "gevent/corecext.pyx":419 * def update(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_now_update(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":420 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_now_update(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":419 * def update(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_now_update(self._ptr) */ } /* "gevent/corecext.pyx":421 * if not self._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_now_update(self._ptr) # <<<<<<<<<<<<<< * * def __repr__(self): */ ev_now_update(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":417 * return libev.ev_now(self._ptr) * * def update(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.update", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":423 * libev.ev_now_update(self._ptr) * * def __repr__(self): # <<<<<<<<<<<<<< * return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_31__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_31__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_30__repr__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/corecext.pyx":424 * * def __repr__(self): * return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) # <<<<<<<<<<<<<< * * property default: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":423 * libev.ev_now_update(self._ptr) * * def __repr__(self): # <<<<<<<<<<<<<< * return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.loop.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":428 * property default: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_7default___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":430 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return True if libev.ev_is_default_loop(self._ptr) else False */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":431 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return True if libev.ev_is_default_loop(self._ptr) else False * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":430 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return True if libev.ev_is_default_loop(self._ptr) else False */ } /* "gevent/corecext.pyx":432 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return True if libev.ev_is_default_loop(self._ptr) else False # <<<<<<<<<<<<<< * * property iteration: */ __Pyx_XDECREF(__pyx_r); if ((ev_is_default_loop(__pyx_v_self->_ptr) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_2 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_2 = Py_False; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":428 * property default: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.default.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":436 * property iteration: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_9iteration___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":438 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_iteration(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":439 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_iteration(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":438 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_iteration(self._ptr) */ } /* "gevent/corecext.pyx":440 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return libev.ev_iteration(self._ptr) # <<<<<<<<<<<<<< * * property depth: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_iteration(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":436 * property iteration: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.iteration.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":444 * property depth: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_5depth___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":446 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_depth(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":447 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_depth(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":446 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_depth(self._ptr) */ } /* "gevent/corecext.pyx":448 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return libev.ev_depth(self._ptr) # <<<<<<<<<<<<<< * * property backend_int: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_depth(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":444 * property depth: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.depth.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":452 * property backend_int: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_11backend_int___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":454 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_backend(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":455 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_backend(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":454 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_backend(self._ptr) */ } /* "gevent/corecext.pyx":456 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return libev.ev_backend(self._ptr) # <<<<<<<<<<<<<< * * property backend: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_backend(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":452 * property backend_int: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.backend_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":460 * property backend: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_7backend___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self) { unsigned int __pyx_v_backend; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *(*__pyx_t_9)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":462 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef unsigned int backend = libev.ev_backend(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":463 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":462 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef unsigned int backend = libev.ev_backend(self._ptr) */ } /* "gevent/corecext.pyx":464 * if not self._ptr: * raise ValueError('operation on destroyed loop') * cdef unsigned int backend = libev.ev_backend(self._ptr) # <<<<<<<<<<<<<< * for key, value in _flags: * if key == backend: */ __pyx_v_backend = ev_backend(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":465 * raise ValueError('operation on destroyed loop') * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: # <<<<<<<<<<<<<< * if key == backend: * return value */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_7 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_7); __pyx_t_7 = 0; /* "gevent/corecext.pyx":466 * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: * if key == backend: # <<<<<<<<<<<<<< * return value * return backend */ __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyObject_RichCompare(__pyx_v_key, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":467 * for key, value in _flags: * if key == backend: * return value # <<<<<<<<<<<<<< * return backend * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":466 * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: * if key == backend: # <<<<<<<<<<<<<< * return value * return backend */ } /* "gevent/corecext.pyx":465 * raise ValueError('operation on destroyed loop') * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: # <<<<<<<<<<<<<< * if key == backend: * return value */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":468 * if key == backend: * return value * return backend # <<<<<<<<<<<<<< * * property pendingcnt: */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":460 * property backend: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gevent.corecext.loop.backend.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":472 * property pendingcnt: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_10pendingcnt___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":474 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_pending_count(self._ptr) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":475 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_pending_count(self._ptr) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":474 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return libev.ev_pending_count(self._ptr) */ } /* "gevent/corecext.pyx":476 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return libev.ev_pending_count(self._ptr) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_pending_count(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":472 * property pendingcnt: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.pendingcnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":482 * * * def io(self, int fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * return io(self, fd, events, ref, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":479 * * * def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * return io(self, fd, events, ref, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) int __pyx_v_fd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) vfd_socket_t __pyx_v_fd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) int __pyx_v_events; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("io (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[4] = {0,0,0,0}; values[2] = ((PyObject *)Py_True); values[3] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--; else { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_v_fd = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[0]); if (unlikely((__pyx_v_fd == (vfd_socket_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_v_ref = values[2]; __pyx_v_priority = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_32io(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("io", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":483 * * def io(self, int fd, int events, ref=True, priority=None): * return io(self, fd, events, ref, priority) # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":480 * * def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): * return io(self, fd, events, ref, priority) # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_1 = __Pyx_PyInt_From_vfd_socket_t(__pyx_v_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_1); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority); __pyx_t_1 = 0; __pyx_t_2 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":482 * * * def io(self, int fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * return io(self, fd, events, ref, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":479 * * * def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * return io(self, fd, events, ref, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":486 * * * def timer(self, double after, double repeat=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * return timer(self, after, repeat, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_after; double __pyx_v_repeat; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("timer (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[4] = {0,0,0,0}; values[2] = ((PyObject *)Py_True); values[3] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_repeat); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "timer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_after = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} if (values[1]) { __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_repeat = ((double)0.0); } __pyx_v_ref = values[2]; __pyx_v_priority = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("timer", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_34timer(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("timer", 0); /* "gevent/corecext.pyx":487 * * def timer(self, double after, double repeat=0.0, ref=True, priority=None): * return timer(self, after, repeat, ref, priority) # <<<<<<<<<<<<<< * * def signal(self, int signum, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_after); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_timer), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":486 * * * def timer(self, double after, double repeat=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * return timer(self, after, repeat, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":489 * return timer(self, after, repeat, ref, priority) * * def signal(self, int signum, ref=True, priority=None): # <<<<<<<<<<<<<< * return signal(self, signum, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_signum; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("signal (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signum,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signum)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "signal") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_signum = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_signum == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("signal", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_36signal(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_signum, __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("signal", 0); /* "gevent/corecext.pyx":490 * * def signal(self, int signum, ref=True, priority=None): * return signal(self, signum, ref, priority) # <<<<<<<<<<<<<< * * def idle(self, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_signum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_priority); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_signal), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":489 * return timer(self, after, repeat, ref, priority) * * def signal(self, int signum, ref=True, priority=None): # <<<<<<<<<<<<<< * return signal(self, signum, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":492 * return signal(self, signum, ref, priority) * * def idle(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return idle(self, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("idle (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_True); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "idle") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ref = values[0]; __pyx_v_priority = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("idle", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_38idle(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("idle", 0); /* "gevent/corecext.pyx":493 * * def idle(self, ref=True, priority=None): * return idle(self, ref, priority) # <<<<<<<<<<<<<< * * def prepare(self, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_idle), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":492 * return signal(self, signum, ref, priority) * * def idle(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return idle(self, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":495 * return idle(self, ref, priority) * * def prepare(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return prepare(self, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("prepare (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_True); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prepare") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ref = values[0]; __pyx_v_priority = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("prepare", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_40prepare(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prepare", 0); /* "gevent/corecext.pyx":496 * * def prepare(self, ref=True, priority=None): * return prepare(self, ref, priority) # <<<<<<<<<<<<<< * * def check(self, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_prepare), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":495 * return idle(self, ref, priority) * * def prepare(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return prepare(self, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":498 * return prepare(self, ref, priority) * * def check(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return check(self, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("check (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_True); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ref = values[0]; __pyx_v_priority = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("check", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_42check(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("check", 0); /* "gevent/corecext.pyx":499 * * def check(self, ref=True, priority=None): * return check(self, ref, priority) # <<<<<<<<<<<<<< * * def fork(self, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_check), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":498 * return prepare(self, ref, priority) * * def check(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return check(self, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":501 * return check(self, ref, priority) * * def fork(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return fork(self, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fork (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_True); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fork") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ref = values[0]; __pyx_v_priority = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fork", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_44fork(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("fork", 0); /* "gevent/corecext.pyx":502 * * def fork(self, ref=True, priority=None): * return fork(self, ref, priority) # <<<<<<<<<<<<<< * * def async(self, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_fork), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":501 * return check(self, ref, priority) * * def fork(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return fork(self, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":504 * return fork(self, ref, priority) * * def async(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return async(self, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_47async(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_47async(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("async (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[2] = {0,0}; values[0] = ((PyObject *)Py_True); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "async") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ref = values[0]; __pyx_v_priority = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("async", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.async", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_46async(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_46async(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("async", 0); /* "gevent/corecext.pyx":505 * * def async(self, ref=True, priority=None): * return async(self, ref, priority) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_async), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":504 * return fork(self, ref, priority) * * def async(self, ref=True, priority=None): # <<<<<<<<<<<<<< * return async(self, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.async", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":510 * * * def child(self, int pid, bint trace=0, ref=True): # <<<<<<<<<<<<<< * return child(self, pid, trace, ref) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":518 * * * def stat(self, str path, float interval=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * return stat(self, path, interval, ref, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_pid; int __pyx_v_trace; PyObject *__pyx_v_ref = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("child (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0}; PyObject* values[3] = {0,0,0}; values[2] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trace); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "child") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_pid = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} if (values[1]) { __pyx_v_trace = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_trace = ((int)0); } __pyx_v_ref = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("child", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4loop_48child(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_pid, __pyx_v_trace, __pyx_v_ref); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("child", 0); /* "gevent/corecext.pyx":511 * * def child(self, int pid, bint trace=0, ref=True): * return child(self, pid, trace, ref) # <<<<<<<<<<<<<< * * def install_sigchld(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_trace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_child), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":510 * * * def child(self, int pid, bint trace=0, ref=True): # <<<<<<<<<<<<<< * return child(self, pid, trace, ref) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":513 * return child(self, pid, trace, ref) * * def install_sigchld(self): # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("install_sigchld (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_50install_sigchld(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("install_sigchld", 0); /* "gevent/corecext.pyx":514 * * def install_sigchld(self): * libev.gevent_install_sigchld_handler() # <<<<<<<<<<<<<< * * */ gevent_install_sigchld_handler(); /* "gevent/corecext.pyx":513 * return child(self, pid, trace, ref) * * def install_sigchld(self): # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":518 * * * def stat(self, str path, float interval=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * return stat(self, path, interval, ref, priority) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_53stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_53stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_v_path = 0; float __pyx_v_interval; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stat (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[4] = {0,0,0,0}; values[2] = ((PyObject *)Py_True); values[3] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interval); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stat") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_path = ((PyObject*)values[0]); if (values[1]) { __pyx_v_interval = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_interval = ((float)0.0); } __pyx_v_ref = values[2]; __pyx_v_priority = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("stat", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_52stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_48stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_52stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stat", 0); /* "gevent/corecext.pyx":519 * * def stat(self, str path, float interval=0.0, ref=True, priority=None): * return stat(self, path, interval, ref, priority) # <<<<<<<<<<<<<< * * def run_callback(self, func, *args): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_interval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_path); __Pyx_GIVEREF(__pyx_v_path); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_path); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_ref); __Pyx_INCREF(__pyx_v_priority); __Pyx_GIVEREF(__pyx_v_priority); PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_priority); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_stat), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":518 * * * def stat(self, str path, float interval=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * return stat(self, path, interval, ref, priority) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":521 * return stat(self, path, interval, ref, priority) * * def run_callback(self, func, *args): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_55run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_55run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_v_func = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("run_callback (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "run_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_func = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("run_callback", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_54run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_50run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_54run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pf_6gevent_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) struct PyGeventCallbackObject *__pyx_v_cb = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("run_callback", 0); /* "gevent/corecext.pyx":523 * def run_callback(self, func, *args): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef callback cb = callback(func, args) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":524 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef callback cb = callback(func, args) * self._callbacks.append(cb) */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":523 * def run_callback(self, func, *args): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * cdef callback cb = callback(func, args) */ } /* "gevent/corecext.pyx":525 * if not self._ptr: * raise ValueError('operation on destroyed loop') * cdef callback cb = callback(func, args) # <<<<<<<<<<<<<< * self._callbacks.append(cb) * libev.ev_ref(self._ptr) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_func); __Pyx_GIVEREF(__pyx_v_func); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_func); __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_args); __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext_callback), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_cb = ((struct PyGeventCallbackObject *)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":526 * raise ValueError('operation on destroyed loop') * cdef callback cb = callback(func, args) * self._callbacks.append(cb) # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * return cb */ if (unlikely(__pyx_v_self->_callbacks == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_callbacks, ((PyObject *)__pyx_v_cb)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":527 * cdef callback cb = callback(func, args) * self._callbacks.append(cb) * libev.ev_ref(self._ptr) # <<<<<<<<<<<<<< * return cb * */ ev_ref(__pyx_v_self->_ptr); /* "gevent/corecext.pyx":528 * self._callbacks.append(cb) * libev.ev_ref(self._ptr) * return cb # <<<<<<<<<<<<<< * * def _format(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_cb)); __pyx_r = ((PyObject *)__pyx_v_cb); goto __pyx_L0; /* "gevent/corecext.pyx":521 * return stat(self, path, interval, ref, priority) * * def run_callback(self, func, *args): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_cb); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":530 * return cb * * def _format(self): # <<<<<<<<<<<<<< * if not self._ptr: * return 'destroyed' */ /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_57_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_57_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format (wrapper)", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_56_format(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_56_format(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_52_format(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyObject *__pyx_v_msg = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_t_4 = NULL; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_format", 0); /* "gevent/corecext.pyx":531 * * def _format(self): * if not self._ptr: # <<<<<<<<<<<<<< * return 'destroyed' * cdef object msg = self.backend */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":532 * def _format(self): * if not self._ptr: * return 'destroyed' # <<<<<<<<<<<<<< * cdef object msg = self.backend * if self.default: */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_destroyed); __pyx_r = __pyx_n_s_destroyed; goto __pyx_L0; /* "gevent/corecext.pyx":531 * * def _format(self): * if not self._ptr: # <<<<<<<<<<<<<< * return 'destroyed' * cdef object msg = self.backend */ } /* "gevent/corecext.pyx":533 * if not self._ptr: * return 'destroyed' * cdef object msg = self.backend # <<<<<<<<<<<<<< * if self.default: * msg += ' default' */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/corecext.pyx":534 * return 'destroyed' * cdef object msg = self.backend * if self.default: # <<<<<<<<<<<<<< * msg += ' default' * msg += ' pending=%s' % self.pendingcnt */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_default); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":535 * cdef object msg = self.backend * if self.default: * msg += ' default' # <<<<<<<<<<<<<< * msg += ' pending=%s' % self.pendingcnt * */ __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_kp_s_default_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":534 * return 'destroyed' * cdef object msg = self.backend * if self.default: # <<<<<<<<<<<<<< * msg += ' default' * msg += ' pending=%s' % self.pendingcnt */ } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":536 * if self.default: * msg += ' default' * msg += ' pending=%s' % self.pendingcnt # <<<<<<<<<<<<<< * * */ #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":536 * if self.default: * msg += ' default' * msg += ' pending=%s' % self.pendingcnt # <<<<<<<<<<<<<< * * msg += self._format_details() */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pendingcnt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_pending_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2); __pyx_t_2 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":540 * * * return msg # <<<<<<<<<<<<<< * * */ #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":538 * msg += ' pending=%s' % self.pendingcnt * * msg += self._format_details() # <<<<<<<<<<<<<< * * return msg */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format_details); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":540 * msg += self._format_details() * * return msg # <<<<<<<<<<<<<< * * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_msg); __pyx_r = __pyx_v_msg; goto __pyx_L0; /* "gevent/corecext.pyx":530 * return cb * * def _format(self): # <<<<<<<<<<<<<< * if not self._ptr: * return 'destroyed' */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_XDECREF(__pyx_t_4); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_AddTraceback("gevent.corecext.loop._format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":544 * * * def _format_details(self): # <<<<<<<<<<<<<< * cdef str msg = '' * cdef object fileno = self.fileno() */ /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_59_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_59_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format_details (wrapper)", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_58_format_details(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_58_format_details(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_54_format_details(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_v_msg = 0; PyObject *__pyx_v_fileno = 0; PyObject *__pyx_v_sigfd = 0; PyObject *__pyx_v_activecnt = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_format_details", 0); /* "gevent/corecext.pyx":545 * * def _format_details(self): * cdef str msg = '' # <<<<<<<<<<<<<< * cdef object fileno = self.fileno() * cdef object sigfd = None */ __Pyx_INCREF(__pyx_kp_s__21); __pyx_v_msg = __pyx_kp_s__21; /* "gevent/corecext.pyx":546 * def _format_details(self): * cdef str msg = '' * cdef object fileno = self.fileno() # <<<<<<<<<<<<<< * cdef object sigfd = None * cdef object activecnt = None */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_fileno = __pyx_t_1; __pyx_t_1 = 0; /* "gevent/corecext.pyx":547 * cdef str msg = '' * cdef object fileno = self.fileno() * cdef object sigfd = None # <<<<<<<<<<<<<< * cdef object activecnt = None * try: */ __Pyx_INCREF(Py_None); __pyx_v_sigfd = Py_None; /* "gevent/corecext.pyx":548 * cdef object fileno = self.fileno() * cdef object sigfd = None * cdef object activecnt = None # <<<<<<<<<<<<<< * try: * sigfd = self.sigfd */ __Pyx_INCREF(Py_None); __pyx_v_activecnt = Py_None; /* "gevent/corecext.pyx":549 * cdef object sigfd = None * cdef object activecnt = None * try: # <<<<<<<<<<<<<< * sigfd = self.sigfd * except AttributeError: */ { __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "gevent/corecext.pyx":550 * cdef object activecnt = None * try: * sigfd = self.sigfd # <<<<<<<<<<<<<< * except AttributeError: * sigfd = None */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sigfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_sigfd, __pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":549 * cdef object sigfd = None * cdef object activecnt = None * try: # <<<<<<<<<<<<<< * sigfd = self.sigfd * except AttributeError: */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":551 * try: * sigfd = self.sigfd * except AttributeError: # <<<<<<<<<<<<<< * sigfd = None * try: */ __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_7) { __Pyx_AddTraceback("gevent.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); /* "gevent/corecext.pyx":552 * sigfd = self.sigfd * except AttributeError: * sigfd = None # <<<<<<<<<<<<<< * try: * activecnt = self.activecnt */ __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_sigfd, Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* "gevent/corecext.pyx":549 * cdef object sigfd = None * cdef object activecnt = None * try: # <<<<<<<<<<<<<< * sigfd = self.sigfd * except AttributeError: */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L10_try_end:; } /* "gevent/corecext.pyx":553 * except AttributeError: * sigfd = None * try: # <<<<<<<<<<<<<< * activecnt = self.activecnt * except AttributeError: */ { __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_4); /*try:*/ { /* "gevent/corecext.pyx":554 * sigfd = None * try: * activecnt = self.activecnt # <<<<<<<<<<<<<< * except AttributeError: * pass */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_activecnt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L13_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_activecnt, __pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":553 * except AttributeError: * sigfd = None * try: # <<<<<<<<<<<<<< * activecnt = self.activecnt * except AttributeError: */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L20_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":555 * try: * activecnt = self.activecnt * except AttributeError: # <<<<<<<<<<<<<< * pass * if activecnt is not None: */ __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_7) { PyErr_Restore(0,0,0); goto __pyx_L14_exception_handled; } goto __pyx_L15_except_error; __pyx_L15_except_error:; /* "gevent/corecext.pyx":553 * except AttributeError: * sigfd = None * try: # <<<<<<<<<<<<<< * activecnt = self.activecnt * except AttributeError: */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L1_error; __pyx_L14_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); __pyx_L20_try_end:; } /* "gevent/corecext.pyx":557 * except AttributeError: * pass * if activecnt is not None: # <<<<<<<<<<<<<< * msg += ' ref=' + repr(activecnt) * if fileno is not None: */ __pyx_t_8 = (__pyx_v_activecnt != Py_None); __pyx_t_9 = (__pyx_t_8 != 0); if (__pyx_t_9) { /* "gevent/corecext.pyx":558 * pass * if activecnt is not None: * msg += ' ref=' + repr(activecnt) # <<<<<<<<<<<<<< * if fileno is not None: * msg += ' fileno=' + repr(fileno) */ __pyx_t_3 = PyObject_Repr(__pyx_v_activecnt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_kp_s_ref_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "gevent/corecext.pyx":557 * except AttributeError: * pass * if activecnt is not None: # <<<<<<<<<<<<<< * msg += ' ref=' + repr(activecnt) * if fileno is not None: */ } /* "gevent/corecext.pyx":559 * if activecnt is not None: * msg += ' ref=' + repr(activecnt) * if fileno is not None: # <<<<<<<<<<<<<< * msg += ' fileno=' + repr(fileno) * if sigfd is not None and sigfd != -1: */ __pyx_t_9 = (__pyx_v_fileno != Py_None); __pyx_t_8 = (__pyx_t_9 != 0); if (__pyx_t_8) { /* "gevent/corecext.pyx":560 * msg += ' ref=' + repr(activecnt) * if fileno is not None: * msg += ' fileno=' + repr(fileno) # <<<<<<<<<<<<<< * if sigfd is not None and sigfd != -1: * msg += ' sigfd=' + repr(sigfd) */ __pyx_t_3 = PyObject_Repr(__pyx_v_fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_kp_s_fileno_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "gevent/corecext.pyx":559 * if activecnt is not None: * msg += ' ref=' + repr(activecnt) * if fileno is not None: # <<<<<<<<<<<<<< * msg += ' fileno=' + repr(fileno) * if sigfd is not None and sigfd != -1: */ } /* "gevent/corecext.pyx":561 * if fileno is not None: * msg += ' fileno=' + repr(fileno) * if sigfd is not None and sigfd != -1: # <<<<<<<<<<<<<< * msg += ' sigfd=' + repr(sigfd) * return msg */ __pyx_t_9 = (__pyx_v_sigfd != Py_None); __pyx_t_10 = (__pyx_t_9 != 0); if (__pyx_t_10) { } else { __pyx_t_8 = __pyx_t_10; goto __pyx_L24_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_v_sigfd, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __pyx_t_10; __pyx_L24_bool_binop_done:; if (__pyx_t_8) { /* "gevent/corecext.pyx":562 * msg += ' fileno=' + repr(fileno) * if sigfd is not None and sigfd != -1: * msg += ' sigfd=' + repr(sigfd) # <<<<<<<<<<<<<< * return msg * */ __pyx_t_3 = PyObject_Repr(__pyx_v_sigfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_kp_s_sigfd_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "gevent/corecext.pyx":561 * if fileno is not None: * msg += ' fileno=' + repr(fileno) * if sigfd is not None and sigfd != -1: # <<<<<<<<<<<<<< * msg += ' sigfd=' + repr(sigfd) * return msg */ } /* "gevent/corecext.pyx":563 * if sigfd is not None and sigfd != -1: * msg += ' sigfd=' + repr(sigfd) * return msg # <<<<<<<<<<<<<< * * def fileno(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_msg); __pyx_r = __pyx_v_msg; goto __pyx_L0; /* "gevent/corecext.pyx":544 * * * def _format_details(self): # <<<<<<<<<<<<<< * cdef str msg = '' * cdef object fileno = self.fileno() */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_fileno); __Pyx_XDECREF(__pyx_v_sigfd); __Pyx_XDECREF(__pyx_v_activecnt); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":565 * return msg * * def fileno(self): # <<<<<<<<<<<<<< * cdef int fd * if self._ptr: */ /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_61fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_61fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fileno (wrapper)", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_60fileno(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_60fileno(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_56fileno(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) int __pyx_v_fd; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("fileno", 0); /* "gevent/corecext.pyx":567 * def fileno(self): * cdef int fd * if self._ptr: # <<<<<<<<<<<<<< * fd = self._ptr.backend_fd * if fd >= 0: */ __pyx_t_1 = (__pyx_v_self->_ptr != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":568 * cdef int fd * if self._ptr: * fd = self._ptr.backend_fd # <<<<<<<<<<<<<< * if fd >= 0: * return fd */ __pyx_t_2 = __pyx_v_self->_ptr->backend_fd; __pyx_v_fd = __pyx_t_2; /* "gevent/corecext.pyx":569 * if self._ptr: * fd = self._ptr.backend_fd * if fd >= 0: # <<<<<<<<<<<<<< * return fd * */ __pyx_t_1 = ((__pyx_v_fd >= 0) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":570 * fd = self._ptr.backend_fd * if fd >= 0: * return fd # <<<<<<<<<<<<<< * * property activecnt: */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":569 * if self._ptr: * fd = self._ptr.backend_fd * if fd >= 0: # <<<<<<<<<<<<<< * return fd * */ } /* "gevent/corecext.pyx":567 * def fileno(self): * cdef int fd * if self._ptr: # <<<<<<<<<<<<<< * fd = self._ptr.backend_fd * if fd >= 0: */ } /* "gevent/corecext.pyx":565 * return msg * * def fileno(self): # <<<<<<<<<<<<<< * cdef int fd * if self._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.loop.fileno", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":574 * property activecnt: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_9activecnt___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":576 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.activecnt */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":577 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.activecnt * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":576 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.activecnt */ } /* "gevent/corecext.pyx":578 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return self._ptr.activecnt # <<<<<<<<<<<<<< * * property sig_pending: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->activecnt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":574 * property activecnt: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.activecnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":582 * property sig_pending: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_11sig_pending___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":584 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.sig_pending */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":585 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.sig_pending * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":584 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.sig_pending */ } /* "gevent/corecext.pyx":586 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return self._ptr.sig_pending # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->sig_pending); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":582 * property sig_pending: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.sig_pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":600 * property origflags: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":591 * property sigfd: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* Python wrapper */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self) { #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_pw_6gevent_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_9origflags___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_r = __pyx_pf_6gevent_8corecext_4loop_5sigfd___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":593 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.sigfd */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":594 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.sigfd * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":593 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.sigfd */ } /* "gevent/corecext.pyx":595 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return self._ptr.sigfd # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->sigfd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":591 * property sigfd: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.sigfd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":600 * property origflags: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_9origflags___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":602 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return _flags_to_list(self._ptr.origflags) */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":603 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return _flags_to_list(self._ptr.origflags) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":602 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return _flags_to_list(self._ptr.origflags) */ } /* "gevent/corecext.pyx":604 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return _flags_to_list(self._ptr.origflags) # <<<<<<<<<<<<<< * * property origflags_int: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_f_6gevent_8corecext__flags_to_list(__pyx_v_self->_ptr->origflags, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":600 * property origflags: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.origflags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":608 * property origflags_int: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_13origflags_int___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":610 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.origflags */ __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":611 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.origflags * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":610 * def __get__(self): * * if not self._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * return self._ptr.origflags */ } /* "gevent/corecext.pyx":612 * if not self._ptr: * raise ValueError('operation on destroyed loop') * return self._ptr.origflags # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_ptr->origflags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":608 * property origflags_int: * * def __get__(self): # <<<<<<<<<<<<<< * * if not self._ptr: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.loop.origflags_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":241 * cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: * cdef libev.ev_loop* _ptr * cdef public object error_handler # <<<<<<<<<<<<<< * cdef libev.ev_prepare _prepare * cdef public list _callbacks */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_13error_handler___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->error_handler); __pyx_r = __pyx_v_self->error_handler; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_13error_handler_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->error_handler); __Pyx_DECREF(__pyx_v_self->error_handler); __pyx_v_self->error_handler = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_13error_handler_4__del__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->error_handler); __Pyx_DECREF(__pyx_v_self->error_handler); __pyx_v_self->error_handler = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":243 * cdef public object error_handler * cdef libev.ev_prepare _prepare * cdef public list _callbacks # <<<<<<<<<<<<<< * cdef libev.ev_timer _timer0 * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_10_callbacks___get__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callbacks); __pyx_r = __pyx_v_self->_callbacks; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_10_callbacks_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->_callbacks); __Pyx_DECREF(__pyx_v_self->_callbacks); __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.loop._callbacks.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4loop_10_callbacks_4__del__(((struct PyGeventLoopObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callbacks); __Pyx_DECREF(__pyx_v_self->_callbacks); __pyx_v_self->_callbacks = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":621 * cdef public tuple args * * def __init__(self, callback, args): # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_args,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_callback = values[0]; __pyx_v_args = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_8callback___init__(((struct PyGeventCallbackObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":622 * * def __init__(self, callback, args): * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->callback); __Pyx_DECREF(__pyx_v_self->callback); __pyx_v_self->callback = __pyx_v_callback; /* "gevent/corecext.pyx":623 * def __init__(self, callback, args): * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * * def stop(self): */ if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":621 * cdef public tuple args * * def __init__(self, callback, args): # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":625 * self.args = args * * def stop(self): # <<<<<<<<<<<<<< * self.callback = None * self.args = None */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_2stop(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":626 * * def stop(self): * self.callback = None # <<<<<<<<<<<<<< * self.args = None * */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->callback); __Pyx_DECREF(__pyx_v_self->callback); __pyx_v_self->callback = Py_None; /* "gevent/corecext.pyx":627 * def stop(self): * self.callback = None * self.args = None # <<<<<<<<<<<<<< * * # Note, that __nonzero__ and pending are different */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":625 * self.args = args * * def stop(self): # <<<<<<<<<<<<<< * self.callback = None * self.args = None */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":634 * # 'pending' has the same meaning as libev watchers: it is cleared before entering callback * * def __nonzero__(self): # <<<<<<<<<<<<<< * # it's nonzero if it's pending or currently executing * return self.args is not None */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_4__nonzero__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__nonzero__", 0); /* "gevent/corecext.pyx":636 * def __nonzero__(self): * # it's nonzero if it's pending or currently executing * return self.args is not None # <<<<<<<<<<<<<< * * property pending: */ __pyx_t_1 = (__pyx_v_self->args != ((PyObject*)Py_None)); __pyx_r = __pyx_t_1; goto __pyx_L0; /* "gevent/corecext.pyx":634 * # 'pending' has the same meaning as libev watchers: it is cleared before entering callback * * def __nonzero__(self): # <<<<<<<<<<<<<< * # it's nonzero if it's pending or currently executing * return self.args is not None */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":640 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return self.callback is not None * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_7pending___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":641 * * def __get__(self): * return self.callback is not None # <<<<<<<<<<<<<< * * def __repr__(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = (__pyx_v_self->callback != Py_None); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":640 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return self.callback is not None * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.callback.pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":643 * return self.callback is not None * * def __repr__(self): # <<<<<<<<<<<<<< * if Py_ReprEnter(self) != 0: * return "<...>" */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_7__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_7__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_6__repr__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_v_format = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; char const *__pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/corecext.pyx":644 * * def __repr__(self): * if Py_ReprEnter(self) != 0: # <<<<<<<<<<<<<< * return "<...>" * try: */ __pyx_t_1 = ((Py_ReprEnter(((PyObject*)__pyx_v_self)) != 0) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":645 * def __repr__(self): * if Py_ReprEnter(self) != 0: * return "<...>" # <<<<<<<<<<<<<< * try: * format = self._format() */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__21); __pyx_r = __pyx_kp_s__21; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__26); __pyx_r = __pyx_kp_s__26; #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__27); __pyx_r = __pyx_kp_s__27; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) goto __pyx_L0; /* "gevent/corecext.pyx":644 * * def __repr__(self): * if Py_ReprEnter(self) != 0: # <<<<<<<<<<<<<< * return "<...>" * try: */ } /* "gevent/corecext.pyx":646 * if Py_ReprEnter(self) != 0: * return "<...>" * try: # <<<<<<<<<<<<<< * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) */ /*try:*/ { /* "gevent/corecext.pyx":647 * return "<...>" * try: * format = self._format() # <<<<<<<<<<<<<< * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.pending: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_format = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/corecext.pyx":648 * try: * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) # <<<<<<<<<<<<<< * if self.pending: * result += " pending" */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_INCREF(__pyx_v_format); __Pyx_GIVEREF(__pyx_v_format); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_format); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_result = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":649 * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.pending: # <<<<<<<<<<<<<< * result += " pending" * if self.callback is not None: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":650 * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.pending: * result += " pending" # <<<<<<<<<<<<<< * if self.callback is not None: * result += " callback=%r" % (self.callback, ) */ __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":649 * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.pending: # <<<<<<<<<<<<<< * result += " pending" * if self.callback is not None: */ } /* "gevent/corecext.pyx":651 * if self.pending: * result += " pending" * if self.callback is not None: # <<<<<<<<<<<<<< * result += " callback=%r" % (self.callback, ) * if self.args is not None: */ __pyx_t_1 = (__pyx_v_self->callback != Py_None); __pyx_t_5 = (__pyx_t_1 != 0); if (__pyx_t_5) { /* "gevent/corecext.pyx":652 * result += " pending" * if self.callback is not None: * result += " callback=%r" % (self.callback, ) # <<<<<<<<<<<<<< * if self.args is not None: * result += " args=%r" % (self.args, ) */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_self->callback); __Pyx_GIVEREF(__pyx_v_self->callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->callback); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":651 * if self.pending: * result += " pending" * if self.callback is not None: # <<<<<<<<<<<<<< * result += " callback=%r" % (self.callback, ) * if self.args is not None: */ } /* "gevent/corecext.pyx":653 * if self.callback is not None: * result += " callback=%r" % (self.callback, ) * if self.args is not None: # <<<<<<<<<<<<<< * result += " args=%r" % (self.args, ) * if self.callback is None and self.args is None: */ __pyx_t_5 = (__pyx_v_self->args != ((PyObject*)Py_None)); __pyx_t_1 = (__pyx_t_5 != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":654 * result += " callback=%r" % (self.callback, ) * if self.args is not None: * result += " args=%r" % (self.args, ) # <<<<<<<<<<<<<< * if self.callback is None and self.args is None: * result += " stopped" */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_self->args); __Pyx_GIVEREF(__pyx_v_self->args); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->args); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":653 * if self.callback is not None: * result += " callback=%r" % (self.callback, ) * if self.args is not None: # <<<<<<<<<<<<<< * result += " args=%r" % (self.args, ) * if self.callback is None and self.args is None: */ } /* "gevent/corecext.pyx":655 * if self.args is not None: * result += " args=%r" % (self.args, ) * if self.callback is None and self.args is None: # <<<<<<<<<<<<<< * result += " stopped" * return result + ">" */ __pyx_t_5 = (__pyx_v_self->callback == Py_None); __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { } else { __pyx_t_1 = __pyx_t_6; goto __pyx_L11_bool_binop_done; } __pyx_t_6 = (__pyx_v_self->args == ((PyObject*)Py_None)); __pyx_t_5 = (__pyx_t_6 != 0); __pyx_t_1 = __pyx_t_5; __pyx_L11_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":656 * result += " args=%r" % (self.args, ) * if self.callback is None and self.args is None: * result += " stopped" # <<<<<<<<<<<<<< * return result + ">" * finally: */ __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_stopped); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":655 * if self.args is not None: * result += " args=%r" % (self.args, ) * if self.callback is None and self.args is None: # <<<<<<<<<<<<<< * result += " stopped" * return result + ">" */ } /* "gevent/corecext.pyx":657 * if self.callback is None and self.args is None: * result += " stopped" * return result + ">" # <<<<<<<<<<<<<< * finally: * Py_ReprLeave(self) */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__22); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__27); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__28); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L4_return; } /* "gevent/corecext.pyx":659 * return result + ">" * finally: * Py_ReprLeave(self) # <<<<<<<<<<<<<< * * def _format(self): */ /*finally:*/ { /*exception exit:*/{ __pyx_L5_error:; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; { Py_ReprLeave(((PyObject*)__pyx_v_self)); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_15 = __pyx_r; __pyx_r = 0; Py_ReprLeave(((PyObject*)__pyx_v_self)); __pyx_r = __pyx_t_15; __pyx_t_15 = 0; goto __pyx_L0; } } /* "gevent/corecext.pyx":643 * return self.callback is not None * * def __repr__(self): # <<<<<<<<<<<<<< * if Py_ReprEnter(self) != 0: * return "<...>" */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext.callback.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_format); __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":661 * Py_ReprLeave(self) * * def _format(self): # <<<<<<<<<<<<<< * return '' * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_8_format(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format", 0); /* "gevent/corecext.pyx":662 * * def _format(self): * return '' # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__23); __pyx_r = __pyx_kp_s__23; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__21); __pyx_r = __pyx_kp_s__21; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) goto __pyx_L0; /* "gevent/corecext.pyx":661 * Py_ReprLeave(self) * * def _format(self): # <<<<<<<<<<<<<< * return '' * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":618 * * cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: * cdef public object callback # <<<<<<<<<<<<<< * cdef public tuple args * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_8callback___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->callback); __pyx_r = __pyx_v_self->callback; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_8callback_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->callback); __Pyx_DECREF(__pyx_v_self->callback); __pyx_v_self->callback = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_8callback_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->callback); __Pyx_DECREF(__pyx_v_self->callback); __pyx_v_self->callback = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":619 * cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: * cdef public object callback * cdef public tuple args # <<<<<<<<<<<<<< * * def __init__(self, callback, args): */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_4args___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_4args_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.callback.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_8callback_4args_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":688 * """Abstract base class for all the watchers""" * * def __repr__(self): # <<<<<<<<<<<<<< * if Py_ReprEnter(self) != 0: * return "<...>" */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7watcher_1__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7watcher_1__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7watcher___repr__(((struct PyGeventWatcherObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7watcher___repr__(struct PyGeventWatcherObject *__pyx_v_self) { PyObject *__pyx_v_format = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; char const *__pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); /* "gevent/corecext.pyx":689 * * def __repr__(self): * if Py_ReprEnter(self) != 0: # <<<<<<<<<<<<<< * return "<...>" * try: */ __pyx_t_1 = ((Py_ReprEnter(((PyObject*)__pyx_v_self)) != 0) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":690 * def __repr__(self): * if Py_ReprEnter(self) != 0: * return "<...>" # <<<<<<<<<<<<<< * try: * format = self._format() */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__21); __pyx_r = __pyx_kp_s__21; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__26); __pyx_r = __pyx_kp_s__26; #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__27); __pyx_r = __pyx_kp_s__27; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) goto __pyx_L0; /* "gevent/corecext.pyx":689 * * def __repr__(self): * if Py_ReprEnter(self) != 0: # <<<<<<<<<<<<<< * return "<...>" * try: */ } /* "gevent/corecext.pyx":691 * if Py_ReprEnter(self) != 0: * return "<...>" * try: # <<<<<<<<<<<<<< * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) */ /*try:*/ { /* "gevent/corecext.pyx":692 * return "<...>" * try: * format = self._format() # <<<<<<<<<<<<<< * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.active: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_format = __pyx_t_2; __pyx_t_2 = 0; /* "gevent/corecext.pyx":693 * try: * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) # <<<<<<<<<<<<<< * if self.active: * result += " active" */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_INCREF(__pyx_v_format); __Pyx_GIVEREF(__pyx_v_format); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_format); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_result = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":694 * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.active: # <<<<<<<<<<<<<< * result += " active" * if self.pending: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_active); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":695 * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.active: * result += " active" # <<<<<<<<<<<<<< * if self.pending: * result += " pending" */ __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_active_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":694 * format = self._format() * result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) * if self.active: # <<<<<<<<<<<<<< * result += " active" * if self.pending: */ } /* "gevent/corecext.pyx":696 * if self.active: * result += " active" * if self.pending: # <<<<<<<<<<<<<< * result += " pending" * if self.callback is not None: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* "gevent/corecext.pyx":697 * result += " active" * if self.pending: * result += " pending" # <<<<<<<<<<<<<< * if self.callback is not None: * result += " callback=%r" % (self.callback, ) */ __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":696 * if self.active: * result += " active" * if self.pending: # <<<<<<<<<<<<<< * result += " pending" * if self.callback is not None: */ } /* "gevent/corecext.pyx":698 * if self.pending: * result += " pending" * if self.callback is not None: # <<<<<<<<<<<<<< * result += " callback=%r" % (self.callback, ) * if self.args is not None: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = (__pyx_t_4 != Py_None); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = (__pyx_t_1 != 0); if (__pyx_t_5) { /* "gevent/corecext.pyx":699 * result += " pending" * if self.callback is not None: * result += " callback=%r" % (self.callback, ) # <<<<<<<<<<<<<< * if self.args is not None: * result += " args=%r" % (self.args, ) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "gevent/corecext.pyx":698 * if self.pending: * result += " pending" * if self.callback is not None: # <<<<<<<<<<<<<< * result += " callback=%r" % (self.callback, ) * if self.args is not None: */ } /* "gevent/corecext.pyx":700 * if self.callback is not None: * result += " callback=%r" % (self.callback, ) * if self.args is not None: # <<<<<<<<<<<<<< * result += " args=%r" % (self.args, ) * return result + ">" */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = (__pyx_t_2 != Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = (__pyx_t_5 != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":701 * result += " callback=%r" % (self.callback, ) * if self.args is not None: * result += " args=%r" % (self.args, ) # <<<<<<<<<<<<<< * return result + ">" * finally: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "gevent/corecext.pyx":700 * if self.callback is not None: * result += " callback=%r" % (self.callback, ) * if self.args is not None: # <<<<<<<<<<<<<< * result += " args=%r" % (self.args, ) * return result + ">" */ } /* "gevent/corecext.pyx":702 * if self.args is not None: * result += " args=%r" % (self.args, ) * return result + ">" # <<<<<<<<<<<<<< * finally: * Py_ReprLeave(self) */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__22); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__27); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__28); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L5_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L4_return; } /* "gevent/corecext.pyx":704 * return result + ">" * finally: * Py_ReprLeave(self) # <<<<<<<<<<<<<< * * def _format(self): */ /*finally:*/ { /*exception exit:*/{ __pyx_L5_error:; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename; { Py_ReprLeave(((PyObject*)__pyx_v_self)); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_14 = __pyx_r; __pyx_r = 0; Py_ReprLeave(((PyObject*)__pyx_v_self)); __pyx_r = __pyx_t_14; __pyx_t_14 = 0; goto __pyx_L0; } } /* "gevent/corecext.pyx":688 * """Abstract base class for all the watchers""" * * def __repr__(self): # <<<<<<<<<<<<<< * if Py_ReprEnter(self) != 0: * return "<...>" */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext.watcher.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_format); __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":706 * Py_ReprLeave(self) * * def _format(self): # <<<<<<<<<<<<<< * return '' * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7watcher_3_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7watcher_3_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7watcher_2_format(((struct PyGeventWatcherObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7watcher_2_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format", 0); /* "gevent/corecext.pyx":707 * * def _format(self): * return '' # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__23); __pyx_r = __pyx_kp_s__23; #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __Pyx_INCREF(__pyx_kp_s__21); __pyx_r = __pyx_kp_s__21; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) goto __pyx_L0; /* "gevent/corecext.pyx":706 * Py_ReprLeave(self) * * def _format(self): # <<<<<<<<<<<<<< * return '' * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":721 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_3ref___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_3ref___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":722 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":721 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":724 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_3ref_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_3ref_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":726 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":727 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":726 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":728 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":729 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":730 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":729 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":731 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":732 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":731 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":733 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":728 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":735 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":736 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":735 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":737 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":738 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":739 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":740 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":738 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":724 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":744 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_8callback___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_8callback___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":745 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":744 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":747 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_8callback_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_8callback_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":748 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":749 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":748 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":750 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":747 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.io.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":752 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_stop(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_stop(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":754 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":755 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":754 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":756 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":757 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_io_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":758 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_io_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":756 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":759 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_io_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_io_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":760 * self._flags &= ~2 * libev.ev_io_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":761 * libev.ev_io_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":762 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":763 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":764 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":762 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":752 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":768 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_8priority___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_8priority___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":769 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":768 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":771 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.io.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_2io_8priority_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_8priority_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":772 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":773 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":772 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":774 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":771 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":776 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.io.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_2io_2feed(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_2feed(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":778 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":779 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":778 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":780 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":781 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":782 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":783 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":784 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":782 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":785 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":786 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":787 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":788 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args, pass_events=False): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":786 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":776 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":790 * self._flags |= 1 * * def start(self, object callback, *args, pass_events=False): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_pass_events = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_pass_events,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (kw_args == 1) { const Py_ssize_t index = 1; PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); if (value) { values[index] = value; kw_args--; } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; __pyx_v_pass_events = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_2io_4start(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_pass_events, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_4start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":792 * def start(self, object callback, *args, pass_events=False): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":793 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":792 * def start(self, object callback, *args, pass_events=False): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":794 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":795 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * if pass_events: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":794 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":796 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * if pass_events: * self.args = (GEVENT_CORE_EVENTS, ) + args */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":797 * raise TypeError('callback must be callable, not None') * self.callback = callback * if pass_events: # <<<<<<<<<<<<<< * self.args = (GEVENT_CORE_EVENTS, ) + args * else: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_pass_events); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_3) { /* "gevent/corecext.pyx":798 * self.callback = callback * if pass_events: * self.args = (GEVENT_CORE_EVENTS, ) + args # <<<<<<<<<<<<<< * else: * self.args = args */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(GEVENT_CORE_EVENTS); __Pyx_GIVEREF(GEVENT_CORE_EVENTS); PyTuple_SET_ITEM(__pyx_t_2, 0, GEVENT_CORE_EVENTS); __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":797 * raise TypeError('callback must be callable, not None') * self.callback = callback * if pass_events: # <<<<<<<<<<<<<< * self.args = (GEVENT_CORE_EVENTS, ) + args * else: */ goto __pyx_L5; } /* "gevent/corecext.pyx":800 * self.args = (GEVENT_CORE_EVENTS, ) + args * else: * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ /*else*/ { __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; } __pyx_L5:; /* "gevent/corecext.pyx":801 * else: * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":802 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_io_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":803 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_io_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":801 * else: * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":804 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_io_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_io_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":805 * self._flags |= 2 * libev.ev_io_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":806 * libev.ev_io_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":807 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":805 * self._flags |= 2 * libev.ev_io_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":790 * self._flags |= 1 * * def start(self, object callback, *args, pass_events=False): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":811 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_6active___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_6active___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":812 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":811 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":817 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_7pending___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_7pending___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":818 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":817 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":838 * * * def __init__(self, loop loop, int fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * if fd < 0: * raise ValueError('fd must be non-negative: %r' % fd) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":822 * * * def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) int __pyx_v_fd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) vfd_socket_t __pyx_v_fd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) int __pyx_v_events; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)Py_True); values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--; else { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--; else { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_v_fd = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[1]); if (unlikely((__pyx_v_fd == (vfd_socket_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_v_ref = values[3]; __pyx_v_priority = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_r = __pyx_pf_6gevent_8corecext_2io_6__init__(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static int __pyx_pf_6gevent_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static int __pyx_pf_6gevent_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_v_vfd; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":839 * * def __init__(self, loop loop, int fd, int events, ref=True, priority=None): * if fd < 0: # <<<<<<<<<<<<<< * raise ValueError('fd must be non-negative: %r' % fd) * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): */ __pyx_t_1 = ((__pyx_v_fd < 0) != 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":823 * * def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): # <<<<<<<<<<<<<< * raise ValueError('illegal event mask: %r' % events) * cdef int vfd = libev.vfd_open(fd) */ __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) if (__pyx_t_1) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":840 * def __init__(self, loop loop, int fd, int events, ref=True, priority=None): * if fd < 0: * raise ValueError('fd must be non-negative: %r' % fd) # <<<<<<<<<<<<<< * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":824 * def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) # <<<<<<<<<<<<<< * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_fd_must_be_non_negative_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":839 * * def __init__(self, loop loop, int fd, int events, ref=True, priority=None): * if fd < 0: # <<<<<<<<<<<<<< * raise ValueError('fd must be non-negative: %r' % fd) * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): */ } /* "gevent/corecext.pyx":841 * if fd < 0: * raise ValueError('fd must be non-negative: %r' % fd) * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): # <<<<<<<<<<<<<< * raise ValueError('illegal event mask: %r' % events) * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) */ __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":842 * raise ValueError('fd must be non-negative: %r' % fd) * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) * self.loop = loop */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":841 * if fd < 0: * raise ValueError('fd must be non-negative: %r' % fd) * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): # <<<<<<<<<<<<<< * raise ValueError('illegal event mask: %r' % events) * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) */ } /* "gevent/corecext.pyx":843 * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_fd, __pyx_v_events); /* "gevent/corecext.pyx":844 * raise ValueError('illegal event mask: %r' % events) * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":823 * * def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): # <<<<<<<<<<<<<< * raise ValueError('illegal event mask: %r' % events) * cdef int vfd = libev.vfd_open(fd) */ } /* "gevent/corecext.pyx":825 * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) * cdef int vfd = libev.vfd_open(fd) # <<<<<<<<<<<<<< * libev.vfd_free(self._watcher.fd) * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) */ __pyx_t_4 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vfd = __pyx_t_4; /* "gevent/corecext.pyx":826 * raise ValueError('illegal event mask: %r' % events) * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) * self.loop = loop */ vfd_free(__pyx_v_self->_watcher.fd); /* "gevent/corecext.pyx":827 * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_events); /* "gevent/corecext.pyx":828 * libev.vfd_free(self._watcher.fd) * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":845 * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":829 * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) if (__pyx_t_1) { #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":846 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":830 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_v_self->_flags = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":845 * libev.ev_io_init(&self._watcher, gevent_callback_io, fd, events) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L5; } /* "gevent/corecext.pyx":848 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":829 * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, events) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L4; } /* "gevent/corecext.pyx":832 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /*else*/ { __pyx_v_self->_flags = 4; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_L5:; /* "gevent/corecext.pyx":849 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_L4:; /* "gevent/corecext.pyx":833 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_t_1 = (__pyx_v_priority != Py_None); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* "gevent/corecext.pyx":850 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_5); /* "gevent/corecext.pyx":849 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":838 * * * def __init__(self, loop loop, int fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * if fd < 0: * raise ValueError('fd must be non-negative: %r' % fd) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) __pyx_t_5 = (__pyx_t_1 != 0); if (__pyx_t_5) { /* "gevent/corecext.pyx":834 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_4); /* "gevent/corecext.pyx":833 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":822 * * * def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): # <<<<<<<<<<<<<< * if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): * raise ValueError('illegal event mask: %r' % events) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":856 * property fd: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.vfd_get(self._watcher.fd) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_2fd___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":857 * * def __get__(self): * return libev.vfd_get(self._watcher.fd) # <<<<<<<<<<<<<< * * def __set__(self, long fd): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_long(vfd_get(__pyx_v_self->_watcher.fd)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":856 * property fd: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.vfd_get(self._watcher.fd) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.fd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":859 * return libev.vfd_get(self._watcher.fd) * * def __set__(self, long fd): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd) { long __pyx_v_fd; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_fd); { __pyx_v_fd = __Pyx_PyInt_As_long(__pyx_arg_fd); if (unlikely((__pyx_v_fd == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_2io_2fd_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((long)__pyx_v_fd)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd) { int __pyx_v_vfd; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":860 * * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") * cdef int vfd = libev.vfd_open(fd) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":861 * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") # <<<<<<<<<<<<<< * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":860 * * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") * cdef int vfd = libev.vfd_open(fd) */ } /* "gevent/corecext.pyx":862 * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") * cdef int vfd = libev.vfd_open(fd) # <<<<<<<<<<<<<< * libev.vfd_free(self._watcher.fd) * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, self._watcher.events) */ __pyx_t_3 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vfd = __pyx_t_3; /* "gevent/corecext.pyx":863 * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, self._watcher.events) * */ vfd_free(__pyx_v_self->_watcher.fd); /* "gevent/corecext.pyx":864 * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) * libev.ev_io_init(&self._watcher, gevent_callback_io, vfd, self._watcher.events) # <<<<<<<<<<<<<< * * property events: */ ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_self->_watcher.events); /* "gevent/corecext.pyx":859 * return libev.vfd_get(self._watcher.fd) * * def __set__(self, long fd): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":868 * property events: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.events * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_6events___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":869 * * def __get__(self): * return self._watcher.events # <<<<<<<<<<<<<< * * def __set__(self, int events): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.events); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":868 * property events: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.events * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.events.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":871 * return self._watcher.events * * def __set__(self, int events): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events) { int __pyx_v_events; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_events); { __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_2io_6events_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((int)__pyx_v_events)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":872 * * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":873 * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":872 * * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) */ } /* "gevent/corecext.pyx":874 * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) # <<<<<<<<<<<<<< * * property events_str: */ ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_self->_watcher.fd, __pyx_v_events); /* "gevent/corecext.pyx":871 * return self._watcher.events * * def __set__(self, int events): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":878 * property events_str: * * def __get__(self): # <<<<<<<<<<<<<< * return _events_to_str(self._watcher.events) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_10events_str___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":879 * * def __get__(self): * return _events_to_str(self._watcher.events) # <<<<<<<<<<<<<< * * def _format(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext__events_to_str(__pyx_v_self->_watcher.events, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":878 * property events_str: * * def __get__(self): # <<<<<<<<<<<<<< * return _events_to_str(self._watcher.events) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.events_str.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":881 * return _events_to_str(self._watcher.events) * * def _format(self): # <<<<<<<<<<<<<< * return ' fd=%s events=%s' % (self.fd, self.events_str) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_8_format(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_format", 0); /* "gevent/corecext.pyx":882 * * def _format(self): * return ' fd=%s events=%s' % (self.fd, self.events_str) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_events_str); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_fd_s_events_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":881 * return _events_to_str(self._watcher.events) * * def _format(self): # <<<<<<<<<<<<<< * return ' fd=%s events=%s' % (self.fd, self.events_str) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.io._format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) /* "gevent/corecext.pyx":886 * * * def __cinit__(self): # <<<<<<<<<<<<<< * self._watcher.fd = -1; * */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_11__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_11__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_6gevent_8corecext_2io_10__cinit__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_10__cinit__(struct PyGeventIOObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); /* "gevent/corecext.pyx":887 * * def __cinit__(self): * self._watcher.fd = -1; # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_v_self->_watcher.fd = -1; /* "gevent/corecext.pyx":886 * * * def __cinit__(self): # <<<<<<<<<<<<<< * self._watcher.fd = -1; * */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":889 * self._watcher.fd = -1; * * def __dealloc__(self): # <<<<<<<<<<<<<< * libev.vfd_free(self._watcher.fd) * */ /* Python wrapper */ static void __pyx_pw_6gevent_8corecext_2io_13__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6gevent_8corecext_2io_13__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6gevent_8corecext_2io_12__dealloc__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_6gevent_8corecext_2io_12__dealloc__(struct PyGeventIOObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); /* "gevent/corecext.pyx":890 * * def __dealloc__(self): * libev.vfd_free(self._watcher.fd) # <<<<<<<<<<<<<< * * */ vfd_free(__pyx_v_self->_watcher.fd); /* "gevent/corecext.pyx":889 * self._watcher.fd = -1; * * def __dealloc__(self): # <<<<<<<<<<<<<< * libev.vfd_free(self._watcher.fd) * */ /* function exit code */ __Pyx_RefNannyFinishContext(); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED) && defined(_WIN32)) } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":713 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4loop___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_4loop___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4loop_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_4loop_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4loop_4__del__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_4loop_4__del__(struct PyGeventIOObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":715 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_io _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4args___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_4args___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4args_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_4args_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_2io_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_2io_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_4args_4__del__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_2io_4args_4__del__(struct PyGeventIOObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":716 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_io _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_2io_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_2io_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_2io_6_flags___get__(((struct PyGeventIOObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_2io_6_flags___get__(struct PyGeventIOObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.io._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":906 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_3ref___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_3ref___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":907 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":906 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":909 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_3ref_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_3ref_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":911 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":912 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":911 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":913 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":914 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":915 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":914 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":916 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":917 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":916 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":918 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":913 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":920 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":921 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":920 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":922 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":923 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":924 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":925 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":923 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":909 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":929 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_8callback___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_8callback___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":930 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":929 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":932 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_8callback_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_8callback_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":933 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":934 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":933 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":935 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":932 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.timer.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":937 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_stop(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_stop(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":939 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":940 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":939 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":941 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":942 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_timer_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":943 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_timer_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":941 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":944 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_timer_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_timer_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":945 * self._flags &= ~2 * libev.ev_timer_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":946 * libev.ev_timer_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":947 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":948 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":949 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":947 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":937 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":953 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_8priority___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_8priority___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":954 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":953 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.timer.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":956 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.timer.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5timer_8priority_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_8priority_2__set__(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":957 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":958 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":957 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":959 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":956 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":961 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.timer.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5timer_2feed(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_2feed(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":963 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":964 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":963 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":965 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":966 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":967 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":968 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":969 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":967 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":970 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":971 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":972 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":973 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args, update=True): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":971 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":961 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":975 * self._flags |= 1 * * def start(self, object callback, *args, update=True): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_update = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (kw_args == 1) { const Py_ssize_t index = 1; PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); if (value) { values[index] = value; kw_args--; } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; __pyx_v_update = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4start(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":977 * def start(self, object callback, *args, update=True): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":978 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":977 * def start(self, object callback, *args, update=True): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":979 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":980 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":979 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":981 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":982 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":983 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":984 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * if update: */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":985 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * if update: * libev.ev_now_update(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":983 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":986 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * if update: # <<<<<<<<<<<<<< * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_start(self.loop._ptr, &self._watcher) */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_3) { /* "gevent/corecext.pyx":987 * self._flags |= 2 * if update: * libev.ev_now_update(self.loop._ptr) # <<<<<<<<<<<<<< * libev.ev_timer_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ ev_now_update(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":986 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * if update: # <<<<<<<<<<<<<< * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_start(self.loop._ptr, &self._watcher) */ } /* "gevent/corecext.pyx":988 * if update: * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_timer_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":989 * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":990 * libev.ev_timer_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":991 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":989 * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":975 * self._flags |= 1 * * def start(self, object callback, *args, update=True): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":995 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_6active___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_6active___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":996 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":995 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1001 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_7pending___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_7pending___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1002 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1001 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1004 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * if repeat < 0.0: * raise ValueError("repeat must be positive or zero: %r" % repeat) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; double __pyx_v_after; double __pyx_v_repeat; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)Py_True); values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_repeat); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); if (values[1]) { __pyx_v_after = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_after = ((double)0.0); } if (values[2]) { __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_repeat = ((double)0.0); } __pyx_v_ref = values[3]; __pyx_v_priority = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_5timer_6__init__(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_6__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1005 * * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): * if repeat < 0.0: # <<<<<<<<<<<<<< * raise ValueError("repeat must be positive or zero: %r" % repeat) * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) */ __pyx_t_1 = ((__pyx_v_repeat < 0.0) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1006 * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): * if repeat < 0.0: * raise ValueError("repeat must be positive or zero: %r" % repeat) # <<<<<<<<<<<<<< * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) * self.loop = loop */ __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1005 * * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): * if repeat < 0.0: # <<<<<<<<<<<<<< * raise ValueError("repeat must be positive or zero: %r" % repeat) * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) */ } /* "gevent/corecext.pyx":1007 * if repeat < 0.0: * raise ValueError("repeat must be positive or zero: %r" % repeat) * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_timer_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_timer), __pyx_v_after, __pyx_v_repeat); /* "gevent/corecext.pyx":1008 * raise ValueError("repeat must be positive or zero: %r" % repeat) * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1009 * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1010 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1009 * libev.ev_timer_init(&self._watcher, gevent_callback_timer, after, repeat) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L4; } /* "gevent/corecext.pyx":1012 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L4:; /* "gevent/corecext.pyx":1013 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* "gevent/corecext.pyx":1014 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * property at: */ __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_5); /* "gevent/corecext.pyx":1013 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1004 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * if repeat < 0.0: * raise ValueError("repeat must be positive or zero: %r" % repeat) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1018 * property at: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.at * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_2at___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1019 * * def __get__(self): * return self._watcher.at # <<<<<<<<<<<<<< * * # QQQ: add 'after' and 'repeat' properties? */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.at); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1018 * property at: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.at * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.timer.at.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1023 * # QQQ: add 'after' and 'repeat' properties? * * def again(self, object callback, *args, update=True): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_9again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_9again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_update = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("again (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (kw_args == 1) { const Py_ssize_t index = 1; PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); if (value) { values[index] = value; kw_args--; } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "again") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; __pyx_v_update = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("again", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5timer_8again(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_8again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("again", 0); /* "gevent/corecext.pyx":1025 * def again(self, object callback, *args, update=True): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1026 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1025 * def again(self, object callback, *args, update=True): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1027 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1028 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1029 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1030 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * if update: */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1031 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * if update: * libev.ev_now_update(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1029 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1032 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * if update: # <<<<<<<<<<<<<< * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_again(self.loop._ptr, &self._watcher) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1033 * self._flags |= 2 * if update: * libev.ev_now_update(self.loop._ptr) # <<<<<<<<<<<<<< * libev.ev_timer_again(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ ev_now_update(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1032 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * if update: # <<<<<<<<<<<<<< * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_again(self.loop._ptr, &self._watcher) */ } /* "gevent/corecext.pyx":1034 * if update: * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_again(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_timer_again(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1035 * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_again(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1036 * libev.ev_timer_again(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1037 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1035 * libev.ev_now_update(self.loop._ptr) * libev.ev_timer_again(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1023 * # QQQ: add 'after' and 'repeat' properties? * * def again(self, object callback, *args, update=True): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":898 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4loop___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_4loop___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4loop_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_4loop_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.timer.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4loop_4__del__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_4loop_4__del__(struct PyGeventTimerObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":900 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_timer _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4args___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_4args___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4args_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_4args_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.timer.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5timer_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5timer_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_4args_4__del__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5timer_4args_4__del__(struct PyGeventTimerObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":901 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_timer _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5timer_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5timer_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5timer_6_flags___get__(((struct PyGeventTimerObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5timer_6_flags___get__(struct PyGeventTimerObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.timer._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1051 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_3ref___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_3ref___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1052 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1051 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1054 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_3ref_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_3ref_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1056 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1057 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1056 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1058 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1059 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1060 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1059 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1061 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1062 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1061 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1063 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1058 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1065 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1066 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1065 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1067 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1068 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1069 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1070 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1068 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1054 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.signal.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1074 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_8callback___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_8callback___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1075 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1074 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1077 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_8callback_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_8callback_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1078 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1079 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1078 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1080 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1077 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.signal.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1082 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_stop(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_stop(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1084 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1085 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1084 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1086 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1087 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_signal_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1088 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_signal_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1086 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1089 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_signal_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_signal_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1090 * self._flags &= ~2 * libev.ev_signal_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1091 * libev.ev_signal_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1092 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1093 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1094 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1092 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1082 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.signal.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1098 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_8priority___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_8priority___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1099 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1098 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.signal.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1101 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.signal.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_6signal_8priority_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_8priority_2__set__(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1102 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1103 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1102 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1104 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1101 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.signal.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1106 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.signal.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_6signal_2feed(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_2feed(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1108 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1109 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1108 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1110 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1111 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1112 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1113 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1114 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1112 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1115 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1116 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1117 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1118 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1116 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1106 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.signal.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1120 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.signal.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4start(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_4start(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1122 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1123 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1122 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1124 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1125 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1124 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1126 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1127 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1128 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1129 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_signal_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1130 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_signal_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1128 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1131 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_signal_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_signal_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1132 * self._flags |= 2 * libev.ev_signal_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1133 * libev.ev_signal_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1134 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1132 * self._flags |= 2 * libev.ev_signal_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1120 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.signal.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1138 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_6active___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_6active___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1139 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1138 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1144 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_7pending___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_7pending___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1145 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * def __init__(self, loop loop, int signalnum, ref=True, priority=None): */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1144 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1147 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, int signalnum, ref=True, priority=None): # <<<<<<<<<<<<<< * if signalnum < 1 or signalnum >= signalmodule.NSIG: * raise ValueError('illegal signal number: %r' % signalnum) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; int __pyx_v_signalnum; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_signalnum,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[4] = {0,0,0,0}; values[2] = ((PyObject *)Py_True); values[3] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signalnum)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_signalnum = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ref = values[2]; __pyx_v_priority = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_6signal_6__init__(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_signalnum, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_6__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1148 * * def __init__(self, loop loop, int signalnum, ref=True, priority=None): * if signalnum < 1 or signalnum >= signalmodule.NSIG: # <<<<<<<<<<<<<< * raise ValueError('illegal signal number: %r' % signalnum) * # still possible to crash on one of libev's asserts: */ __pyx_t_2 = ((__pyx_v_signalnum < 1) != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_signalmodule); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NSIG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1149 * def __init__(self, loop loop, int signalnum, ref=True, priority=None): * if signalnum < 1 or signalnum >= signalmodule.NSIG: * raise ValueError('illegal signal number: %r' % signalnum) # <<<<<<<<<<<<<< * # still possible to crash on one of libev's asserts: * # 1) "libev: ev_signal_start called with illegal signal number" */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_illegal_signal_number_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1148 * * def __init__(self, loop loop, int signalnum, ref=True, priority=None): * if signalnum < 1 or signalnum >= signalmodule.NSIG: # <<<<<<<<<<<<<< * raise ValueError('illegal signal number: %r' % signalnum) * # still possible to crash on one of libev's asserts: */ } /* "gevent/corecext.pyx":1155 * # 2) "libev: a signal must not be attached to two different loops" * # we probably could check that in LIBEV_EMBED mode, but not in general * libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_signal_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_signal), __pyx_v_signalnum); /* "gevent/corecext.pyx":1156 * # we probably could check that in LIBEV_EMBED mode, but not in general * libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1157 * libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1158 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1157 * libev.ev_signal_init(&self._watcher, gevent_callback_signal, signalnum) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L6; } /* "gevent/corecext.pyx":1160 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L6:; /* "gevent/corecext.pyx":1161 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1162 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_6); /* "gevent/corecext.pyx":1161 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1147 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, int signalnum, ref=True, priority=None): # <<<<<<<<<<<<<< * if signalnum < 1 or signalnum >= signalmodule.NSIG: * raise ValueError('illegal signal number: %r' % signalnum) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1043 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4loop___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_4loop___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4loop_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_4loop_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.signal.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4loop_4__del__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_4loop_4__del__(struct PyGeventSignalObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1045 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_signal _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4args___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_4args___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4args_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_4args_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.signal.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_6signal_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_6signal_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_4args_4__del__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_6signal_4args_4__del__(struct PyGeventSignalObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1046 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_signal _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_6signal_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_6signal_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_6signal_6_flags___get__(((struct PyGeventSignalObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_6signal_6_flags___get__(struct PyGeventSignalObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.signal._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1176 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_3ref___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_3ref___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1177 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1176 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1179 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_3ref_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_3ref_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1181 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1182 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1181 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1183 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1184 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1185 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1184 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1186 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1187 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1186 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1188 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1183 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1190 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1191 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1190 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1192 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1193 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1194 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1195 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1193 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1179 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.idle.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1199 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_8callback___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_8callback___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1200 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1199 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1202 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_8callback_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_8callback_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1203 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1204 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1203 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1205 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1202 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.idle.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1207 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_stop(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_stop(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1209 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1210 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1209 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1211 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1212 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_idle_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1213 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_idle_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1211 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1214 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_idle_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_idle_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1215 * self._flags &= ~2 * libev.ev_idle_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1216 * libev.ev_idle_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1217 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1218 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1219 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1217 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1207 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.idle.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1223 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_8priority___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_8priority___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1224 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1223 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.idle.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1226 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.idle.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4idle_8priority_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_8priority_2__set__(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1227 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1228 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1227 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1229 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1226 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.idle.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1231 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.idle.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4idle_2feed(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_2feed(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1233 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1234 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1233 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1235 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1236 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1237 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1238 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1239 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1237 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1240 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1241 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1242 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1243 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1241 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1231 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.idle.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1245 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1245; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1245; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.idle.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4start(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_4start(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1247 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1248 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1247 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1249 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1250 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1249 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1251 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1252 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1253 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1254 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_idle_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1255 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_idle_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1253 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1256 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_idle_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_idle_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1257 * self._flags |= 2 * libev.ev_idle_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1258 * libev.ev_idle_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1259 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1257 * self._flags |= 2 * libev.ev_idle_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1245 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.idle.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1263 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_6active___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_6active___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1264 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1263 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1269 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_7pending___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_7pending___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1270 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1269 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1273 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) * self.loop = loop */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.idle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_4idle_6__init__(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_6__init__(struct PyGeventIdleObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1274 * * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_idle_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_idle)); /* "gevent/corecext.pyx":1275 * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1276 * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1277 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1276 * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":1279 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L3:; /* "gevent/corecext.pyx":1280 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1281 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); /* "gevent/corecext.pyx":1280 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1273 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_idle_init(&self._watcher, gevent_callback_idle ) * self.loop = loop */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.idle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1168 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4loop___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_4loop___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4loop_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_4loop_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.idle.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4loop_4__del__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_4loop_4__del__(struct PyGeventIdleObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1170 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_idle _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4args___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_4args___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4args_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_4args_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.idle.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4idle_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4idle_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_4args_4__del__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4idle_4args_4__del__(struct PyGeventIdleObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1171 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_idle _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4idle_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4idle_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4idle_6_flags___get__(((struct PyGeventIdleObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4idle_6_flags___get__(struct PyGeventIdleObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.idle._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1295 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_3ref___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_3ref___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1296 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1295 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1298 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_3ref_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_3ref_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1300 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1301 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1300 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1302 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1303 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1304 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1303 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1305 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1306 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1305 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1307 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1302 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1309 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1310 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1309 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1311 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1312 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1313 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1314 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1312 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1298 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.prepare.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1318 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_8callback___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_8callback___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1319 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1318 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1321 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_8callback_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_8callback_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1322 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1323 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1322 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1324 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1321 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.prepare.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1326 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_stop(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_stop(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1328 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1329 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1328 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1330 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1331 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_prepare_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1332 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_prepare_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1330 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1333 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_prepare_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_prepare_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1334 * self._flags &= ~2 * libev.ev_prepare_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1335 * libev.ev_prepare_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1336 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1337 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1338 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1336 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1326 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.prepare.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1342 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_8priority___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_8priority___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1343 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1342 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.prepare.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1345 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.prepare.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_8priority_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_8priority_2__set__(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1346 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1347 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1346 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1348 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1345 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.prepare.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1350 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.prepare.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_2feed(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_2feed(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1352 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1353 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1352 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1354 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1355 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1356 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1357 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1358 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1356 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1359 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1360 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1361 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1362 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1360 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1350 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.prepare.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1364 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.prepare.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4start(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4start(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1366 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1367 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1366 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1368 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1369 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1368 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1370 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1371 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1372 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1373 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_prepare_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1374 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_prepare_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1372 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1375 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_prepare_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_prepare_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1376 * self._flags |= 2 * libev.ev_prepare_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1377 * libev.ev_prepare_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1378 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1376 * self._flags |= 2 * libev.ev_prepare_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1364 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.prepare.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1382 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_6active___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_6active___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1383 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1382 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1388 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_7pending___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_7pending___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1389 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1388 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1392 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) * self.loop = loop */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.prepare.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_6__init__(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_6__init__(struct PyGeventPrepareObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1393 * * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_prepare_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_prepare)); /* "gevent/corecext.pyx":1394 * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1395 * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1396 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1395 * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":1398 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L3:; /* "gevent/corecext.pyx":1399 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1400 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); /* "gevent/corecext.pyx":1399 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1392 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_prepare_init(&self._watcher, gevent_callback_prepare ) * self.loop = loop */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.prepare.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1287 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4loop___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4loop___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4loop_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_4loop_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.prepare.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4loop_4__del__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_4loop_4__del__(struct PyGeventPrepareObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1289 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_prepare _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4args___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_4args___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4args_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_4args_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.prepare.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_7prepare_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_7prepare_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_4args_4__del__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_7prepare_4args_4__del__(struct PyGeventPrepareObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1290 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_prepare _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_7prepare_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_7prepare_6_flags___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_7prepare_6_flags___get__(struct PyGeventPrepareObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.prepare._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1414 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_3ref___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_3ref___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1415 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1414 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1417 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_3ref_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_3ref_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1419 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1420 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1419 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1421 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1422 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1423 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1422 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1424 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1425 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1424 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1426 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1421 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1428 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1429 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1428 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1430 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1431 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1432 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1433 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1431 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1417 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.check.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1437 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_8callback___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_8callback___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1438 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1437 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1440 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_8callback_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_8callback_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1441 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1442 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1441 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1443 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1440 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.check.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1445 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_stop(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_stop(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1447 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1448 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1447 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1449 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1450 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_check_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1451 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_check_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1449 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1452 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_check_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_check_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1453 * self._flags &= ~2 * libev.ev_check_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1454 * libev.ev_check_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1455 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1456 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1457 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1455 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1445 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.check.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1461 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_8priority___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_8priority___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1462 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1461 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.check.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1464 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.check.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5check_8priority_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_8priority_2__set__(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1465 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1466 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1465 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1467 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1464 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.check.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1469 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.check.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5check_2feed(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_2feed(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1471 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1472 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1471 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1473 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1474 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1475 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1476 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1477 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1475 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1478 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1479 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1480 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1481 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1479 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1469 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.check.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1483 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.check.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5check_4start(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_4start(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1485 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1486 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1485 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1487 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1488 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1487 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1489 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1490 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1491 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1492 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_check_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1493 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_check_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1491 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1494 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_check_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_check_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1495 * self._flags |= 2 * libev.ev_check_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1496 * libev.ev_check_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1497 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1495 * self._flags |= 2 * libev.ev_check_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1483 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.check.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1501 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_6active___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_6active___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1502 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1501 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1507 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_7pending___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_7pending___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1508 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1507 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1511 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_check_init(&self._watcher, gevent_callback_check ) * self.loop = loop */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.check.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_5check_6__init__(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_6__init__(struct PyGeventCheckObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1512 * * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_check_init(&self._watcher, gevent_callback_check ) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_check_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_check)); /* "gevent/corecext.pyx":1513 * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_check_init(&self._watcher, gevent_callback_check ) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1514 * libev.ev_check_init(&self._watcher, gevent_callback_check ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1515 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1514 * libev.ev_check_init(&self._watcher, gevent_callback_check ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":1517 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L3:; /* "gevent/corecext.pyx":1518 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1519 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); /* "gevent/corecext.pyx":1518 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1511 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_check_init(&self._watcher, gevent_callback_check ) * self.loop = loop */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.check.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1406 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4loop___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_4loop___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4loop_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_4loop_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.check.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4loop_4__del__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_4loop_4__del__(struct PyGeventCheckObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1408 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_check _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4args___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_4args___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4args_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_4args_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.check.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5check_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5check_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_4args_4__del__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5check_4args_4__del__(struct PyGeventCheckObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1409 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_check _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5check_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5check_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5check_6_flags___get__(((struct PyGeventCheckObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5check_6_flags___get__(struct PyGeventCheckObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.check._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1533 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_3ref___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_3ref___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1534 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1533 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1536 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_3ref_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_3ref_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1538 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1539 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1538 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1540 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1541 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1542 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1541 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1543 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1544 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1543 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1545 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1540 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1547 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1548 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1547 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1549 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1550 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1551 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1552 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1550 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1536 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.fork.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1556 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_8callback___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_8callback___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1557 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1556 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1559 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_8callback_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_8callback_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1560 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1561 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1560 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1562 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1559 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.fork.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1564 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_stop(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_stop(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1566 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1567 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1566 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1568 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1569 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_fork_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1570 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_fork_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1568 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1571 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_fork_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_fork_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1572 * self._flags &= ~2 * libev.ev_fork_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1573 * libev.ev_fork_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1574 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1575 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1576 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1574 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1564 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.fork.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1580 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_8priority___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_8priority___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1581 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1581; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1580 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.fork.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1583 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1583; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.fork.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4fork_8priority_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_8priority_2__set__(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1584 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1585 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1584 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1586 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1583 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.fork.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1588 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.fork.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4fork_2feed(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_2feed(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1590 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1591 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1590 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1592 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1593 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1594 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1595 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1596 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1594 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1597 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1598 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1599 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1600 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1598 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1588 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.fork.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1602 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.fork.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4start(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_4start(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1604 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1605 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1604 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1606 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1607 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1606 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1608 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1609 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1610 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1611 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_fork_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1612 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_fork_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1610 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1613 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_fork_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_fork_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1614 * self._flags |= 2 * libev.ev_fork_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1615 * libev.ev_fork_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1616 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1614 * self._flags |= 2 * libev.ev_fork_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1602 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.fork.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1620 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_6active___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_6active___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1621 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1620 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1626 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_7pending___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_7pending___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1627 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1626 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1630 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) * self.loop = loop */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.fork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_4fork_6__init__(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_6__init__(struct PyGeventForkObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1631 * * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_fork_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_fork)); /* "gevent/corecext.pyx":1632 * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1633 * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1634 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1633 * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":1636 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L3:; /* "gevent/corecext.pyx":1637 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1638 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); /* "gevent/corecext.pyx":1637 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1630 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_fork_init(&self._watcher, gevent_callback_fork ) * self.loop = loop */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.fork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1525 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4loop___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_4loop___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4loop_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_4loop_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.fork.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4loop_4__del__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_4loop_4__del__(struct PyGeventForkObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1527 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_fork _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4args___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_4args___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4args_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_4args_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.fork.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4fork_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4fork_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_4args_4__del__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4fork_4args_4__del__(struct PyGeventForkObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1528 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_fork _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4fork_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4fork_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4fork_6_flags___get__(((struct PyGeventForkObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4fork_6_flags___get__(struct PyGeventForkObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.fork._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1652 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_3ref___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_3ref___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1653 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1652 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1655 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_3ref_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_3ref_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1657 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1658 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1657 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1659 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1660 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1661 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1660 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1662 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1663 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1662 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1664 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1659 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1666 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1667 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1666 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1668 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1669 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1670 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1671 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1669 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1655 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1675 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_8callback___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_8callback___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1676 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1675 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1678 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_8callback_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_8callback_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1679 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1680 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1679 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1681 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1678 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.async.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1683 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_stop(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_stop(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1685 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1686 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1685 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1687 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1688 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_async_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1689 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_async_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1687 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1690 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_async_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_async_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1691 * self._flags &= ~2 * libev.ev_async_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1692 * libev.ev_async_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1693 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1694 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1695 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1693 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1683 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1699 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_8priority___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_8priority___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1700 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1699 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.async.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1702 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.async.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5async_8priority_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_8priority_2__set__(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1703 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1704 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1703 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1705 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1702 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1707 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.async.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5async_2feed(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_2feed(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1709 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1710 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1709 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1711 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1712 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1713 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1714 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1715 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1713 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1716 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1717 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1718 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1719 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1717 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1707 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1721 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.async.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5async_4start(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_4start(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1723 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1724 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1723 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1725 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1726 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1725 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1727 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1728 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1729 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1730 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_async_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1731 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_async_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1729 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1732 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_async_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_async_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1733 * self._flags |= 2 * libev.ev_async_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1734 * libev.ev_async_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1735 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1733 * self._flags |= 2 * libev.ev_async_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1721 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1739 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_6active___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_6active___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1740 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * property pending: */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1739 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1744 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_async_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_7pending___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_7pending___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1745 * * def __get__(self): * return True if libev.ev_async_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_async_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1744 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_async_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1748 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_async_init(&self._watcher, gevent_callback_async ) * self.loop = loop */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_ref = values[1]; __pyx_v_priority = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.async.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_5async_6__init__(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_6__init__(struct PyGeventAsyncObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1749 * * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_async_init(&self._watcher, gevent_callback_async ) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_async_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_async)); /* "gevent/corecext.pyx":1750 * def __init__(self, loop loop , ref=True, priority=None): * libev.ev_async_init(&self._watcher, gevent_callback_async ) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1751 * libev.ev_async_init(&self._watcher, gevent_callback_async ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1752 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1751 * libev.ev_async_init(&self._watcher, gevent_callback_async ) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":1754 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L3:; /* "gevent/corecext.pyx":1755 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_1 = (__pyx_v_priority != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":1756 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def send(self): */ __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); /* "gevent/corecext.pyx":1755 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":1748 * * * def __init__(self, loop loop , ref=True, priority=None): # <<<<<<<<<<<<<< * libev.ev_async_init(&self._watcher, gevent_callback_async ) * self.loop = loop */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("gevent.corecext.async.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1758 * libev.ev_set_priority(&self._watcher, priority) * * def send(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_9send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_9send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("send (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_8send(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_8send(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("send", 0); /* "gevent/corecext.pyx":1760 * def send(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_async_send(self.loop._ptr, &self._watcher) */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1761 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_async_send(self.loop._ptr, &self._watcher) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1760 * def send(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * libev.ev_async_send(self.loop._ptr, &self._watcher) */ } /* "gevent/corecext.pyx":1762 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * libev.ev_async_send(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * * */ ev_async_send(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1758 * libev.ev_set_priority(&self._watcher, priority) * * def send(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.async.send", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1644 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4loop___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_4loop___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4loop_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_4loop_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.async.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4loop_4__del__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_4loop_4__del__(struct PyGeventAsyncObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1646 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_async _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4args___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_4args___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4args_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_4args_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.async.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5async_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5async_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_4args_4__del__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5async_4args_4__del__(struct PyGeventAsyncObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1647 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_async _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5async_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5async_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5async_6_flags___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5async_6_flags___get__(struct PyGeventAsyncObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1647; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.async._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) /* "gevent/corecext.pyx":1778 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_3ref___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_3ref___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1779 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1778 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1781 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_3ref_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_3ref_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1783 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1784 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1783 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1785 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1786 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1787 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1786 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1788 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1789 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1788 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1790 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1785 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1792 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1793 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1792 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1794 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1795 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1796 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1797 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1795 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1781 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.child.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1801 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_8callback___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_8callback___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1802 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1801 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1804 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_8callback_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_8callback_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1805 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1806 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1805 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1807 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1804 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.child.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1809 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_stop(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_stop(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1811 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1812 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1811 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1813 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1814 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_child_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1815 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_child_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1813 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1816 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_child_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_child_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1817 * self._flags &= ~2 * libev.ev_child_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1818 * libev.ev_child_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1819 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1820 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1821 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1819 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1809 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.child.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1825 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_8priority___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_8priority___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1826 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1825 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1828 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.child.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5child_8priority_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_8priority_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1829 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1830 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1829 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1831 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1828 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.child.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1833 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.child.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5child_2feed(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_2feed(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1835 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1836 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1835 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1837 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1838 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1839 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1840 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1841 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1839 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1842 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1843 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1844 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1845 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1843 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1833 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.child.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1847 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.child.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5child_4start(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_4start(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1849 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1850 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1849 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1851 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1852 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1851 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1853 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1854 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1855 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1856 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_child_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1857 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_child_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1855 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1858 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_child_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_child_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1859 * self._flags |= 2 * libev.ev_child_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1860 * libev.ev_child_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1861 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1859 * self._flags |= 2 * libev.ev_child_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1847 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.child.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1865 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_6active___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_6active___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1866 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1865 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1871 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_7pending___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_7pending___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1872 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * * def __init__(self, loop loop, int pid, bint trace=0, ref=True): */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1871 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1874 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, int pid, bint trace=0, ref=True): # <<<<<<<<<<<<<< * if not loop.default: * raise TypeError('child watchers are only available on the default loop') */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; int __pyx_v_pid; int __pyx_v_trace; PyObject *__pyx_v_ref = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0}; PyObject* values[4] = {0,0,0,0}; values[3] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trace); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_pid = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L3_error;} if (values[2]) { __pyx_v_trace = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_trace = ((int)0); } __pyx_v_ref = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_5child_6__init__(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_pid, __pyx_v_trace, __pyx_v_ref); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_6__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":1875 * * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: # <<<<<<<<<<<<<< * raise TypeError('child watchers are only available on the default loop') * libev.gevent_install_sigchld_handler() */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_loop), __pyx_n_s_default); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((!__pyx_t_2) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1876 * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: * raise TypeError('child watchers are only available on the default loop') # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1875 * * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: # <<<<<<<<<<<<<< * raise TypeError('child watchers are only available on the default loop') * libev.gevent_install_sigchld_handler() */ } /* "gevent/corecext.pyx":1877 * if not loop.default: * raise TypeError('child watchers are only available on the default loop') * libev.gevent_install_sigchld_handler() # <<<<<<<<<<<<<< * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) * self.loop = loop */ gevent_install_sigchld_handler(); /* "gevent/corecext.pyx":1878 * raise TypeError('child watchers are only available on the default loop') * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ ev_child_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_child), __pyx_v_pid, __pyx_v_trace); /* "gevent/corecext.pyx":1879 * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":1880 * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_3) { /* "gevent/corecext.pyx":1881 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":1880 * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L4; } /* "gevent/corecext.pyx":1883 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * * def _format(self): */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L4:; /* "gevent/corecext.pyx":1874 * return True if libev.ev_is_pending(&self._watcher) else False * * def __init__(self, loop loop, int pid, bint trace=0, ref=True): # <<<<<<<<<<<<<< * if not loop.default: * raise TypeError('child watchers are only available on the default loop') */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1885 * self._flags = 4 * * def _format(self): # <<<<<<<<<<<<<< * return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_format (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_8_format(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_8_format(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_format", 0); /* "gevent/corecext.pyx":1886 * * def _format(self): * return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) # <<<<<<<<<<<<<< * * property pid: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rstatus); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_pid_r_rstatus_r, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1885 * self._flags = 4 * * def _format(self): # <<<<<<<<<<<<<< * return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent.corecext.child._format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1890 * property pid: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.pid * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_3pid___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1891 * * def __get__(self): * return self._watcher.pid # <<<<<<<<<<<<<< * * property rpid: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.pid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1890 * property pid: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.pid * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.pid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1895 * property rpid: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.rpid * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4rpid___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1896 * * def __get__(self): * return self._watcher.rpid # <<<<<<<<<<<<<< * * def __set__(self, int value): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rpid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1895 * property rpid: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.rpid * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.rpid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1898 * return self._watcher.rpid * * def __set__(self, int value): # <<<<<<<<<<<<<< * self._watcher.rpid = value * */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) { int __pyx_v_value; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_value); { __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1898; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.child.rpid.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5child_4rpid_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1899 * * def __set__(self, int value): * self._watcher.rpid = value # <<<<<<<<<<<<<< * * property rstatus: */ __pyx_v_self->_watcher.rpid = __pyx_v_value; /* "gevent/corecext.pyx":1898 * return self._watcher.rpid * * def __set__(self, int value): # <<<<<<<<<<<<<< * self._watcher.rpid = value * */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1903 * property rstatus: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.rstatus * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_7rstatus___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1904 * * def __get__(self): * return self._watcher.rstatus # <<<<<<<<<<<<<< * * def __set__(self, int value): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rstatus); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1903 * property rstatus: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.rstatus * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.rstatus.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1906 * return self._watcher.rstatus * * def __set__(self, int value): # <<<<<<<<<<<<<< * self._watcher.rstatus = value * */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) { int __pyx_v_value; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_value); { __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.child.rstatus.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_5child_7rstatus_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1907 * * def __set__(self, int value): * self._watcher.rstatus = value # <<<<<<<<<<<<<< * * */ __pyx_v_self->_watcher.rstatus = __pyx_v_value; /* "gevent/corecext.pyx":1906 * return self._watcher.rstatus * * def __set__(self, int value): # <<<<<<<<<<<<<< * self._watcher.rstatus = value * */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1770 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4loop___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_4loop___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4loop_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_4loop_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4loop_4__del__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_4loop_4__del__(struct PyGeventChildObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1772 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_child _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4args___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_4args___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4args_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_4args_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_5child_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_5child_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_4args_4__del__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_5child_4args_4__del__(struct PyGeventChildObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1773 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_child _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_5child_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_5child_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_5child_6_flags___get__(((struct PyGeventChildObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_5child_6_flags___get__(struct PyGeventChildObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.child._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":1923 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_3ref___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1924 * * def __get__(self): * return False if self._flags & 4 else True # <<<<<<<<<<<<<< * * def __set__(self, object value): */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_self->_flags & 4) != 0)) { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } else { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1923 * property ref: * * def __get__(self): # <<<<<<<<<<<<<< * return False if self._flags & 4 else True * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1926 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_3ref_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1928 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1928 * def __set__(self, object value): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if value: */ } /* "gevent/corecext.pyx":1930 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "gevent/corecext.pyx":1931 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1932 * if value: * if not self._flags & 4: * return # ref is already True # <<<<<<<<<<<<<< * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1931 * raise ValueError('operation on destroyed loop') * if value: * if not self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already True * if self._flags & 2: # ev_unref was called, undo */ } /* "gevent/corecext.pyx":1933 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1934 * return # ref is already True * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~6 # do not want unref, no outstanding unref * else: */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1933 * if not self._flags & 4: * return # ref is already True * if self._flags & 2: # ev_unref was called, undo # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref */ } /* "gevent/corecext.pyx":1935 * if self._flags & 2: # ev_unref was called, undo * libev.ev_ref(self.loop._ptr) * self._flags &= ~6 # do not want unref, no outstanding unref # <<<<<<<<<<<<<< * else: * if self._flags & 4: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); /* "gevent/corecext.pyx":1930 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if value: # <<<<<<<<<<<<<< * if not self._flags & 4: * return # ref is already True */ goto __pyx_L4; } /* "gevent/corecext.pyx":1937 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ /*else*/ { __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1938 * else: * if self._flags & 4: * return # ref is already False # <<<<<<<<<<<<<< * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): */ __pyx_r = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1937 * self._flags &= ~6 # do not want unref, no outstanding unref * else: * if self._flags & 4: # <<<<<<<<<<<<<< * return # ref is already False * self._flags |= 4 */ } /* "gevent/corecext.pyx":1939 * if self._flags & 4: * return # ref is already False * self._flags |= 4 # <<<<<<<<<<<<<< * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); /* "gevent/corecext.pyx":1940 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1941 * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1942 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * * property callback: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1940 * return # ref is already False * self._flags |= 4 * if not self._flags & 2 and libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } } __pyx_L4:; /* "gevent/corecext.pyx":1926 * return False if self._flags & 4 else True * * def __set__(self, object value): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1946 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8callback_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_8callback___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_8callback___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1947 * * def __get__(self): * return self._callback # <<<<<<<<<<<<<< * * def __set__(self, object callback): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_callback); __pyx_r = __pyx_v_self->_callback; goto __pyx_L0; /* "gevent/corecext.pyx":1946 * property callback: * * def __get__(self): # <<<<<<<<<<<<<< * return self._callback * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1949 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_8callback_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_8callback_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1950 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_callback != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "gevent/corecext.pyx":1951 * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) # <<<<<<<<<<<<<< * self._callback = callback * */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1950 * * def __set__(self, object callback): * if not PyCallable_Check(callback) and callback is not None: # <<<<<<<<<<<<<< * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback */ } /* "gevent/corecext.pyx":1952 * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) * self._callback = callback # <<<<<<<<<<<<<< * * def stop(self): */ __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = __pyx_v_callback; /* "gevent/corecext.pyx":1949 * return self._callback * * def __set__(self, object callback): # <<<<<<<<<<<<<< * if not PyCallable_Check(callback) and callback is not None: * raise TypeError("Expected callable, not %r" % (callback, )) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gevent.corecext.stat.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1954 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_stop(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_stop(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("stop", 0); /* "gevent/corecext.pyx":1956 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1956 * def stop(self): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if self._flags & 2: */ } /* "gevent/corecext.pyx":1958 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1959 * raise ValueError('operation on destroyed loop') * if self._flags & 2: * libev.ev_ref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags &= ~2 * libev.ev_stat_stop(self.loop._ptr, &self._watcher) */ ev_ref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1960 * if self._flags & 2: * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 # <<<<<<<<<<<<<< * libev.ev_stat_stop(self.loop._ptr, &self._watcher) * self._callback = None */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); /* "gevent/corecext.pyx":1958 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if self._flags & 2: # <<<<<<<<<<<<<< * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 */ } /* "gevent/corecext.pyx":1961 * libev.ev_ref(self.loop._ptr) * self._flags &= ~2 * libev.ev_stat_stop(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * self._callback = None * self.args = None */ ev_stat_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":1962 * self._flags &= ~2 * libev.ev_stat_stop(self.loop._ptr, &self._watcher) * self._callback = None # <<<<<<<<<<<<<< * self.args = None * if self._flags & 1: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_callback); __Pyx_DECREF(__pyx_v_self->_callback); __pyx_v_self->_callback = Py_None; /* "gevent/corecext.pyx":1963 * libev.ev_stat_stop(self.loop._ptr, &self._watcher) * self._callback = None * self.args = None # <<<<<<<<<<<<<< * if self._flags & 1: * Py_DECREF(self) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* "gevent/corecext.pyx":1964 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1965 * self.args = None * if self._flags & 1: * Py_DECREF(self) # <<<<<<<<<<<<<< * self._flags &= ~1 * */ Py_DECREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1966 * if self._flags & 1: * Py_DECREF(self) * self._flags &= ~1 # <<<<<<<<<<<<<< * * property priority: */ __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); /* "gevent/corecext.pyx":1964 * self._callback = None * self.args = None * if self._flags & 1: # <<<<<<<<<<<<<< * Py_DECREF(self) * self._flags &= ~1 */ } /* "gevent/corecext.pyx":1954 * self._callback = callback * * def stop(self): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1970 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8priority_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_8priority___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_8priority___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":1971 * * def __get__(self): * return libev.ev_priority(&self._watcher) # <<<<<<<<<<<<<< * * def __set__(self, int priority): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":1970 * property priority: * * def __get__(self): # <<<<<<<<<<<<<< * return libev.ev_priority(&self._watcher) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.stat.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1973 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { int __pyx_v_priority; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_priority); { __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.stat.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4stat_8priority_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((int)__pyx_v_priority)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_8priority_2__set__(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_priority) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); /* "gevent/corecext.pyx":1974 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1974 * * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): # <<<<<<<<<<<<<< * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) */ } /* "gevent/corecext.pyx":1976 * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * def feed(self, int revents, object callback, *args): */ ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); /* "gevent/corecext.pyx":1973 * return libev.ev_priority(&self._watcher) * * def __set__(self, int priority): # <<<<<<<<<<<<<< * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1978 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_revents; PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("feed (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_callback = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.stat.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4stat_2feed(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_2feed(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("feed", 0); /* "gevent/corecext.pyx":1980 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1980 * def feed(self, int revents, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * self.callback = callback */ } /* "gevent/corecext.pyx":1982 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1983 * raise ValueError('operation on destroyed loop') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":1984 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1985 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":1986 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":1984 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":1987 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); /* "gevent/corecext.pyx":1988 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1989 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":1990 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * def start(self, object callback, *args): */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":1988 * self._flags |= 2 * libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1978 * libev.ev_set_priority(&self._watcher, priority) * * def feed(self, int revents, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1992 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_callback = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("start (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1992; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_callback = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1992; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gevent.corecext.stat.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4start(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4start(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("start", 0); /* "gevent/corecext.pyx":1994 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1994 * def start(self, object callback, *args): * * if not self.loop._ptr: # <<<<<<<<<<<<<< * raise ValueError('operation on destroyed loop') * if callback is None: */ } /* "gevent/corecext.pyx":1996 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1996 * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') * if callback is None: # <<<<<<<<<<<<<< * raise TypeError('callback must be callable, not None') * self.callback = callback */ } /* "gevent/corecext.pyx":1998 * if callback is None: * raise TypeError('callback must be callable, not None') * self.callback = callback # <<<<<<<<<<<<<< * self.args = args * if self._flags & 6 == 4: */ if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":1999 * raise TypeError('callback must be callable, not None') * self.callback = callback * self.args = args # <<<<<<<<<<<<<< * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = __pyx_v_args; /* "gevent/corecext.pyx":2000 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":2001 * self.args = args * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) # <<<<<<<<<<<<<< * self._flags |= 2 * libev.ev_stat_start(self.loop._ptr, &self._watcher) */ ev_unref(__pyx_v_self->loop->_ptr); /* "gevent/corecext.pyx":2002 * if self._flags & 6 == 4: * libev.ev_unref(self.loop._ptr) * self._flags |= 2 # <<<<<<<<<<<<<< * libev.ev_stat_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); /* "gevent/corecext.pyx":2000 * self.callback = callback * self.args = args * if self._flags & 6 == 4: # <<<<<<<<<<<<<< * libev.ev_unref(self.loop._ptr) * self._flags |= 2 */ } /* "gevent/corecext.pyx":2003 * libev.ev_unref(self.loop._ptr) * self._flags |= 2 * libev.ev_stat_start(self.loop._ptr, &self._watcher) # <<<<<<<<<<<<<< * if not self._flags & 1: * Py_INCREF(self) */ ev_stat_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); /* "gevent/corecext.pyx":2004 * self._flags |= 2 * libev.ev_stat_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); if (__pyx_t_3) { /* "gevent/corecext.pyx":2005 * libev.ev_stat_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: * Py_INCREF(self) # <<<<<<<<<<<<<< * self._flags |= 1 * */ Py_INCREF(((PyObject*)__pyx_v_self)); /* "gevent/corecext.pyx":2006 * if not self._flags & 1: * Py_INCREF(self) * self._flags |= 1 # <<<<<<<<<<<<<< * * property active: */ __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); /* "gevent/corecext.pyx":2004 * self._flags |= 2 * libev.ev_stat_start(self.loop._ptr, &self._watcher) * if not self._flags & 1: # <<<<<<<<<<<<<< * Py_INCREF(self) * self._flags |= 1 */ } /* "gevent/corecext.pyx":1992 * self._flags |= 1 * * def start(self, object callback, *args): # <<<<<<<<<<<<<< * * if not self.loop._ptr: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.start", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2010 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6active_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_6active___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_6active___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":2011 * * def __get__(self): * return True if libev.ev_is_active(&self._watcher) else False # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":2010 * property active: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_active(&self._watcher) else False * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2016 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * cdef readonly str path */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_7pending_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_7pending___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_7pending___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":2017 * * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False # <<<<<<<<<<<<<< * cdef readonly str path * cdef readonly bytes _paths */ __Pyx_XDECREF(__pyx_r); if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { __Pyx_INCREF(Py_True); __pyx_t_1 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_1 = Py_False; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":2016 * property pending: * * def __get__(self): # <<<<<<<<<<<<<< * return True if libev.ev_is_pending(&self._watcher) else False * cdef readonly str path */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2021 * cdef readonly bytes _paths * * def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * self.path = path * cdef bytes paths */ /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct PyGeventLoopObject *__pyx_v_loop = 0; PyObject *__pyx_v_path = 0; float __pyx_v_interval; PyObject *__pyx_v_ref = 0; PyObject *__pyx_v_priority = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)Py_True); values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interval); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); __pyx_v_path = ((PyObject*)values[1]); if (values[2]) { __pyx_v_interval = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_interval = ((float)0.0); } __pyx_v_ref = values[3]; __pyx_v_priority = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("gevent.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_8corecext_loop, 1, "loop", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6gevent_8corecext_4stat_6__init__(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_6__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { PyObject *__pyx_v_paths = 0; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; char *__pyx_t_8; int __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "gevent/corecext.pyx":2022 * * def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): * self.path = path # <<<<<<<<<<<<<< * cdef bytes paths * if isinstance(path, unicode): */ __Pyx_INCREF(__pyx_v_path); __Pyx_GIVEREF(__pyx_v_path); __Pyx_GOTREF(__pyx_v_self->path); __Pyx_DECREF(__pyx_v_self->path); __pyx_v_self->path = __pyx_v_path; /* "gevent/corecext.pyx":2024 * self.path = path * cdef bytes paths * if isinstance(path, unicode): # <<<<<<<<<<<<<< * # the famous Python3 filesystem encoding debacle hits us here. Can we do better? * # We must keep a reference to the encoded string so that its bytes don't get freed */ __pyx_t_1 = PyUnicode_Check(__pyx_v_path); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":2028 * # We must keep a reference to the encoded string so that its bytes don't get freed * # and overwritten, leading to strange errors from libev ("no such file or directory") * paths = (path).encode(sys.getfilesystemencoding()) # <<<<<<<<<<<<<< * self._paths = paths * else: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (__pyx_t_6) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_7) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_paths = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":2029 * # and overwritten, leading to strange errors from libev ("no such file or directory") * paths = (path).encode(sys.getfilesystemencoding()) * self._paths = paths # <<<<<<<<<<<<<< * else: * paths = path */ __Pyx_INCREF(__pyx_v_paths); __Pyx_GIVEREF(__pyx_v_paths); __Pyx_GOTREF(__pyx_v_self->_paths); __Pyx_DECREF(__pyx_v_self->_paths); __pyx_v_self->_paths = __pyx_v_paths; /* "gevent/corecext.pyx":2024 * self.path = path * cdef bytes paths * if isinstance(path, unicode): # <<<<<<<<<<<<<< * # the famous Python3 filesystem encoding debacle hits us here. Can we do better? * # We must keep a reference to the encoded string so that its bytes don't get freed */ goto __pyx_L3; } /* "gevent/corecext.pyx":2031 * self._paths = paths * else: * paths = path # <<<<<<<<<<<<<< * self._paths = paths * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) */ /*else*/ { __pyx_t_3 = __pyx_v_path; __Pyx_INCREF(__pyx_t_3); __pyx_v_paths = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "gevent/corecext.pyx":2032 * else: * paths = path * self._paths = paths # <<<<<<<<<<<<<< * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) * self.loop = loop */ __Pyx_INCREF(__pyx_v_paths); __Pyx_GIVEREF(__pyx_v_paths); __Pyx_GOTREF(__pyx_v_self->_paths); __Pyx_DECREF(__pyx_v_self->_paths); __pyx_v_self->_paths = __pyx_v_paths; } __pyx_L3:; /* "gevent/corecext.pyx":2033 * paths = path * self._paths = paths * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) # <<<<<<<<<<<<<< * self.loop = loop * if ref: */ __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_paths); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_stat_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_stat), ((char *)__pyx_t_8), __pyx_v_interval); /* "gevent/corecext.pyx":2034 * self._paths = paths * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) * self.loop = loop # <<<<<<<<<<<<<< * if ref: * self._flags = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_loop)); __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = __pyx_v_loop; /* "gevent/corecext.pyx":2035 * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { /* "gevent/corecext.pyx":2036 * self.loop = loop * if ref: * self._flags = 0 # <<<<<<<<<<<<<< * else: * self._flags = 4 */ __pyx_v_self->_flags = 0; /* "gevent/corecext.pyx":2035 * libev.ev_stat_init(&self._watcher, gevent_callback_stat, paths, interval) * self.loop = loop * if ref: # <<<<<<<<<<<<<< * self._flags = 0 * else: */ goto __pyx_L4; } /* "gevent/corecext.pyx":2038 * self._flags = 0 * else: * self._flags = 4 # <<<<<<<<<<<<<< * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) */ /*else*/ { __pyx_v_self->_flags = 4; } __pyx_L4:; /* "gevent/corecext.pyx":2039 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_t_2 = (__pyx_v_priority != Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":2040 * self._flags = 4 * if priority is not None: * libev.ev_set_priority(&self._watcher, priority) # <<<<<<<<<<<<<< * * property attr: */ __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_9); /* "gevent/corecext.pyx":2039 * else: * self._flags = 4 * if priority is not None: # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ } /* "gevent/corecext.pyx":2021 * cdef readonly bytes _paths * * def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): # <<<<<<<<<<<<<< * self.path = path * cdef bytes paths */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gevent.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_paths); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2044 * property attr: * * def __get__(self): # <<<<<<<<<<<<<< * if not self._watcher.attr.st_nlink: * return */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4attr___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":2045 * * def __get__(self): * if not self._watcher.attr.st_nlink: # <<<<<<<<<<<<<< * return * return _pystat_fromstructstat(&self._watcher.attr) */ __pyx_t_1 = ((!(__pyx_v_self->_watcher.attr.st_nlink != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":2046 * def __get__(self): * if not self._watcher.attr.st_nlink: * return # <<<<<<<<<<<<<< * return _pystat_fromstructstat(&self._watcher.attr) * */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/corecext.pyx":2045 * * def __get__(self): * if not self._watcher.attr.st_nlink: # <<<<<<<<<<<<<< * return * return _pystat_fromstructstat(&self._watcher.attr) */ } /* "gevent/corecext.pyx":2047 * if not self._watcher.attr.st_nlink: * return * return _pystat_fromstructstat(&self._watcher.attr) # <<<<<<<<<<<<<< * * property prev: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.attr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":2044 * property attr: * * def __get__(self): # <<<<<<<<<<<<<< * if not self._watcher.attr.st_nlink: * return */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.attr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2051 * property prev: * * def __get__(self): # <<<<<<<<<<<<<< * if not self._watcher.prev.st_nlink: * return */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4prev___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":2052 * * def __get__(self): * if not self._watcher.prev.st_nlink: # <<<<<<<<<<<<<< * return * return _pystat_fromstructstat(&self._watcher.prev) */ __pyx_t_1 = ((!(__pyx_v_self->_watcher.prev.st_nlink != 0)) != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":2053 * def __get__(self): * if not self._watcher.prev.st_nlink: * return # <<<<<<<<<<<<<< * return _pystat_fromstructstat(&self._watcher.prev) * */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "gevent/corecext.pyx":2052 * * def __get__(self): * if not self._watcher.prev.st_nlink: # <<<<<<<<<<<<<< * return * return _pystat_fromstructstat(&self._watcher.prev) */ } /* "gevent/corecext.pyx":2054 * if not self._watcher.prev.st_nlink: * return * return _pystat_fromstructstat(&self._watcher.prev) # <<<<<<<<<<<<<< * * property interval: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.prev)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":2051 * property prev: * * def __get__(self): # <<<<<<<<<<<<<< * if not self._watcher.prev.st_nlink: * return */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent.corecext.stat.prev.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2058 * property interval: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.interval * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_8interval___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); /* "gevent/corecext.pyx":2059 * * def __get__(self): * return self._watcher.interval # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.interval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "gevent/corecext.pyx":2058 * property interval: * * def __get__(self): # <<<<<<<<<<<<<< * return self._watcher.interval * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.stat.interval.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1915 * * * cdef public loop loop # <<<<<<<<<<<<<< * cdef object _callback * cdef public tuple args */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4loop_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4loop___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4loop___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); __pyx_r = ((PyObject *)__pyx_v_self->loop); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4loop_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_4loop_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_8corecext_loop))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.stat.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_4loop_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4loop_4__del__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_4loop_4__del__(struct PyGeventStatObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->loop); __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1917 * cdef public loop loop * cdef object _callback * cdef public tuple args # <<<<<<<<<<<<<< * cdef readonly int _flags * cdef libev.ev_stat _watcher */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4args_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4args___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4args___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->args); __pyx_r = __pyx_v_self->args; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4args_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_4args_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.stat.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_6gevent_8corecext_4stat_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_6gevent_8corecext_4stat_4args_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4args_4__del__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_8corecext_4stat_4args_4__del__(struct PyGeventStatObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->args); __Pyx_DECREF(__pyx_v_self->args); __pyx_v_self->args = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":1918 * cdef object _callback * cdef public tuple args * cdef readonly int _flags # <<<<<<<<<<<<<< * cdef libev.ev_stat _watcher * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6_flags_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_6_flags___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_6_flags___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.stat._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2018 * def __get__(self): * return True if libev.ev_is_pending(&self._watcher) else False * cdef readonly str path # <<<<<<<<<<<<<< * cdef readonly bytes _paths * */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_4path___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->path); __pyx_r = __pyx_v_self->path; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2019 * return True if libev.ev_is_pending(&self._watcher) else False * cdef readonly str path * cdef readonly bytes _paths # <<<<<<<<<<<<<< * * def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): */ /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_4stat_6_paths___get__(((struct PyGeventStatObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_paths); __pyx_r = __pyx_v_self->_paths; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "gevent/corecext.pyx":2065 * * * cdef void _syserr_cb(char* msg) with gil: # <<<<<<<<<<<<<< * try: * __SYSERR_CALLBACK(msg, errno) */ static void __pyx_f_6gevent_8corecext__syserr_cb(char *__pyx_v_msg) { PyObject *__pyx_v_print_exc = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; Py_ssize_t __pyx_t_9; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; int __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("_syserr_cb", 0); /* "gevent/corecext.pyx":2066 * * cdef void _syserr_cb(char* msg) with gil: * try: # <<<<<<<<<<<<<< * __SYSERR_CALLBACK(msg, errno) * except: */ { __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "gevent/corecext.pyx":2067 * cdef void _syserr_cb(char* msg) with gil: * try: * __SYSERR_CALLBACK(msg, errno) # <<<<<<<<<<<<<< * except: * set_syserr_cb(None) */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_msg); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":2066 * * cdef void _syserr_cb(char* msg) with gil: * try: # <<<<<<<<<<<<<< * __SYSERR_CALLBACK(msg, errno) * except: */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "gevent/corecext.pyx":2068 * try: * __SYSERR_CALLBACK(msg, errno) * except: # <<<<<<<<<<<<<< * set_syserr_cb(None) * print_exc = getattr(traceback, 'print_exc', None) */ /*except:*/ { __Pyx_AddTraceback("gevent.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_10); /* "gevent/corecext.pyx":2069 * __SYSERR_CALLBACK(msg, errno) * except: * set_syserr_cb(None) # <<<<<<<<<<<<<< * print_exc = getattr(traceback, 'print_exc', None) * if print_exc is not None: */ __pyx_t_7 = __pyx_f_6gevent_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "gevent/corecext.pyx":2070 * except: * set_syserr_cb(None) * print_exc = getattr(traceback, 'print_exc', None) # <<<<<<<<<<<<<< * if print_exc is not None: * print_exc() */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_7, __pyx_n_s_print_exc, Py_None); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_print_exc = __pyx_t_6; __pyx_t_6 = 0; /* "gevent/corecext.pyx":2071 * set_syserr_cb(None) * print_exc = getattr(traceback, 'print_exc', None) * if print_exc is not None: # <<<<<<<<<<<<<< * print_exc() * */ __pyx_t_11 = (__pyx_v_print_exc != Py_None); __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* "gevent/corecext.pyx":2072 * print_exc = getattr(traceback, 'print_exc', None) * if print_exc is not None: * print_exc() # <<<<<<<<<<<<<< * * */ __Pyx_INCREF(__pyx_v_print_exc); __pyx_t_7 = __pyx_v_print_exc; __pyx_t_8 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (__pyx_t_8) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "gevent/corecext.pyx":2071 * set_syserr_cb(None) * print_exc = getattr(traceback, 'print_exc', None) * if print_exc is not None: # <<<<<<<<<<<<<< * print_exc() * */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L4_exception_handled; } __pyx_L5_except_error:; /* "gevent/corecext.pyx":2066 * * cdef void _syserr_cb(char* msg) with gil: * try: # <<<<<<<<<<<<<< * __SYSERR_CALLBACK(msg, errno) * except: */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L10_try_end:; } /* "gevent/corecext.pyx":2065 * * * cdef void _syserr_cb(char* msg) with gil: # <<<<<<<<<<<<<< * try: * __SYSERR_CALLBACK(msg, errno) */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("gevent.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_print_exc); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD PyGILState_Release(__pyx_gilstate_save); #endif } /* "gevent/corecext.pyx":2075 * * * cpdef set_syserr_cb(callback): # <<<<<<<<<<<<<< * global __SYSERR_CALLBACK * if callback is None: */ static PyObject *__pyx_pw_6gevent_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_f_6gevent_8corecext_set_syserr_cb(PyObject *__pyx_v_callback, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_syserr_cb", 0); /* "gevent/corecext.pyx":2077 * cpdef set_syserr_cb(callback): * global __SYSERR_CALLBACK * if callback is None: # <<<<<<<<<<<<<< * libev.ev_set_syserr_cb(NULL) * __SYSERR_CALLBACK = None */ __pyx_t_1 = (__pyx_v_callback == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "gevent/corecext.pyx":2078 * global __SYSERR_CALLBACK * if callback is None: * libev.ev_set_syserr_cb(NULL) # <<<<<<<<<<<<<< * __SYSERR_CALLBACK = None * elif callable(callback): */ ev_set_syserr_cb(NULL); /* "gevent/corecext.pyx":2079 * if callback is None: * libev.ev_set_syserr_cb(NULL) * __SYSERR_CALLBACK = None # <<<<<<<<<<<<<< * elif callable(callback): * libev.ev_set_syserr_cb(_syserr_cb) */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":2077 * cpdef set_syserr_cb(callback): * global __SYSERR_CALLBACK * if callback is None: # <<<<<<<<<<<<<< * libev.ev_set_syserr_cb(NULL) * __SYSERR_CALLBACK = None */ goto __pyx_L3; } /* "gevent/corecext.pyx":2080 * libev.ev_set_syserr_cb(NULL) * __SYSERR_CALLBACK = None * elif callable(callback): # <<<<<<<<<<<<<< * libev.ev_set_syserr_cb(_syserr_cb) * __SYSERR_CALLBACK = callback */ __pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "gevent/corecext.pyx":2081 * __SYSERR_CALLBACK = None * elif callable(callback): * libev.ev_set_syserr_cb(_syserr_cb) # <<<<<<<<<<<<<< * __SYSERR_CALLBACK = callback * else: */ ev_set_syserr_cb(((void *)__pyx_f_6gevent_8corecext__syserr_cb)); /* "gevent/corecext.pyx":2082 * elif callable(callback): * libev.ev_set_syserr_cb(_syserr_cb) * __SYSERR_CALLBACK = callback # <<<<<<<<<<<<<< * else: * raise TypeError('Expected callable or None, got %r' % (callback, )) */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":2080 * libev.ev_set_syserr_cb(NULL) * __SYSERR_CALLBACK = None * elif callable(callback): # <<<<<<<<<<<<<< * libev.ev_set_syserr_cb(_syserr_cb) * __SYSERR_CALLBACK = callback */ goto __pyx_L3; } /* "gevent/corecext.pyx":2084 * __SYSERR_CALLBACK = callback * else: * raise TypeError('Expected callable or None, got %r' % (callback, )) # <<<<<<<<<<<<<< * * */ /*else*/ { __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; /* "gevent/corecext.pyx":2075 * * * cpdef set_syserr_cb(callback): # <<<<<<<<<<<<<< * global __SYSERR_CALLBACK * if callback is None: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_pw_6gevent_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_syserr_cb (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_8corecext_20set_syserr_cb(__pyx_self, ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_syserr_cb", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_8corecext_set_syserr_cb(__pyx_v_callback, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_tp_new_6gevent_8corecext__EVENTSType(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; return o; } static void __pyx_tp_dealloc_6gevent_8corecext__EVENTSType(PyObject *o) { #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif (*Py_TYPE(o)->tp_free)(o); } static PyMethodDef __pyx_methods_6gevent_8corecext__EVENTSType[] = { {0, 0, 0, 0} }; static PyTypeObject __pyx_type_6gevent_8corecext__EVENTSType = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext._EVENTSType", /*tp_name*/ sizeof(struct __pyx_obj_6gevent_8corecext__EVENTSType), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext__EVENTSType, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_8corecext_11_EVENTSType_1__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext__EVENTSType, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext__EVENTSType, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_6gevent_8corecext_loop __pyx_vtable_6gevent_8corecext_loop; static PyObject *__pyx_tp_new_6gevent_8corecext_loop(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct PyGeventLoopObject *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct PyGeventLoopObject *)o); p->__pyx_vtab = __pyx_vtabptr_6gevent_8corecext_loop; p->error_handler = Py_None; Py_INCREF(Py_None); p->_callbacks = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_loop(PyObject *o) { struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_6gevent_8corecext_4loop_7__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->error_handler); Py_CLEAR(p->_callbacks); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_6gevent_8corecext_loop(PyObject *o, visitproc v, void *a) { int e; struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; if (p->error_handler) { e = (*v)(p->error_handler, a); if (e) return e; } if (p->_callbacks) { e = (*v)(p->_callbacks, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_loop(PyObject *o) { PyObject* tmp; struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; tmp = ((PyObject*)p->error_handler); p->error_handler = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callbacks); p->_callbacks = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_ptr(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_3ptr_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_WatcherType(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_11WatcherType_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_MAXPRI(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_6MAXPRI_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_MINPRI(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_6MINPRI_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_default(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_7default_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_iteration(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_9iteration_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_depth(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_5depth_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_backend_int(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_11backend_int_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_backend(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_7backend_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_pendingcnt(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_10pendingcnt_1__get__(o); } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_getprop_6gevent_8corecext_4loop_activecnt(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_9activecnt_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_sig_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_11sig_pending_1__get__(o); } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) static PyObject *__pyx_getprop_6gevent_8corecext_4loop_sigfd(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_5sigfd_1__get__(o); } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) static PyObject *__pyx_getprop_6gevent_8corecext_4loop_origflags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_9origflags_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4loop_origflags_int(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_13origflags_int_1__get__(o); } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_getprop_6gevent_8corecext_4loop_error_handler(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_13error_handler_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4loop_error_handler(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4loop_13error_handler_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4loop_13error_handler_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4loop__callbacks(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4loop_10_callbacks_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4loop__callbacks(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4loop_10_callbacks_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4loop_10_callbacks_5__del__(o); } } static PyMethodDef __pyx_methods_6gevent_8corecext_loop[] = { {"_stop_watchers", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_3_stop_watchers, METH_NOARGS, 0}, {"destroy", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_5destroy, METH_NOARGS, 0}, {"_handle_syserr", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_9_handle_syserr, METH_VARARGS|METH_KEYWORDS, 0}, {"handle_error", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_11handle_error, METH_VARARGS|METH_KEYWORDS, 0}, {"_default_handle_error", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_13_default_handle_error, METH_VARARGS|METH_KEYWORDS, 0}, {"run", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_15run, METH_VARARGS|METH_KEYWORDS, 0}, {"reinit", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_17reinit, METH_NOARGS, 0}, {"ref", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_19ref, METH_NOARGS, 0}, {"unref", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_21unref, METH_NOARGS, 0}, {"break_", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_23break_, METH_VARARGS|METH_KEYWORDS, 0}, {"verify", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_25verify, METH_NOARGS, 0}, {"now", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_27now, METH_NOARGS, 0}, {"update", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_29update, METH_NOARGS, 0}, {"io", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_33io, METH_VARARGS|METH_KEYWORDS, 0}, {"timer", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_35timer, METH_VARARGS|METH_KEYWORDS, 0}, {"signal", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_37signal, METH_VARARGS|METH_KEYWORDS, 0}, {"idle", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_39idle, METH_VARARGS|METH_KEYWORDS, 0}, {"prepare", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_41prepare, METH_VARARGS|METH_KEYWORDS, 0}, {"check", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_43check, METH_VARARGS|METH_KEYWORDS, 0}, {"fork", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_45fork, METH_VARARGS|METH_KEYWORDS, 0}, {"async", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_47async, METH_VARARGS|METH_KEYWORDS, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {"child", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_49child, METH_VARARGS|METH_KEYWORDS, 0}, {"install_sigchld", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_51install_sigchld, METH_NOARGS, 0}, {"stat", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_53stat, METH_VARARGS|METH_KEYWORDS, 0}, {"run_callback", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_55run_callback, METH_VARARGS|METH_KEYWORDS, 0}, {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_57_format, METH_NOARGS, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) {"stat", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_49stat, METH_VARARGS|METH_KEYWORDS, 0}, {"run_callback", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_51run_callback, METH_VARARGS|METH_KEYWORDS, 0}, {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_53_format, METH_NOARGS, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) {"_format_details", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_59_format_details, METH_NOARGS, 0}, {"fileno", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_61fileno, METH_NOARGS, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) {"_format_details", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_55_format_details, METH_NOARGS, 0}, {"fileno", (PyCFunction)__pyx_pw_6gevent_8corecext_4loop_57fileno, METH_NOARGS, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_loop[] = { {(char *)"ptr", __pyx_getprop_6gevent_8corecext_4loop_ptr, 0, 0, 0}, {(char *)"WatcherType", __pyx_getprop_6gevent_8corecext_4loop_WatcherType, 0, 0, 0}, {(char *)"MAXPRI", __pyx_getprop_6gevent_8corecext_4loop_MAXPRI, 0, 0, 0}, {(char *)"MINPRI", __pyx_getprop_6gevent_8corecext_4loop_MINPRI, 0, 0, 0}, {(char *)"default", __pyx_getprop_6gevent_8corecext_4loop_default, 0, 0, 0}, {(char *)"iteration", __pyx_getprop_6gevent_8corecext_4loop_iteration, 0, 0, 0}, {(char *)"depth", __pyx_getprop_6gevent_8corecext_4loop_depth, 0, 0, 0}, {(char *)"backend_int", __pyx_getprop_6gevent_8corecext_4loop_backend_int, 0, 0, 0}, {(char *)"backend", __pyx_getprop_6gevent_8corecext_4loop_backend, 0, 0, 0}, {(char *)"pendingcnt", __pyx_getprop_6gevent_8corecext_4loop_pendingcnt, 0, 0, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {(char *)"activecnt", __pyx_getprop_6gevent_8corecext_4loop_activecnt, 0, 0, 0}, {(char *)"sig_pending", __pyx_getprop_6gevent_8corecext_4loop_sig_pending, 0, 0, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) {(char *)"sigfd", __pyx_getprop_6gevent_8corecext_4loop_sigfd, 0, 0, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {(char *)"origflags", __pyx_getprop_6gevent_8corecext_4loop_origflags, 0, 0, 0}, {(char *)"origflags_int", __pyx_getprop_6gevent_8corecext_4loop_origflags_int, 0, 0, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {(char *)"error_handler", __pyx_getprop_6gevent_8corecext_4loop_error_handler, __pyx_setprop_6gevent_8corecext_4loop_error_handler, 0, 0}, {(char *)"_callbacks", __pyx_getprop_6gevent_8corecext_4loop__callbacks, __pyx_setprop_6gevent_8corecext_4loop__callbacks, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventLoop_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.loop", /*tp_name*/ sizeof(struct PyGeventLoopObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_loop, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_8corecext_4loop_31__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_loop, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_loop, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_loop, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_loop, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_4loop_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_loop, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_callback(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct PyGeventCallbackObject *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct PyGeventCallbackObject *)o); p->callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_callback(PyObject *o) { struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->callback); Py_CLEAR(p->args); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_6gevent_8corecext_callback(PyObject *o, visitproc v, void *a) { int e; struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; if (p->callback) { e = (*v)(p->callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_callback(PyObject *o) { PyObject* tmp; struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; tmp = ((PyObject*)p->callback); p->callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_8callback_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_8callback_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_8callback_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_8callback_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_8callback_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_8callback_8callback_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_8callback_8callback_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_8callback_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_8callback_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_8callback_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_8callback_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_8callback_4args_5__del__(o); } } static PyMethodDef __pyx_methods_6gevent_8corecext_callback[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_8callback_3stop, METH_NOARGS, 0}, {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_8callback_9_format, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_callback[] = { {(char *)"pending", __pyx_getprop_6gevent_8corecext_8callback_pending, 0, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_8callback_callback, __pyx_setprop_6gevent_8corecext_8callback_callback, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_8callback_args, __pyx_setprop_6gevent_8corecext_8callback_args, 0, 0}, {0, 0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_callback = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY 0, /*nb_divide*/ #endif 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ __pyx_pw_6gevent_8corecext_8callback_5__nonzero__, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY 0, /*nb_coerce*/ #endif 0, /*nb_int*/ #if PY_MAJOR_VERSION < 3 0, /*nb_long*/ #else 0, /*reserved*/ #endif 0, /*nb_float*/ #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY 0, /*nb_oct*/ #endif #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY 0, /*nb_hex*/ #endif 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY 0, /*nb_inplace_divide*/ #endif 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ 0, /*nb_index*/ #if PY_VERSION_HEX >= 0x03050000 0, /*nb_matrix_multiply*/ #endif #if PY_VERSION_HEX >= 0x03050000 0, /*nb_inplace_matrix_multiply*/ #endif }; DL_EXPORT(PyTypeObject) PyGeventCallback_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.callback", /*tp_name*/ sizeof(struct PyGeventCallbackObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_callback, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_8corecext_8callback_7__repr__, /*tp_repr*/ &__pyx_tp_as_number_callback, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_callback, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_callback, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_callback, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_callback, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_8callback_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_callback, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_watcher(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; return o; } static void __pyx_tp_dealloc_6gevent_8corecext_watcher(PyObject *o) { #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif (*Py_TYPE(o)->tp_free)(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_watcher[] = { {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_7watcher_3_format, METH_NOARGS, 0}, {0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventWatcher_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.watcher", /*tp_name*/ sizeof(struct PyGeventWatcherObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_watcher, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ "Abstract base class for all the watchers", /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_watcher, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_watcher, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventIOObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventIOObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) if (unlikely(__pyx_pw_6gevent_8corecext_2io_11__cinit__(o, __pyx_empty_tuple, NULL) < 0)) { Py_DECREF(o); o = 0; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) return o; } static void __pyx_tp_dealloc_6gevent_8corecext_io(PyObject *o) { struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_6gevent_8corecext_2io_13__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_io(PyObject *o, visitproc v, void *a) { int e; struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_io)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_io(PyObject *o) { PyObject* tmp; struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_io); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_2io_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_2io_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_2io_fd(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_2fd_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_fd(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_2fd_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_events(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_6events_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_events(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_6events_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_events_str(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_10events_str_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_2io_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_2io_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_2io_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_2io_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_2io_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_2io_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_2io__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_2io_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_io[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_2io_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_2io_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_2io_5start, METH_VARARGS|METH_KEYWORDS, 0}, {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_2io_9_format, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_io[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_2io_ref, __pyx_setprop_6gevent_8corecext_2io_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_2io_callback, __pyx_setprop_6gevent_8corecext_2io_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_2io_priority, __pyx_setprop_6gevent_8corecext_2io_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_2io_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_2io_pending, 0, 0, 0}, {(char *)"fd", __pyx_getprop_6gevent_8corecext_2io_fd, __pyx_setprop_6gevent_8corecext_2io_fd, 0, 0}, {(char *)"events", __pyx_getprop_6gevent_8corecext_2io_events, __pyx_setprop_6gevent_8corecext_2io_events, 0, 0}, {(char *)"events_str", __pyx_getprop_6gevent_8corecext_2io_events_str, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_2io_loop, __pyx_setprop_6gevent_8corecext_2io_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_2io_args, __pyx_setprop_6gevent_8corecext_2io_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_2io__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventIO_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.io", /*tp_name*/ sizeof(struct PyGeventIOObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_io, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_io, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_io, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_io, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_io, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_2io_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_io, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventTimerObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventTimerObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_timer(PyObject *o) { struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_timer(PyObject *o, visitproc v, void *a) { int e; struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_timer)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_timer(PyObject *o) { PyObject* tmp; struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_timer); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5timer_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5timer_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5timer_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5timer_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5timer_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5timer_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_at(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_2at_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5timer_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5timer_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5timer_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5timer_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5timer_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5timer_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5timer_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5timer__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5timer_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_timer[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_5timer_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_5timer_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_5timer_5start, METH_VARARGS|METH_KEYWORDS, 0}, {"again", (PyCFunction)__pyx_pw_6gevent_8corecext_5timer_9again, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_timer[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_5timer_ref, __pyx_setprop_6gevent_8corecext_5timer_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_5timer_callback, __pyx_setprop_6gevent_8corecext_5timer_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_5timer_priority, __pyx_setprop_6gevent_8corecext_5timer_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_5timer_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_5timer_pending, 0, 0, 0}, {(char *)"at", __pyx_getprop_6gevent_8corecext_5timer_at, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_5timer_loop, __pyx_setprop_6gevent_8corecext_5timer_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_5timer_args, __pyx_setprop_6gevent_8corecext_5timer_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_5timer__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventTimer_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.timer", /*tp_name*/ sizeof(struct PyGeventTimerObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_timer, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_timer, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_timer, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_timer, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_timer, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_5timer_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_timer, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventSignalObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventSignalObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_signal(PyObject *o) { struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_signal(PyObject *o, visitproc v, void *a) { int e; struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_signal)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_signal(PyObject *o) { PyObject* tmp; struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_signal); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_6signal_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_6signal_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_6signal_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_6signal_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_6signal_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_6signal_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_6signal_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_6signal_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_6signal_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_6signal_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_6signal_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_6signal_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_6signal_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_6signal__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_6signal_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_signal[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_6signal_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_6signal_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_6signal_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_signal[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_6signal_ref, __pyx_setprop_6gevent_8corecext_6signal_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_6signal_callback, __pyx_setprop_6gevent_8corecext_6signal_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_6signal_priority, __pyx_setprop_6gevent_8corecext_6signal_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_6signal_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_6signal_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_6signal_loop, __pyx_setprop_6gevent_8corecext_6signal_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_6signal_args, __pyx_setprop_6gevent_8corecext_6signal_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_6signal__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventSignal_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.signal", /*tp_name*/ sizeof(struct PyGeventSignalObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_signal, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_signal, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_signal, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_signal, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_signal, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_6signal_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_signal, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventIdleObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventIdleObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_idle(PyObject *o) { struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_idle(PyObject *o, visitproc v, void *a) { int e; struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_idle)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_idle(PyObject *o) { PyObject* tmp; struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_idle); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4idle_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4idle_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4idle_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4idle_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4idle_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4idle_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4idle_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4idle_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4idle_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4idle_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4idle_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4idle_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4idle_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4idle__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4idle_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_idle[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_4idle_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_4idle_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_4idle_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_idle[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_4idle_ref, __pyx_setprop_6gevent_8corecext_4idle_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_4idle_callback, __pyx_setprop_6gevent_8corecext_4idle_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_4idle_priority, __pyx_setprop_6gevent_8corecext_4idle_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_4idle_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_4idle_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_4idle_loop, __pyx_setprop_6gevent_8corecext_4idle_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_4idle_args, __pyx_setprop_6gevent_8corecext_4idle_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_4idle__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventIdle_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.idle", /*tp_name*/ sizeof(struct PyGeventIdleObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_idle, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_idle, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_idle, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_idle, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_idle, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_4idle_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_idle, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventPrepareObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventPrepareObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_prepare(PyObject *o) { struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_prepare(PyObject *o, visitproc v, void *a) { int e; struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_prepare)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_prepare(PyObject *o) { PyObject* tmp; struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_prepare); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_7prepare_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_7prepare_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_7prepare_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_7prepare_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_7prepare_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_7prepare_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_7prepare_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_7prepare_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_7prepare_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_7prepare_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_7prepare_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_7prepare_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_7prepare__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_7prepare_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_prepare[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_7prepare_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_7prepare_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_7prepare_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_prepare[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_7prepare_ref, __pyx_setprop_6gevent_8corecext_7prepare_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_7prepare_callback, __pyx_setprop_6gevent_8corecext_7prepare_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_7prepare_priority, __pyx_setprop_6gevent_8corecext_7prepare_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_7prepare_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_7prepare_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_7prepare_loop, __pyx_setprop_6gevent_8corecext_7prepare_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_7prepare_args, __pyx_setprop_6gevent_8corecext_7prepare_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_7prepare__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventPrepare_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.prepare", /*tp_name*/ sizeof(struct PyGeventPrepareObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_prepare, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_prepare, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_prepare, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_prepare, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_prepare, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_7prepare_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_prepare, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventCheckObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventCheckObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_check(PyObject *o) { struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_check(PyObject *o, visitproc v, void *a) { int e; struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_check)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_check(PyObject *o) { PyObject* tmp; struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_check); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_5check_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5check_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5check_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5check_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5check_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5check_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5check_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5check_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5check_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5check_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5check_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5check_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5check_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5check_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5check_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5check_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5check_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5check_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5check_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5check__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5check_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_check[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_5check_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_5check_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_5check_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_check[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_5check_ref, __pyx_setprop_6gevent_8corecext_5check_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_5check_callback, __pyx_setprop_6gevent_8corecext_5check_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_5check_priority, __pyx_setprop_6gevent_8corecext_5check_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_5check_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_5check_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_5check_loop, __pyx_setprop_6gevent_8corecext_5check_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_5check_args, __pyx_setprop_6gevent_8corecext_5check_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_5check__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventCheck_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.check", /*tp_name*/ sizeof(struct PyGeventCheckObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_check, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_check, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_check, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_check, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_check, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_5check_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_check, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventForkObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventForkObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_fork(PyObject *o) { struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_fork(PyObject *o, visitproc v, void *a) { int e; struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_fork)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_fork(PyObject *o) { PyObject* tmp; struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_fork); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4fork_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4fork_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4fork_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4fork_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4fork_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4fork_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4fork_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4fork_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4fork_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4fork_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4fork_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4fork_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4fork_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4fork__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4fork_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_fork[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_4fork_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_4fork_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_4fork_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_fork[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_4fork_ref, __pyx_setprop_6gevent_8corecext_4fork_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_4fork_callback, __pyx_setprop_6gevent_8corecext_4fork_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_4fork_priority, __pyx_setprop_6gevent_8corecext_4fork_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_4fork_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_4fork_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_4fork_loop, __pyx_setprop_6gevent_8corecext_4fork_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_4fork_args, __pyx_setprop_6gevent_8corecext_4fork_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_4fork__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventFork_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.fork", /*tp_name*/ sizeof(struct PyGeventForkObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_fork, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_fork, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_fork, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_fork, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_fork, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_4fork_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_fork, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_6gevent_8corecext_async(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventAsyncObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventAsyncObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_async(PyObject *o) { struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_async(PyObject *o, visitproc v, void *a) { int e; struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_async)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_async(PyObject *o) { PyObject* tmp; struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_async); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_5async_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5async_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5async_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5async_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5async_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5async_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5async_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5async_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5async_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5async_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5async_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5async_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5async_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5async_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5async_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5async_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5async_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5async_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5async_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5async__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5async_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_async[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_5async_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_5async_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_5async_5start, METH_VARARGS|METH_KEYWORDS, 0}, {"send", (PyCFunction)__pyx_pw_6gevent_8corecext_5async_9send, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_async[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_5async_ref, __pyx_setprop_6gevent_8corecext_5async_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_5async_callback, __pyx_setprop_6gevent_8corecext_5async_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_5async_priority, __pyx_setprop_6gevent_8corecext_5async_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_5async_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_5async_pending, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_5async_loop, __pyx_setprop_6gevent_8corecext_5async_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_5async_args, __pyx_setprop_6gevent_8corecext_5async_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_5async__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventAsync_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.async", /*tp_name*/ sizeof(struct PyGeventAsyncObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_async, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_async, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_async, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_async, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_async, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_5async_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_async, /*tp_new*/ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) static PyObject *__pyx_tp_new_6gevent_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventChildObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventChildObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_child(PyObject *o) { struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_child(PyObject *o, visitproc v, void *a) { int e; struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_child)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_child(PyObject *o) { PyObject* tmp; struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_child); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_5child_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5child_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5child_pid(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_3pid_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_5child_rpid(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_4rpid_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_rpid(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_4rpid_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_rstatus(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_7rstatus_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_rstatus(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_7rstatus_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5child_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5child_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_5child_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_5child_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_5child_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_5child__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_5child_6_flags_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_child[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_5child_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_5child_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_5child_5start, METH_VARARGS|METH_KEYWORDS, 0}, {"_format", (PyCFunction)__pyx_pw_6gevent_8corecext_5child_9_format, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_child[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_5child_ref, __pyx_setprop_6gevent_8corecext_5child_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_5child_callback, __pyx_setprop_6gevent_8corecext_5child_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_5child_priority, __pyx_setprop_6gevent_8corecext_5child_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_5child_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_5child_pending, 0, 0, 0}, {(char *)"pid", __pyx_getprop_6gevent_8corecext_5child_pid, 0, 0, 0}, {(char *)"rpid", __pyx_getprop_6gevent_8corecext_5child_rpid, __pyx_setprop_6gevent_8corecext_5child_rpid, 0, 0}, {(char *)"rstatus", __pyx_getprop_6gevent_8corecext_5child_rstatus, __pyx_setprop_6gevent_8corecext_5child_rstatus, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_5child_loop, __pyx_setprop_6gevent_8corecext_5child_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_5child_args, __pyx_setprop_6gevent_8corecext_5child_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_5child__flags, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventChild_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.child", /*tp_name*/ sizeof(struct PyGeventChildObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_child, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_child, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_child, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_child, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_child, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_5child_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_child, /*tp_new*/ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyObject *__pyx_tp_new_6gevent_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k) { struct PyGeventStatObject *p; PyObject *o = __pyx_tp_new_6gevent_8corecext_watcher(t, a, k); if (unlikely(!o)) return 0; p = ((struct PyGeventStatObject *)o); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); p->_callback = Py_None; Py_INCREF(Py_None); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); p->path = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_paths = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6gevent_8corecext_stat(PyObject *o) { struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->loop); Py_CLEAR(p->_callback); Py_CLEAR(p->args); Py_CLEAR(p->path); Py_CLEAR(p->_paths); #if CYTHON_COMPILING_IN_CPYTHON if (PyType_IS_GC(Py_TYPE(o)->tp_base)) #endif PyObject_GC_Track(o); __pyx_tp_dealloc_6gevent_8corecext_watcher(o); } static int __pyx_tp_traverse_6gevent_8corecext_stat(PyObject *o, visitproc v, void *a) { int e; struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; e = ((likely(__pyx_ptype_6gevent_8corecext_watcher)) ? ((__pyx_ptype_6gevent_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_8corecext_stat)); if (e) return e; if (p->loop) { e = (*v)(((PyObject*)p->loop), a); if (e) return e; } if (p->_callback) { e = (*v)(p->_callback, a); if (e) return e; } if (p->args) { e = (*v)(p->args, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext_stat(PyObject *o) { PyObject* tmp; struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; if (likely(__pyx_ptype_6gevent_8corecext_watcher)) { if (__pyx_ptype_6gevent_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_8corecext_stat); tmp = ((PyObject*)p->loop); p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->_callback); p->_callback = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->args); p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_ref(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_3ref_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4stat_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4stat_3ref_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_callback(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_8callback_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4stat_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4stat_8callback_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_priority(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_8priority_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4stat_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4stat_8priority_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_active(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_6active_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_pending(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_7pending_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_attr(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_4attr_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_prev(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_4prev_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_interval(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_8interval_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_loop(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_4loop_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4stat_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4stat_4loop_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4stat_4loop_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_args(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_4args_1__get__(o); } static int __pyx_setprop_6gevent_8corecext_4stat_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_6gevent_8corecext_4stat_4args_3__set__(o, v); } else { return __pyx_pw_6gevent_8corecext_4stat_4args_5__del__(o); } } static PyObject *__pyx_getprop_6gevent_8corecext_4stat__flags(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_6_flags_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat_path(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_4path_1__get__(o); } static PyObject *__pyx_getprop_6gevent_8corecext_4stat__paths(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6gevent_8corecext_4stat_6_paths_1__get__(o); } static PyMethodDef __pyx_methods_6gevent_8corecext_stat[] = { {"stop", (PyCFunction)__pyx_pw_6gevent_8corecext_4stat_1stop, METH_NOARGS, 0}, {"feed", (PyCFunction)__pyx_pw_6gevent_8corecext_4stat_3feed, METH_VARARGS|METH_KEYWORDS, 0}, {"start", (PyCFunction)__pyx_pw_6gevent_8corecext_4stat_5start, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6gevent_8corecext_stat[] = { {(char *)"ref", __pyx_getprop_6gevent_8corecext_4stat_ref, __pyx_setprop_6gevent_8corecext_4stat_ref, 0, 0}, {(char *)"callback", __pyx_getprop_6gevent_8corecext_4stat_callback, __pyx_setprop_6gevent_8corecext_4stat_callback, 0, 0}, {(char *)"priority", __pyx_getprop_6gevent_8corecext_4stat_priority, __pyx_setprop_6gevent_8corecext_4stat_priority, 0, 0}, {(char *)"active", __pyx_getprop_6gevent_8corecext_4stat_active, 0, 0, 0}, {(char *)"pending", __pyx_getprop_6gevent_8corecext_4stat_pending, 0, 0, 0}, {(char *)"attr", __pyx_getprop_6gevent_8corecext_4stat_attr, 0, 0, 0}, {(char *)"prev", __pyx_getprop_6gevent_8corecext_4stat_prev, 0, 0, 0}, {(char *)"interval", __pyx_getprop_6gevent_8corecext_4stat_interval, 0, 0, 0}, {(char *)"loop", __pyx_getprop_6gevent_8corecext_4stat_loop, __pyx_setprop_6gevent_8corecext_4stat_loop, 0, 0}, {(char *)"args", __pyx_getprop_6gevent_8corecext_4stat_args, __pyx_setprop_6gevent_8corecext_4stat_args, 0, 0}, {(char *)"_flags", __pyx_getprop_6gevent_8corecext_4stat__flags, 0, 0, 0}, {(char *)"path", __pyx_getprop_6gevent_8corecext_4stat_path, 0, 0, 0}, {(char *)"_paths", __pyx_getprop_6gevent_8corecext_4stat__paths, 0, 0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) PyGeventStat_Type = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.stat", /*tp_name*/ sizeof(struct PyGeventStatObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext_stat, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6gevent_8corecext_7watcher_1__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext_stat, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext_stat, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6gevent_8corecext_stat, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_6gevent_8corecext_stat, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_6gevent_8corecext_4stat_7__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext_stat, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *__pyx_freelist_6gevent_8corecext___pyx_scope_struct__genexpr[8]; static int __pyx_freecount_6gevent_8corecext___pyx_scope_struct__genexpr = 0; static PyObject *__pyx_tp_new_6gevent_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gevent_8corecext___pyx_scope_struct__genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr)))) { o = (PyObject*)__pyx_freelist_6gevent_8corecext___pyx_scope_struct__genexpr[--__pyx_freecount_6gevent_8corecext___pyx_scope_struct__genexpr]; memset(o, 0, sizeof(struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } return o; } static void __pyx_tp_dealloc_6gevent_8corecext___pyx_scope_struct__genexpr(PyObject *o) { struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_v_flag); Py_CLEAR(p->__pyx_v_string); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gevent_8corecext___pyx_scope_struct__genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr)))) { __pyx_freelist_6gevent_8corecext___pyx_scope_struct__genexpr[__pyx_freecount_6gevent_8corecext___pyx_scope_struct__genexpr++] = ((struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_6gevent_8corecext___pyx_scope_struct__genexpr(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)o; if (p->__pyx_v_flag) { e = (*v)(p->__pyx_v_flag, a); if (e) return e; } if (p->__pyx_v_string) { e = (*v)(p->__pyx_v_string, a); if (e) return e; } return 0; } static int __pyx_tp_clear_6gevent_8corecext___pyx_scope_struct__genexpr(PyObject *o) { PyObject* tmp; struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr *)o; tmp = ((PyObject*)p->__pyx_v_flag); p->__pyx_v_flag = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_string); p->__pyx_v_string = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyTypeObject __pyx_type_6gevent_8corecext___pyx_scope_struct__genexpr = { PyVarObject_HEAD_INIT(0, 0) "gevent.corecext.__pyx_scope_struct__genexpr", /*tp_name*/ sizeof(struct __pyx_obj_6gevent_8corecext___pyx_scope_struct__genexpr), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6gevent_8corecext___pyx_scope_struct__genexpr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_6gevent_8corecext___pyx_scope_struct__genexpr, /*tp_traverse*/ __pyx_tp_clear_6gevent_8corecext___pyx_scope_struct__genexpr, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6gevent_8corecext___pyx_scope_struct__genexpr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {"_flags_to_list", (PyCFunction)__pyx_pw_6gevent_8corecext_5_flags_to_list, METH_O, 0}, {"_flags_to_int", (PyCFunction)__pyx_pw_6gevent_8corecext_7_flags_to_int, METH_O, 0}, {"_check_flags", (PyCFunction)__pyx_pw_6gevent_8corecext_9_check_flags, METH_O, 0}, {"_events_to_str", (PyCFunction)__pyx_pw_6gevent_8corecext_11_events_to_str, METH_O, 0}, {"set_syserr_cb", (PyCFunction)__pyx_pw_6gevent_8corecext_21set_syserr_cb, METH_O, 0}, {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "corecext", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0}, {&__pyx_n_s_ASYNC, __pyx_k_ASYNC, sizeof(__pyx_k_ASYNC), 0, 0, 1, 1}, {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, {&__pyx_n_s_BACKEND_EPOLL, __pyx_k_BACKEND_EPOLL, sizeof(__pyx_k_BACKEND_EPOLL), 0, 0, 1, 1}, {&__pyx_n_s_BACKEND_KQUEUE, __pyx_k_BACKEND_KQUEUE, sizeof(__pyx_k_BACKEND_KQUEUE), 0, 0, 1, 1}, {&__pyx_n_s_BACKEND_POLL, __pyx_k_BACKEND_POLL, sizeof(__pyx_k_BACKEND_POLL), 0, 0, 1, 1}, {&__pyx_n_s_BACKEND_PORT, __pyx_k_BACKEND_PORT, sizeof(__pyx_k_BACKEND_PORT), 0, 0, 1, 1}, {&__pyx_n_s_BACKEND_SELECT, __pyx_k_BACKEND_SELECT, sizeof(__pyx_k_BACKEND_SELECT), 0, 0, 1, 1}, {&__pyx_n_s_CHECK, __pyx_k_CHECK, sizeof(__pyx_k_CHECK), 0, 0, 1, 1}, {&__pyx_n_s_CHILD, __pyx_k_CHILD, sizeof(__pyx_k_CHILD), 0, 0, 1, 1}, {&__pyx_n_s_CLEANUP, __pyx_k_CLEANUP, sizeof(__pyx_k_CLEANUP), 0, 0, 1, 1}, {&__pyx_n_s_CUSTOM, __pyx_k_CUSTOM, sizeof(__pyx_k_CUSTOM), 0, 0, 1, 1}, {&__pyx_kp_s_Cannot_set_priority_of_an_active, __pyx_k_Cannot_set_priority_of_an_active, sizeof(__pyx_k_Cannot_set_priority_of_an_active), 0, 0, 1, 0}, {&__pyx_n_s_EMBED, __pyx_k_EMBED, sizeof(__pyx_k_EMBED), 0, 0, 1, 1}, {&__pyx_n_s_ERROR, __pyx_k_ERROR, sizeof(__pyx_k_ERROR), 0, 0, 1, 1}, {&__pyx_n_s_EVENTS, __pyx_k_EVENTS, sizeof(__pyx_k_EVENTS), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_n_s_EV_USE_4HEAP, __pyx_k_EV_USE_4HEAP, sizeof(__pyx_k_EV_USE_4HEAP), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_k_EV_USE_CLOCK_SYSCALL, sizeof(__pyx_k_EV_USE_CLOCK_SYSCALL), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_EVENTFD, __pyx_k_EV_USE_EVENTFD, sizeof(__pyx_k_EV_USE_EVENTFD), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_FLOOR, __pyx_k_EV_USE_FLOOR, sizeof(__pyx_k_EV_USE_FLOOR), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_INOTIFY, __pyx_k_EV_USE_INOTIFY, sizeof(__pyx_k_EV_USE_INOTIFY), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_MONOTONIC, __pyx_k_EV_USE_MONOTONIC, sizeof(__pyx_k_EV_USE_MONOTONIC), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_NANOSLEEP, __pyx_k_EV_USE_NANOSLEEP, sizeof(__pyx_k_EV_USE_NANOSLEEP), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_REALTIME, __pyx_k_EV_USE_REALTIME, sizeof(__pyx_k_EV_USE_REALTIME), 0, 0, 1, 1}, {&__pyx_n_s_EV_USE_SIGNALFD, __pyx_k_EV_USE_SIGNALFD, sizeof(__pyx_k_EV_USE_SIGNALFD), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_kp_s_Expected_callable_not_r, __pyx_k_Expected_callable_not_r, sizeof(__pyx_k_Expected_callable_not_r), 0, 0, 1, 0}, {&__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_k_Expected_callable_or_None_got_r, sizeof(__pyx_k_Expected_callable_or_None_got_r), 0, 0, 1, 0}, {&__pyx_n_s_FORK, __pyx_k_FORK, sizeof(__pyx_k_FORK), 0, 0, 1, 1}, {&__pyx_n_s_FORKCHECK, __pyx_k_FORKCHECK, sizeof(__pyx_k_FORKCHECK), 0, 0, 1, 1}, {&__pyx_n_s_IDLE, __pyx_k_IDLE, sizeof(__pyx_k_IDLE), 0, 0, 1, 1}, {&__pyx_n_s_IOFDSET, __pyx_k_IOFDSET, sizeof(__pyx_k_IOFDSET), 0, 0, 1, 1}, {&__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_k_Invalid_backend_or_flag_s_Possib, sizeof(__pyx_k_Invalid_backend_or_flag_s_Possib), 0, 0, 1, 0}, {&__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_k_Invalid_value_for_backend_0x_x, sizeof(__pyx_k_Invalid_value_for_backend_0x_x), 0, 0, 1, 0}, {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, {&__pyx_n_s_LIBEV_EMBED, __pyx_k_LIBEV_EMBED, sizeof(__pyx_k_LIBEV_EMBED), 0, 0, 1, 1}, {&__pyx_n_s_MAXPRI, __pyx_k_MAXPRI, sizeof(__pyx_k_MAXPRI), 0, 0, 1, 1}, {&__pyx_n_s_MINPRI, __pyx_k_MINPRI, sizeof(__pyx_k_MINPRI), 0, 0, 1, 1}, {&__pyx_n_s_NOINOTIFY, __pyx_k_NOINOTIFY, sizeof(__pyx_k_NOINOTIFY), 0, 0, 1, 1}, {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1}, {&__pyx_n_s_NOSIGMASK, __pyx_k_NOSIGMASK, sizeof(__pyx_k_NOSIGMASK), 0, 0, 1, 1}, {&__pyx_n_s_NSIG, __pyx_k_NSIG, sizeof(__pyx_k_NSIG), 0, 0, 1, 1}, {&__pyx_n_s_PERIODIC, __pyx_k_PERIODIC, sizeof(__pyx_k_PERIODIC), 0, 0, 1, 1}, {&__pyx_n_s_PREPARE, __pyx_k_PREPARE, sizeof(__pyx_k_PREPARE), 0, 0, 1, 1}, {&__pyx_n_s_READ, __pyx_k_READ, sizeof(__pyx_k_READ), 0, 0, 1, 1}, {&__pyx_n_s_READWRITE, __pyx_k_READWRITE, sizeof(__pyx_k_READWRITE), 0, 0, 1, 1}, {&__pyx_n_s_SIGNAL, __pyx_k_SIGNAL, sizeof(__pyx_k_SIGNAL), 0, 0, 1, 1}, {&__pyx_n_s_SIGNALFD, __pyx_k_SIGNALFD, sizeof(__pyx_k_SIGNALFD), 0, 0, 1, 1}, {&__pyx_n_s_STAT, __pyx_k_STAT, sizeof(__pyx_k_STAT), 0, 0, 1, 1}, {&__pyx_n_s_SYSERR_CALLBACK, __pyx_k_SYSERR_CALLBACK, sizeof(__pyx_k_SYSERR_CALLBACK), 0, 0, 1, 1}, {&__pyx_n_s_SystemError, __pyx_k_SystemError, sizeof(__pyx_k_SystemError), 0, 0, 1, 1}, {&__pyx_n_s_TIMER, __pyx_k_TIMER, sizeof(__pyx_k_TIMER), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_UNDEF, __pyx_k_UNDEF, sizeof(__pyx_k_UNDEF), 0, 0, 1, 1}, {&__pyx_kp_s_Unsupported_backend_s, __pyx_k_Unsupported_backend_s, sizeof(__pyx_k_Unsupported_backend_s), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_WRITE, __pyx_k_WRITE, sizeof(__pyx_k_WRITE), 0, 0, 1, 1}, {&__pyx_kp_s__21, __pyx_k__21, sizeof(__pyx_k__21), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) {&__pyx_kp_s__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 0, 1, 0}, {&__pyx_kp_s__23, __pyx_k__23, sizeof(__pyx_k__23), 0, 0, 1, 0}, #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) {&__pyx_kp_s__26, __pyx_k__26, sizeof(__pyx_k__26), 0, 0, 1, 0}, #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_kp_s__27, __pyx_k__27, sizeof(__pyx_k__27), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) {&__pyx_kp_s__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0}, {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0}, {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0}, {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1}, {&__pyx_kp_s_active_2, __pyx_k_active_2, sizeof(__pyx_k_active_2), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_n_s_activecnt, __pyx_k_activecnt, sizeof(__pyx_k_activecnt), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_after, __pyx_k_after, sizeof(__pyx_k_after), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_kp_s_args_r, __pyx_k_args_r, sizeof(__pyx_k_args_r), 0, 0, 1, 0}, {&__pyx_n_s_backend, __pyx_k_backend, sizeof(__pyx_k_backend), 0, 0, 1, 1}, {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1}, {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1}, {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1}, {&__pyx_kp_s_callback_must_be_callable_not_No, __pyx_k_callback_must_be_callable_not_No, sizeof(__pyx_k_callback_must_be_callable_not_No), 0, 0, 1, 0}, {&__pyx_kp_s_callback_r, __pyx_k_callback_r, sizeof(__pyx_k_callback_r), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {&__pyx_kp_s_child_watchers_are_only_availabl, __pyx_k_child_watchers_are_only_availabl, sizeof(__pyx_k_child_watchers_are_only_availabl), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, {&__pyx_n_s_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 0, 1, 1}, {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1}, {&__pyx_kp_s_default_2, __pyx_k_default_2, sizeof(__pyx_k_default_2), 0, 0, 1, 0}, {&__pyx_n_s_default_handle_error, __pyx_k_default_handle_error, sizeof(__pyx_k_default_handle_error), 0, 0, 1, 1}, {&__pyx_n_s_destroyed, __pyx_k_destroyed, sizeof(__pyx_k_destroyed), 0, 0, 1, 1}, {&__pyx_n_s_embeddable_backends, __pyx_k_embeddable_backends, sizeof(__pyx_k_embeddable_backends), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_epoll, __pyx_k_epoll, sizeof(__pyx_k_epoll), 0, 0, 1, 1}, {&__pyx_n_s_errno, __pyx_k_errno, sizeof(__pyx_k_errno), 0, 0, 1, 1}, {&__pyx_kp_s_ev_default_loop_s_failed, __pyx_k_ev_default_loop_s_failed, sizeof(__pyx_k_ev_default_loop_s_failed), 0, 0, 1, 0}, {&__pyx_kp_s_ev_loop_new_s_failed, __pyx_k_ev_loop_new_s_failed, sizeof(__pyx_k_ev_loop_new_s_failed), 0, 0, 1, 0}, {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1}, {&__pyx_n_s_events_2, __pyx_k_events_2, sizeof(__pyx_k_events_2), 0, 0, 1, 1}, {&__pyx_n_s_events_str, __pyx_k_events_str, sizeof(__pyx_k_events_str), 0, 0, 1, 1}, {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {&__pyx_kp_s_fd_must_be_non_negative_r, __pyx_k_fd_must_be_non_negative_r, sizeof(__pyx_k_fd_must_be_non_negative_r), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_kp_s_fd_s_events_s, __pyx_k_fd_s_events_s, sizeof(__pyx_k_fd_s_events_s), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1}, {&__pyx_kp_s_fileno_2, __pyx_k_fileno_2, sizeof(__pyx_k_fileno_2), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, {&__pyx_n_s_flags_2, __pyx_k_flags_2, sizeof(__pyx_k_flags_2), 0, 0, 1, 1}, {&__pyx_n_s_flags_str2int, __pyx_k_flags_str2int, sizeof(__pyx_k_flags_str2int), 0, 0, 1, 1}, {&__pyx_n_s_forkcheck, __pyx_k_forkcheck, sizeof(__pyx_k_forkcheck), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_n_s_format_details, __pyx_k_format_details, sizeof(__pyx_k_format_details), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1}, {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1}, {&__pyx_n_s_get_header_version, __pyx_k_get_header_version, sizeof(__pyx_k_get_header_version), 0, 0, 1, 1}, {&__pyx_n_s_get_version, __pyx_k_get_version, sizeof(__pyx_k_get_version), 0, 0, 1, 1}, {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1}, {&__pyx_kp_s_gevent_core_EVENTS, __pyx_k_gevent_core_EVENTS, sizeof(__pyx_k_gevent_core_EVENTS), 0, 0, 1, 0}, {&__pyx_n_s_gevent_corecext, __pyx_k_gevent_corecext, sizeof(__pyx_k_gevent_corecext), 0, 0, 1, 1}, {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, {&__pyx_n_s_handle_syserr, __pyx_k_handle_syserr, sizeof(__pyx_k_handle_syserr), 0, 0, 1, 1}, {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1}, {&__pyx_n_s_how, __pyx_k_how, sizeof(__pyx_k_how), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_kp_s_illegal_event_mask_r, __pyx_k_illegal_event_mask_r, sizeof(__pyx_k_illegal_event_mask_r), 0, 0, 1, 0}, {&__pyx_kp_s_illegal_signal_number_r, __pyx_k_illegal_signal_number_r, sizeof(__pyx_k_illegal_signal_number_r), 0, 0, 1, 0}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 0, 1, 1}, {&__pyx_kp_s_io_watcher_attribute_events_is, __pyx_k_io_watcher_attribute_events_is, sizeof(__pyx_k_io_watcher_attribute_events_is), 0, 0, 1, 0}, {&__pyx_kp_s_io_watcher_attribute_fd_is_read, __pyx_k_io_watcher_attribute_fd_is_read, sizeof(__pyx_k_io_watcher_attribute_fd_is_read), 0, 0, 1, 0}, {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1}, {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, {&__pyx_n_s_kqueue, __pyx_k_kqueue, sizeof(__pyx_k_kqueue), 0, 0, 1, 1}, {&__pyx_n_s_level, __pyx_k_level, sizeof(__pyx_k_level), 0, 0, 1, 1}, {&__pyx_kp_s_libev_d_02d, __pyx_k_libev_d_02d, sizeof(__pyx_k_libev_d_02d), 0, 0, 1, 0}, {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_noenv, __pyx_k_noenv, sizeof(__pyx_k_noenv), 0, 0, 1, 1}, {&__pyx_n_s_noinotify, __pyx_k_noinotify, sizeof(__pyx_k_noinotify), 0, 0, 1, 1}, {&__pyx_n_s_nosigmask, __pyx_k_nosigmask, sizeof(__pyx_k_nosigmask), 0, 0, 1, 1}, {&__pyx_n_s_nowait, __pyx_k_nowait, sizeof(__pyx_k_nowait), 0, 0, 1, 1}, {&__pyx_n_s_once, __pyx_k_once, sizeof(__pyx_k_once), 0, 0, 1, 1}, {&__pyx_kp_s_operation_on_destroyed_loop, __pyx_k_operation_on_destroyed_loop, sizeof(__pyx_k_operation_on_destroyed_loop), 0, 0, 1, 0}, {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1}, {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1}, {&__pyx_n_s_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 0, 0, 1, 1}, {&__pyx_kp_s_pending_2, __pyx_k_pending_2, sizeof(__pyx_k_pending_2), 0, 0, 1, 0}, {&__pyx_kp_s_pending_s, __pyx_k_pending_s, sizeof(__pyx_k_pending_s), 0, 0, 1, 0}, {&__pyx_n_s_pendingcnt, __pyx_k_pendingcnt, sizeof(__pyx_k_pendingcnt), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1}, {&__pyx_kp_s_pid_r_rstatus_r, __pyx_k_pid_r_rstatus_r, sizeof(__pyx_k_pid_r_rstatus_r), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_poll, __pyx_k_poll, sizeof(__pyx_k_poll), 0, 0, 1, 1}, {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1}, {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1}, {&__pyx_n_s_print_exception, __pyx_k_print_exception, sizeof(__pyx_k_print_exception), 0, 0, 1, 1}, {&__pyx_n_s_priority, __pyx_k_priority, sizeof(__pyx_k_priority), 0, 0, 1, 1}, {&__pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_k_private_tmp_gevent_python2_7_ge, sizeof(__pyx_k_private_tmp_gevent_python2_7_ge), 0, 0, 1, 0}, {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_recommended_backends, __pyx_k_recommended_backends, sizeof(__pyx_k_recommended_backends), 0, 0, 1, 1}, {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_kp_s_ref_2, __pyx_k_ref_2, sizeof(__pyx_k_ref_2), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1}, {&__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_k_repeat_must_be_positive_or_zero, sizeof(__pyx_k_repeat_must_be_positive_or_zero), 0, 0, 1, 0}, {&__pyx_n_s_revents, __pyx_k_revents, sizeof(__pyx_k_revents), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {&__pyx_n_s_rstatus, __pyx_k_rstatus, sizeof(__pyx_k_rstatus), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_kp_s_s_at_0x_x_s, __pyx_k_s_at_0x_x_s, sizeof(__pyx_k_s_at_0x_x_s), 0, 0, 1, 0}, {&__pyx_kp_s_s_at_0x_x_s_2, __pyx_k_s_at_0x_x_s_2, sizeof(__pyx_k_s_at_0x_x_s_2), 0, 0, 1, 0}, {&__pyx_n_s_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 1, 1}, {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) {&__pyx_n_s_sigfd, __pyx_k_sigfd, sizeof(__pyx_k_sigfd), 0, 0, 1, 1}, {&__pyx_kp_s_sigfd_2, __pyx_k_sigfd_2, sizeof(__pyx_k_sigfd_2), 0, 0, 1, 0}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_signal, __pyx_k_signal, sizeof(__pyx_k_signal), 0, 0, 1, 1}, {&__pyx_n_s_signalfd, __pyx_k_signalfd, sizeof(__pyx_k_signalfd), 0, 0, 1, 1}, {&__pyx_n_s_signalmodule, __pyx_k_signalmodule, sizeof(__pyx_k_signalmodule), 0, 0, 1, 1}, {&__pyx_n_s_signalnum, __pyx_k_signalnum, sizeof(__pyx_k_signalnum), 0, 0, 1, 1}, {&__pyx_n_s_signum, __pyx_k_signum, sizeof(__pyx_k_signum), 0, 0, 1, 1}, {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, {&__pyx_n_s_stop_watchers, __pyx_k_stop_watchers, sizeof(__pyx_k_stop_watchers), 0, 0, 1, 1}, {&__pyx_kp_s_stopped, __pyx_k_stopped, sizeof(__pyx_k_stopped), 0, 0, 1, 0}, {&__pyx_n_s_strerror, __pyx_k_strerror, sizeof(__pyx_k_strerror), 0, 0, 1, 1}, {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1}, {&__pyx_n_s_supported_backends, __pyx_k_supported_backends, sizeof(__pyx_k_supported_backends), 0, 0, 1, 1}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1}, #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1}, {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1}, {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_SystemError = __Pyx_GetBuiltinName(__pyx_n_s_SystemError); if (!__pyx_builtin_SystemError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "gevent/corecext.pyx":170 * try: * if isinstance(flags, basestring): * flags = flags.split(',') # <<<<<<<<<<<<<< * for value in flags: * value = value.strip().lower() */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "gevent/corecext.pyx":374 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef unsigned int flags = 0 * if nowait: */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "gevent/corecext.pyx":390 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_ref(self._ptr) * */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "gevent/corecext.pyx":396 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_unref(self._ptr) * */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); /* "gevent/corecext.pyx":402 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_break(self._ptr, how) * */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); /* "gevent/corecext.pyx":408 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_verify(self._ptr) * */ __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); /* "gevent/corecext.pyx":414 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_now(self._ptr) * */ __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* "gevent/corecext.pyx":420 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_now_update(self._ptr) * */ __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* "gevent/corecext.pyx":431 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return True if libev.ev_is_default_loop(self._ptr) else False * */ __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* "gevent/corecext.pyx":439 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_iteration(self._ptr) * */ __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15); /* "gevent/corecext.pyx":447 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_depth(self._ptr) * */ __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); /* "gevent/corecext.pyx":455 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_backend(self._ptr) * */ __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); /* "gevent/corecext.pyx":463 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef unsigned int backend = libev.ev_backend(self._ptr) * for key, value in _flags: */ __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); /* "gevent/corecext.pyx":475 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return libev.ev_pending_count(self._ptr) * */ __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); /* "gevent/corecext.pyx":524 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * cdef callback cb = callback(func, args) * self._callbacks.append(cb) */ __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":727 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":577 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.activecnt * */ __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* "gevent/corecext.pyx":585 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.sig_pending * */ __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":603 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return _flags_to_list(self._ptr.origflags) * */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":594 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.sigfd * */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":755 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":611 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.origflags * */ __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":603 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return _flags_to_list(self._ptr.origflags) * */ __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":773 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":611 * * if not self._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * return self._ptr.origflags * */ __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":779 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27); /* "gevent/corecext.pyx":793 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":727 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28); #endif /* (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":795 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * if pass_events: */ __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":755 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":861 * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") # <<<<<<<<<<<<<< * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) */ __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":773 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":755 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":873 * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) * */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":779 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":773 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":912 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":793 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":779 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":940 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":795 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * if pass_events: */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":793 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":958 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":861 * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") # <<<<<<<<<<<<<< * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":795 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * if pass_events: */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":964 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":873 * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) * */ __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":861 * def __set__(self, long fd): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") # <<<<<<<<<<<<<< * cdef int vfd = libev.vfd_open(fd) * libev.vfd_free(self._watcher.fd) */ __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":978 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":912 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":873 * def __set__(self, int events): * if libev.ev_is_active(&self._watcher): * raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") # <<<<<<<<<<<<<< * libev.ev_io_init(&self._watcher, gevent_callback_io, self._watcher.fd, events) * */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":980 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":940 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":912 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1026 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":958 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":940 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1057 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":964 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":958 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1085 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":978 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":964 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__40); __Pyx_GIVEREF(__pyx_tuple__40); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1103 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":980 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":978 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1109 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1026 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":980 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1123 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1057 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1026 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__43); __Pyx_GIVEREF(__pyx_tuple__43); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1125 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1085 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1057 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1182 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1103 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1085 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__45); __Pyx_GIVEREF(__pyx_tuple__45); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1210 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1109 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1103 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1228 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1123 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1109 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1234 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1125 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1123 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1248 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1182 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1125 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1250 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1210 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1182 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__50); __Pyx_GIVEREF(__pyx_tuple__50); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1301 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1228 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1210 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__51); __Pyx_GIVEREF(__pyx_tuple__51); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1329 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1234 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1228 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__52); __Pyx_GIVEREF(__pyx_tuple__52); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1347 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1248 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1234 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__53); __Pyx_GIVEREF(__pyx_tuple__53); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1353 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1250 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1248 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__54); __Pyx_GIVEREF(__pyx_tuple__54); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1367 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1301 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1250 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1369 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1329 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1301 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__56); __Pyx_GIVEREF(__pyx_tuple__56); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1420 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1347 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1329 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1448 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1353 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1347 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__58); __Pyx_GIVEREF(__pyx_tuple__58); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1466 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1367 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1353 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__59); __Pyx_GIVEREF(__pyx_tuple__59); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1472 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1369 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1367 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__60); __Pyx_GIVEREF(__pyx_tuple__60); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1486 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1420 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1369 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__61); __Pyx_GIVEREF(__pyx_tuple__61); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1488 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1448 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1420 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__62); __Pyx_GIVEREF(__pyx_tuple__62); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1539 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1466 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1448 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__63); __Pyx_GIVEREF(__pyx_tuple__63); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1567 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1472 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1466 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__64); __Pyx_GIVEREF(__pyx_tuple__64); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1585 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1486 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1472 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__65); __Pyx_GIVEREF(__pyx_tuple__65); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1591 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1488 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1486 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__66); __Pyx_GIVEREF(__pyx_tuple__66); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1605 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1539 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1488 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__67); __Pyx_GIVEREF(__pyx_tuple__67); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1607 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1567 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1539 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__68); __Pyx_GIVEREF(__pyx_tuple__68); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1658 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1585 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1567 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__69); __Pyx_GIVEREF(__pyx_tuple__69); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1686 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1591 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1585 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__70); __Pyx_GIVEREF(__pyx_tuple__70); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1704 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1605 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1591 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__71); __Pyx_GIVEREF(__pyx_tuple__71); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1710 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1607 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1605 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__72); __Pyx_GIVEREF(__pyx_tuple__72); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1724 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1658 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1607 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__73); __Pyx_GIVEREF(__pyx_tuple__73); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1726 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1686 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1658 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__74); __Pyx_GIVEREF(__pyx_tuple__74); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1761 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_async_send(self.loop._ptr, &self._watcher) * */ __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1704 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1686 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__75); __Pyx_GIVEREF(__pyx_tuple__75); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1784 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1710 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1704 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__76); __Pyx_GIVEREF(__pyx_tuple__76); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1812 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1724 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1710 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__77); __Pyx_GIVEREF(__pyx_tuple__77); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1830 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1726 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1724 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__78); __Pyx_GIVEREF(__pyx_tuple__78); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1836 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1761 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_async_send(self.loop._ptr, &self._watcher) * */ __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1726 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__79); __Pyx_GIVEREF(__pyx_tuple__79); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1850 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1784 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":1761 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * libev.ev_async_send(self.loop._ptr, &self._watcher) * */ __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__80); __Pyx_GIVEREF(__pyx_tuple__80); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1852 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1812 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1784 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__81); __Pyx_GIVEREF(__pyx_tuple__81); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1876 * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: * raise TypeError('child watchers are only available on the default loop') # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1830 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1812 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__82); __Pyx_GIVEREF(__pyx_tuple__82); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1836 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1830 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__83); __Pyx_GIVEREF(__pyx_tuple__83); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1850 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1836 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__84); __Pyx_GIVEREF(__pyx_tuple__84); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1852 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1850 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_tuple__85); __Pyx_GIVEREF(__pyx_tuple__85); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1876 * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: * raise TypeError('child watchers are only available on the default loop') # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) */ __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__86 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1852 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__86); __Pyx_GIVEREF(__pyx_tuple__86); #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1876 * def __init__(self, loop loop, int pid, bint trace=0, ref=True): * if not loop.default: * raise TypeError('child watchers are only available on the default loop') # <<<<<<<<<<<<<< * libev.gevent_install_sigchld_handler() * libev.ev_child_init(&self._watcher, gevent_callback_child, pid, trace) */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__87); __Pyx_GIVEREF(__pyx_tuple__87); #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1929 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if value: * if not self._flags & 4: */ __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__88); __Pyx_GIVEREF(__pyx_tuple__88); #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1957 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if self._flags & 2: * libev.ev_ref(self.loop._ptr) */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__89); __Pyx_GIVEREF(__pyx_tuple__89); #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (defined(LIBEV_EMBED) && defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1975 * def __set__(self, int priority): * if libev.ev_is_active(&self._watcher): * raise AttributeError("Cannot set priority of an active watcher") # <<<<<<<<<<<<<< * libev.ev_set_priority(&self._watcher, priority) * */ __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) __Pyx_GOTREF(__pyx_tuple__90); __Pyx_GIVEREF(__pyx_tuple__90); #endif /* (!EV_USE_SIGNALFD && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__91 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1981 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__91); __Pyx_GIVEREF(__pyx_tuple__91); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__92 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1995 * * if not self.loop._ptr: * raise ValueError('operation on destroyed loop') # <<<<<<<<<<<<<< * if callback is None: * raise TypeError('callback must be callable, not None') */ __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__92); __Pyx_GIVEREF(__pyx_tuple__92); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__93 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":1997 * raise ValueError('operation on destroyed loop') * if callback is None: * raise TypeError('callback must be callable, not None') # <<<<<<<<<<<<<< * self.callback = callback * self.args = args */ __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__93); __Pyx_GIVEREF(__pyx_tuple__93); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__94); __Pyx_GIVEREF(__pyx_tuple__94); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__95 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_tuple__95 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__95); __Pyx_GIVEREF(__pyx_tuple__95); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__96 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_tuple__96 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) __Pyx_GOTREF(__pyx_tuple__96); __Pyx_GIVEREF(__pyx_tuple__96); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_tuple__97 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__97); __Pyx_GIVEREF(__pyx_tuple__97); #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":100 * * * def get_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_version, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":104 * * * def get_header_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_get_header_version, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":213 * * * def supported_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_supported_backends()) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_supported_backends, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":217 * * * def recommended_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_recommended_backends()) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__89 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_recommended_backends, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":221 * * * def embeddable_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_embeddable_backends()) * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_embeddable_backends, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":225 * * * def time(): # <<<<<<<<<<<<<< * return libev.ev_time() * */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_gevent_python2_7_ge, __pyx_n_s_time, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initcorecext(void); /*proto*/ PyMODINIT_FUNC initcorecext(void) #else PyMODINIT_FUNC PyInit_corecext(void); /*proto*/ PyMODINIT_FUNC PyInit_corecext(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_corecext(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("corecext", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_gevent__corecext) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "gevent.corecext")) { if (unlikely(PyDict_SetItemString(modules, "gevent.corecext", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ __pyx_v_6gevent_8corecext_integer_types = ((PyObject*)Py_None); Py_INCREF(Py_None); GEVENT_CORE_EVENTS = Py_None; Py_INCREF(Py_None); /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_6gevent_8corecext__EVENTSType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_6gevent_8corecext__EVENTSType.tp_print = 0; __pyx_ptype_6gevent_8corecext__EVENTSType = &__pyx_type_6gevent_8corecext__EVENTSType; __pyx_vtabptr_6gevent_8corecext_loop = &__pyx_vtable_6gevent_8corecext_loop; __pyx_vtable_6gevent_8corecext_loop._run_callbacks = (PyObject *(*)(struct PyGeventLoopObject *))__pyx_f_6gevent_8corecext_4loop__run_callbacks; __pyx_vtable_6gevent_8corecext_loop.handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8corecext_4loop_handle_error; __pyx_vtable_6gevent_8corecext_loop._default_handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_8corecext_4loop__default_handle_error; if (PyType_Ready(&PyGeventLoop_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventLoop_Type.tp_print = 0; if (__Pyx_SetVtable(PyGeventLoop_Type.tp_dict, __pyx_vtabptr_6gevent_8corecext_loop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "loop", (PyObject *)&PyGeventLoop_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_loop = &PyGeventLoop_Type; if (PyType_Ready(&PyGeventCallback_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventCallback_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "callback", (PyObject *)&PyGeventCallback_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_callback = &PyGeventCallback_Type; if (PyType_Ready(&PyGeventWatcher_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventWatcher_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "watcher", (PyObject *)&PyGeventWatcher_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_watcher = &PyGeventWatcher_Type; PyGeventIO_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventIO_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventIO_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "io", (PyObject *)&PyGeventIO_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_io = &PyGeventIO_Type; PyGeventTimer_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventTimer_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventTimer_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "timer", (PyObject *)&PyGeventTimer_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_timer = &PyGeventTimer_Type; PyGeventSignal_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventSignal_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventSignal_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "signal", (PyObject *)&PyGeventSignal_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_signal = &PyGeventSignal_Type; PyGeventIdle_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventIdle_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventIdle_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "idle", (PyObject *)&PyGeventIdle_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_idle = &PyGeventIdle_Type; PyGeventPrepare_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventPrepare_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventPrepare_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "prepare", (PyObject *)&PyGeventPrepare_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_prepare = &PyGeventPrepare_Type; PyGeventCheck_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventCheck_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventCheck_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "check", (PyObject *)&PyGeventCheck_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_check = &PyGeventCheck_Type; PyGeventFork_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventFork_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventFork_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "fork", (PyObject *)&PyGeventFork_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1522; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_fork = &PyGeventFork_Type; PyGeventAsync_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventAsync_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventAsync_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "async", (PyObject *)&PyGeventAsync_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_async = &PyGeventAsync_Type; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) PyGeventChild_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventChild_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventChild_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "child", (PyObject *)&PyGeventChild_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_child = &PyGeventChild_Type; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) PyGeventStat_Type.tp_base = __pyx_ptype_6gevent_8corecext_watcher; if (PyType_Ready(&PyGeventStat_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyGeventStat_Type.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "stat", (PyObject *)&PyGeventStat_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6gevent_8corecext_stat = &PyGeventStat_Type; if (PyType_Ready(&__pyx_type_6gevent_8corecext___pyx_scope_struct__genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_6gevent_8corecext___pyx_scope_struct__genexpr.tp_print = 0; __pyx_ptype_6gevent_8corecext___pyx_scope_struct__genexpr = &__pyx_type_6gevent_8corecext___pyx_scope_struct__genexpr; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "gevent/corecext.pyx":9 * # Note for PY3: not doing so will leave reference to locals() on import * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) # <<<<<<<<<<<<<< * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__82, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__93, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__86, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__94, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__87, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":10 * # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) * sys = __import__('sys', level=0) * os = __import__('os', level=0) # <<<<<<<<<<<<<< * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__90, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__83, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__94, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__87, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__95, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__88, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":11 * sys = __import__('sys', level=0) * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) # <<<<<<<<<<<<<< * signalmodule = __import__('signal', level=0) * */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__91, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__84, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__95, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__88, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__96, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_traceback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":12 * os = __import__('os', level=0) * traceback = __import__('traceback', level=0) * signalmodule = __import__('signal', level=0) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__92, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__85, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__96, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__97, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__90, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_signalmodule, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":15 * * * __all__ = ['get_version', # <<<<<<<<<<<<<< * 'get_header_version', * 'supported_backends', */ __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_version); __Pyx_GIVEREF(__pyx_n_s_get_version); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_version); __Pyx_INCREF(__pyx_n_s_get_header_version); __Pyx_GIVEREF(__pyx_n_s_get_header_version); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_get_header_version); __Pyx_INCREF(__pyx_n_s_supported_backends); __Pyx_GIVEREF(__pyx_n_s_supported_backends); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_supported_backends); __Pyx_INCREF(__pyx_n_s_recommended_backends); __Pyx_GIVEREF(__pyx_n_s_recommended_backends); PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_recommended_backends); __Pyx_INCREF(__pyx_n_s_embeddable_backends); __Pyx_GIVEREF(__pyx_n_s_embeddable_backends); PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_embeddable_backends); __Pyx_INCREF(__pyx_n_s_time); __Pyx_GIVEREF(__pyx_n_s_time); PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_time); __Pyx_INCREF(__pyx_n_s_loop); __Pyx_GIVEREF(__pyx_n_s_loop); PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_loop); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "gevent/corecext.pyx":25 * cdef tuple integer_types * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * integer_types = int, * else: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "gevent/corecext.pyx":26 * * if sys.version_info[0] >= 3: * integer_types = int, # <<<<<<<<<<<<<< * else: * integer_types = (int, long) */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)(&PyInt_Type))); __Pyx_GIVEREF(((PyObject *)(&PyInt_Type))); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type))); __Pyx_XGOTREF(__pyx_v_6gevent_8corecext_integer_types); __Pyx_DECREF_SET(__pyx_v_6gevent_8corecext_integer_types, ((PyObject*)__pyx_t_2)); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":25 * cdef tuple integer_types * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * integer_types = int, * else: */ goto __pyx_L2; } /* "gevent/corecext.pyx":28 * integer_types = int, * else: * integer_types = (int, long) # <<<<<<<<<<<<<< * * */ /*else*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)(&PyInt_Type))); __Pyx_GIVEREF(((PyObject *)(&PyInt_Type))); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type))); __Pyx_INCREF(((PyObject *)(&PyLong_Type))); __Pyx_GIVEREF(((PyObject *)(&PyLong_Type))); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyLong_Type))); __Pyx_XGOTREF(__pyx_v_6gevent_8corecext_integer_types); __Pyx_DECREF_SET(__pyx_v_6gevent_8corecext_integer_types, ((PyObject*)__pyx_t_2)); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L2:; /* "gevent/corecext.pyx":54 * * * UNDEF = libev.EV_UNDEF # <<<<<<<<<<<<<< * NONE = libev.EV_NONE * READ = libev.EV_READ */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_UNDEF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_UNDEF, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":55 * * UNDEF = libev.EV_UNDEF * NONE = libev.EV_NONE # <<<<<<<<<<<<<< * READ = libev.EV_READ * WRITE = libev.EV_WRITE */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_NONE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":56 * UNDEF = libev.EV_UNDEF * NONE = libev.EV_NONE * READ = libev.EV_READ # <<<<<<<<<<<<<< * WRITE = libev.EV_WRITE * TIMER = libev.EV_TIMER */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_READ, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":57 * NONE = libev.EV_NONE * READ = libev.EV_READ * WRITE = libev.EV_WRITE # <<<<<<<<<<<<<< * TIMER = libev.EV_TIMER * PERIODIC = libev.EV_PERIODIC */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_WRITE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":58 * READ = libev.EV_READ * WRITE = libev.EV_WRITE * TIMER = libev.EV_TIMER # <<<<<<<<<<<<<< * PERIODIC = libev.EV_PERIODIC * SIGNAL = libev.EV_SIGNAL */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_TIMER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMER, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":59 * WRITE = libev.EV_WRITE * TIMER = libev.EV_TIMER * PERIODIC = libev.EV_PERIODIC # <<<<<<<<<<<<<< * SIGNAL = libev.EV_SIGNAL * CHILD = libev.EV_CHILD */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PERIODIC, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":60 * TIMER = libev.EV_TIMER * PERIODIC = libev.EV_PERIODIC * SIGNAL = libev.EV_SIGNAL # <<<<<<<<<<<<<< * CHILD = libev.EV_CHILD * STAT = libev.EV_STAT */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNAL, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":61 * PERIODIC = libev.EV_PERIODIC * SIGNAL = libev.EV_SIGNAL * CHILD = libev.EV_CHILD # <<<<<<<<<<<<<< * STAT = libev.EV_STAT * IDLE = libev.EV_IDLE */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHILD, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":62 * SIGNAL = libev.EV_SIGNAL * CHILD = libev.EV_CHILD * STAT = libev.EV_STAT # <<<<<<<<<<<<<< * IDLE = libev.EV_IDLE * PREPARE = libev.EV_PREPARE */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_STAT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":63 * CHILD = libev.EV_CHILD * STAT = libev.EV_STAT * IDLE = libev.EV_IDLE # <<<<<<<<<<<<<< * PREPARE = libev.EV_PREPARE * CHECK = libev.EV_CHECK */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDLE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":64 * STAT = libev.EV_STAT * IDLE = libev.EV_IDLE * PREPARE = libev.EV_PREPARE # <<<<<<<<<<<<<< * CHECK = libev.EV_CHECK * EMBED = libev.EV_EMBED */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PREPARE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":65 * IDLE = libev.EV_IDLE * PREPARE = libev.EV_PREPARE * CHECK = libev.EV_CHECK # <<<<<<<<<<<<<< * EMBED = libev.EV_EMBED * FORK = libev.EV_FORK */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHECK, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":66 * PREPARE = libev.EV_PREPARE * CHECK = libev.EV_CHECK * EMBED = libev.EV_EMBED # <<<<<<<<<<<<<< * FORK = libev.EV_FORK * CLEANUP = libev.EV_CLEANUP */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMBED, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":67 * CHECK = libev.EV_CHECK * EMBED = libev.EV_EMBED * FORK = libev.EV_FORK # <<<<<<<<<<<<<< * CLEANUP = libev.EV_CLEANUP * ASYNC = libev.EV_ASYNC */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORK, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":68 * EMBED = libev.EV_EMBED * FORK = libev.EV_FORK * CLEANUP = libev.EV_CLEANUP # <<<<<<<<<<<<<< * ASYNC = libev.EV_ASYNC * CUSTOM = libev.EV_CUSTOM */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CLEANUP, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":69 * FORK = libev.EV_FORK * CLEANUP = libev.EV_CLEANUP * ASYNC = libev.EV_ASYNC # <<<<<<<<<<<<<< * CUSTOM = libev.EV_CUSTOM * ERROR = libev.EV_ERROR */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ASYNC, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":70 * CLEANUP = libev.EV_CLEANUP * ASYNC = libev.EV_ASYNC * CUSTOM = libev.EV_CUSTOM # <<<<<<<<<<<<<< * ERROR = libev.EV_ERROR * */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUSTOM, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":71 * ASYNC = libev.EV_ASYNC * CUSTOM = libev.EV_CUSTOM * ERROR = libev.EV_ERROR # <<<<<<<<<<<<<< * * READWRITE = libev.EV_READ | libev.EV_WRITE */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ERROR, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":73 * ERROR = libev.EV_ERROR * * READWRITE = libev.EV_READ | libev.EV_WRITE # <<<<<<<<<<<<<< * * MINPRI = libev.EV_MINPRI */ __pyx_t_2 = __Pyx_PyInt_From_int((EV_READ | EV_WRITE)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_READWRITE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":75 * READWRITE = libev.EV_READ | libev.EV_WRITE * * MINPRI = libev.EV_MINPRI # <<<<<<<<<<<<<< * MAXPRI = libev.EV_MAXPRI * */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_MINPRI, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":76 * * MINPRI = libev.EV_MINPRI * MAXPRI = libev.EV_MAXPRI # <<<<<<<<<<<<<< * * BACKEND_PORT = libev.EVBACKEND_PORT */ __pyx_t_2 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAXPRI, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":78 * MAXPRI = libev.EV_MAXPRI * * BACKEND_PORT = libev.EVBACKEND_PORT # <<<<<<<<<<<<<< * BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE * BACKEND_EPOLL = libev.EVBACKEND_EPOLL */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_PORT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":79 * * BACKEND_PORT = libev.EVBACKEND_PORT * BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE # <<<<<<<<<<<<<< * BACKEND_EPOLL = libev.EVBACKEND_EPOLL * BACKEND_POLL = libev.EVBACKEND_POLL */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_KQUEUE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":80 * BACKEND_PORT = libev.EVBACKEND_PORT * BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE * BACKEND_EPOLL = libev.EVBACKEND_EPOLL # <<<<<<<<<<<<<< * BACKEND_POLL = libev.EVBACKEND_POLL * BACKEND_SELECT = libev.EVBACKEND_SELECT */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_EPOLL, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":81 * BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE * BACKEND_EPOLL = libev.EVBACKEND_EPOLL * BACKEND_POLL = libev.EVBACKEND_POLL # <<<<<<<<<<<<<< * BACKEND_SELECT = libev.EVBACKEND_SELECT * FORKCHECK = libev.EVFLAG_FORKCHECK */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_POLL, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":82 * BACKEND_EPOLL = libev.EVBACKEND_EPOLL * BACKEND_POLL = libev.EVBACKEND_POLL * BACKEND_SELECT = libev.EVBACKEND_SELECT # <<<<<<<<<<<<<< * FORKCHECK = libev.EVFLAG_FORKCHECK * NOINOTIFY = libev.EVFLAG_NOINOTIFY */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_SELECT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":83 * BACKEND_POLL = libev.EVBACKEND_POLL * BACKEND_SELECT = libev.EVBACKEND_SELECT * FORKCHECK = libev.EVFLAG_FORKCHECK # <<<<<<<<<<<<<< * NOINOTIFY = libev.EVFLAG_NOINOTIFY * SIGNALFD = libev.EVFLAG_SIGNALFD */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORKCHECK, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":84 * BACKEND_SELECT = libev.EVBACKEND_SELECT * FORKCHECK = libev.EVFLAG_FORKCHECK * NOINOTIFY = libev.EVFLAG_NOINOTIFY # <<<<<<<<<<<<<< * SIGNALFD = libev.EVFLAG_SIGNALFD * NOSIGMASK = libev.EVFLAG_NOSIGMASK */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOINOTIFY, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":85 * FORKCHECK = libev.EVFLAG_FORKCHECK * NOINOTIFY = libev.EVFLAG_NOINOTIFY * SIGNALFD = libev.EVFLAG_SIGNALFD # <<<<<<<<<<<<<< * NOSIGMASK = libev.EVFLAG_NOSIGMASK * */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNALFD, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":86 * NOINOTIFY = libev.EVFLAG_NOINOTIFY * SIGNALFD = libev.EVFLAG_SIGNALFD * NOSIGMASK = libev.EVFLAG_NOSIGMASK # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOSIGMASK, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":96 * * * cdef public object GEVENT_CORE_EVENTS = _EVENTSType() # <<<<<<<<<<<<<< * EVENTS = GEVENT_CORE_EVENTS * */ __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_8corecext__EVENTSType), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(GEVENT_CORE_EVENTS); __Pyx_DECREF_SET(GEVENT_CORE_EVENTS, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":97 * * cdef public object GEVENT_CORE_EVENTS = _EVENTSType() * EVENTS = GEVENT_CORE_EVENTS # <<<<<<<<<<<<<< * * */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_EVENTS, GEVENT_CORE_EVENTS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":100 * * * def get_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) * */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_1get_version, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":104 * * * def get_header_version(): # <<<<<<<<<<<<<< * return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) * */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_3get_header_version, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_header_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":109 * * # This list backends in the order they are actually tried by libev * _flags = [(libev.EVBACKEND_PORT, 'port'), # <<<<<<<<<<<<<< * (libev.EVBACKEND_KQUEUE, 'kqueue'), * (libev.EVBACKEND_EPOLL, 'epoll'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_port); __Pyx_GIVEREF(__pyx_n_s_port); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_port); __pyx_t_2 = 0; /* "gevent/corecext.pyx":110 * # This list backends in the order they are actually tried by libev * _flags = [(libev.EVBACKEND_PORT, 'port'), * (libev.EVBACKEND_KQUEUE, 'kqueue'), # <<<<<<<<<<<<<< * (libev.EVBACKEND_EPOLL, 'epoll'), * (libev.EVBACKEND_POLL, 'poll'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_kqueue); __Pyx_GIVEREF(__pyx_n_s_kqueue); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_kqueue); __pyx_t_2 = 0; /* "gevent/corecext.pyx":111 * _flags = [(libev.EVBACKEND_PORT, 'port'), * (libev.EVBACKEND_KQUEUE, 'kqueue'), * (libev.EVBACKEND_EPOLL, 'epoll'), # <<<<<<<<<<<<<< * (libev.EVBACKEND_POLL, 'poll'), * (libev.EVBACKEND_SELECT, 'select'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_epoll); __Pyx_GIVEREF(__pyx_n_s_epoll); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_epoll); __pyx_t_2 = 0; /* "gevent/corecext.pyx":112 * (libev.EVBACKEND_KQUEUE, 'kqueue'), * (libev.EVBACKEND_EPOLL, 'epoll'), * (libev.EVBACKEND_POLL, 'poll'), # <<<<<<<<<<<<<< * (libev.EVBACKEND_SELECT, 'select'), * (libev.EVFLAG_NOENV, 'noenv'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_poll); __Pyx_GIVEREF(__pyx_n_s_poll); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_poll); __pyx_t_2 = 0; /* "gevent/corecext.pyx":113 * (libev.EVBACKEND_EPOLL, 'epoll'), * (libev.EVBACKEND_POLL, 'poll'), * (libev.EVBACKEND_SELECT, 'select'), # <<<<<<<<<<<<<< * (libev.EVFLAG_NOENV, 'noenv'), * (libev.EVFLAG_FORKCHECK, 'forkcheck'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_select); __Pyx_GIVEREF(__pyx_n_s_select); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_select); __pyx_t_2 = 0; /* "gevent/corecext.pyx":114 * (libev.EVBACKEND_POLL, 'poll'), * (libev.EVBACKEND_SELECT, 'select'), * (libev.EVFLAG_NOENV, 'noenv'), # <<<<<<<<<<<<<< * (libev.EVFLAG_FORKCHECK, 'forkcheck'), * (libev.EVFLAG_NOINOTIFY, 'noinotify'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOENV); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_noenv); __Pyx_GIVEREF(__pyx_n_s_noenv); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_noenv); __pyx_t_2 = 0; /* "gevent/corecext.pyx":115 * (libev.EVBACKEND_SELECT, 'select'), * (libev.EVFLAG_NOENV, 'noenv'), * (libev.EVFLAG_FORKCHECK, 'forkcheck'), # <<<<<<<<<<<<<< * (libev.EVFLAG_NOINOTIFY, 'noinotify'), * (libev.EVFLAG_SIGNALFD, 'signalfd'), */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_forkcheck); __Pyx_GIVEREF(__pyx_n_s_forkcheck); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_forkcheck); __pyx_t_2 = 0; /* "gevent/corecext.pyx":116 * (libev.EVFLAG_NOENV, 'noenv'), * (libev.EVFLAG_FORKCHECK, 'forkcheck'), * (libev.EVFLAG_NOINOTIFY, 'noinotify'), # <<<<<<<<<<<<<< * (libev.EVFLAG_SIGNALFD, 'signalfd'), * (libev.EVFLAG_NOSIGMASK, 'nosigmask')] */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_noinotify); __Pyx_GIVEREF(__pyx_n_s_noinotify); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_noinotify); __pyx_t_2 = 0; /* "gevent/corecext.pyx":117 * (libev.EVFLAG_FORKCHECK, 'forkcheck'), * (libev.EVFLAG_NOINOTIFY, 'noinotify'), * (libev.EVFLAG_SIGNALFD, 'signalfd'), # <<<<<<<<<<<<<< * (libev.EVFLAG_NOSIGMASK, 'nosigmask')] * */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_signalfd); __Pyx_GIVEREF(__pyx_n_s_signalfd); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_signalfd); __pyx_t_2 = 0; /* "gevent/corecext.pyx":118 * (libev.EVFLAG_NOINOTIFY, 'noinotify'), * (libev.EVFLAG_SIGNALFD, 'signalfd'), * (libev.EVFLAG_NOSIGMASK, 'nosigmask')] # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_nosigmask); __Pyx_GIVEREF(__pyx_n_s_nosigmask); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_nosigmask); __pyx_t_2 = 0; /* "gevent/corecext.pyx":109 * * # This list backends in the order they are actually tried by libev * _flags = [(libev.EVBACKEND_PORT, 'port'), # <<<<<<<<<<<<<< * (libev.EVBACKEND_KQUEUE, 'kqueue'), * (libev.EVBACKEND_EPOLL, 'epoll'), */ __pyx_t_2 = PyList_New(10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12); __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "gevent/corecext.pyx":121 * * * _flags_str2int = dict((string, flag) for (flag, string) in _flags) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __pyx_pf_6gevent_8corecext_22genexpr(NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags_str2int, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":124 * * * _events = [(libev.EV_READ, 'READ'), # <<<<<<<<<<<<<< * (libev.EV_WRITE, 'WRITE'), * (libev.EV__IOFDSET, '_IOFDSET'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_READ); __Pyx_GIVEREF(__pyx_n_s_READ); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_READ); __pyx_t_12 = 0; /* "gevent/corecext.pyx":125 * * _events = [(libev.EV_READ, 'READ'), * (libev.EV_WRITE, 'WRITE'), # <<<<<<<<<<<<<< * (libev.EV__IOFDSET, '_IOFDSET'), * (libev.EV_PERIODIC, 'PERIODIC'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_WRITE); __Pyx_GIVEREF(__pyx_n_s_WRITE); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_WRITE); __pyx_t_12 = 0; /* "gevent/corecext.pyx":126 * _events = [(libev.EV_READ, 'READ'), * (libev.EV_WRITE, 'WRITE'), * (libev.EV__IOFDSET, '_IOFDSET'), # <<<<<<<<<<<<<< * (libev.EV_PERIODIC, 'PERIODIC'), * (libev.EV_SIGNAL, 'SIGNAL'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV__IOFDSET); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_IOFDSET); __Pyx_GIVEREF(__pyx_n_s_IOFDSET); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_IOFDSET); __pyx_t_12 = 0; /* "gevent/corecext.pyx":127 * (libev.EV_WRITE, 'WRITE'), * (libev.EV__IOFDSET, '_IOFDSET'), * (libev.EV_PERIODIC, 'PERIODIC'), # <<<<<<<<<<<<<< * (libev.EV_SIGNAL, 'SIGNAL'), * (libev.EV_CHILD, 'CHILD'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_PERIODIC); __Pyx_GIVEREF(__pyx_n_s_PERIODIC); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_PERIODIC); __pyx_t_12 = 0; /* "gevent/corecext.pyx":128 * (libev.EV__IOFDSET, '_IOFDSET'), * (libev.EV_PERIODIC, 'PERIODIC'), * (libev.EV_SIGNAL, 'SIGNAL'), # <<<<<<<<<<<<<< * (libev.EV_CHILD, 'CHILD'), * (libev.EV_STAT, 'STAT'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_SIGNAL); __Pyx_GIVEREF(__pyx_n_s_SIGNAL); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_SIGNAL); __pyx_t_12 = 0; /* "gevent/corecext.pyx":129 * (libev.EV_PERIODIC, 'PERIODIC'), * (libev.EV_SIGNAL, 'SIGNAL'), * (libev.EV_CHILD, 'CHILD'), # <<<<<<<<<<<<<< * (libev.EV_STAT, 'STAT'), * (libev.EV_IDLE, 'IDLE'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_CHILD); __Pyx_GIVEREF(__pyx_n_s_CHILD); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_CHILD); __pyx_t_12 = 0; /* "gevent/corecext.pyx":130 * (libev.EV_SIGNAL, 'SIGNAL'), * (libev.EV_CHILD, 'CHILD'), * (libev.EV_STAT, 'STAT'), # <<<<<<<<<<<<<< * (libev.EV_IDLE, 'IDLE'), * (libev.EV_PREPARE, 'PREPARE'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_STAT); __Pyx_GIVEREF(__pyx_n_s_STAT); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_STAT); __pyx_t_12 = 0; /* "gevent/corecext.pyx":131 * (libev.EV_CHILD, 'CHILD'), * (libev.EV_STAT, 'STAT'), * (libev.EV_IDLE, 'IDLE'), # <<<<<<<<<<<<<< * (libev.EV_PREPARE, 'PREPARE'), * (libev.EV_CHECK, 'CHECK'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_IDLE); __Pyx_GIVEREF(__pyx_n_s_IDLE); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_IDLE); __pyx_t_12 = 0; /* "gevent/corecext.pyx":132 * (libev.EV_STAT, 'STAT'), * (libev.EV_IDLE, 'IDLE'), * (libev.EV_PREPARE, 'PREPARE'), # <<<<<<<<<<<<<< * (libev.EV_CHECK, 'CHECK'), * (libev.EV_EMBED, 'EMBED'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_PREPARE); __Pyx_GIVEREF(__pyx_n_s_PREPARE); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_PREPARE); __pyx_t_12 = 0; /* "gevent/corecext.pyx":133 * (libev.EV_IDLE, 'IDLE'), * (libev.EV_PREPARE, 'PREPARE'), * (libev.EV_CHECK, 'CHECK'), # <<<<<<<<<<<<<< * (libev.EV_EMBED, 'EMBED'), * (libev.EV_FORK, 'FORK'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_CHECK); __Pyx_GIVEREF(__pyx_n_s_CHECK); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CHECK); __pyx_t_12 = 0; /* "gevent/corecext.pyx":134 * (libev.EV_PREPARE, 'PREPARE'), * (libev.EV_CHECK, 'CHECK'), * (libev.EV_EMBED, 'EMBED'), # <<<<<<<<<<<<<< * (libev.EV_FORK, 'FORK'), * (libev.EV_CLEANUP, 'CLEANUP'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_EMBED); __Pyx_GIVEREF(__pyx_n_s_EMBED); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_EMBED); __pyx_t_12 = 0; /* "gevent/corecext.pyx":135 * (libev.EV_CHECK, 'CHECK'), * (libev.EV_EMBED, 'EMBED'), * (libev.EV_FORK, 'FORK'), # <<<<<<<<<<<<<< * (libev.EV_CLEANUP, 'CLEANUP'), * (libev.EV_ASYNC, 'ASYNC'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_FORK); __Pyx_GIVEREF(__pyx_n_s_FORK); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_FORK); __pyx_t_12 = 0; /* "gevent/corecext.pyx":136 * (libev.EV_EMBED, 'EMBED'), * (libev.EV_FORK, 'FORK'), * (libev.EV_CLEANUP, 'CLEANUP'), # <<<<<<<<<<<<<< * (libev.EV_ASYNC, 'ASYNC'), * (libev.EV_CUSTOM, 'CUSTOM'), */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_CLEANUP); __Pyx_GIVEREF(__pyx_n_s_CLEANUP); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_CLEANUP); __pyx_t_12 = 0; /* "gevent/corecext.pyx":137 * (libev.EV_FORK, 'FORK'), * (libev.EV_CLEANUP, 'CLEANUP'), * (libev.EV_ASYNC, 'ASYNC'), # <<<<<<<<<<<<<< * (libev.EV_CUSTOM, 'CUSTOM'), * (libev.EV_ERROR, 'ERROR')] */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_ASYNC); __Pyx_GIVEREF(__pyx_n_s_ASYNC); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ASYNC); __pyx_t_12 = 0; /* "gevent/corecext.pyx":138 * (libev.EV_CLEANUP, 'CLEANUP'), * (libev.EV_ASYNC, 'ASYNC'), * (libev.EV_CUSTOM, 'CUSTOM'), # <<<<<<<<<<<<<< * (libev.EV_ERROR, 'ERROR')] * */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_CUSTOM); __Pyx_GIVEREF(__pyx_n_s_CUSTOM); PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_CUSTOM); __pyx_t_12 = 0; /* "gevent/corecext.pyx":139 * (libev.EV_ASYNC, 'ASYNC'), * (libev.EV_CUSTOM, 'CUSTOM'), * (libev.EV_ERROR, 'ERROR')] # <<<<<<<<<<<<<< * * */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_12); __Pyx_INCREF(__pyx_n_s_ERROR); __Pyx_GIVEREF(__pyx_n_s_ERROR); PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ERROR); __pyx_t_12 = 0; /* "gevent/corecext.pyx":124 * * * _events = [(libev.EV_READ, 'READ'), # <<<<<<<<<<<<<< * (libev.EV_WRITE, 'WRITE'), * (libev.EV__IOFDSET, '_IOFDSET'), */ __pyx_t_12 = PyList_New(16); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_2); PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_11); PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyList_SET_ITEM(__pyx_t_12, 3, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyList_SET_ITEM(__pyx_t_12, 4, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyList_SET_ITEM(__pyx_t_12, 5, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_12, 6, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_12, 7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyList_SET_ITEM(__pyx_t_12, 8, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_12, 9, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_13); PyList_SET_ITEM(__pyx_t_12, 10, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyList_SET_ITEM(__pyx_t_12, 11, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_15); PyList_SET_ITEM(__pyx_t_12, 12, __pyx_t_15); __Pyx_GIVEREF(__pyx_t_16); PyList_SET_ITEM(__pyx_t_12, 13, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_17); PyList_SET_ITEM(__pyx_t_12, 14, __pyx_t_17); __Pyx_GIVEREF(__pyx_t_18); PyList_SET_ITEM(__pyx_t_12, 15, __pyx_t_18); __pyx_t_2 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_events, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":155 * * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * basestring = (bytes, str) * else: */ __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_version_info); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_18, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = PyObject_RichCompare(__pyx_t_12, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__pyx_t_3) { /* "gevent/corecext.pyx":156 * * if sys.version_info[0] >= 3: * basestring = (bytes, str) # <<<<<<<<<<<<<< * else: * basestring = __builtins__.basestring */ __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_18); __Pyx_INCREF(((PyObject *)(&PyBytes_Type))); __Pyx_GIVEREF(((PyObject *)(&PyBytes_Type))); PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)(&PyBytes_Type))); __Pyx_INCREF(((PyObject *)(&PyString_Type))); __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); PyTuple_SET_ITEM(__pyx_t_18, 1, ((PyObject *)(&PyString_Type))); if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; /* "gevent/corecext.pyx":155 * * * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< * basestring = (bytes, str) * else: */ goto __pyx_L3; } /* "gevent/corecext.pyx":158 * basestring = (bytes, str) * else: * basestring = __builtins__.basestring # <<<<<<<<<<<<<< * * */ /*else*/ { __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_18); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_basestring); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_L3:; /* "gevent/corecext.pyx":213 * * * def supported_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_supported_backends()) * */ __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_13supported_backends, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_supported_backends, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":217 * * * def recommended_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_recommended_backends()) * */ __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_15recommended_backends, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_recommended_backends, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":221 * * * def embeddable_backends(): # <<<<<<<<<<<<<< * return _flags_to_list(libev.ev_embeddable_backends()) * */ __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_17embeddable_backends, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_embeddable_backends, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":225 * * * def time(): # <<<<<<<<<<<<<< * return libev.ev_time() * */ __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_8corecext_19time, NULL, __pyx_n_s_gevent_corecext); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":231 * * * cdef bint _default_loop_destroyed = False # <<<<<<<<<<<<<< * * */ __pyx_v_6gevent_8corecext__default_loop_destroyed = 0; /* "gevent/corecext.pyx":399 * libev.ev_unref(self._ptr) * * def break_(self, int how=libev.EVBREAK_ONE): # <<<<<<<<<<<<<< * * if not self._ptr: */ __pyx_k__9 = EVBREAK_ONE; /* "gevent/corecext.pyx":2062 * * * __SYSERR_CALLBACK = None # <<<<<<<<<<<<<< * * */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":2099 * * * LIBEV_EMBED = False # <<<<<<<<<<<<<< * */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBEV_EMBED, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) /* "gevent/corecext.pyx":2088 * * * LIBEV_EMBED = True # <<<<<<<<<<<<<< * EV_USE_FLOOR = libev.EV_USE_FLOOR * EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBEV_EMBED, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "gevent/corecext.pyx":2089 * * LIBEV_EMBED = True * EV_USE_FLOOR = libev.EV_USE_FLOOR # <<<<<<<<<<<<<< * EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL * EV_USE_REALTIME = libev.EV_USE_REALTIME */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_FLOOR); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_FLOOR, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2090 * LIBEV_EMBED = True * EV_USE_FLOOR = libev.EV_USE_FLOOR * EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL # <<<<<<<<<<<<<< * EV_USE_REALTIME = libev.EV_USE_REALTIME * EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_CLOCK_SYSCALL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2091 * EV_USE_FLOOR = libev.EV_USE_FLOOR * EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL * EV_USE_REALTIME = libev.EV_USE_REALTIME # <<<<<<<<<<<<<< * EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC * EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_REALTIME); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_REALTIME, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2092 * EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL * EV_USE_REALTIME = libev.EV_USE_REALTIME * EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC # <<<<<<<<<<<<<< * EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP * EV_USE_INOTIFY = libev.EV_USE_INOTIFY */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_MONOTONIC); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_MONOTONIC, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2093 * EV_USE_REALTIME = libev.EV_USE_REALTIME * EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC * EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP # <<<<<<<<<<<<<< * EV_USE_INOTIFY = libev.EV_USE_INOTIFY * EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_NANOSLEEP); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_NANOSLEEP, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2094 * EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC * EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP * EV_USE_INOTIFY = libev.EV_USE_INOTIFY # <<<<<<<<<<<<<< * EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD * EV_USE_EVENTFD = libev.EV_USE_EVENTFD */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_INOTIFY); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_INOTIFY, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2095 * EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP * EV_USE_INOTIFY = libev.EV_USE_INOTIFY * EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD # <<<<<<<<<<<<<< * EV_USE_EVENTFD = libev.EV_USE_EVENTFD * EV_USE_4HEAP = libev.EV_USE_4HEAP */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_SIGNALFD); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_SIGNALFD, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2096 * EV_USE_INOTIFY = libev.EV_USE_INOTIFY * EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD * EV_USE_EVENTFD = libev.EV_USE_EVENTFD # <<<<<<<<<<<<<< * EV_USE_4HEAP = libev.EV_USE_4HEAP * */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_EVENTFD); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_EVENTFD, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "gevent/corecext.pyx":2097 * EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD * EV_USE_EVENTFD = libev.EV_USE_EVENTFD * EV_USE_4HEAP = libev.EV_USE_4HEAP # <<<<<<<<<<<<<< * * */ __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_4HEAP); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_4HEAP, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (defined(LIBEV_EMBED)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) /* "gevent/corecext.pyx":1 * # Generated by cythonpp.py on 2016-03-05 07:11:05 # <<<<<<<<<<<<<< * # Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. * cimport cython */ __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init gevent.corecext", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init gevent.corecext"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else PyErr_GetExcInfo(type, value, tb); #endif } static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(type, value, tb); #endif } static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_COMPILING_IN_CPYTHON tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } #if !CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) { return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL); } #endif static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (PyErr_ExceptionMatches(PyExc_OverflowError)) PyErr_Clear(); else return NULL; } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r = __Pyx_GetAttr(o, n); if (unlikely(!r)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); r = d; Py_INCREF(d); } return r; bad: return NULL; } static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); } static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (none_allowed && obj == Py_None) return 1; else if (exact) { if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(PyObject_TypeCheck(obj, type))) return 1; } __Pyx_RaiseArgumentTypeInvalid(name, obj, type); return 0; } static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #else PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) } static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) } static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { PyTypeObject* type = Py_TYPE(obj); while (type && type->tp_traverse != current_tp_traverse) type = type->tp_base; while (type && type->tp_traverse == current_tp_traverse) type = type->tp_base; if (type && type->tp_traverse) return type->tp_traverse(obj, v, a); return 0; } static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { PyTypeObject* type = Py_TYPE(obj); while (type && type->tp_clear != current_tp_clear) type = type->tp_base; while (type && type->tp_clear == current_tp_clear) type = type->tp_base; if (type && type->tp_clear) type->tp_clear(obj); } static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (unsigned int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(unsigned int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) case -2: if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -3: if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -4: if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; } #endif if (sizeof(unsigned int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (unsigned int) -1; } } else { unsigned int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned int) -1; val = __Pyx_PyInt_As_unsigned_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned int"); return (unsigned int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); return (unsigned int) -1; } static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(size_t) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (size_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (size_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(size_t) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) case -2: if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -3: if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -4: if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; } #endif if (sizeof(size_t) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else size_t val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (size_t) -1; } } else { size_t val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (size_t) -1; val = __Pyx_PyInt_As_size_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to size_t"); return (size_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to size_t"); return (size_t) -1; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static CYTHON_INLINE vfd_socket_t __Pyx_PyInt_As_vfd_socket_t(PyObject *x) { const vfd_socket_t neg_one = (vfd_socket_t) -1, const_zero = (vfd_socket_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(vfd_socket_t) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (vfd_socket_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (vfd_socket_t) 0; case 1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, digit, digits[0]) case 2: if (8 * sizeof(vfd_socket_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) >= 2 * PyLong_SHIFT) { return (vfd_socket_t) (((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); } } break; case 3: if (8 * sizeof(vfd_socket_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) >= 3 * PyLong_SHIFT) { return (vfd_socket_t) (((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); } } break; case 4: if (8 * sizeof(vfd_socket_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) >= 4 * PyLong_SHIFT) { return (vfd_socket_t) (((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (vfd_socket_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(vfd_socket_t) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(vfd_socket_t) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (vfd_socket_t) 0; case -1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, digit, +digits[0]) case -2: if (8 * sizeof(vfd_socket_t) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { return (vfd_socket_t) (((vfd_socket_t)-1)*(((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; case 2: if (8 * sizeof(vfd_socket_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { return (vfd_socket_t) ((((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; case -3: if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { return (vfd_socket_t) (((vfd_socket_t)-1)*(((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; case 3: if (8 * sizeof(vfd_socket_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { return (vfd_socket_t) ((((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; case -4: if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 4 * PyLong_SHIFT) { return (vfd_socket_t) (((vfd_socket_t)-1)*(((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; case 4: if (8 * sizeof(vfd_socket_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(vfd_socket_t) - 1 > 4 * PyLong_SHIFT) { return (vfd_socket_t) ((((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); } } break; } #endif if (sizeof(vfd_socket_t) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, long, PyLong_AsLong(x)) } else if (sizeof(vfd_socket_t) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else vfd_socket_t val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (vfd_socket_t) -1; } } else { vfd_socket_t val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (vfd_socket_t) -1; val = __Pyx_PyInt_As_vfd_socket_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to vfd_socket_t"); return (vfd_socket_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to vfd_socket_t"); return (vfd_socket_t) -1; } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(unsigned int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(unsigned int), little, !is_unsigned); } } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) static CYTHON_INLINE PyObject* __Pyx_PyInt_From_vfd_socket_t(vfd_socket_t value) { const vfd_socket_t neg_one = (vfd_socket_t) -1, const_zero = (vfd_socket_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(vfd_socket_t) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(vfd_socket_t) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(vfd_socket_t) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(vfd_socket_t) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(vfd_socket_t) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(vfd_socket_t), little, !is_unsigned); } } #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(_WIN32)) */ #if (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); if (!fake_module) return NULL; Py_INCREF(fake_module); cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); if (cached_type) { if (!PyType_Check((PyObject*)cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", type->tp_name); goto bad; } if (cached_type->tp_basicsize != type->tp_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", type->tp_name); goto bad; } } else { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) goto bad; Py_INCREF(type); cached_type = type; } done: Py_DECREF(fake_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { PyObject *method, *result = NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto bad; #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyMethod_Check(method))) { PyObject *self = PyMethod_GET_SELF(method); if (likely(self)) { PyObject *args; PyObject *function = PyMethod_GET_FUNCTION(method); args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); Py_INCREF(function); Py_DECREF(method); method = NULL; result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); return result; } } #endif result = __Pyx_PyObject_CallOneArg(method, arg); bad: Py_XDECREF(method); return result; } #include #include static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); static PyObject *__Pyx_Coroutine_Close(PyObject *self); static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) #if 1 || PY_VERSION_HEX < 0x030300B0 static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; __Pyx_ErrFetch(&et, &ev, &tb); if (!et) { Py_XDECREF(tb); Py_XDECREF(ev); Py_INCREF(Py_None); *pvalue = Py_None; return 0; } if (likely(et == PyExc_StopIteration)) { #if PY_VERSION_HEX >= 0x030300A0 if (ev && Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); Py_XDECREF(tb); Py_DECREF(et); *pvalue = value; return 0; } #endif if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { if (!ev) { Py_INCREF(Py_None); ev = Py_None; } else if (PyTuple_Check(ev)) { if (PyTuple_GET_SIZE(ev) >= 1) { PyObject *value; #if CYTHON_COMPILING_IN_CPYTHON value = PySequence_ITEM(ev, 0); #else value = PyTuple_GET_ITEM(ev, 0); Py_INCREF(value); #endif Py_DECREF(ev); ev = value; } else { Py_INCREF(Py_None); Py_DECREF(ev); ev = Py_None; } } Py_XDECREF(tb); Py_DECREF(et); *pvalue = ev; return 0; } } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { __Pyx_ErrRestore(et, ev, tb); return -1; } PyErr_NormalizeException(&et, &ev, &tb); if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { __Pyx_ErrRestore(et, ev, tb); return -1; } Py_XDECREF(tb); Py_DECREF(et); #if PY_VERSION_HEX >= 0x030300A0 value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); #else { PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); Py_DECREF(ev); if (likely(args)) { value = PySequence_GetItem(args, 0); Py_DECREF(args); } if (unlikely(!value)) { __Pyx_ErrRestore(NULL, NULL, NULL); Py_INCREF(Py_None); value = Py_None; } } #endif *pvalue = value; return 0; } #endif static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) { PyObject *exc_type = self->exc_type; PyObject *exc_value = self->exc_value; PyObject *exc_traceback = self->exc_traceback; self->exc_type = NULL; self->exc_value = NULL; self->exc_traceback = NULL; Py_XDECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_traceback); } static CYTHON_INLINE int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) { if (unlikely(gen->is_running)) { PyErr_SetString(PyExc_ValueError, "generator already executing"); return 1; } return 0; } static CYTHON_INLINE PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) { PyObject *retval; assert(!self->is_running); if (unlikely(self->resume_label == 0)) { if (unlikely(value && value != Py_None)) { PyErr_SetString(PyExc_TypeError, "can't send non-None value to a " "just-started generator"); return NULL; } } if (unlikely(self->resume_label == -1)) { PyErr_SetNone(PyExc_StopIteration); return NULL; } if (value) { #if CYTHON_COMPILING_IN_PYPY #else if (self->exc_traceback) { PyThreadState *tstate = PyThreadState_GET(); PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; PyFrameObject *f = tb->tb_frame; Py_XINCREF(tstate->frame); assert(f->f_back == NULL); f->f_back = tstate->frame; } #endif __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback); } else { __Pyx_Coroutine_ExceptionClear(self); } self->is_running = 1; retval = self->body((PyObject *) self, value); self->is_running = 0; if (retval) { __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback); #if CYTHON_COMPILING_IN_PYPY #else if (self->exc_traceback) { PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; PyFrameObject *f = tb->tb_frame; Py_CLEAR(f->f_back); } #endif } else { __Pyx_Coroutine_ExceptionClear(self); } return retval; } static CYTHON_INLINE PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) { if (unlikely(!retval && !PyErr_Occurred())) { PyErr_SetNone(PyExc_StopIteration); } return retval; } static CYTHON_INLINE PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { PyObject *ret; PyObject *val = NULL; __Pyx_Coroutine_Undelegate(gen); __Pyx_PyGen_FetchStopIterationValue(&val); ret = __Pyx_Coroutine_SendEx(gen, val); Py_XDECREF(val); return ret; } static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { PyObject *retval; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) return NULL; if (yf) { PyObject *ret; gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_CheckExact(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif { if (value == Py_None) ret = PyIter_Next(yf); else ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); } gen->is_running = 0; if (likely(ret)) { return ret; } retval = __Pyx_Coroutine_FinishDelegation(gen); } else { retval = __Pyx_Coroutine_SendEx(gen, value); } return __Pyx_Coroutine_MethodReturn(retval); } static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { PyObject *retval = NULL; int err = 0; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_CheckExact(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else #endif { PyObject *meth; gen->is_running = 1; meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close); if (unlikely(!meth)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_WriteUnraisable(yf); } PyErr_Clear(); } else { retval = PyObject_CallFunction(meth, NULL); Py_DECREF(meth); if (!retval) err = -1; } gen->is_running = 0; } Py_XDECREF(retval); return err; } static PyObject *__Pyx_Generator_Next(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) return NULL; if (yf) { PyObject *ret; gen->is_running = 1; ret = Py_TYPE(yf)->tp_iternext(yf); gen->is_running = 0; if (likely(ret)) { return ret; } return __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_SendEx(gen, Py_None); } static PyObject *__Pyx_Coroutine_Close(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *retval, *raised_exception; PyObject *yf = gen->yieldfrom; int err = 0; if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) return NULL; if (yf) { Py_INCREF(yf); err = __Pyx_Coroutine_CloseIter(gen, yf); __Pyx_Coroutine_Undelegate(gen); Py_DECREF(yf); } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); retval = __Pyx_Coroutine_SendEx(gen, NULL); if (retval) { Py_DECREF(retval); PyErr_SetString(PyExc_RuntimeError, "generator ignored GeneratorExit"); return NULL; } raised_exception = PyErr_Occurred(); if (!raised_exception || raised_exception == PyExc_StopIteration || raised_exception == PyExc_GeneratorExit || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit) || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration)) { if (raised_exception) PyErr_Clear(); Py_INCREF(Py_None); return Py_None; } return NULL; } static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *typ; PyObject *tb = NULL; PyObject *val = NULL; PyObject *yf = gen->yieldfrom; if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) return NULL; if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) return NULL; if (yf) { PyObject *ret; Py_INCREF(yf); if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) { int err = __Pyx_Coroutine_CloseIter(gen, yf); Py_DECREF(yf); __Pyx_Coroutine_Undelegate(gen); if (err < 0) return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); goto throw_here; } gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Coroutine_Throw(yf, args); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_CheckExact(yf)) { ret = __Pyx_Coroutine_Throw(yf, args); } else #endif { PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); if (unlikely(!meth)) { Py_DECREF(yf); if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { gen->is_running = 0; return NULL; } PyErr_Clear(); __Pyx_Coroutine_Undelegate(gen); gen->is_running = 0; goto throw_here; } ret = PyObject_CallObject(meth, args); Py_DECREF(meth); } gen->is_running = 0; Py_DECREF(yf); if (!ret) { ret = __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_MethodReturn(ret); } throw_here: __Pyx_Raise(typ, val, tb, NULL); return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); } static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; Py_VISIT(gen->closure); Py_VISIT(gen->classobj); Py_VISIT(gen->yieldfrom); Py_VISIT(gen->exc_type); Py_VISIT(gen->exc_value); Py_VISIT(gen->exc_traceback); return 0; } static int __Pyx_Coroutine_clear(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; Py_CLEAR(gen->closure); Py_CLEAR(gen->classobj); Py_CLEAR(gen->yieldfrom); Py_CLEAR(gen->exc_type); Py_CLEAR(gen->exc_value); Py_CLEAR(gen->exc_traceback); Py_CLEAR(gen->gi_name); Py_CLEAR(gen->gi_qualname); return 0; } static void __Pyx_Coroutine_dealloc(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); if (gen->resume_label > 0) { PyObject_GC_Track(self); #if PY_VERSION_HEX >= 0x030400a1 if (PyObject_CallFinalizerFromDealloc(self)) #else Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) #endif { return; } PyObject_GC_UnTrack(self); } __Pyx_Coroutine_clear(self); PyObject_GC_Del(gen); } static void __Pyx_Coroutine_del(PyObject *self) { PyObject *res; PyObject *error_type, *error_value, *error_traceback; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; if (gen->resume_label <= 0) return ; #if PY_VERSION_HEX < 0x030400a1 assert(self->ob_refcnt == 0); self->ob_refcnt = 1; #endif __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); res = __Pyx_Coroutine_Close(self); if (res == NULL) PyErr_WriteUnraisable(self); else Py_DECREF(res); __Pyx_ErrRestore(error_type, error_value, error_traceback); #if PY_VERSION_HEX < 0x030400a1 assert(self->ob_refcnt > 0); if (--self->ob_refcnt == 0) { return; } { Py_ssize_t refcnt = self->ob_refcnt; _Py_NewReference(self); self->ob_refcnt = refcnt; } #if CYTHON_COMPILING_IN_CPYTHON assert(PyType_IS_GC(self->ob_type) && _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); _Py_DEC_REFTOTAL; #endif #ifdef COUNT_ALLOCS --Py_TYPE(self)->tp_frees; --Py_TYPE(self)->tp_allocs; #endif #endif } static PyObject * __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self) { Py_INCREF(self->gi_name); return self->gi_name; } static int __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = self->gi_name; Py_INCREF(value); self->gi_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self) { Py_INCREF(self->gi_qualname); return self->gi_qualname; } static int __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = self->gi_qualname; Py_INCREF(value); self->gi_qualname = value; Py_XDECREF(tmp); return 0; } static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *closure, PyObject *name, PyObject *qualname) { __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); if (gen == NULL) return NULL; gen->body = body; gen->closure = closure; Py_XINCREF(closure); gen->is_running = 0; gen->resume_label = 0; gen->classobj = NULL; gen->yieldfrom = NULL; gen->exc_type = NULL; gen->exc_value = NULL; gen->exc_traceback = NULL; gen->gi_weakreflist = NULL; Py_XINCREF(qualname); gen->gi_qualname = qualname; Py_XINCREF(name); gen->gi_name = name; PyObject_GC_Track(gen); return gen; } static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) int result; PyObject *globals, *result_obj; globals = PyDict_New(); if (unlikely(!globals)) goto ignore; result = PyDict_SetItemString(globals, "_cython_coroutine_type", #ifdef __Pyx_Coroutine_USED (PyObject*)__pyx_CoroutineType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; result = PyDict_SetItemString(globals, "_cython_generator_type", #ifdef __Pyx_Generator_USED (PyObject*)__pyx_GeneratorType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; result_obj = PyRun_String(py_code, Py_file_input, globals, globals); if (unlikely(!result_obj)) goto ignore; Py_DECREF(result_obj); Py_DECREF(globals); return module; ignore: Py_XDECREF(globals); PyErr_WriteUnraisable(module); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { Py_DECREF(module); module = NULL; } #else py_code++; #endif return module; } #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static PyObject* __Pyx_patch_abc_module(PyObject *module); static PyObject* __Pyx_patch_abc_module(PyObject *module) { module = __Pyx_Coroutine_patch_module( module, "" "if _cython_generator_type is not None:\n" " try: Generator = _module.Generator\n" " except AttributeError: pass\n" " else: Generator.register(_cython_generator_type)\n" "if _cython_coroutine_type is not None:\n" " try: Coroutine = _module.Coroutine\n" " except AttributeError: pass\n" " else: Coroutine.register(_cython_coroutine_type)\n" ); return module; } #endif static int __Pyx_patch_abc(void) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static int abc_patched = 0; if (!abc_patched) { PyObject *module; module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections"); if (!module) { PyErr_WriteUnraisable(NULL); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, ((PY_VERSION_HEX >= 0x03030000) ? "Cython module failed to register with collections.abc module" : "Cython module failed to register with collections module"), 1) < 0)) { return -1; } } else { module = __Pyx_patch_abc_module(module); abc_patched = 1; if (unlikely(!module)) return -1; Py_DECREF(module); } module = PyImport_ImportModule("backports_abc"); if (module) { module = __Pyx_patch_abc_module(module); Py_XDECREF(module); } if (!module) { PyErr_Clear(); } } #else if (0) __Pyx_Coroutine_patch_module(NULL, NULL); #endif return 0; } static PyMethodDef __pyx_Generator_methods[] = { {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS, (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, {0, 0, 0, 0} }; static PyMemberDef __pyx_Generator_memberlist[] = { {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, {0, 0, 0, 0, 0} }; static PyGetSetDef __pyx_Generator_getsets[] = { {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, (char*) PyDoc_STR("name of the generator"), 0}, {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, (char*) PyDoc_STR("qualified name of the generator"), 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_GeneratorType_type = { PyVarObject_HEAD_INIT(0, 0) "generator", sizeof(__pyx_CoroutineObject), 0, (destructor) __Pyx_Coroutine_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, 0, (traverseproc) __Pyx_Coroutine_traverse, 0, 0, offsetof(__pyx_CoroutineObject, gi_weakreflist), 0, (iternextfunc) __Pyx_Generator_Next, __pyx_Generator_methods, __pyx_Generator_memberlist, __pyx_Generator_getsets, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #else __Pyx_Coroutine_del, #endif 0, #if PY_VERSION_HEX >= 0x030400a1 __Pyx_Coroutine_del, #endif }; static int __pyx_Generator_init(void) { __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr; __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); if (unlikely(!__pyx_GeneratorType)) { return -1; } return 0; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ #endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED)) || (!EV_USE_SIGNALFD) */ #include "callbacks.c" gevent-1.1.0/gevent/gevent.corecext.h0000644000076500000000000001363212666555370020311 0ustar jmaddenwheel00000000000000/* Generated by Cython 0.23.4 */ #ifndef __PYX_HAVE__gevent__corecext #define __PYX_HAVE__gevent__corecext struct PyGeventLoopObject; struct PyGeventCallbackObject; struct PyGeventWatcherObject; struct PyGeventIOObject; struct PyGeventTimerObject; struct PyGeventSignalObject; struct PyGeventIdleObject; struct PyGeventPrepareObject; struct PyGeventCheckObject; struct PyGeventForkObject; struct PyGeventAsyncObject; struct PyGeventStatObject; /* "gevent/corecext.pyx":239 * * * cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: # <<<<<<<<<<<<<< * cdef libev.ev_loop* _ptr * cdef public object error_handler */ struct PyGeventLoopObject { PyObject_HEAD struct __pyx_vtabstruct_6gevent_8corecext_loop *__pyx_vtab; struct ev_loop *_ptr; PyObject *error_handler; struct ev_prepare _prepare; PyObject *_callbacks; struct ev_timer _timer0; struct ev_timer _periodic_signal_checker; }; /* "gevent/corecext.pyx":617 * * * cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: # <<<<<<<<<<<<<< * cdef public object callback * cdef public tuple args */ struct PyGeventCallbackObject { PyObject_HEAD PyObject *callback; PyObject *args; }; /* "gevent/corecext.pyx":685 * * * cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: # <<<<<<<<<<<<<< * """Abstract base class for all the watchers""" * */ struct PyGeventWatcherObject { PyObject_HEAD }; /* "gevent/corecext.pyx":710 * * * cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventIOObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_io _watcher; }; /* "gevent/corecext.pyx":895 * * * cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventTimerObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_timer _watcher; }; /* "gevent/corecext.pyx":1040 * * * cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventSignalObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_signal _watcher; }; /* "gevent/corecext.pyx":1165 * * * cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventIdleObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_idle _watcher; }; /* "gevent/corecext.pyx":1284 * * * cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventPrepareObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_prepare _watcher; }; /* "gevent/corecext.pyx":1403 * * * cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventCheckObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_check _watcher; }; /* "gevent/corecext.pyx":1522 * * * cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventForkObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_fork _watcher; }; /* "gevent/corecext.pyx":1641 * * * cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventAsyncObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_async _watcher; }; /* "gevent/corecext.pyx":1912 * * * cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: # <<<<<<<<<<<<<< * * */ struct PyGeventStatObject { struct PyGeventWatcherObject __pyx_base; struct PyGeventLoopObject *loop; PyObject *_callback; PyObject *args; int _flags; struct ev_stat _watcher; PyObject *path; PyObject *_paths; }; #ifndef __PYX_HAVE_API__gevent__corecext #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(_T) _T #endif __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventLoop_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventCallback_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventWatcher_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventIO_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventTimer_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventSignal_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventIdle_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventPrepare_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventCheck_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventFork_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventAsync_Type; __PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventStat_Type; __PYX_EXTERN_C DL_IMPORT(PyObject) *GEVENT_CORE_EVENTS; #endif /* !__PYX_HAVE_API__gevent__corecext */ #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initcorecext(void); #else PyMODINIT_FUNC PyInit_corecext(void); #endif #endif /* !__PYX_HAVE__gevent__corecext */ gevent-1.1.0/gevent/greenlet.py0000644000076500000000000006231712666555342017217 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. import sys from gevent.hub import GreenletExit from gevent.hub import InvalidSwitchError from gevent.hub import PY3 from gevent.hub import PYPY from gevent.hub import Waiter from gevent.hub import get_hub from gevent.hub import getcurrent from gevent.hub import greenlet from gevent.hub import iwait from gevent.hub import reraise from gevent.hub import wait from gevent.timeout import Timeout from gevent._tblib import dump_traceback from gevent._tblib import load_traceback from collections import deque __all__ = ['Greenlet', 'joinall', 'killall'] if PYPY: import _continuation _continulet = _continuation.continulet class SpawnedLink(object): """A wrapper around link that calls it in another greenlet. Can be called only from main loop. """ __slots__ = ['callback'] def __init__(self, callback): if not callable(callback): raise TypeError("Expected callable: %r" % (callback, )) self.callback = callback def __call__(self, source): g = greenlet(self.callback, get_hub()) g.switch(source) def __hash__(self): return hash(self.callback) def __eq__(self, other): return self.callback == getattr(other, 'callback', other) def __str__(self): return str(self.callback) def __repr__(self): return repr(self.callback) def __getattr__(self, item): assert item != 'callback' return getattr(self.callback, item) class SuccessSpawnedLink(SpawnedLink): """A wrapper around link that calls it in another greenlet only if source succeed. Can be called only from main loop. """ __slots__ = [] def __call__(self, source): if source.successful(): return SpawnedLink.__call__(self, source) class FailureSpawnedLink(SpawnedLink): """A wrapper around link that calls it in another greenlet only if source failed. Can be called only from main loop. """ __slots__ = [] def __call__(self, source): if not source.successful(): return SpawnedLink.__call__(self, source) class _lazy(object): def __init__(self, func): self.data = (func, func.__name__) def __get__(self, inst, class_): if inst is None: return self func, name = self.data value = func(inst) inst.__dict__[name] = value return value class Greenlet(greenlet): """A light-weight cooperatively-scheduled execution unit. """ value = None _exc_info = () _notifier = None #: An event, such as a timer or a callback that fires. It is established in #: start() and start_later() as those two objects, respectively. #: Once this becomes non-None, the Greenlet cannot be started again. Conversely, #: kill() and throw() check for non-None to determine if this object has ever been #: scheduled for starting. A placeholder _dummy_event is assigned by them to prevent #: the greenlet from being started in the future, if necessary. _start_event = None args = () _kwargs = None def __init__(self, run=None, *args, **kwargs): """ Greenlet constructor. :param args: The arguments passed to the ``run`` function. :param kwargs: The keyword arguments passed to the ``run`` function. :keyword run: The callable object to run. If not given, this object's `_run` method will be invoked (typically defined by subclasses). .. versionchanged:: 1.1b1 The ``run`` argument to the constructor is now verified to be a callable object. Previously, passing a non-callable object would fail after the greenlet was spawned. """ # greenlet.greenlet(run=None, parent=None) # Calling it with both positional arguments instead of a keyword # argument (parent=get_hub()) speeds up creation of this object ~30%: # python -m timeit -s 'import gevent' 'gevent.Greenlet()' # Python 3.5: 2.70usec with keywords vs 1.94usec with positional # Python 3.4: 2.32usec with keywords vs 1.74usec with positional # Python 3.3: 2.55usec with keywords vs 1.92usec with positional # Python 2.7: 1.73usec with keywords vs 1.40usec with positional greenlet.__init__(self, None, get_hub()) if run is not None: self._run = run # If they didn't pass a callable at all, then they must # already have one. Note that subclassing to override the run() method # itself has never been documented or supported. if not callable(self._run): raise TypeError("The run argument or self._run must be callable") if args: self.args = args if kwargs: self._kwargs = kwargs @property def kwargs(self): return self._kwargs or {} @_lazy def _links(self): return deque() def _has_links(self): return '_links' in self.__dict__ and self._links def _raise_exception(self): reraise(*self.exc_info) @property def loop(self): # needed by killall return self.parent.loop def __bool__(self): return self._start_event is not None and self._exc_info is Greenlet._exc_info __nonzero__ = __bool__ ### Lifecycle if PYPY: # oops - pypy's .dead relies on __nonzero__ which we overriden above @property def dead(self): if self._greenlet__main: return False if self.__start_cancelled_by_kill or self.__started_but_aborted: return True return self._greenlet__started and not _continulet.is_pending(self) else: @property def dead(self): return self.__start_cancelled_by_kill or self.__started_but_aborted or greenlet.dead.__get__(self) @property def __never_started_or_killed(self): return self._start_event is None @property def __start_pending(self): return (self._start_event is not None and (self._start_event.pending or getattr(self._start_event, 'active', False))) @property def __start_cancelled_by_kill(self): return self._start_event is _cancelled_start_event @property def __start_completed(self): return self._start_event is _start_completed_event @property def __started_but_aborted(self): return (not self.__never_started_or_killed # we have been started or killed and not self.__start_cancelled_by_kill # we weren't killed, so we must have been started and not self.__start_completed # the start never completed and not self.__start_pending) # and we're not pending, so we must have been aborted def __cancel_start(self): if self._start_event is None: # prevent self from ever being started in the future self._start_event = _cancelled_start_event # cancel any pending start event # NOTE: If this was a real pending start event, this will leave a # "dangling" callback/timer object in the hub.loop.callbacks list; # depending on where we are in the event loop, it may even be in a local # variable copy of that list (in _run_callbacks). This isn't a problem, # except for the leak-tests. self._start_event.stop() def __handle_death_before_start(self, *args): # args is (t, v, tb) or simply t or v if self._exc_info is Greenlet._exc_info and self.dead: # the greenlet was never switched to before and it will never be, _report_error was not called # the result was not set and the links weren't notified. let's do it here. # checking that self.dead is true is essential, because throw() does not necessarily kill the greenlet # (if the exception raised by throw() is caught somewhere inside the greenlet). if len(args) == 1: arg = args[0] #if isinstance(arg, type): if type(arg) is type(Exception): args = (arg, arg(), None) else: args = (type(arg), arg, None) elif not args: args = (GreenletExit, GreenletExit(), None) self._report_error(args) @property def started(self): # DEPRECATED return bool(self) def ready(self): """ Return a true value if and only if the greenlet has finished execution. .. versionchanged:: 1.1 This function is only guaranteed to return true or false *values*, not necessarily the literal constants ``True`` or ``False``. """ return self.dead or self._exc_info def successful(self): """ Return a true value if and only if the greenlet has finished execution successfully, that is, without raising an error. .. tip:: A greenlet that has been killed with the default :class:`GreenletExit` exception is considered successful. That is, ``GreenletExit`` is not considered an error. .. note:: This function is only guaranteed to return true or false *values*, not necessarily the literal constants ``True`` or ``False``. """ return self._exc_info and self._exc_info[1] is None def __repr__(self): classname = self.__class__.__name__ result = '<%s at %s' % (classname, hex(id(self))) formatted = self._formatinfo() if formatted: result += ': ' + formatted return result + '>' def _formatinfo(self): try: return self._formatted_info except AttributeError: pass try: result = getfuncname(self.__dict__['_run']) except Exception: pass else: args = [] if self.args: args = [repr(x)[:50] for x in self.args] if self._kwargs: args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self._kwargs.items()]) if args: result += '(' + ', '.join(args) + ')' # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed self._formatted_info = result return result return '' @property def exception(self): """Holds the exception instance raised by the function if the greenlet has finished with an error. Otherwise ``None``. """ return self._exc_info[1] if self._exc_info else None @property def exc_info(self): """Holds the exc_info three-tuple raised by the function if the greenlet finished with an error. Otherwise a false value.""" e = self._exc_info if e: return (e[0], e[1], load_traceback(e[2])) def throw(self, *args): """Immediatelly switch into the greenlet and raise an exception in it. Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever. To raise an exception in a safe manner from any greenlet, use :meth:`kill`. If a greenlet was started but never switched to yet, then also a) cancel the event that will start it b) fire the notifications as if an exception was raised in a greenlet """ self.__cancel_start() try: if not self.dead: # Prevent switching into a greenlet *at all* if we had never # started it. Usually this is the same thing that happens by throwing, # but if this is done from the hub with nothing else running, prevents a # LoopExit. greenlet.throw(self, *args) finally: self.__handle_death_before_start(*args) def start(self): """Schedule the greenlet to run in this loop iteration""" if self._start_event is None: self._start_event = self.parent.loop.run_callback(self.switch) def start_later(self, seconds): """Schedule the greenlet to run in the future loop iteration *seconds* later""" if self._start_event is None: self._start_event = self.parent.loop.timer(seconds) self._start_event.start(self.switch) @classmethod def spawn(cls, *args, **kwargs): """ Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``. This can be used as ``gevent.spawn`` or ``Greenlet.spawn``. The arguments are passed to :meth:`Greenlet.__init__`. .. versionchanged:: 1.1b1 If a *function* is given that is not callable, immediately raise a :exc:`TypeError` instead of spawning a greenlet that will raise an uncaught TypeError. """ g = cls(*args, **kwargs) g.start() return g @classmethod def spawn_later(cls, seconds, *args, **kwargs): """ Create and return a new Greenlet object scheduled to run ``function(*args, **kwargs)`` in the future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later`` or ``gevent.spawn_later``. The arguments are passed to :meth:`Greenlet.__init__`. .. versionchanged:: 1.1b1 If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword ) is given to this classmethod (and not a classmethod of a subclass), it is verified to be callable. Previously, the spawned greenlet would have failed when it started running. """ if cls is Greenlet and not args and 'run' not in kwargs: raise TypeError("") g = cls(*args, **kwargs) g.start_later(seconds) return g def kill(self, exception=GreenletExit, block=True, timeout=None): """ Raise the ``exception`` in the greenlet. If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires. If block is ``False``, the current greenlet is not unscheduled. The function always returns ``None`` and never raises an error. .. note:: Depending on what this greenlet is executing and the state of the event loop, the exception may or may not be raised immediately when this greenlet resumes execution. It may be raised on a subsequent green call, or, if this greenlet exits before making such a call, it may not be raised at all. As of 1.1, an example where the exception is raised later is if this greenlet had called :func:`sleep(0) `; an example where the exception is raised immediately is if this greenlet had called :func:`sleep(0.1) `. See also :func:`gevent.kill`. :keyword type exception: The type of exception to raise in the greenlet. The default is :class:`GreenletExit`, which indicates a :meth:`successful` completion of the greenlet. .. versionchanged:: 0.13.0 *block* is now ``True`` by default. .. versionchanged:: 1.1a2 If this greenlet had never been switched to, killing it will prevent it from ever being switched to. """ self.__cancel_start() if self.dead: self.__handle_death_before_start(exception) else: waiter = Waiter() if block else None self.parent.loop.run_callback(_kill, self, exception, waiter) if block: waiter.get() self.join(timeout) # it should be OK to use kill() in finally or kill a greenlet from more than one place; # thus it should not raise when the greenlet is already killed (= not started) def get(self, block=True, timeout=None): """Return the result the greenlet has returned or re-raise the exception it has raised. If block is ``False``, raise :class:`gevent.Timeout` if the greenlet is still alive. If block is ``True``, unschedule the current greenlet until the result is available or the timeout expires. In the latter case, :class:`gevent.Timeout` is raised. """ if self.ready(): if self.successful(): return self.value self._raise_exception() if not block: raise Timeout() switch = getcurrent().switch self.rawlink(switch) try: t = Timeout._start_new_or_dummy(timeout) try: result = self.parent.switch() if result is not self: raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, )) finally: t.cancel() except: # unlinking in 'except' instead of finally is an optimization: # if switch occurred normally then link was already removed in _notify_links # and there's no need to touch the links set. # Note, however, that if "Invalid switch" assert was removed and invalid switch # did happen, the link would remain, causing another invalid switch later in this greenlet. self.unlink(switch) raise if self.ready(): if self.successful(): return self.value self._raise_exception() def join(self, timeout=None): """Wait until the greenlet finishes or *timeout* expires. Return ``None`` regardless. """ if self.ready(): return switch = getcurrent().switch self.rawlink(switch) try: t = Timeout._start_new_or_dummy(timeout) try: result = self.parent.switch() if result is not self: raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, )) finally: t.cancel() except Timeout as ex: self.unlink(switch) if ex is not t: raise except: self.unlink(switch) raise def _report_result(self, result): self._exc_info = (None, None, None) self.value = result if self._has_links() and not self._notifier: self._notifier = self.parent.loop.run_callback(self._notify_links) def _report_error(self, exc_info): if isinstance(exc_info[1], GreenletExit): self._report_result(exc_info[1]) return self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2]) if self._has_links() and not self._notifier: self._notifier = self.parent.loop.run_callback(self._notify_links) try: self.parent.handle_error(self, *exc_info) finally: del exc_info def run(self): try: self.__cancel_start() self._start_event = _start_completed_event try: result = self._run(*self.args, **self.kwargs) except: self._report_error(sys.exc_info()) return self._report_result(result) finally: self.__dict__.pop('_run', None) self.__dict__.pop('args', None) self.__dict__.pop('kwargs', None) def _run(self): """Subclasses may override this method to take any number of arguments and keyword arguments. .. versionadded:: 1.1a3 Previously, if no callable object was passed to the constructor, the spawned greenlet would later fail with an AttributeError. """ return def rawlink(self, callback): """Register a callable to be executed when the greenlet finishes execution. The *callback* will be called with this instance as an argument. .. caution:: The callable will be called in the HUB greenlet. """ if not callable(callback): raise TypeError('Expected callable: %r' % (callback, )) self._links.append(callback) if self.ready() and self._links and not self._notifier: self._notifier = self.parent.loop.run_callback(self._notify_links) def link(self, callback, SpawnedLink=SpawnedLink): """Link greenlet's completion to a callable. The *callback* will be called with this instance as an argument once this greenlet's dead. A callable is called in its own greenlet. """ self.rawlink(SpawnedLink(callback)) def unlink(self, callback): """Remove the callback set by :meth:`link` or :meth:`rawlink`""" try: self._links.remove(callback) except ValueError: pass def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): """Like :meth:`link` but *callback* is only notified when the greenlet has completed successfully.""" self.link(callback, SpawnedLink=SpawnedLink) def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): """Like :meth:`link` but *callback* is only notified when the greenlet dies because of an unhandled exception.""" self.link(callback, SpawnedLink=SpawnedLink) def _notify_links(self): while self._links: link = self._links.popleft() try: link(self) except: self.parent.handle_error((link, self), *sys.exc_info()) class _dummy_event(object): pending = False active = False def stop(self): pass _cancelled_start_event = _dummy_event() _start_completed_event = _dummy_event() del _dummy_event def _kill(greenlet, exception, waiter): try: greenlet.throw(exception) except: # XXX do we need this here? greenlet.parent.handle_error(greenlet, *sys.exc_info()) if waiter is not None: waiter.switch() def joinall(greenlets, timeout=None, raise_error=False, count=None): """ Wait for the ``greenlets`` to finish. :param greenlets: A sequence (supporting :func:`len`) of greenlets to wait for. :keyword float timeout: If given, the maximum number of seconds to wait. :return: A sequence of the greenlets that finished before the timeout (if any) expired. """ if not raise_error: return wait(greenlets, timeout=timeout, count=count) done = [] for obj in iwait(greenlets, timeout=timeout, count=count): if getattr(obj, 'exception', None) is not None: if hasattr(obj, '_raise_exception'): obj._raise_exception() else: raise obj.exception done.append(obj) return done def _killall3(greenlets, exception, waiter): diehards = [] for g in greenlets: if not g.dead: try: g.throw(exception) except: g.parent.handle_error(g, *sys.exc_info()) if not g.dead: diehards.append(g) waiter.switch(diehards) def _killall(greenlets, exception): for g in greenlets: if not g.dead: try: g.throw(exception) except: g.parent.handle_error(g, *sys.exc_info()) def killall(greenlets, exception=GreenletExit, block=True, timeout=None): """ Forceably terminate all the ``greenlets`` by causing them to raise ``exception``. :param greenlets: A **bounded** iterable of the non-None greenlets to terminate. *All* the items in this iterable must be greenlets that belong to the same thread. :keyword exception: The exception to raise in the greenlets. By default this is :class:`GreenletExit`. :keyword bool block: If True (the default) then this function only returns when all the greenlets are dead; the current greenlet is unscheduled during that process. If greenlets ignore the initial exception raised in them, then they will be joined (with :func:`gevent.joinall`) and allowed to die naturally. If False, this function returns immediately and greenlets will raise the exception asynchronously. :keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is only honored when ``block`` is True. :raise Timeout: If blocking and a timeout is given that elapses before all the greenlets are dead. .. versionchanged:: 1.1a2 *greenlets* can be any iterable of greenlets, like an iterator or a set. Previously it had to be a list or tuple. """ # support non-indexable containers like iterators or set objects greenlets = list(greenlets) if not greenlets: return loop = greenlets[0].loop if block: waiter = Waiter() loop.run_callback(_killall3, greenlets, exception, waiter) t = Timeout._start_new_or_dummy(timeout) try: alive = waiter.get() if alive: joinall(alive, raise_error=False) finally: t.cancel() else: loop.run_callback(_killall, greenlets, exception) if PY3: _meth_self = "__self__" else: _meth_self = "im_self" def getfuncname(func): if not hasattr(func, _meth_self): try: funcname = func.__name__ except AttributeError: pass else: if funcname != '': return funcname return repr(func) gevent-1.1.0/gevent/hub.py0000644000076500000000000010644112666555342016165 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2015 Denis Bilenko. See LICENSE for details. """ Event-loop hub. """ from __future__ import absolute_import from functools import partial as _functools_partial import os import sys import traceback from greenlet import greenlet, getcurrent, GreenletExit __all__ = ['getcurrent', 'GreenletExit', 'spawn_raw', 'sleep', 'kill', 'signal', 'reinit', 'get_hub', 'Hub', 'Waiter'] PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] >= 3 PYPY = hasattr(sys, 'pypy_version_info') if PY3: string_types = str, integer_types = int, text_type = str xrange = range def reraise(tp, value, tb=None): if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value else: import __builtin__ string_types = __builtin__.basestring, text_type = __builtin__.unicode integer_types = (int, __builtin__.long) xrange = __builtin__.xrange from gevent._util_py2 import reraise if sys.version_info[0] <= 2: import thread else: import _thread as thread # These must be the "real" native thread versions, # not monkey-patched. threadlocal = thread._local class _threadlocal(threadlocal): def __init__(self): # Use a class with an initializer so that we can test # for 'is None' instead of catching AttributeError, making # the code cleaner and possibly solving some corner cases # (like #687) threadlocal.__init__(self) self.Hub = None self.loop = None self.hub = None _threadlocal = _threadlocal() get_ident = thread.get_ident MAIN_THREAD = get_ident() class _NONE(object): "A special thingy you must never pass to any of gevent API" __slots__ = () def __repr__(self): return '<_NONE>' _NONE = _NONE() class LoopExit(Exception): """ Exception thrown when the hub finishes running. In a normal application, this is never thrown or caught explicitly. The internal implementation of functions like :func:`join` and :func:`joinall` may catch it, but user code generally should not. .. caution:: Errors in application programming can also lead to this exception being raised. Some examples include (but are not limited too): - greenlets deadlocking on a lock; - using a socket or other gevent object with native thread affinity from a different thread """ pass class BlockingSwitchOutError(AssertionError): pass class InvalidSwitchError(AssertionError): pass class ConcurrentObjectUseError(AssertionError): # raised when an object is used (waited on) by two greenlets # independently, meaning the object was entered into a blocking # state by one greenlet and then another while still blocking in the # first one pass def spawn_raw(function, *args, **kwargs): """ Create a new :class:`greenlet.greenlet` object and schedule it to run ``function(*args, **kwargs)``. This returns a raw :class:`~greenlet.greenlet` which does not have all the useful methods that :class:`gevent.Greenlet` has. Typically, applications should prefer :func:`~gevent.spawn`, but this method may occasionally be useful as an optimization if there are many greenlets involved. .. versionchanged:: 1.1b1 If *function* is not callable, immediately raise a :exc:`TypeError` instead of spawning a greenlet that will raise an uncaught TypeError. .. versionchanged:: 1.1rc2 Accept keyword arguments for ``function`` as previously (incorrectly) documented. Note that this may incur an additional expense. .. versionchanged:: 1.1a3 Verify that ``function`` is callable, raising a TypeError if not. Previously, the spawned greenlet would have failed the first time it was switched to. """ if not callable(function): raise TypeError("function must be callable") hub = get_hub() # The callback class object that we use to run this doesn't # accept kwargs (and those objects are heavily used, as well as being # implemented twice in core.ppyx and corecffi.py) so do it with a partial if kwargs: function = _functools_partial(function, *args, **kwargs) g = greenlet(function, hub) hub.loop.run_callback(g.switch) else: g = greenlet(function, hub) hub.loop.run_callback(g.switch, *args) return g def sleep(seconds=0, ref=True): """ Put the current greenlet to sleep for at least *seconds*. *seconds* may be specified as an integer, or a float if fractional seconds are desired. .. tip:: In the current implementation, a value of 0 (the default) means to yield execution to any other runnable greenlets, but this greenlet may be scheduled again before the event loop cycles (in an extreme case, a greenlet that repeatedly sleeps with 0 can prevent greenlets that are ready to do I/O from being scheduled for some (small) period of time); a value greater than 0, on the other hand, will delay running this greenlet until the next iteration of the loop. If *ref* is False, the greenlet running ``sleep()`` will not prevent :func:`gevent.wait` from exiting. .. seealso:: :func:`idle` """ hub = get_hub() loop = hub.loop if seconds <= 0: waiter = Waiter() loop.run_callback(waiter.switch) waiter.get() else: hub.wait(loop.timer(seconds, ref=ref)) def idle(priority=0): """ Cause the calling greenlet to wait until the event loop is idle. Idle is defined as having no other events of the same or higher *priority* pending. That is, as long as sockets, timeouts or even signals of the same or higher priority are being processed, the loop is not idle. .. seealso:: :func:`sleep` """ hub = get_hub() watcher = hub.loop.idle() if priority: watcher.priority = priority hub.wait(watcher) def kill(greenlet, exception=GreenletExit): """ Kill greenlet asynchronously. The current greenlet is not unscheduled. .. note:: The method :meth:`Greenlet.kill` method does the same and more (and the same caveats listed there apply here). However, the MAIN greenlet - the one that exists initially - does not have a ``kill()`` method, and neither do any created with :func:`spawn_raw`, so you have to use this function. .. versionchanged:: 1.1a2 If the ``greenlet`` has a :meth:`kill ` method, calls it. This prevents a greenlet from being switched to for the first time after it's been killed but not yet executed. """ if not greenlet.dead: if hasattr(greenlet, 'kill'): # dealing with gevent.greenlet.Greenlet. Use it, especially # to avoid allowing one to be switched to for the first time # after it's been killed greenlet.kill(exception=exception, block=False) else: get_hub().loop.run_callback(greenlet.throw, exception) class signal(object): """ Call the *handler* with the *args* and *kwargs* when the process receives the signal *signalnum*. The *handler* will be run in a new greenlet when the signal is delivered. This returns an object with the useful method ``cancel``, which, when called, will prevent future deliveries of *signalnum* from calling *handler*. .. note:: This may not operate correctly with SIGCHLD if libev child watchers are used (as they are by default with os.fork). """ # XXX: This is manually documented in gevent.rst while it is aliased in # the gevent module. greenlet_class = None def __init__(self, signalnum, handler, *args, **kwargs): self.hub = get_hub() self.watcher = self.hub.loop.signal(signalnum, ref=False) self.watcher.start(self._start) self.handler = handler self.args = args self.kwargs = kwargs if self.greenlet_class is None: from gevent import Greenlet self.greenlet_class = Greenlet def _get_ref(self): return self.watcher.ref def _set_ref(self, value): self.watcher.ref = value ref = property(_get_ref, _set_ref) del _get_ref, _set_ref def cancel(self): self.watcher.stop() def _start(self): try: greenlet = self.greenlet_class(self.handle) greenlet.switch() except: self.hub.handle_error(None, *sys._exc_info()) def handle(self): try: self.handler(*self.args, **self.kwargs) except: self.hub.handle_error(None, *sys.exc_info()) def reinit(): """ Prepare the gevent hub to run in a new (forked) process. This should be called *immediately* after :func:`os.fork` in the child process. This is done automatically by :func:`gevent.os.fork` or if the :mod:`os` module has been monkey-patched. If this function is not called in a forked process, symptoms may include hanging of functions like :func:`socket.getaddrinfo`, and the hub's threadpool is unlikely to work. .. note:: Registered fork watchers may or may not run before this function (and thus ``gevent.os.fork``) return. If they have not run, they will run "soon", after an iteration of the event loop. You can force this by inserting a few small (but non-zero) calls to :func:`sleep` after fork returns. (As of gevent 1.1 and before, fork watchers will not have run, but this may change in the future.) .. note:: This function may be removed in a future major release if the fork process can be more smoothly managed. .. warning:: See remarks in :func:`gevent.os.fork` about greenlets and libev watchers in the child process. """ # The loop reinit function in turn calls libev's ev_loop_fork # function. hub = _get_hub() if hub is not None: # Note that we reinit the existing loop, not destroy it. # See https://github.com/gevent/gevent/issues/200. hub.loop.reinit() # libev's fork watchers are slow to fire because the only fire # at the beginning of a loop; due to our use of callbacks that # run at the end of the loop, that may be too late. The # threadpool and resolvers depend on the fork handlers being # run (specifically, the threadpool will fail in the forked # child if there were any threads in it, which there will be # if the resolver_thread was in use (the default) before the # fork.) # # If the forked process wants to use the threadpool or # resolver immediately (in a queued callback), it would hang. # # The below is a workaround. Fortunately, both of these # methods are idempotent and can be called multiple times # following a fork if the suddenly started working, or were # already working on some platforms. Other threadpools and fork handlers # will be called at an arbitrary time later ('soon') if hasattr(hub.threadpool, '_on_fork'): hub.threadpool._on_fork() # resolver_ares also has a fork watcher that's not firing if hasattr(hub.resolver, '_on_fork'): hub.resolver._on_fork() # TODO: We'd like to sleep for a non-zero amount of time to force the loop to make a # pass around before returning to this greenlet. That will allow any # user-provided fork watchers to run. (Two calls are necessary.) HOWEVER, if # we do this, certain tests that heavily mix threads and forking, # like 2.7/test_threading:test_reinit_tls_after_fork, fail. It's not immediately clear # why. #sleep(0.00001) #sleep(0.00001) def get_hub_class(): """Return the type of hub to use for the current thread. If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used. """ hubtype = _threadlocal.Hub if hubtype is None: hubtype = _threadlocal.Hub = Hub return hubtype def get_hub(*args, **kwargs): """ Return the hub for the current thread. If a hub does not exist in the current thread, a new one is created of the type returned by :func:`get_hub_class`. """ hub = _threadlocal.hub if hub is None: hubtype = get_hub_class() hub = _threadlocal.hub = hubtype(*args, **kwargs) return hub def _get_hub(): """Return the hub for the current thread. Return ``None`` if no hub has been created yet. """ return _threadlocal.hub def set_hub(hub): _threadlocal.hub = hub def _import(path): if isinstance(path, list): if not path: raise ImportError('Cannot import from empty list: %r' % (path, )) for item in path[:-1]: try: return _import(item) except ImportError: pass return _import(path[-1]) if not isinstance(path, string_types): return path if '.' not in path: raise ImportError("Cannot import %r (required format: [path/][package.]module.class)" % path) if '/' in path: package_path, path = path.rsplit('/', 1) sys.path = [package_path] + sys.path else: package_path = None try: module, item = path.rsplit('.', 1) x = __import__(module) for attr in path.split('.')[1:]: oldx = x x = getattr(x, attr, _NONE) if x is _NONE: raise ImportError('Cannot import %r from %r' % (attr, oldx)) return x finally: try: sys.path.remove(package_path) except ValueError: pass def config(default, envvar): result = os.environ.get(envvar) or default if isinstance(result, string_types): return result.split(',') return result def resolver_config(default, envvar): result = config(default, envvar) return [_resolvers.get(x, x) for x in result] _resolvers = {'ares': 'gevent.resolver_ares.Resolver', 'thread': 'gevent.resolver_thread.Resolver', 'block': 'gevent.socket.BlockingResolver'} _DEFAULT_LOOP_CLASS = 'gevent.core.loop' class Hub(greenlet): """A greenlet that runs the event loop. It is created automatically by :func:`get_hub`. **Switching** Every time this greenlet (i.e., the event loop) is switched *to*, if the current greenlet has a ``switch_out`` method, it will be called. This allows a greenlet to take some cleanup actions before yielding control. This method should not call any gevent blocking functions. """ #: If instances of these classes are raised into the event loop, #: they will be propagated out to the main greenlet (where they will #: usually be caught by Python itself) SYSTEM_ERROR = (KeyboardInterrupt, SystemExit, SystemError) #: Instances of these classes are not considered to be errors and #: do not get logged/printed when raised by the event loop. NOT_ERROR = (GreenletExit, SystemExit) loop_class = config(_DEFAULT_LOOP_CLASS, 'GEVENT_LOOP') # For the standard class, go ahead and import it when this class # is defined. This is no loss of generality because the envvar is # only read when this class is defined, and we know that the # standard class will be available. This can solve problems with # the class being imported from multiple threads at once, leading # to one of the imports failing. Only do this for the object we # need in the constructor, as the rest of the factories are # themselves handled lazily. See #687. (People using a custom loop_class # can probably manage to get_hub() from the main thread or otherwise import # that loop_class themselves.) if loop_class == [_DEFAULT_LOOP_CLASS]: loop_class = [_import(loop_class)] resolver_class = ['gevent.resolver_thread.Resolver', 'gevent.resolver_ares.Resolver', 'gevent.socket.BlockingResolver'] #: The class or callable object, or the name of a factory function or class, #: that will be used to create :attr:`resolver`. By default, configured according to #: :doc:`dns`. If a list, a list of objects in preference order. resolver_class = resolver_config(resolver_class, 'GEVENT_RESOLVER') threadpool_class = config('gevent.threadpool.ThreadPool', 'GEVENT_THREADPOOL') backend = config(None, 'GEVENT_BACKEND') format_context = 'pprint.pformat' threadpool_size = 10 def __init__(self, loop=None, default=None): greenlet.__init__(self) if hasattr(loop, 'run'): if default is not None: raise TypeError("Unexpected argument: default") self.loop = loop elif _threadlocal.loop is not None: # Reuse a loop instance previously set by # destroying a hub without destroying the associated # loop. See #237 and #238. self.loop = _threadlocal.loop else: if default is None and get_ident() != MAIN_THREAD: default = False loop_class = _import(self.loop_class) if loop is None: loop = self.backend self.loop = loop_class(flags=loop, default=default) self._resolver = None self._threadpool = None self.format_context = _import(self.format_context) def __repr__(self): if self.loop is None: info = 'destroyed' else: try: info = self.loop._format() except Exception as ex: info = str(ex) or repr(ex) or 'error' result = '<%s at 0x%x %s' % (self.__class__.__name__, id(self), info) if self._resolver is not None: result += ' resolver=%r' % self._resolver if self._threadpool is not None: result += ' threadpool=%r' % self._threadpool return result + '>' def handle_error(self, context, type, value, tb): """ Called by the event loop when an error occurs. The arguments type, value, and tb are the standard tuple returned by :func:`sys.exc_info`. Applications can set a property on the hub with this same signature to override the error handling provided by this class. Errors that are :attr:`system errors ` are passed to :meth:`handle_system_error`. :param context: If this is ``None``, indicates a system error that should generally result in exiting the loop and being thrown to the parent greenlet. """ if isinstance(value, str): # Cython can raise errors where the value is a plain string # e.g., AttributeError, "_semaphore.Semaphore has no attr", value = type(value) if not issubclass(type, self.NOT_ERROR): self.print_exception(context, type, value, tb) if context is None or issubclass(type, self.SYSTEM_ERROR): self.handle_system_error(type, value) def handle_system_error(self, type, value): current = getcurrent() if current is self or current is self.parent or self.loop is None: self.parent.throw(type, value) else: # in case system error was handled and life goes on # switch back to this greenlet as well cb = None try: cb = self.loop.run_callback(current.switch) except: traceback.print_exc() try: self.parent.throw(type, value) finally: if cb is not None: cb.stop() def print_exception(self, context, type, value, tb): # Python 3 does not gracefully handle None value or tb in # traceback.print_exception() as previous versions did. if value is None: sys.stderr.write('%s\n' % type.__name__) else: traceback.print_exception(type, value, tb) del tb if context is not None: if not isinstance(context, str): try: context = self.format_context(context) except: traceback.print_exc() context = repr(context) sys.stderr.write('%s failed with %s\n\n' % (context, getattr(type, '__name__', 'exception'), )) def switch(self): switch_out = getattr(getcurrent(), 'switch_out', None) if switch_out is not None: switch_out() return greenlet.switch(self) def switch_out(self): raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback') def wait(self, watcher): """ Wait until the *watcher* (which should not be started) is ready. The current greenlet will be unscheduled during this time. .. seealso:: :class:`gevent.core.io`, :class:`gevent.core.timer`, :class:`gevent.core.signal`, :class:`gevent.core.idle`, :class:`gevent.core.prepare`, :class:`gevent.core.check`, :class:`gevent.core.fork`, :class:`gevent.core.async`, :class:`gevent.core.child`, :class:`gevent.core.stat` """ waiter = Waiter() unique = object() watcher.start(waiter.switch, unique) try: result = waiter.get() if result is not unique: raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (getcurrent(), result, unique)) finally: watcher.stop() def cancel_wait(self, watcher, error): """ Cancel an in-progress call to :meth:`wait` by throwing the given *error* in the waiting greenlet. """ if watcher.callback is not None: self.loop.run_callback(self._cancel_wait, watcher, error) def _cancel_wait(self, watcher, error): if watcher.active: switch = watcher.callback if switch is not None: greenlet = getattr(switch, '__self__', None) if greenlet is not None: greenlet.throw(error) def run(self): """ Entry-point to running the loop. This method is called automatically when the hub greenlet is scheduled; do not call it directly. :raises LoopExit: If the loop finishes running. This means that there are no other scheduled greenlets, and no active watchers or servers. In some situations, this indicates a programming error. """ assert self is getcurrent(), 'Do not call Hub.run() directly' while True: loop = self.loop loop.error_handler = self try: loop.run() finally: loop.error_handler = None # break the refcount cycle self.parent.throw(LoopExit('This operation would block forever', self)) # this function must never return, as it will cause switch() in the parent greenlet # to return an unexpected value # It is still possible to kill this greenlet with throw. However, in that case # switching to it is no longer safe, as switch will return immediatelly def join(self, timeout=None): """Wait for the event loop to finish. Exits only when there are no more spawned greenlets, started servers, active timeouts or watchers. If *timeout* is provided, wait no longer for the specified number of seconds. Returns True if exited because the loop finished execution. Returns False if exited because of timeout expired. """ assert getcurrent() is self.parent, "only possible from the MAIN greenlet" if self.dead: return True waiter = Waiter() if timeout is not None: timeout = self.loop.timer(timeout, ref=False) timeout.start(waiter.switch) try: try: waiter.get() except LoopExit: return True finally: if timeout is not None: timeout.stop() return False def destroy(self, destroy_loop=None): if self._resolver is not None: self._resolver.close() del self._resolver if self._threadpool is not None: self._threadpool.kill() del self._threadpool if destroy_loop is None: destroy_loop = not self.loop.default if destroy_loop: if _threadlocal.loop is self.loop: # Don't let anyone try to reuse this _threadlocal.loop = None self.loop.destroy() else: # Store in case another hub is created for this # thread. _threadlocal.loop = self.loop self.loop = None if _threadlocal.hub is self: _threadlocal.hub = None def _get_resolver(self): if self._resolver is None: if self.resolver_class is not None: self.resolver_class = _import(self.resolver_class) self._resolver = self.resolver_class(hub=self) return self._resolver def _set_resolver(self, value): self._resolver = value def _del_resolver(self): del self._resolver resolver = property(_get_resolver, _set_resolver, _del_resolver) def _get_threadpool(self): if self._threadpool is None: if self.threadpool_class is not None: self.threadpool_class = _import(self.threadpool_class) self._threadpool = self.threadpool_class(self.threadpool_size, hub=self) return self._threadpool def _set_threadpool(self, value): self._threadpool = value def _del_threadpool(self): del self._threadpool threadpool = property(_get_threadpool, _set_threadpool, _del_threadpool) class Waiter(object): """ A low level communication utility for greenlets. Waiter is a wrapper around greenlet's ``switch()`` and ``throw()`` calls that makes them somewhat safer: * switching will occur only if the waiting greenlet is executing :meth:`get` method currently; * any error raised in the greenlet is handled inside :meth:`switch` and :meth:`throw` * if :meth:`switch`/:meth:`throw` is called before the receiver calls :meth:`get`, then :class:`Waiter` will store the value/exception. The following :meth:`get` will return the value/raise the exception. The :meth:`switch` and :meth:`throw` methods must only be called from the :class:`Hub` greenlet. The :meth:`get` method must be called from a greenlet other than :class:`Hub`. >>> result = Waiter() >>> timer = get_hub().loop.timer(0.1) >>> timer.start(result.switch, 'hello from Waiter') >>> result.get() # blocks for 0.1 seconds 'hello from Waiter' If switch is called before the greenlet gets a chance to call :meth:`get` then :class:`Waiter` stores the value. >>> result = Waiter() >>> timer = get_hub().loop.timer(0.1) >>> timer.start(result.switch, 'hi from Waiter') >>> sleep(0.2) >>> result.get() # returns immediatelly without blocking 'hi from Waiter' .. warning:: This a limited and dangerous way to communicate between greenlets. It can easily leave a greenlet unscheduled forever if used incorrectly. Consider using safer classes such as :class:`gevent.event.Event`, :class:`gevent.event.AsyncResult`, or :class:`gevent.queue.Queue`. """ __slots__ = ['hub', 'greenlet', 'value', '_exception'] def __init__(self, hub=None): if hub is None: self.hub = get_hub() else: self.hub = hub self.greenlet = None self.value = None self._exception = _NONE def clear(self): self.greenlet = None self.value = None self._exception = _NONE def __str__(self): if self._exception is _NONE: return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet) elif self._exception is None: return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value) else: return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info) def ready(self): """Return true if and only if it holds a value or an exception""" return self._exception is not _NONE def successful(self): """Return true if and only if it is ready and holds a value""" return self._exception is None @property def exc_info(self): "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``." if self._exception is not _NONE: return self._exception def switch(self, value=None): """Switch to the greenlet if one's available. Otherwise store the value.""" greenlet = self.greenlet if greenlet is None: self.value = value self._exception = None else: assert getcurrent() is self.hub, "Can only use Waiter.switch method from the Hub greenlet" switch = greenlet.switch try: switch(value) except: self.hub.handle_error(switch, *sys.exc_info()) def switch_args(self, *args): return self.switch(args) def throw(self, *throw_args): """Switch to the greenlet with the exception. If there's no greenlet, store the exception.""" greenlet = self.greenlet if greenlet is None: self._exception = throw_args else: assert getcurrent() is self.hub, "Can only use Waiter.switch method from the Hub greenlet" throw = greenlet.throw try: throw(*throw_args) except: self.hub.handle_error(throw, *sys.exc_info()) def get(self): """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called.""" if self._exception is not _NONE: if self._exception is None: return self.value else: getcurrent().throw(*self._exception) else: if self.greenlet is not None: raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, )) self.greenlet = getcurrent() try: return self.hub.switch() finally: self.greenlet = None def __call__(self, source): if source.exception is None: self.switch(source.value) else: self.throw(source.exception) # can also have a debugging version, that wraps the value in a tuple (self, value) in switch() # and unwraps it in wait() thus checking that switch() was indeed called class _MultipleWaiter(Waiter): """ An internal extension of Waiter that can be used if multiple objects must be waited on, and there is a chance that in between waits greenlets might be switched out. All greenlets that switch to this waiter will have their value returned. This does not handle exceptions or throw methods. """ __slots__ = ['_values'] def __init__(self, *args, **kwargs): Waiter.__init__(self, *args, **kwargs) # we typically expect a relatively small number of these to be outstanding. # since we pop from the left, a deque might be slightly # more efficient, but since we're in the hub we avoid imports if # we can help it to better support monkey-patching, and delaying the import # here can be impractical (see https://github.com/gevent/gevent/issues/652) self._values = list() def switch(self, value): self._values.append(value) Waiter.switch(self, True) def get(self): if not self._values: Waiter.get(self) Waiter.clear(self) return self._values.pop(0) def iwait(objects, timeout=None, count=None): """ Iteratively yield *objects* as they are ready, until all (or *count*) are ready or *timeout* expired. :param objects: A sequence (supporting :func:`len`) containing objects implementing the wait protocol (rawlink() and unlink()). :keyword int count: If not `None`, then a number specifying the maximum number of objects to wait for. If ``None`` (the default), all objects are waited for. :keyword float timeout: If given, specifies a maximum number of seconds to wait. If the timeout expires before the desired waited-for objects are available, then this method returns immediately. .. seealso:: :func:`wait` .. versionchanged:: 1.1a1 Add the *count* parameter. .. versionchanged:: 1.1a2 No longer raise :exc:`LoopExit` if our caller switches greenlets in between items yielded by this function. """ # QQQ would be nice to support iterable here that can be generated slowly (why?) if objects is None: yield get_hub().join(timeout=timeout) return count = len(objects) if count is None else min(count, len(objects)) waiter = _MultipleWaiter() switch = waiter.switch if timeout is not None: timer = get_hub().loop.timer(timeout, priority=-1) timer.start(switch, _NONE) try: for obj in objects: obj.rawlink(switch) for _ in xrange(count): item = waiter.get() waiter.clear() if item is _NONE: return yield item finally: if timeout is not None: timer.stop() for obj in objects: unlink = getattr(obj, 'unlink', None) if unlink: try: unlink(switch) except: traceback.print_exc() def wait(objects=None, timeout=None, count=None): """ Wait for ``objects`` to become ready or for event loop to finish. If ``objects`` is provided, it must be a list containing objects implementing the wait protocol (rawlink() and unlink() methods): - :class:`gevent.Greenlet` instance - :class:`gevent.event.Event` instance - :class:`gevent.lock.Semaphore` instance - :class:`gevent.subprocess.Popen` instance If ``objects`` is ``None`` (the default), ``wait()`` blocks until the current event loop has nothing to do (or until ``timeout`` passes): - all greenlets have finished - all servers were stopped - all event loop watchers were stopped. If ``count`` is ``None`` (the default), wait for all ``objects`` to become ready. If ``count`` is a number, wait for (up to) ``count`` objects to become ready. (For example, if count is ``1`` then the function exits when any object in the list is ready). If ``timeout`` is provided, it specifies the maximum number of seconds ``wait()`` will block. Returns the list of ready objects, in the order in which they were ready. .. seealso:: :func:`iwait` """ if objects is None: return get_hub().join(timeout=timeout) return list(iwait(objects, timeout, count)) class linkproxy(object): __slots__ = ['callback', 'obj'] def __init__(self, callback, obj): self.callback = callback self.obj = obj def __call__(self, *args): callback = self.callback obj = self.obj self.callback = None self.obj = None callback(obj) gevent-1.1.0/gevent/libev.h0000644000076500000000000000155512666555342016307 0ustar jmaddenwheel00000000000000#if defined(LIBEV_EMBED) #include "ev.c" #else #include "ev.h" #ifndef _WIN32 #include #endif #endif #ifndef _WIN32 static struct sigaction libev_sigchld; static int sigchld_state = 0; static struct ev_loop* gevent_ev_default_loop(unsigned int flags) { struct ev_loop* result; struct sigaction tmp; if (sigchld_state) return ev_default_loop(flags); sigaction(SIGCHLD, NULL, &tmp); result = ev_default_loop(flags); // XXX what if SIGCHLD received there? sigaction(SIGCHLD, &tmp, &libev_sigchld); sigchld_state = 1; return result; } static void gevent_install_sigchld_handler(void) { if (sigchld_state == 1) { sigaction(SIGCHLD, &libev_sigchld, NULL); sigchld_state = 2; } } #else #define gevent_ev_default_loop ev_default_loop static void gevent_install_sigchld_handler(void) { } #endif gevent-1.1.0/gevent/libev.pxd0000644000076500000000000001134312666555342016647 0ustar jmaddenwheel00000000000000cdef extern from "libev_vfd.h": #ifdef _WIN32 #ifdef _WIN64 ctypedef long long vfd_socket_t #else ctypedef long vfd_socket_t #endif #else ctypedef int vfd_socket_t #endif long vfd_get(int) int vfd_open(long) except -1 void vfd_free(int) cdef extern from "libev.h": int EV_MINPRI int EV_MAXPRI int EV_VERSION_MAJOR int EV_VERSION_MINOR int EV_USE_FLOOR int EV_USE_CLOCK_SYSCALL int EV_USE_REALTIME int EV_USE_MONOTONIC int EV_USE_NANOSLEEP int EV_USE_SELECT int EV_USE_POLL int EV_USE_EPOLL int EV_USE_KQUEUE int EV_USE_PORT int EV_USE_INOTIFY int EV_USE_SIGNALFD int EV_USE_EVENTFD int EV_USE_4HEAP int EV_USE_IOCP int EV_SELECT_IS_WINSOCKET int EV_UNDEF int EV_NONE int EV_READ int EV_WRITE int EV__IOFDSET int EV_TIMER int EV_PERIODIC int EV_SIGNAL int EV_CHILD int EV_STAT int EV_IDLE int EV_PREPARE int EV_CHECK int EV_EMBED int EV_FORK int EV_CLEANUP int EV_ASYNC int EV_CUSTOM int EV_ERROR int EVFLAG_AUTO int EVFLAG_NOENV int EVFLAG_FORKCHECK int EVFLAG_NOINOTIFY int EVFLAG_SIGNALFD int EVFLAG_NOSIGMASK int EVBACKEND_SELECT int EVBACKEND_POLL int EVBACKEND_EPOLL int EVBACKEND_KQUEUE int EVBACKEND_DEVPOLL int EVBACKEND_PORT int EVBACKEND_IOCP int EVBACKEND_ALL int EVBACKEND_MASK int EVRUN_NOWAIT int EVRUN_ONCE int EVBREAK_CANCEL int EVBREAK_ONE int EVBREAK_ALL struct ev_loop: int activecnt int sig_pending int backend_fd int sigfd unsigned int origflags struct ev_io: int fd int events struct ev_timer: double at struct ev_signal: pass struct ev_idle: pass struct ev_prepare: pass struct ev_check: pass struct ev_fork: pass struct ev_async: pass struct ev_child: int pid int rpid int rstatus struct stat: int st_nlink struct ev_stat: stat attr stat prev double interval int ev_version_major() int ev_version_minor() unsigned int ev_supported_backends() unsigned int ev_recommended_backends() unsigned int ev_embeddable_backends() double ev_time() void ev_set_syserr_cb(void *) int ev_priority(void*) void ev_set_priority(void*, int) int ev_is_pending(void*) int ev_is_active(void*) void ev_io_init(ev_io*, void* callback, int fd, int events) void ev_io_start(ev_loop*, ev_io*) void ev_io_stop(ev_loop*, ev_io*) void ev_feed_event(ev_loop*, void*, int) void ev_timer_init(ev_timer*, void* callback, double, double) void ev_timer_start(ev_loop*, ev_timer*) void ev_timer_stop(ev_loop*, ev_timer*) void ev_timer_again(ev_loop*, ev_timer*) void ev_signal_init(ev_signal*, void* callback, int) void ev_signal_start(ev_loop*, ev_signal*) void ev_signal_stop(ev_loop*, ev_signal*) void ev_idle_init(ev_idle*, void* callback) void ev_idle_start(ev_loop*, ev_idle*) void ev_idle_stop(ev_loop*, ev_idle*) void ev_prepare_init(ev_prepare*, void* callback) void ev_prepare_start(ev_loop*, ev_prepare*) void ev_prepare_stop(ev_loop*, ev_prepare*) void ev_check_init(ev_check*, void* callback) void ev_check_start(ev_loop*, ev_check*) void ev_check_stop(ev_loop*, ev_check*) void ev_fork_init(ev_fork*, void* callback) void ev_fork_start(ev_loop*, ev_fork*) void ev_fork_stop(ev_loop*, ev_fork*) void ev_async_init(ev_async*, void* callback) void ev_async_start(ev_loop*, ev_async*) void ev_async_stop(ev_loop*, ev_async*) void ev_async_send(ev_loop*, ev_async*) int ev_async_pending(ev_async*) void ev_child_init(ev_child*, void* callback, int, int) void ev_child_start(ev_loop*, ev_child*) void ev_child_stop(ev_loop*, ev_child*) void ev_stat_init(ev_stat*, void* callback, char*, double) void ev_stat_start(ev_loop*, ev_stat*) void ev_stat_stop(ev_loop*, ev_stat*) ev_loop* ev_default_loop(unsigned int flags) ev_loop* ev_loop_new(unsigned int flags) void ev_loop_destroy(ev_loop*) void ev_loop_fork(ev_loop*) int ev_is_default_loop(ev_loop*) unsigned int ev_iteration(ev_loop*) unsigned int ev_depth(ev_loop*) unsigned int ev_backend(ev_loop*) void ev_verify(ev_loop*) void ev_run(ev_loop*, int flags) nogil double ev_now(ev_loop*) void ev_now_update(ev_loop*) void ev_ref(ev_loop*) void ev_unref(ev_loop*) void ev_break(ev_loop*, int) unsigned int ev_pending_count(ev_loop*) ev_loop* gevent_ev_default_loop(unsigned int flags) void gevent_install_sigchld_handler() gevent-1.1.0/gevent/libev_vfd.h0000644000076500000000000001274212666555342017146 0ustar jmaddenwheel00000000000000#ifdef _WIN32 #ifdef _WIN64 typedef PY_LONG_LONG vfd_socket_t; #define vfd_socket_object PyLong_FromLongLong #else typedef long vfd_socket_t; #define vfd_socket_object PyInt_FromLong #endif #ifdef LIBEV_EMBED /* * If libev on win32 is embedded, then we can use an * arbitrary mapping between integer fds and OS * handles. Then by defining special macros libev * will use our functions. */ #define WIN32_LEAN_AND_MEAN #include #include typedef struct vfd_entry_t { vfd_socket_t handle; /* OS handle, i.e. SOCKET */ int count; /* Reference count, 0 if free */ int next; /* Next free fd, -1 if last */ } vfd_entry; #define VFD_INCREMENT 128 static int vfd_num = 0; /* num allocated fds */ static int vfd_max = 0; /* max allocated fds */ static int vfd_next = -1; /* next free fd for reuse */ static PyObject* vfd_map = NULL; /* map OS handle -> virtual fd */ static vfd_entry* vfd_entries = NULL; /* list of virtual fd entries */ #ifdef WITH_THREAD static CRITICAL_SECTION* volatile vfd_lock = NULL; static CRITICAL_SECTION* vfd_make_lock() { if (vfd_lock == NULL) { /* must use malloc and not PyMem_Malloc here */ CRITICAL_SECTION* lock = malloc(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(lock); if (InterlockedCompareExchangePointer(&vfd_lock, lock, NULL) != NULL) { /* another thread initialized lock first */ DeleteCriticalSection(lock); free(lock); } } return vfd_lock; } #define VFD_LOCK_ENTER EnterCriticalSection(vfd_make_lock()) #define VFD_LOCK_LEAVE LeaveCriticalSection(vfd_lock) #define VFD_GIL_DECLARE PyGILState_STATE ___save #define VFD_GIL_ENSURE ___save = PyGILState_Ensure() #define VFD_GIL_RELEASE PyGILState_Release(___save) #else #define VFD_LOCK_ENTER #define VFD_LOCK_LEAVE #define VFD_GIL_DECLARE #define VFD_GIL_ENSURE #define VFD_GIL_RELEASE #endif /* * Given a virtual fd returns an OS handle or -1 * This function is speed critical, so it cannot use GIL */ static vfd_socket_t vfd_get(int fd) { int handle = -1; VFD_LOCK_ENTER; if (vfd_entries != NULL && fd >= 0 && fd < vfd_num) handle = vfd_entries[fd].handle; VFD_LOCK_LEAVE; return handle; } #define EV_FD_TO_WIN32_HANDLE(fd) vfd_get((fd)) /* * Given an OS handle finds or allocates a virtual fd * Returns -1 on failure and sets Python exception if pyexc is non-zero */ static int vfd_open_(vfd_socket_t handle, int pyexc) { VFD_GIL_DECLARE; int fd = -1; unsigned long arg; PyObject* key = NULL; PyObject* value; if (!pyexc) { VFD_GIL_ENSURE; } if (ioctlsocket(handle, FIONREAD, &arg) != 0) { if (pyexc) PyErr_Format(PyExc_IOError, #ifdef _WIN64 "%lld is not a socket (files are not supported)", #else "%ld is not a socket (files are not supported)", #endif handle); goto done; } if (vfd_map == NULL) { vfd_map = PyDict_New(); if (vfd_map == NULL) goto done; } key = vfd_socket_object(handle); /* check if it's already in the dict */ value = PyDict_GetItem(vfd_map, key); if (value != NULL) { /* is it safe to use PyInt_AS_LONG(value) here? */ fd = PyInt_AsLong(value); if (fd >= 0) { ++vfd_entries[fd].count; goto done; } } /* use the free entry, if available */ if (vfd_next >= 0) { fd = vfd_next; vfd_next = vfd_entries[fd].next; VFD_LOCK_ENTER; goto allocated; } /* check if it would be out of bounds */ if (vfd_num >= FD_SETSIZE) { /* libev's select doesn't support more that FD_SETSIZE fds */ if (pyexc) PyErr_Format(PyExc_IOError, "cannot watch more than %d sockets", (int)FD_SETSIZE); goto done; } /* allocate more space if needed */ VFD_LOCK_ENTER; if (vfd_num >= vfd_max) { int newsize = vfd_max + VFD_INCREMENT; vfd_entry* entries = PyMem_Realloc(vfd_entries, sizeof(vfd_entry) * newsize); if (entries == NULL) { VFD_LOCK_LEAVE; if (pyexc) PyErr_NoMemory(); goto done; } vfd_entries = entries; vfd_max = newsize; } fd = vfd_num++; allocated: /* vfd_lock must be acquired when entering here */ vfd_entries[fd].handle = handle; vfd_entries[fd].count = 1; VFD_LOCK_LEAVE; value = PyInt_FromLong(fd); PyDict_SetItem(vfd_map, key, value); Py_DECREF(value); done: Py_XDECREF(key); if (!pyexc) { VFD_GIL_RELEASE; } return fd; } #define vfd_open(fd) vfd_open_((fd), 1) #define EV_WIN32_HANDLE_TO_FD(handle) vfd_open_((handle), 0) static void vfd_free_(int fd, int needclose) { VFD_GIL_DECLARE; PyObject* key; if (needclose) { VFD_GIL_ENSURE; } if (fd < 0 || fd >= vfd_num) goto done; /* out of bounds */ if (vfd_entries[fd].count <= 0) goto done; /* free entry, ignore */ if (!--vfd_entries[fd].count) { /* fd has just been freed */ vfd_socket_t handle = vfd_entries[fd].handle; vfd_entries[fd].handle = -1; vfd_entries[fd].next = vfd_next; vfd_next = fd; if (needclose) closesocket(handle); /* vfd_map is assumed to be != NULL */ key = vfd_socket_object(handle); PyDict_DelItem(vfd_map, key); Py_DECREF(key); } done: if (needclose) { VFD_GIL_RELEASE; } } #define vfd_free(fd) vfd_free_((fd), 0) #define EV_WIN32_CLOSE_FD(fd) vfd_free_((fd), 1) #else /* * If libev on win32 is not embedded in gevent, then * the only way to map vfds is to use the default of * using runtime fds in libev. Note that it will leak * fds, because there's no way of closing them safely */ #define vfd_get(fd) _get_osfhandle((fd)) #define vfd_open(fd) _open_osfhandle((fd), 0) #define vfd_free(fd) #endif #else /* * On non-win32 platforms vfd_* are noop macros */ typedef int vfd_socket_t; #define vfd_get(fd) (fd) #define vfd_open(fd) ((int)(fd)) #define vfd_free(fd) #endif gevent-1.1.0/gevent/local.py0000644000076500000000000002110412666555342016471 0ustar jmaddenwheel00000000000000""" Greenlet-local objects. This module is based on `_threading_local.py`__ from the standard library of Python 3.4. __ https://github.com/python/cpython/blob/3.4/Lib/_threading_local.py Greenlet-local objects support the management of greenlet-local data. If you have data that you want to be local to a greenlet, simply create a greenlet-local object and use its attributes: >>> mydata = local() >>> mydata.number = 42 >>> mydata.number 42 You can also access the local-object's dictionary: >>> mydata.__dict__ {'number': 42} >>> mydata.__dict__.setdefault('widgets', []) [] >>> mydata.widgets [] What's important about greenlet-local objects is that their data are local to a greenlet. If we access the data in a different greenlet: >>> log = [] >>> def f(): ... items = list(mydata.__dict__.items()) ... items.sort() ... log.append(items) ... mydata.number = 11 ... log.append(mydata.number) >>> greenlet = gevent.spawn(f) >>> greenlet.join() >>> log [[], 11] we get different data. Furthermore, changes made in the other greenlet don't affect data seen in this greenlet: >>> mydata.number 42 Of course, values you get from a local object, including a __dict__ attribute, are for whatever greenlet was current at the time the attribute was read. For that reason, you generally don't want to save these values across greenlets, as they apply only to the greenlet they came from. You can create custom local objects by subclassing the local class: >>> class MyLocal(local): ... number = 2 ... initialized = False ... def __init__(self, **kw): ... if self.initialized: ... raise SystemError('__init__ called too many times') ... self.initialized = True ... self.__dict__.update(kw) ... def squared(self): ... return self.number ** 2 This can be useful to support default values, methods and initialization. Note that if you define an __init__ method, it will be called each time the local object is used in a separate greenlet. This is necessary to initialize each greenlet's dictionary. Now if we create a local object: >>> mydata = MyLocal(color='red') Now we have a default number: >>> mydata.number 2 an initial color: >>> mydata.color 'red' >>> del mydata.color And a method that operates on the data: >>> mydata.squared() 4 As before, we can access the data in a separate greenlet: >>> log = [] >>> greenlet = gevent.spawn(f) >>> greenlet.join() >>> log [[('color', 'red'), ('initialized', True)], 11] without affecting this greenlet's data: >>> mydata.number 2 >>> mydata.color Traceback (most recent call last): ... AttributeError: 'MyLocal' object has no attribute 'color' Note that subclasses can define slots, but they are not greenlet local. They are shared across greenlets:: >>> class MyLocal(local): ... __slots__ = 'number' >>> mydata = MyLocal() >>> mydata.number = 42 >>> mydata.color = 'red' So, the separate greenlet: >>> greenlet = gevent.spawn(f) >>> greenlet.join() affects what we see: >>> mydata.number 11 >>> del mydata .. versionchanged:: 1.1a2 Update the implementation to match Python 3.4 instead of Python 2.5. This results in locals being eligible for garbage collection as soon as their greenlet exits. """ from copy import copy from weakref import ref from contextlib import contextmanager from gevent.hub import getcurrent, PYPY from gevent.lock import RLock __all__ = ["local"] class _wrefdict(dict): """A dict that can be weak referenced""" class _localimpl(object): """A class managing thread-local dicts""" __slots__ = 'key', 'dicts', 'localargs', 'locallock', '__weakref__' def __init__(self): # The key used in the Thread objects' attribute dicts. # We keep it a string for speed but make it unlikely to clash with # a "real" attribute. self.key = '_threading_local._localimpl.' + str(id(self)) # { id(Thread) -> (ref(Thread), thread-local dict) } self.dicts = _wrefdict() def get_dict(self): """Return the dict for the current thread. Raises KeyError if none defined.""" thread = getcurrent() return self.dicts[id(thread)][1] def create_dict(self): """Create a new dict for the current thread, and return it.""" localdict = {} key = self.key thread = getcurrent() idt = id(thread) # If we are working with a gevent.greenlet.Greenlet, we can # pro-actively clear out with a link. Use rawlink to avoid # spawning any more greenlets try: rawlink = thread.rawlink except AttributeError: # Otherwise we need to do it with weak refs def local_deleted(_, key=key): # When the localimpl is deleted, remove the thread attribute. thread = wrthread() if thread is not None: del thread.__dict__[key] def thread_deleted(_, idt=idt): # When the thread is deleted, remove the local dict. # Note that this is suboptimal if the thread object gets # caught in a reference loop. We would like to be called # as soon as the OS-level thread ends instead. _local = wrlocal() if _local is not None: _local.dicts.pop(idt, None) wrlocal = ref(self, local_deleted) wrthread = ref(thread, thread_deleted) thread.__dict__[key] = wrlocal else: wrdicts = ref(self.dicts) def clear(_): dicts = wrdicts() if dicts: dicts.pop(idt, None) rawlink(clear) wrthread = None self.dicts[idt] = wrthread, localdict return localdict @contextmanager def _patch(self): impl = object.__getattribute__(self, '_local__impl') orig_dct = object.__getattribute__(self, '__dict__') try: dct = impl.get_dict() except KeyError: # it's OK to acquire the lock here and not earlier, because the above code won't switch out # however, subclassed __init__ might switch, so we do need to acquire the lock here dct = impl.create_dict() args, kw = impl.localargs with impl.locallock: self.__init__(*args, **kw) with impl.locallock: object.__setattr__(self, '__dict__', dct) yield object.__setattr__(self, '__dict__', orig_dct) class local(object): """ An object whose attributes are greenlet-local. """ __slots__ = '_local__impl', '__dict__' def __new__(cls, *args, **kw): if args or kw: if (PYPY and cls.__init__ == object.__init__) or (not PYPY and cls.__init__ is object.__init__): raise TypeError("Initialization arguments are not supported") self = object.__new__(cls) impl = _localimpl() impl.localargs = (args, kw) impl.locallock = RLock() object.__setattr__(self, '_local__impl', impl) # We need to create the thread dict in anticipation of # __init__ being called, to make sure we don't call it # again ourselves. impl.create_dict() return self def __getattribute__(self, name): with _patch(self): return object.__getattribute__(self, name) def __setattr__(self, name, value): if name == '__dict__': raise AttributeError( "%r object attribute '__dict__' is read-only" % self.__class__.__name__) with _patch(self): return object.__setattr__(self, name, value) def __delattr__(self, name): if name == '__dict__': raise AttributeError( "%r object attribute '__dict__' is read-only" % self.__class__.__name__) with _patch(self): return object.__delattr__(self, name) def __copy__(self): impl = object.__getattribute__(self, '_local__impl') current = getcurrent() currentId = id(current) d = impl.get_dict() duplicate = copy(d) cls = type(self) if (PYPY and cls.__init__ != object.__init__) or (not PYPY and cls.__init__ is not object.__init__): args, kw = impl.localargs instance = cls(*args, **kw) else: instance = cls() new_impl = object.__getattribute__(instance, '_local__impl') tpl = new_impl.dicts[currentId] new_impl.dicts[currentId] = (tpl[0], duplicate) return instance gevent-1.1.0/gevent/lock.py0000644000076500000000000001672612666555342016345 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. """Locking primitives""" from __future__ import absolute_import from gevent.hub import getcurrent, PYPY from gevent._semaphore import Semaphore, BoundedSemaphore __all__ = ['Semaphore', 'DummySemaphore', 'BoundedSemaphore', 'RLock'] # On PyPy, we don't compile the Semaphore class with Cython. Under # Cython, each individual method holds the GIL for its entire # duration, ensuring that no other thread can interrupt us in an # unsafe state (only when we _do_wait do we call back into Python and # allow switching threads). Simulate that here through the use of a manual # lock. (We use a separate lock for each semaphore to allow sys.settrace functions # to use locks *other* than the one being traced.) if PYPY: # TODO: Need to use monkey.get_original? from thread import allocate_lock as _allocate_lock from thread import get_ident as _get_ident _sem_lock = _allocate_lock() class _OwnedLock(object): def __init__(self): self._owner = None self._block = _allocate_lock() self._locking = {} self._count = 0 def untraceable(f): # Don't allow re-entry to these functions in a single thread, as can # happen if a sys.settrace is used def wrapper(self): me = _get_ident() try: count = self._locking[me] except KeyError: count = self._locking[me] = 1 else: count = self._locking[me] = count + 1 if count: return try: return f(self) finally: count = count - 1 if not count: del self._locking[me] else: self._locking[me] = count return wrapper @untraceable def acquire(self): me = _get_ident() if self._owner == me: self._count += 1 return self._owner = me self._block.acquire() self._count = 1 @untraceable def release(self): self._count = count = self._count - 1 if not count: self._block.release() self._owner = None # acquire, wait, and release all acquire the lock on entry and release it # on exit. acquire and wait can call _do_wait, which must release it on entry # and re-acquire it for them on exit. class _around(object): before = None after = None def __enter__(self): self.before() def __exit__(self, t, v, tb): self.after() def _decorate(func, cmname): # functools.wrap? def wrapped(self, *args, **kwargs): with getattr(self, cmname): return func(self, *args, **kwargs) return wrapped Semaphore._py3k_acquire = Semaphore.acquire = _decorate(Semaphore.acquire, '_lock_locked') Semaphore.release = _decorate(Semaphore.release, '_lock_locked') Semaphore.wait = _decorate(Semaphore.wait, '_lock_locked') Semaphore._do_wait = _decorate(Semaphore._do_wait, '_lock_unlocked') _Sem_init = Semaphore.__init__ def __init__(self, *args, **kwargs): l = self._lock_lock = _OwnedLock() self._lock_locked = _around() self._lock_locked.before = l.acquire self._lock_locked.after = l.release self._lock_unlocked = _around() self._lock_unlocked.before = l.release self._lock_unlocked.after = l.acquire _Sem_init(self, *args, **kwargs) Semaphore.__init__ = __init__ del _decorate class DummySemaphore(object): """ DummySemaphore(value=None) -> DummySemaphore A Semaphore initialized with "infinite" initial value. None of its methods ever block. This can be used to parameterize on whether or not to actually guard access to a potentially limited resource. If the resource is actually limited, such as a fixed-size thread pool, use a real :class:`Semaphore`, but if the resource is unbounded, use an instance of this class. In that way none of the supporting code needs to change. Similarly, it can be used to parameterize on whether or not to enforce mutual exclusion to some underlying object. If the underlying object is known to be thread-safe itself mutual exclusion is not needed and a ``DummySemaphore`` can be used, but if that's not true, use a real ``Semaphore``. """ # Internally this is used for exactly the purpose described in the # documentation. gevent.pool.Pool uses it instead of a Semaphore # when the pool size is unlimited, and # gevent.fileobject.FileObjectThread takes a parameter that # determines whether it should lock around IO to the underlying # file object. def __init__(self, value=None): """ .. versionchanged:: 1.1rc3 Accept and ignore a *value* argument for compatibility with Semaphore. """ pass def __str__(self): return '<%s>' % self.__class__.__name__ def locked(self): """A DummySemaphore is never locked so this always returns False.""" return False def release(self): """Releasing a dummy semaphore does nothing.""" pass def rawlink(self, callback): # XXX should still work and notify? pass def unlink(self, callback): pass def wait(self, timeout=None): """Waiting for a DummySemaphore returns immediately.""" pass def acquire(self, blocking=True, timeout=None): """ A DummySemaphore can always be acquired immediately so this always returns True and ignores its arguments. .. versionchanged:: 1.1a1 Always return *true*. """ return True def __enter__(self): pass def __exit__(self, typ, val, tb): pass class RLock(object): def __init__(self): self._block = Semaphore(1) self._owner = None self._count = 0 def __repr__(self): return "<%s at 0x%x _block=%s _count=%r _owner=%r)>" % ( self.__class__.__name__, id(self), self._block, self._count, self._owner) def acquire(self, blocking=1): me = getcurrent() if self._owner is me: self._count = self._count + 1 return 1 rc = self._block.acquire(blocking) if rc: self._owner = me self._count = 1 return rc def __enter__(self): return self.acquire() def release(self): if self._owner is not getcurrent(): raise RuntimeError("cannot release un-aquired lock") self._count = count = self._count - 1 if not count: self._owner = None self._block.release() def __exit__(self, typ, value, tb): self.release() # Internal methods used by condition variables def _acquire_restore(self, count_owner): count, owner = count_owner self._block.acquire() self._count = count self._owner = owner def _release_save(self): count = self._count self._count = 0 owner = self._owner self._owner = None self._block.release() return (count, owner) def _is_owned(self): return self._owner is getcurrent() gevent-1.1.0/gevent/monkey.py0000644000076500000000000005627412666555342016721 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. # pylint: disable=redefined-outer-name """ Make the standard library cooperative. Patching ======== The primary purpose of this module is to carefully patch, in place, portions of the standard library with gevent-friendly functions that behave in the same way as the original (at least as closely as possible). The primary interface to this is the :func:`patch_all` function, which performs all the available patches. It accepts arguments to limit the patching to certain modules, but most programs will want to use the default values as they receive the most wide-spread testing. Patching *should be done as early as possible* in the lifecycle of the program. For example, the main module (the one that tests against ``__main__`` or is otherwise the first imported) should begin with this code, ideally before any other imports:: from gevent import monkey monkey.patch_all() .. tip:: Some frameworks, such as gunicorn, handle monkey-patching for you. Check their documentation to be sure. Querying -------- Sometimes it is helpful to know if objects have been monkey-patched, and in advanced cases even to have access to the original standard library functions. This module provides functions for that purpose. - :func:`is_module_patched` - :func:`is_object_patched` - :func:`get_original` Use as a module =============== Sometimes it is useful to run existing python scripts or modules that were not built to be gevent aware under gevent. To do so, this module can be run as the main module, passing the script and its arguments. For details, see the :func:`main` function. Functions ========= """ from __future__ import absolute_import from __future__ import print_function import sys __all__ = [ 'patch_all', 'patch_builtins', 'patch_dns', 'patch_os', 'patch_select', 'patch_signal', 'patch_socket', 'patch_ssl', 'patch_subprocess', 'patch_sys', 'patch_thread', 'patch_time', # query functions 'get_original', 'is_module_patched', 'is_object_patched', # module functions 'main', ] if sys.version_info[0] >= 3: string_types = str, PY3 = True else: import __builtin__ string_types = __builtin__.basestring PY3 = False if sys.platform.startswith("win"): WIN = True else: WIN = False # maps module name -> {attribute name: original item} # e.g. "time" -> {"sleep": built-in function sleep} saved = {} def is_module_patched(modname): """Check if a module has been replaced with a cooperative version.""" return modname in saved def is_object_patched(modname, objname): """Check if an object in a module has been replaced with a cooperative version.""" return is_module_patched(modname) and objname in saved[modname] def _get_original(name, items): d = saved.get(name, {}) values = [] module = None for item in items: if item in d: values.append(d[item]) else: if module is None: module = __import__(name) values.append(getattr(module, item)) return values def get_original(mod_name, item_name): """Retrieve the original object from a module. If the object has not been patched, then that object will still be retrieved. :param item_name: A string or sequence of strings naming the attribute(s) on the module ``mod_name`` to return. :return: The original value if a string was given for ``item_name`` or a sequence of original values if a sequence was passed. """ if isinstance(item_name, string_types): return _get_original(mod_name, [item_name])[0] else: return _get_original(mod_name, item_name) def patch_item(module, attr, newitem): NONE = object() olditem = getattr(module, attr, NONE) if olditem is not NONE: saved.setdefault(module.__name__, {}).setdefault(attr, olditem) setattr(module, attr, newitem) def remove_item(module, attr): NONE = object() olditem = getattr(module, attr, NONE) if olditem is NONE: return saved.setdefault(module.__name__, {}).setdefault(attr, olditem) delattr(module, attr) def patch_module(name, items=None): gevent_module = getattr(__import__('gevent.' + name), name) module_name = getattr(gevent_module, '__target__', name) module = __import__(module_name) if items is None: items = getattr(gevent_module, '__implements__', None) if items is None: raise AttributeError('%r does not have __implements__' % gevent_module) for attr in items: patch_item(module, attr, getattr(gevent_module, attr)) return module def _queue_warning(message, _warnings): # Queues a warning to show after the monkey-patching process is all done. # Done this way to avoid extra imports during the process itself, just # in case. If we're calling a function one-off (unusual) go ahead and do it if _warnings is None: _process_warnings([message]) else: _warnings.append(message) def _process_warnings(_warnings): import warnings for warning in _warnings: warnings.warn(warning, RuntimeWarning, stacklevel=3) def _patch_sys_std(name): from gevent.fileobject import FileObjectThread orig = getattr(sys, name) if not isinstance(orig, FileObjectThread): patch_item(sys, name, FileObjectThread(orig)) def patch_sys(stdin=True, stdout=True, stderr=True): """Patch sys.std[in,out,err] to use a cooperative IO via a threadpool. This is relatively dangerous and can have unintended consequences such as hanging the process or `misinterpreting control keys`_ when ``input`` and ``raw_input`` are used. This method does nothing on Python 3. The Python 3 interpreter wants to flush the TextIOWrapper objects that make up stderr/stdout at shutdown time, but using a threadpool at that time leads to a hang. .. _`misinterpreting control keys`: https://github.com/gevent/gevent/issues/274 """ # test__issue6.py demonstrates the hang if these lines are removed; # strangely enough that test passes even without monkey-patching sys if PY3: return if stdin: _patch_sys_std('stdin') if stdout: _patch_sys_std('stdout') if stderr: _patch_sys_std('stderr') def patch_os(): """ Replace :func:`os.fork` with :func:`gevent.fork`, and, on POSIX, :func:`os.waitpid` with :func:`gevent.os.waitpid` (if the environment variable ``GEVENT_NOWAITPID`` is not defined). Does nothing if fork is not available. This method must be used with :func:`patch_signal` to have proper SIGCHLD handling. :func:`patch_all` calls both by default. """ patch_module('os') def patch_time(): """Replace :func:`time.sleep` with :func:`gevent.sleep`.""" from gevent.hub import sleep import time patch_item(time, 'sleep', sleep) def _patch_existing_locks(threading): if len(list(threading.enumerate())) != 1: return try: tid = threading.get_ident() except AttributeError: tid = threading._get_ident() rlock_type = type(threading.RLock()) try: import importlib._bootstrap except ImportError: class _ModuleLock(object): pass else: _ModuleLock = importlib._bootstrap._ModuleLock # It might be possible to walk up all the existing stack frames to find # locked objects...at least if they use `with`. To be sure, we look at every object # Since we're supposed to be done very early in the process, there shouldn't be # too many. # By definition there's only one thread running, so the various # owner attributes were the old (native) thread id. Make it our # current greenlet id so that when it wants to unlock and compare # self.__owner with _get_ident(), they match. gc = __import__('gc') for o in gc.get_objects(): if isinstance(o, rlock_type): if hasattr(o, '_owner'): # Py3 if o._owner is not None: o._owner = tid else: if o._RLock__owner is not None: o._RLock__owner = tid elif isinstance(o, _ModuleLock): if o.owner is not None: o.owner = tid def patch_thread(threading=True, _threading_local=True, Event=False, logging=True, existing_locks=True, _warnings=None): """ Replace the standard :mod:`thread` module to make it greenlet-based. - If *threading* is true (the default), also patch ``threading``. - If *_threading_local* is true (the default), also patch ``_threading_local.local``. - If *logging* is True (the default), also patch locks taken if the logging module has been configured. - If *existing_locks* is True (the default), and the process is still single threaded, make sure than any :class:`threading.RLock` (and, under Python 3, :class:`importlib._bootstrap._ModuleLock`) instances that are currently locked can be properly unlocked. .. caution:: Monkey-patching :mod:`thread` and using :class:`multiprocessing.Queue` or :class:`concurrent.futures.ProcessPoolExecutor` (which uses a ``Queue``) will hang the process. .. versionchanged:: 1.1b1 Add *logging* and *existing_locks* params. """ # Description of the hang: # There is an incompatibility with patching 'thread' and the 'multiprocessing' module: # The problem is that multiprocessing.queues.Queue uses a half-duplex multiprocessing.Pipe, # which is implemented with os.pipe() and _multiprocessing.Connection. os.pipe isn't patched # by gevent, as it returns just a fileno. _multiprocessing.Connection is an internal implementation # class implemented in C, which exposes a 'poll(timeout)' method; under the covers, this issues a # (blocking) select() call: hence the need for a real thread. Except for that method, we could # almost replace Connection with gevent.fileobject.SocketAdapter, plus a trivial # patch to os.pipe (below). Sigh, so close. (With a little work, we could replicate that method) # import os # import fcntl # os_pipe = os.pipe # def _pipe(): # r, w = os_pipe() # fcntl.fcntl(r, fcntl.F_SETFL, os.O_NONBLOCK) # fcntl.fcntl(w, fcntl.F_SETFL, os.O_NONBLOCK) # return r, w # os.pipe = _pipe # The 'threading' module copies some attributes from the # thread module the first time it is imported. If we patch 'thread' # before that happens, then we store the wrong values in 'saved', # So if we're going to patch threading, we either need to import it # before we patch thread, or manually clean up the attributes that # are in trouble. The latter is tricky because of the different names # on different versions. if threading: __import__('threading') patch_module('thread') if threading: threading = patch_module('threading') if Event: from gevent.event import Event patch_item(threading, 'Event', Event) if existing_locks: _patch_existing_locks(threading) if logging and 'logging' in sys.modules: logging = __import__('logging') patch_item(logging, '_lock', threading.RLock()) for wr in logging._handlerList: # In py26, these are actual handlers, not weakrefs handler = wr() if callable(wr) else wr if handler is None: continue if not hasattr(handler, 'lock'): raise TypeError("Unknown/unsupported handler %r" % handler) handler.lock = threading.RLock() if _threading_local: _threading_local = __import__('_threading_local') from gevent.local import local patch_item(_threading_local, 'local', local) if sys.version_info[:2] >= (3, 4): # Issue 18808 changes the nature of Thread.join() to use # locks. This means that a greenlet spawned in the main thread # (which is already running) cannot wait for the main thread---it # hangs forever. We patch around this if possible. See also # gevent.threading. threading = __import__('threading') greenlet = __import__('greenlet') if threading.current_thread() == threading.main_thread(): main_thread = threading.main_thread() _greenlet = main_thread._greenlet = greenlet.getcurrent() from gevent.hub import sleep def join(timeout=None): if threading.current_thread() is main_thread: raise RuntimeError("Cannot join current thread") if _greenlet.dead or not main_thread.is_alive(): return elif timeout: raise ValueError("Cannot use a timeout to join the main thread") # XXX: Make that work else: while main_thread.is_alive(): sleep(0.01) main_thread.join = join # Patch up the ident of the main thread to match. This # matters if threading was imported before monkey-patching # thread oldid = main_thread.ident main_thread._ident = threading.get_ident() if oldid in threading._active: threading._active[main_thread.ident] = threading._active[oldid] if oldid != main_thread.ident: del threading._active[oldid] else: _queue_warning("Monkey-patching not on the main thread; " "threading.main_thread().join() will hang from a greenlet", _warnings) def patch_socket(dns=True, aggressive=True): """Replace the standard socket object with gevent's cooperative sockets. If ``dns`` is true, also patch dns functions in :mod:`socket`. """ from gevent import socket # Note: although it seems like it's not strictly necessary to monkey patch 'create_connection', # it's better to do it. If 'create_connection' was not monkey patched, but the rest of socket module # was, create_connection would still use "green" getaddrinfo and "green" socket. # However, because gevent.socket.socket.connect is a Python function, the exception raised by it causes # _socket object to be referenced by the frame, thus causing the next invocation of bind(source_address) to fail. if dns: items = socket.__implements__ else: items = set(socket.__implements__) - set(socket.__dns__) patch_module('socket', items=items) if aggressive: if 'ssl' not in socket.__implements__: remove_item(socket, 'ssl') def patch_dns(): """Replace DNS functions in :mod:`socket` with cooperative versions. This is only useful if :func:`patch_socket` has been called and is done automatically by that method if requested. """ from gevent import socket patch_module('socket', items=socket.__dns__) def patch_ssl(): """Replace SSLSocket object and socket wrapping functions in :mod:`ssl` with cooperative versions. This is only useful if :func:`patch_socket` has been called. """ patch_module('ssl') def patch_select(aggressive=True): """ Replace :func:`select.select` with :func:`gevent.select.select` and :func:`select.poll` with :class:`gevent.select.poll` (where available). If ``aggressive`` is true (the default), also remove other blocking functions from :mod:`select` and (on Python 3.4 and above) :mod:`selectors`: - :func:`select.epoll` - :func:`select.kqueue` - :func:`select.kevent` - :func:`select.devpoll` (Python 3.5+) - :class:`selectors.EpollSelector` - :class:`selectors.KqueueSelector` - :class:`selectors.DevpollSelector` (Python 3.5+) """ patch_module('select') if aggressive: select = __import__('select') # since these are blocking we're removing them here. This makes some other # modules (e.g. asyncore) non-blocking, as they use select that we provide # when none of these are available. remove_item(select, 'epoll') remove_item(select, 'kqueue') remove_item(select, 'kevent') remove_item(select, 'devpoll') if sys.version_info[:2] >= (3, 4): # Python 3 wants to use `select.select` as a member function, # leading to this error in selectors.py (because gevent.select.select is # not a builtin and doesn't get the magic auto-static that they do) # r, w, _ = self._select(self._readers, self._writers, [], timeout) # TypeError: select() takes from 3 to 4 positional arguments but 5 were given select = __import__('select') selectors = __import__('selectors') if selectors.SelectSelector._select is select.select: def _select(self, *args, **kwargs): return select.select(*args, **kwargs) selectors.SelectSelector._select = _select if aggressive: # If `selectors` had already been imported before we removed # select.epoll|kqueue|devpoll, these may have been defined in terms # of those functions. They'll fail at runtime. remove_item(selectors, 'EpollSelector') remove_item(selectors, 'KqueueSelector') remove_item(selectors, 'DevpollSelector') selectors.DefaultSelector = selectors.SelectSelector def patch_subprocess(): """ Replace :func:`subprocess.call`, :func:`subprocess.check_call`, :func:`subprocess.check_output` and :class:`subprocess.Popen` with :mod:`cooperative versions `. .. note:: On Windows under Python 3, the API support may not completely match the standard library. """ patch_module('subprocess') def patch_builtins(): """ Make the builtin __import__ function `greenlet safe`_ under Python 2. .. note:: This does nothing under Python 3 as it is not necessary. Python 3 features improved import locks that are per-module, not global. .. _greenlet safe: https://github.com/gevent/gevent/issues/108 """ if sys.version_info[:2] < (3, 3): patch_module('builtins') def patch_signal(): """ Make the signal.signal function work with a monkey-patched os. This method must be used with :func:`patch_os` to have proper SIGCHLD handling. :func:`patch_all` calls both by default. .. seealso:: :mod:`gevent.signal` """ patch_module("signal") def _check_repatching(**module_settings): _warnings = [] key = '_gevent_saved_patch_all' if saved.get(key, module_settings) != module_settings: _queue_warning("Patching more than once will result in the union of all True" " parameters being patched", _warnings) first_time = key not in saved saved[key] = module_settings return _warnings, first_time def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False, subprocess=True, sys=False, aggressive=True, Event=False, builtins=True, signal=True): """ Do all of the default monkey patching (calls every other applicable function in this module). .. versionchanged:: 1.1 Issue a :mod:`warning ` if this function is called multiple times with different arguments. The second and subsequent calls will only add more patches, they can never remove existing patches by setting an argument to ``False``. .. versionchanged:: 1.1 Issue a :mod:`warning ` if this function is called with ``os=False`` and ``signal=True``. This will cause SIGCHLD handlers to not be called. This may be an error in the future. """ # Check to see if they're changing the patched list _warnings, first_time = _check_repatching(**locals()) if not _warnings and not first_time: # Nothing to do, identical args to what we just # did return # order is important if os: patch_os() if time: patch_time() if thread: patch_thread(Event=Event) # sys must be patched after thread. in other cases threading._shutdown will be # initiated to _MainThread with real thread ident if sys: patch_sys() if socket: patch_socket(dns=dns, aggressive=aggressive) if select: patch_select(aggressive=aggressive) if ssl: patch_ssl() if httplib: raise ValueError('gevent.httplib is no longer provided, httplib must be False') if subprocess: patch_subprocess() if builtins: patch_builtins() if signal: if not os: _queue_warning('Patching signal but not os will result in SIGCHLD handlers' ' installed after this not being called and os.waitpid may not' ' function correctly if gevent.subprocess is used. This may raise an' ' error in the future.', _warnings) patch_signal() _process_warnings(_warnings) def main(): args = {} argv = sys.argv[1:] verbose = False script_help, patch_all_args, modules = _get_script_help() while argv and argv[0].startswith('--'): option = argv[0][2:] if option == 'verbose': verbose = True elif option.startswith('no-') and option.replace('no-', '') in patch_all_args: args[option[3:]] = False elif option in patch_all_args: args[option] = True if option in modules: for module in modules: args.setdefault(module, False) else: sys.exit(script_help + '\n\n' + 'Cannot patch %r' % option) del argv[0] # TODO: break on -- if verbose: import pprint import os print('gevent.monkey.patch_all(%s)' % ', '.join('%s=%s' % item for item in args.items())) print('sys.version=%s' % (sys.version.strip().replace('\n', ' '), )) print('sys.path=%s' % pprint.pformat(sys.path)) print('sys.modules=%s' % pprint.pformat(sorted(sys.modules.keys()))) print('cwd=%s' % os.getcwd()) patch_all(**args) if argv: sys.argv = argv __package__ = None assert __package__ is None globals()['__file__'] = sys.argv[0] # issue #302 with open(sys.argv[0]) as f: exec(f.read()) else: print(script_help) def _get_script_help(): from inspect import getargspec patch_all_args = getargspec(patch_all)[0] modules = [x for x in patch_all_args if 'patch_' + x in globals()] script_help = """gevent.monkey - monkey patch the standard modules to use gevent. USAGE: python -m gevent.monkey [MONKEY OPTIONS] script [SCRIPT OPTIONS] If no OPTIONS present, monkey patches all the modules it can patch. You can exclude a module with --no-module, e.g. --no-thread. You can specify a module to patch with --module, e.g. --socket. In the latter case only the modules specified on the command line will be patched. MONKEY OPTIONS: --verbose %s""" % ', '.join('--[no-]%s' % m for m in modules) return script_help, patch_all_args, modules main.__doc__ = _get_script_help()[0] if __name__ == '__main__': main() gevent-1.1.0/gevent/os.py0000644000076500000000000003705112666555342016030 0ustar jmaddenwheel00000000000000""" Low-level operating system functions from :mod:`os`. Cooperative I/O =============== This module provides cooperative versions of :func:`os.read` and :func:`os.write`. These functions are *not* monkey-patched; you must explicitly call them or monkey patch them yourself. POSIX functions --------------- On POSIX, non-blocking IO is available. - :func:`nb_read` - :func:`nb_write` - :func:`make_nonblocking` All Platforms ------------- On non-POSIX platforms (e.g., Windows), non-blocking IO is not available. On those platforms (and on POSIX), cooperative IO can be done with the threadpool. - :func:`tp_read` - :func:`tp_write` Child Processes =============== The functions :func:`fork` and (on POSIX) :func:`forkpty` and :func:`waitpid` can be used to manage child processes. .. warning:: Forking a process that uses greenlets does not eliminate all non-running greenlets. Any that were scheduled in the hub of the forking thread in the parent remain scheduled in the child; compare this to how normal threads operate. (This behaviour may change is a subsequent major release.) """ from __future__ import absolute_import import os import sys from gevent.hub import get_hub, reinit, PY3 import errno EAGAIN = getattr(errno, 'EAGAIN', 11) try: import fcntl except ImportError: fcntl = None __implements__ = ['fork'] __extensions__ = ['tp_read', 'tp_write'] _read = os.read _write = os.write ignored_errors = [EAGAIN, errno.EINTR] if fcntl: __extensions__ += ['make_nonblocking', 'nb_read', 'nb_write'] def make_nonblocking(fd): """Put the file descriptor *fd* into non-blocking mode if possible. :return: A boolean value that evaluates to True if successful.""" flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) if not bool(flags & os.O_NONBLOCK): fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) return True def nb_read(fd, n): """Read up to `n` bytes from file descriptor `fd`. Return a string containing the bytes read. If end-of-file is reached, an empty string is returned. The descriptor must be in non-blocking mode. """ hub, event = None, None while True: try: return _read(fd, n) except OSError as e: if e.errno not in ignored_errors: raise if not PY3: sys.exc_clear() if hub is None: hub = get_hub() event = hub.loop.io(fd, 1) hub.wait(event) def nb_write(fd, buf): """Write bytes from buffer `buf` to file descriptor `fd`. Return the number of bytes written. The file descriptor must be in non-blocking mode. """ hub, event = None, None while True: try: return _write(fd, buf) except OSError as e: if e.errno not in ignored_errors: raise if not PY3: sys.exc_clear() if hub is None: hub = get_hub() event = hub.loop.io(fd, 2) hub.wait(event) def tp_read(fd, n): """Read up to *n* bytes from file descriptor *fd*. Return a string containing the bytes read. If end-of-file is reached, an empty string is returned. Reading is done using the threadpool. """ return get_hub().threadpool.apply(_read, (fd, n)) def tp_write(fd, buf): """Write bytes from buffer *buf* to file descriptor *fd*. Return the number of bytes written. Writing is done using the threadpool. """ return get_hub().threadpool.apply(_write, (fd, buf)) if hasattr(os, 'fork'): _raw_fork = os.fork def fork_gevent(): """ Forks the process using :func:`os.fork` and prepares the child process to continue using gevent before returning. .. note:: The PID returned by this function may not be waitable with either the original :func:`os.waitpid` or this module's :func:`waitpid` and it may not generate SIGCHLD signals if libev child watchers are or ever have been in use. For example, the :mod:`gevent.subprocess` module uses libev child watchers (which parts of gevent use libev child watchers is subject to change at any time). Most applications should use :func:`fork_and_watch`, which is monkey-patched as the default replacement for :func:`os.fork` and implements the ``fork`` function of this module by default, unless the environment variable ``GEVENT_NOWAITPID`` is defined before this module is imported. .. versionadded:: 1.1b2 """ result = _raw_fork() if not result: reinit() return result def fork(): """ A wrapper for :func:`fork_gevent` for non-POSIX platforms. """ return fork_gevent() if hasattr(os, 'forkpty'): _raw_forkpty = os.forkpty def forkpty_gevent(): """ Forks the process using :func:`os.forkpty` and prepares the child process to continue using gevent before returning. Returns a tuple (pid, master_fd). The `master_fd` is *not* put into non-blocking mode. Availability: Some Unix systems. .. seealso:: This function has the same limitations as :func:`fork_gevent`. .. versionadded:: 1.1b5 """ pid, master_fd = _raw_forkpty() if not pid: reinit() return pid, master_fd forkpty = forkpty_gevent __implements__.append('forkpty') __extensions__.append("forkpty_gevent") if hasattr(os, 'WNOWAIT') or hasattr(os, 'WNOHANG'): # We can only do this on POSIX import time _waitpid = os.waitpid _WNOHANG = os.WNOHANG # replaced by the signal module. _on_child_hook = lambda: None # {pid -> watcher or tuple(pid, rstatus, timestamp)} _watched_children = {} def _on_child(watcher, callback): # XXX: Could handle tracing here by not stopping # until the pid is terminated watcher.stop() _watched_children[watcher.pid] = (watcher.pid, watcher.rstatus, time.time()) if callback: callback(watcher) # dispatch an "event"; used by gevent.signal.signal _on_child_hook() # now is as good a time as any to reap children _reap_children() def _reap_children(timeout=60): # Remove all the dead children that haven't been waited on # for the *timeout* seconds. # Some platforms queue delivery of SIGCHLD for all children that die; # in that case, a well-behaved application should call waitpid() for each # signal. # Some platforms (linux) only guarantee one delivery if multiple children # die. On that platform, the well-behave application calls waitpid() in a loop # until it gets back -1, indicating no more dead children need to be waited for. # In either case, waitpid should be called the same number of times as dead children, # thus removing all the watchers when a SIGCHLD arrives. The (generous) timeout # is to work with applications that neglect to call waitpid and prevent "unlimited" # growth. # Note that we don't watch for the case of pid wraparound. That is, we fork a new # child with the same pid as an existing watcher, but the child is already dead, # just not waited on yet. now = time.time() oldest_allowed = now - timeout dead = [pid for pid, val in _watched_children.items() if isinstance(val, tuple) and val[2] < oldest_allowed] for pid in dead: del _watched_children[pid] def waitpid(pid, options): """ Wait for a child process to finish. If the child process was spawned using :func:`fork_and_watch`, then this function behaves cooperatively. If not, it *may* have race conditions; see :func:`fork_gevent` for more information. The arguments are as for the underlying :func:`os.waitpid`. Some combinations of *options* may not be supported (as of 1.1 that includes WUNTRACED). Availability: POSIX. .. versionadded:: 1.1b1 """ # XXX Does not handle tracing children if pid <= 0: # magic functions for multiple children. if pid == -1: # Any child. If we have one that we're watching and that finished, # we need to use that one. Otherwise, let the OS take care of it. for k, v in _watched_children.items(): if isinstance(v, tuple): pid = k break if pid <= 0: # If we didn't find anything, go to the OS. Otherwise, # handle waiting return _waitpid(pid, options) if pid in _watched_children: # yes, we're watching it if options & _WNOHANG or isinstance(_watched_children[pid], tuple): # We're either asked not to block, or it already finished, in which # case blocking doesn't matter result = _watched_children[pid] if isinstance(result, tuple): # it finished. libev child watchers # are one-shot del _watched_children[pid] return result[:2] # it's not finished return (0, 0) else: # we should block. Let the underlying OS call block; it should # eventually die with OSError, depending on signal delivery try: return _waitpid(pid, options) except OSError: if pid in _watched_children and isinstance(_watched_children, tuple): result = _watched_children[pid] del _watched_children[pid] return result[:2] raise # we're not watching it return _waitpid(pid, options) def fork_and_watch(callback=None, loop=None, ref=False, fork=fork_gevent): """ Fork a child process and start a child watcher for it in the parent process. This call cooperates with :func:`waitpid` to enable cooperatively waiting for children to finish. When monkey-patching, these functions are patched in as :func:`os.fork` and :func:`os.waitpid`, respectively. In the child process, this function calls :func:`gevent.hub.reinit` before returning. Availability: POSIX. :keyword callback: If given, a callable that will be called with the child watcher when the child finishes. :keyword loop: The loop to start the watcher in. Defaults to the loop of the current hub. :keyword fork: The fork function. Defaults to :func:`the one defined in this module ` (which automatically calls :func:`gevent.hub.reinit`). Pass the builtin :func:`os.fork` function if you do not need to initialize gevent in the child process. .. versionadded:: 1.1b1 .. seealso:: :func:`gevent.monkey.get_original` To access the builtin :func:`os.fork`. """ pid = fork() if pid: # parent loop = loop or get_hub().loop watcher = loop.child(pid) _watched_children[pid] = watcher watcher.start(_on_child, watcher, callback) return pid __extensions__.append('fork_and_watch') __extensions__.append('fork_gevent') if 'forkpty' in __implements__: def forkpty_and_watch(callback=None, loop=None, ref=False, forkpty=forkpty_gevent): """ Like :func:`fork_and_watch`, except using :func:`forkpty_gevent`. Availability: Some Unix systems. .. versionadded:: 1.1b5 """ result = [] def _fork(): pid_and_fd = forkpty() result.append(pid_and_fd) return pid_and_fd[0] fork_and_watch(callback, loop, ref, _fork) return result[0] __extensions__.append('forkpty_and_watch') # Watch children by default if not os.getenv('GEVENT_NOWAITPID'): # Broken out into separate functions instead of simple name aliases # for documentation purposes. def fork(*args, **kwargs): """ Forks a child process and starts a child watcher for it in the parent process so that ``waitpid`` and SIGCHLD work as expected. This implementation of ``fork`` is a wrapper for :func:`fork_and_watch` when the environment variable ``GEVENT_NOWAITPID`` is *not* defined. This is the default and should be used by most applications. .. versionchanged:: 1.1b2 """ # take any args to match fork_and_watch return fork_and_watch(*args, **kwargs) if 'forkpty' in __implements__: def forkpty(*args, **kwargs): """ Like :func:`fork`, but using :func:`forkpty_gevent`. This implementation of ``forkpty`` is a wrapper for :func:`forkpty_and_watch` when the environment variable ``GEVENT_NOWAITPID`` is *not* defined. This is the default and should be used by most applications. .. versionadded:: 1.1b5 """ # take any args to match fork_and_watch return forkpty_and_watch(*args, **kwargs) __implements__.append("waitpid") else: def fork(): """ Forks a child process, initializes gevent in the child, but *does not* prepare the parent to wait for the child or receive SIGCHLD. This implementation of ``fork`` is a wrapper for :func:`fork_gevent` when the environment variable ``GEVENT_NOWAITPID`` *is* defined. This is not recommended for most applications. """ return fork_gevent() if 'forkpty' in __implements__: def forkpty(): """ Like :func:`fork`, but using :func:`os.forkpty` This implementation of ``forkpty`` is a wrapper for :func:`forkpty_gevent` when the environment variable ``GEVENT_NOWAITPID`` *is* defined. This is not recommended for most applications. .. versionadded:: 1.1b5 """ return forkpty_gevent() __extensions__.append("waitpid") else: __implements__.remove('fork') __all__ = __implements__ + __extensions__ gevent-1.1.0/gevent/pool.py0000644000076500000000000006371012666555342016361 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details. """ Managing greenlets in a group. The :class:`Group` class in this module abstracts a group of running greenlets. When a greenlet dies, it's automatically removed from the group. All running greenlets in a group can be waited on with :meth:`Group.join`, or all running greenlets can be killed with :meth:`Group.kill`. The :class:`Pool` class, which is a subclass of :class:`Group`, provides a way to limit concurrency: its :meth:`spawn ` method blocks if the number of greenlets in the pool has already reached the limit, until there is a free slot. """ from bisect import insort_right try: from itertools import izip except ImportError: # Python 3 izip = zip from gevent.hub import GreenletExit, getcurrent, kill as _kill from gevent.greenlet import joinall, Greenlet from gevent.timeout import Timeout from gevent.event import Event from gevent.lock import Semaphore, DummySemaphore __all__ = ['Group', 'Pool'] class IMapUnordered(Greenlet): """ At iterator of map results. """ _zipped = False def __init__(self, func, iterable, spawn=None, maxsize=None, _zipped=False): """ An iterator that. :keyword int maxsize: If given and not-None, specifies the maximum number of finished results that will be allowed to accumulated awaiting the reader; more than that number of results will cause map function greenlets to begin to block. This is most useful is there is a great disparity in the speed of the mapping code and the consumer and the results consume a great deal of resources. Using a bound is more computationally expensive than not using a bound. .. versionchanged:: 1.1b3 Added the *maxsize* parameter. """ from gevent.queue import Queue Greenlet.__init__(self) if spawn is not None: self.spawn = spawn if _zipped: self._zipped = _zipped self.func = func self.iterable = iterable self.queue = Queue() if maxsize: # Bounding the queue is not enough if we want to keep from # accumulating objects; the result value will be around as # the greenlet's result, blocked on self.queue.put(), and # we'll go on to spawn another greenlet, which in turn can # create the result. So we need a semaphore to prevent a # greenlet from exiting while the queue is full so that we # don't spawn the next greenlet (assuming that self.spawn # is of course bounded). (Alternatively we could have the # greenlet itself do the insert into the pool, but that # takes some rework). # # Given the use of a semaphore at this level, sizing the queue becomes # redundant, and that lets us avoid having to use self.link() instead # of self.rawlink() to avoid having blocking methods called in the # hub greenlet. self._result_semaphore = Semaphore(maxsize) else: self._result_semaphore = DummySemaphore() self.count = 0 self.finished = False # If the queue size is unbounded, then we want to call all # the links (_on_finish and _on_result) directly in the hub greenlet # for efficiency. However, if the queue is bounded, we can't do that if # the queue might block (because if there's no waiter the hub can switch to, # the queue simply raises Full). Therefore, in that case, we use # the safer, somewhat-slower (because it spawns a greenlet) link() methods. # This means that _on_finish and _on_result can be called and interleaved in any order # if the call to self.queue.put() blocks.. # Note that right now we're not bounding the queue, instead using a semaphore. self.rawlink(self._on_finish) def __iter__(self): return self def next(self): self._result_semaphore.release() value = self._inext() if isinstance(value, Failure): raise value.exc return value __next__ = next def _inext(self): return self.queue.get() def _ispawn(self, func, item): self._result_semaphore.acquire() self.count += 1 g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item) g.rawlink(self._on_result) return g def _run(self): try: func = self.func for item in self.iterable: self._ispawn(func, item) finally: self.__dict__.pop('spawn', None) self.__dict__.pop('func', None) self.__dict__.pop('iterable', None) def _on_result(self, greenlet): # This method can either be called in the hub greenlet (if the # queue is unbounded) or its own greenlet. If it's called in # its own greenlet, the calls to put() may block and switch # greenlets, which in turn could mutate our state. So any # state on this object that we need to look at, notably # self.count, we need to capture or mutate *before* we put. # (Note that right now we're not bounding the queue, but we may # choose to do so in the future so this implementation will be left in case.) self.count -= 1 count = self.count finished = self.finished ready = self.ready() put_finished = False if ready and count <= 0 and not finished: finished = self.finished = True put_finished = True if greenlet.successful(): self.queue.put(self._iqueue_value_for_success(greenlet)) else: self.queue.put(self._iqueue_value_for_failure(greenlet)) if put_finished: self.queue.put(self._iqueue_value_for_finished()) def _on_finish(self, _self): if self.finished: return if not self.successful(): self.finished = True self.queue.put(self._iqueue_value_for_self_failure()) return if self.count <= 0: self.finished = True self.queue.put(self._iqueue_value_for_finished()) def _iqueue_value_for_success(self, greenlet): return greenlet.value def _iqueue_value_for_failure(self, greenlet): return Failure(greenlet.exception, getattr(greenlet, '_raise_exception')) def _iqueue_value_for_finished(self): return Failure(StopIteration) def _iqueue_value_for_self_failure(self): return Failure(self.exception, self._raise_exception) class IMap(IMapUnordered): # A specialization of IMapUnordered that returns items # in the order in which they were generated, not # the order in which they finish. # We do this by storing tuples (order, value) in the queue # not just value. def __init__(self, *args, **kwargs): self.waiting = [] # QQQ maybe deque will work faster there? self.index = 0 self.maxindex = -1 IMapUnordered.__init__(self, *args, **kwargs) def _inext(self): while True: if self.waiting and self.waiting[0][0] <= self.index: _, value = self.waiting.pop(0) else: index, value = self.queue.get() if index > self.index: insort_right(self.waiting, (index, value)) continue self.index += 1 return value def _ispawn(self, func, item): g = IMapUnordered._ispawn(self, func, item) self.maxindex += 1 g.index = self.maxindex return g def _iqueue_value_for_success(self, greenlet): return (greenlet.index, IMapUnordered._iqueue_value_for_success(self, greenlet)) def _iqueue_value_for_failure(self, greenlet): return (greenlet.index, IMapUnordered._iqueue_value_for_failure(self, greenlet)) def _iqueue_value_for_finished(self): self.maxindex += 1 return (self.maxindex, IMapUnordered._iqueue_value_for_finished(self)) def _iqueue_value_for_self_failure(self): self.maxindex += 1 return (self.maxindex, IMapUnordered._iqueue_value_for_self_failure(self)) class GroupMappingMixin(object): # Internal, non-public API class. # Provides mixin methods for implementing mapping pools. Subclasses must define: # - self.spawn(func, *args, **kwargs): a function that runs `func` with `args` # and `awargs`, potentially asynchronously. Return a value with a `get` method that # blocks until the results of func are available, and a `link` method. # - self._apply_immediately(): should the function passed to apply be called immediately, # synchronously? # - self._apply_async_use_greenlet(): Should apply_async directly call # Greenlet.spawn(), bypassing self.spawn? Return true when self.spawn would block # - self._apply_async_cb_spawn(callback, result): Run the given callback function, possiblly # asynchronously, possibly synchronously. def apply_cb(self, func, args=None, kwds=None, callback=None): """ :meth:`apply` the given *func*, and, if a *callback* is given, run it with the results of *func* (unless an exception was raised.) The *callback* may be called synchronously or asynchronously. If called asynchronously, it will not be tracked by this group. (:class:`Group` and :class:`Pool` call it asynchronously in a new greenlet; :class:`~gevent.threadpool.ThreadPool` calls it synchronously in the current greenlet.) """ result = self.apply(func, args, kwds) if callback is not None: self._apply_async_cb_spawn(callback, result) return result def apply_async(self, func, args=None, kwds=None, callback=None): """ A variant of the apply() method which returns a Greenlet object. If *callback* is specified, then it should be a callable which accepts a single argument. When the result becomes ready callback is applied to it (unless the call failed). """ if args is None: args = () if kwds is None: kwds = {} if self._apply_async_use_greenlet(): # cannot call spawn() directly because it will block return Greenlet.spawn(self.apply_cb, func, args, kwds, callback) greenlet = self.spawn(func, *args, **kwds) if callback is not None: greenlet.link(pass_value(callback)) return greenlet def apply(self, func, args=None, kwds=None): """ Rough quivalent of the :func:`apply()` builtin function blocking until the result is ready and returning it. The ``func`` will *usually*, but not *always*, be run in a way that allows the current greenlet to switch out (for example, in a new greenlet or thread, depending on implementation). But if the current greenlet or thread is already one that was spawned by this pool, the pool may choose to immediately run the `func` synchronously. Any exception ``func`` raises will be propagated to the caller of ``apply`` (that is, this method will raise the exception that ``func`` raised). """ if args is None: args = () if kwds is None: kwds = {} if self._apply_immediately(): return func(*args, **kwds) else: return self.spawn(func, *args, **kwds).get() def map(self, func, iterable): """Return a list made by applying the *func* to each element of the iterable. .. seealso:: :meth:`imap` """ return list(self.imap(func, iterable)) def map_cb(self, func, iterable, callback=None): result = self.map(func, iterable) if callback is not None: callback(result) return result def map_async(self, func, iterable, callback=None): """ A variant of the map() method which returns a Greenlet object that is executing the map function. If callback is specified then it should be a callable which accepts a single argument. """ return Greenlet.spawn(self.map_cb, func, iterable, callback) def __imap(self, cls, func, *iterables, **kwargs): # Python 2 doesn't support the syntax that lets us mix varargs and # a named kwarg, so we have to unpack manually maxsize = kwargs.pop('maxsize', None) if kwargs: raise TypeError("Unsupported keyword arguments") return cls.spawn(func, izip(*iterables), spawn=self.spawn, _zipped=True, maxsize=maxsize) def imap(self, func, *iterables, **kwargs): """ imap(func, *iterables, maxsize=None) -> iterable An equivalent of :func:`itertools.imap`, operating in parallel. The *func* is applied to each element yielded from each iterable in *iterables* in turn, collecting the result. If this object has a bound on the number of active greenlets it can contain (such as :class:`Pool`), then at most that number of tasks will operate in parallel. :keyword int maxsize: If given and not-None, specifies the maximum number of finished results that will be allowed to accumulate awaiting the reader; more than that number of results will cause map function greenlets to begin to block. This is most useful is there is a great disparity in the speed of the mapping code and the consumer and the results consume a great deal of resources. .. note:: This is separate from any bound on the number of active parallel tasks, though they may have some interaction (for example, limiting the number of parallel tasks to the smallest bound). .. note:: Using a bound is slightly more computationally expensive than not using a bound. .. tip:: The :meth:`imap_unordered` method makes much better use of this parameter. Some additional, unspecified, number of objects may be required to be kept in memory to maintain order by this function. :return: An iterable object. .. versionchanged:: 1.1b3 Added the *maxsize* keyword parameter. .. versionchanged:: 1.1a1 Accept multiple *iterables* to iterate in parallel. """ return self.__imap(IMap, func, *iterables, **kwargs) def imap_unordered(self, func, *iterables, **kwargs): """ imap_unordered(func, *iterables, maxsize=None) -> iterable The same as :meth:`imap` except that the ordering of the results from the returned iterator should be considered in arbitrary order. This is lighter weight than :meth:`imap` and should be preferred if order doesn't matter. .. seealso:: :meth:`imap` for more details. """ return self.__imap(IMapUnordered, func, *iterables, **kwargs) class Group(GroupMappingMixin): """ Maintain a group of greenlets that are still running, without limiting their number. Links to each item and removes it upon notification. Groups can be iterated to discover what greenlets they are tracking, they can be tested to see if they contain a greenlet, and they know the number (len) of greenlets they are tracking. If they are not tracking any greenlets, they are False in a boolean context. """ #: The type of Greenlet object we will :meth:`spawn`. This can be changed #: on an instance or in a subclass. greenlet_class = Greenlet def __init__(self, *args): assert len(args) <= 1, args self.greenlets = set(*args) if args: for greenlet in args[0]: greenlet.rawlink(self._discard) # each item we kill we place in dying, to avoid killing the same greenlet twice self.dying = set() self._empty_event = Event() self._empty_event.set() def __repr__(self): return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self.greenlets) def __len__(self): """ Answer how many greenlets we are tracking. Note that if we are empty, we are False in a boolean context. """ return len(self.greenlets) def __contains__(self, item): """ Answer if we are tracking the given greenlet. """ return item in self.greenlets def __iter__(self): """ Iterate across all the greenlets we are tracking, in no particular order. """ return iter(self.greenlets) def add(self, greenlet): """ Begin tracking the greenlet. If this group is :meth:`full`, then this method may block until it is possible to track the greenlet. """ try: rawlink = greenlet.rawlink except AttributeError: pass # non-Greenlet greenlet, like MAIN else: rawlink(self._discard) self.greenlets.add(greenlet) self._empty_event.clear() def _discard(self, greenlet): self.greenlets.discard(greenlet) self.dying.discard(greenlet) if not self.greenlets: self._empty_event.set() def discard(self, greenlet): """ Stop tracking the greenlet. """ self._discard(greenlet) try: unlink = greenlet.unlink except AttributeError: pass # non-Greenlet greenlet, like MAIN else: unlink(self._discard) def start(self, greenlet): """ Start the un-started *greenlet* and add it to the collection of greenlets this group is monitoring. """ self.add(greenlet) greenlet.start() def spawn(self, *args, **kwargs): """ Begin a new greenlet with the given arguments (which are passed to the greenlet constructor) and add it to the collection of greenlets this group is monitoring. :return: The newly started greenlet. """ greenlet = self.greenlet_class(*args, **kwargs) self.start(greenlet) return greenlet # def close(self): # """Prevents any more tasks from being submitted to the pool""" # self.add = RaiseException("This %s has been closed" % self.__class__.__name__) def join(self, timeout=None, raise_error=False): """ Wait for this group to become empty *at least once*. If there are no greenlets in the group, returns immediately. .. note:: By the time the waiting code (the caller of this method) regains control, a greenlet may have been added to this group, and so this object may no longer be empty. (That is, ``group.join(); assert len(group) == 0`` is not guaranteed to hold.) This method only guarantees that the group reached a ``len`` of 0 at some point. :keyword bool raise_error: If True (*not* the default), if any greenlet that finished while the join was in progress raised an exception, that exception will be raised to the caller of this method. If multiple greenlets raised exceptions, which one gets re-raised is not determined. Only greenlets currently in the group when this method is called are guaranteed to be checked for exceptions. """ if raise_error: greenlets = self.greenlets.copy() self._empty_event.wait(timeout=timeout) for greenlet in greenlets: if greenlet.exception is not None: if hasattr(greenlet, '_raise_exception'): greenlet._raise_exception() raise greenlet.exception else: self._empty_event.wait(timeout=timeout) def kill(self, exception=GreenletExit, block=True, timeout=None): """ Kill all greenlets being tracked by this group. """ timer = Timeout._start_new_or_dummy(timeout) try: try: while self.greenlets: for greenlet in list(self.greenlets): if greenlet not in self.dying: try: kill = greenlet.kill except AttributeError: _kill(greenlet, exception) else: kill(exception, block=False) self.dying.add(greenlet) if not block: break joinall(self.greenlets) except Timeout as ex: if ex is not timer: raise finally: timer.cancel() def killone(self, greenlet, exception=GreenletExit, block=True, timeout=None): """ If the given *greenlet* is running and being tracked by this group, kill it. """ if greenlet not in self.dying and greenlet in self.greenlets: greenlet.kill(exception, block=False) self.dying.add(greenlet) if block: greenlet.join(timeout) def full(self): """ Return a value indicating whether this group can track more greenlets. In this implementation, because there are no limits on the number of tracked greenlets, this will always return a ``False`` value. """ return False def wait_available(self, timeout=None): """ Block until it is possible to :meth:`spawn` a new greenlet. In this implementation, because there are no limits on the number of tracked greenlets, this will always return immediately. """ pass # MappingMixin methods def _apply_immediately(self): # If apply() is called from one of our own # worker greenlets, don't spawn a new one return getcurrent() in self def _apply_async_cb_spawn(self, callback, result): Greenlet.spawn(callback, result) def _apply_async_use_greenlet(self): return self.full() # cannot call self.spawn() because it will block class Failure(object): __slots__ = ['exc', '_raise_exception'] def __init__(self, exc, raise_exception=None): self.exc = exc self._raise_exception = raise_exception def raise_exc(self): if self._raise_exception: self._raise_exception() else: raise self.exc class Pool(Group): def __init__(self, size=None, greenlet_class=None): """ Create a new pool. A pool is like a group, but the maximum number of members is governed by the *size* parameter. :keyword int size: If given, this non-negative integer is the maximum count of active greenlets that will be allowed in this pool. A few values have special significance: * ``None`` (the default) places no limit on the number of greenlets. This is useful when you need to track, but not limit, greenlets, as with :class:`gevent.pywsgi.WSGIServer`. A :class:`Group` may be a more efficient way to achieve the same effect. * ``0`` creates a pool that can never have any active greenlets. Attempting to spawn in this pool will block forever. This is only useful if an application uses :meth:`wait_available` with a timeout and checks :meth:`free_count` before attempting to spawn. """ if size is not None and size < 0: raise ValueError('size must not be negative: %r' % (size, )) Group.__init__(self) self.size = size if greenlet_class is not None: self.greenlet_class = greenlet_class if size is None: self._semaphore = DummySemaphore() else: self._semaphore = Semaphore(size) def wait_available(self, timeout=None): """ Wait until it's possible to spawn a greenlet in this pool. :param float timeout: If given, only wait the specified number of seconds. .. warning:: If the pool was initialized with a size of 0, this method will block forever unless a timeout is given. :return: A number indicating how many new greenlets can be put into the pool without blocking. .. versionchanged:: 1.1a3 Added the ``timeout`` parameter. """ return self._semaphore.wait(timeout=timeout) def full(self): """ Return a boolean indicating whether this pool has any room for members. (True if it does, False if it doesn't.) """ return self.free_count() <= 0 def free_count(self): """ Return a number indicating *approximately* how many more members can be added to this pool. """ if self.size is None: return 1 return max(0, self.size - len(self)) def add(self, greenlet): """ Begin tracking the given greenlet, blocking until space is available. .. seealso:: :meth:`Group.add` """ self._semaphore.acquire() try: Group.add(self, greenlet) except: self._semaphore.release() raise def _discard(self, greenlet): Group._discard(self, greenlet) self._semaphore.release() class pass_value(object): __slots__ = ['callback'] def __init__(self, callback): self.callback = callback def __call__(self, source): if source.successful(): self.callback(source.value) def __hash__(self): return hash(self.callback) def __eq__(self, other): return self.callback == getattr(other, 'callback', other) def __str__(self): return str(self.callback) def __repr__(self): return repr(self.callback) def __getattr__(self, item): assert item != 'callback' return getattr(self.callback, item) gevent-1.1.0/gevent/python.pxd0000644000076500000000000000102212666555342017060 0ustar jmaddenwheel00000000000000cdef extern from "Python.h": struct PyObject: pass ctypedef PyObject* PyObjectPtr "PyObject*" void Py_INCREF(PyObjectPtr) void Py_DECREF(PyObjectPtr) void Py_XDECREF(PyObjectPtr) int Py_ReprEnter(PyObjectPtr) void Py_ReprLeave(PyObjectPtr) int PyCallable_Check(PyObjectPtr) cdef extern from "frameobject.h": ctypedef struct PyThreadState: PyObjectPtr exc_type PyObjectPtr exc_value PyObjectPtr exc_traceback PyThreadState* PyThreadState_GET() gevent-1.1.0/gevent/pywsgi.py0000644000076500000000000013763212666555342016737 0ustar jmaddenwheel00000000000000# Copyright (c) 2005-2009, eventlet contributors # Copyright (c) 2009-2015, gevent contributors """ A pure-Python, gevent-friendly WSGI server. The server is provided in :class:`WSGIServer`, but most of the actual WSGI work is handled by :class:`WSGIHandler` --- a new instance is created for each request. The server can be customized to use different subclasses of :class:`WSGIHandler`. """ import errno from io import BytesIO import string import sys import time import traceback from datetime import datetime try: from urllib import unquote except ImportError: from urllib.parse import unquote from gevent import socket import gevent from gevent.server import StreamServer from gevent.hub import GreenletExit, PY3, reraise from functools import partial if PY3: unquote_latin1 = partial(unquote, encoding='latin-1') else: unquote_latin1 = unquote _no_undoc_members = True # Don't put undocumented things into sphinx __all__ = [ 'WSGIServer', 'WSGIHandler', 'LoggingLogAdapter', ] MAX_REQUEST_LINE = 8192 # Weekday and month names for HTTP date/time formatting; always English! _WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] _MONTHNAME = [None, # Dummy so we can use 1-based month numbers "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] # The contents of the "HEX" grammar rule for HTTP, upper and lowercase A-F plus digits, # in byte form for comparing to the network. _HEX = string.hexdigits.encode('ascii') # Errors _ERRORS = dict() _INTERNAL_ERROR_STATUS = '500 Internal Server Error' _INTERNAL_ERROR_BODY = b'Internal Server Error' _INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'), ('Connection', 'close'), ('Content-Length', str(len(_INTERNAL_ERROR_BODY)))] _ERRORS[500] = (_INTERNAL_ERROR_STATUS, _INTERNAL_ERROR_HEADERS, _INTERNAL_ERROR_BODY) _BAD_REQUEST_STATUS = '400 Bad Request' _BAD_REQUEST_BODY = '' _BAD_REQUEST_HEADERS = [('Content-Type', 'text/plain'), ('Connection', 'close'), ('Content-Length', str(len(_BAD_REQUEST_BODY)))] _ERRORS[400] = (_BAD_REQUEST_STATUS, _BAD_REQUEST_HEADERS, _BAD_REQUEST_BODY) _REQUEST_TOO_LONG_RESPONSE = b"HTTP/1.1 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n" _BAD_REQUEST_RESPONSE = b"HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n" _CONTINUE_RESPONSE = b"HTTP/1.1 100 Continue\r\n\r\n" def format_date_time(timestamp): # Return a byte-string of the date and time in HTTP format # .. versionchanged:: 1.1b5 # Return a byte string, not a native string year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp) value = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (_WEEKDAYNAME[wd], day, _MONTHNAME[month], year, hh, mm, ss) if PY3: value = value.encode("latin-1") return value class _InvalidClientInput(IOError): # Internal exception raised by Input indicating that the client # sent invalid data at the lowest level of the stream. The result # *should* be a HTTP 400 error. pass class _InvalidClientRequest(ValueError): # Internal exception raised by WSGIHandler.read_request # indicating that the client sent an HTTP request that cannot # be parsed (e.g., invalid grammar). The result *should* be an # HTTP 400 error pass class Input(object): __slots__ = ('rfile', 'content_length', 'socket', 'position', 'chunked_input', 'chunk_length', '_chunked_input_error') def __init__(self, rfile, content_length, socket=None, chunked_input=False): self.rfile = rfile self.content_length = content_length self.socket = socket self.position = 0 self.chunked_input = chunked_input self.chunk_length = -1 self._chunked_input_error = False def _discard(self): if self._chunked_input_error: # We are in an unknown state, so we can't necessarily discard # the body (e.g., if the client keeps the socket open, we could hang # here forever). # In this case, we've raised an exception and the user of this object # is going to close the socket, so we don't have to discard return if self.socket is None and (self.position < (self.content_length or 0) or self.chunked_input): # ## Read and discard body while 1: d = self.read(16384) if not d: break def _send_100_continue(self): if self.socket is not None: self.socket.sendall(_CONTINUE_RESPONSE) self.socket = None def _do_read(self, length=None, use_readline=False): if use_readline: reader = self.rfile.readline else: reader = self.rfile.read content_length = self.content_length if content_length is None: # Either Content-Length or "Transfer-Encoding: chunked" must be present in a request with a body # if it was chunked, then this function would have not been called return b'' self._send_100_continue() left = content_length - self.position if length is None: length = left elif length > left: length = left if not length: return b'' # On Python 2, self.rfile is usually socket.makefile(), which # uses cStringIO.StringIO. If *length* is greater than the C # sizeof(int) (typically 32 bits signed), parsing the argument to # readline raises OverflowError. StringIO.read(), OTOH, uses # PySize_t, typically a long (64 bits). In a bare readline() # case, because the header lines we're trying to read with # readline are typically expected to be small, we can correct # that failure by simply doing a smaller call to readline and # appending; failures in read we let propagate. try: read = reader(length) except OverflowError: if not use_readline: # Expecting to read more than 64 bits of data. Ouch! raise # We could loop on calls to smaller readline(), appending them # until we actually get a newline. For uses in this module, # we expect the actual length to be small, but WSGI applications # are allowed to pass in an arbitrary length. (This loop isn't optimal, # but even client applications *probably* have short lines.) read = b'' while len(read) < length and not read.endswith(b'\n'): read += reader(MAX_REQUEST_LINE) self.position += len(read) if len(read) < length: if (use_readline and not read.endswith(b"\n")) or not use_readline: raise IOError("unexpected end of file while reading request at position %s" % (self.position,)) return read def __read_chunk_length(self, rfile): # Read and return the next integer chunk length. If no # chunk length can be read, raises _InvalidClientInput. # Here's the production for a chunk: # (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html) # chunk = chunk-size [ chunk-extension ] CRLF # chunk-data CRLF # chunk-size = 1*HEX # chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) # chunk-ext-name = token # chunk-ext-val = token | quoted-string # To cope with malicious or broken clients that fail to send valid # chunk lines, the strategy is to read character by character until we either reach # a ; or newline. If at any time we read a non-HEX digit, we bail. If we hit a # ;, indicating an chunk-extension, we'll read up to the next # MAX_REQUEST_LINE characters # looking for the CRLF, and if we don't find it, we bail. If we read more than 16 hex characters, # (the number needed to represent a 64-bit chunk size), we bail (this protects us from # a client that sends an infinite stream of `F`, for example). buf = BytesIO() while 1: char = rfile.read(1) if not char: self._chunked_input_error = True raise _InvalidClientInput("EOF before chunk end reached") if char == b'\r': break if char == b';': break if char not in _HEX: self._chunked_input_error = True raise _InvalidClientInput("Non-hex data", char) buf.write(char) if buf.tell() > 16: self._chunked_input_error = True raise _InvalidClientInput("Chunk-size too large.") if char == b';': i = 0 while i < MAX_REQUEST_LINE: char = rfile.read(1) if char == b'\r': break i += 1 else: # we read more than MAX_REQUEST_LINE without # hitting CR self._chunked_input_error = True raise _InvalidClientInput("Too large chunk extension") if char == b'\r': # We either got here from the main loop or from the # end of an extension char = rfile.read(1) if char != b'\n': self._chunked_input_error = True raise _InvalidClientInput("Line didn't end in CRLF") return int(buf.getvalue(), 16) def _chunked_read(self, length=None, use_readline=False): rfile = self.rfile self._send_100_continue() if length == 0: return b"" if length is not None and length < 0: length = None if use_readline: reader = self.rfile.readline else: reader = self.rfile.read response = [] while self.chunk_length != 0: maxreadlen = self.chunk_length - self.position if length is not None and length < maxreadlen: maxreadlen = length if maxreadlen > 0: data = reader(maxreadlen) if not data: self.chunk_length = 0 self._chunked_input_error = True raise IOError("unexpected end of file while parsing chunked data") datalen = len(data) response.append(data) self.position += datalen if self.chunk_length == self.position: rfile.readline() if length is not None: length -= datalen if length == 0: break if use_readline and data[-1] == b"\n"[0]: break else: # We're at the beginning of a chunk, so we need to # determine the next size to read self.chunk_length = self.__read_chunk_length(rfile) self.position = 0 if self.chunk_length == 0: # Last chunk. Terminates with a CRLF. rfile.readline() return b''.join(response) def read(self, length=None): if self.chunked_input: return self._chunked_read(length) return self._do_read(length) def readline(self, size=None): if self.chunked_input: return self._chunked_read(size, True) else: return self._do_read(size, use_readline=True) def readlines(self, hint=None): return list(self) def __iter__(self): return self def next(self): line = self.readline() if not line: raise StopIteration return line __next__ = next try: import mimetools headers_factory = mimetools.Message except ImportError: # adapt Python 3 HTTP headers to old API from http import client class OldMessage(client.HTTPMessage): def __init__(self, **kwargs): super().__init__(**kwargs) self.status = '' def getheader(self, name, default=None): return self.get(name, default) @property def headers(self): for key, value in self._headers: yield '%s: %s\r\n' % (key, value) @property def typeheader(self): return self.get('content-type') def headers_factory(fp, *args): try: ret = client.parse_headers(fp, _class=OldMessage) except client.LineTooLong: ret = OldMessage() ret.status = 'Line too long' return ret class WSGIHandler(object): """ Handles HTTP requests from a socket, creates the WSGI environment, and interacts with the WSGI application. This is the default value of :attr:`WSGIServer.handler_class`. This class may be subclassed carefully, and that class set on a :class:`WSGIServer` instance through a keyword argument at construction time. Instances are constructed with the same arguments as passed to the server's :meth:`WSGIServer.handle` method followed by the server itself. The application and environment are obtained from the server. """ protocol_version = 'HTTP/1.1' if PY3: # if we do like Py2, then headers_factory unconditionally # becomes a bound method, meaning the fp argument becomes WSGIHandler def MessageClass(self, *args): return headers_factory(*args) else: MessageClass = headers_factory # Attributes reset at various times for each request; not public # documented. Class attributes to keep the constructor fast # (but not make lint tools complain) status = None # byte string: b'200 OK' _orig_status = None # native string: '200 OK' response_headers = None # list of tuples (b'name', b'value') code = None # Integer parsed from status provided_date = None provided_content_length = None close_connection = False time_start = 0 # time.time() when begin handling request time_finish = 0 # time.time() when done handling request headers_sent = False # Have we already sent headers? response_use_chunked = False # Write with transfer-encoding chunked environ = None # Dict from self.get_environ application = None # application callable from self.server.application requestline = None # native str 'GET / HTTP/1.1' response_length = 0 # How much data we sent result = None # The return value of the WSGI application wsgi_input = None # Instance of Input() content_length = 0 # From application-provided headers Incoming # request headers, instance of MessageClass (gunicorn uses hasattr # on this so the default value needs to be compatible with the # API) headers = headers_factory(BytesIO()) request_version = None # str: 'HTTP 1.1' command = None # str: 'GET' path = None # str: '/' def __init__(self, socket, address, server, rfile=None): # Deprecation: The rfile kwarg was introduced in 1.0a1 as part # of a refactoring. It was never documented or used. It is # considered DEPRECATED and may be removed in the future. Its # use is not supported. self.socket = socket self.client_address = address self.server = server if rfile is None: self.rfile = socket.makefile('rb', -1) else: self.rfile = rfile def handle(self): """ The main request handling method, called by the server. This method runs a request handling loop, calling :meth:`handle_one_request` until all requests on the connection have been handled (that is, it implements keep-alive). """ try: while self.socket is not None: self.time_start = time.time() self.time_finish = 0 result = self.handle_one_request() if result is None: break if result is True: continue self.status, response_body = result self.socket.sendall(response_body) if self.time_finish == 0: self.time_finish = time.time() self.log_request() break finally: if self.socket is not None: _sock = getattr(self.socket, '_sock', None) # Python 3 try: # read out request data to prevent error: [Errno 104] Connection reset by peer if _sock: try: # socket.recv would hang _sock.recv(16384) finally: _sock.close() self.socket.close() except socket.error: pass self.__dict__.pop('socket', None) self.__dict__.pop('rfile', None) def _check_http_version(self): version = self.request_version if not version.startswith("HTTP/"): return False version = tuple(int(x) for x in version[5:].split(".")) # "HTTP/" if version[1] < 0 or version < (0, 9) or version >= (2, 0): return False return True def read_request(self, raw_requestline): """ Parse the incoming request. Parses various headers into ``self.headers`` using :attr:`MessageClass`. Other attributes that are set upon a successful return of this method include ``self.content_length`` and ``self.close_connection``. :param str raw_requestline: A native :class:`str` representing the request line. A processed version of this will be stored into ``self.requestline``. :raises ValueError: If the request is invalid. This error will not be logged as a traceback (because it's a client issue, not a server problem). :return: A boolean value indicating whether the request was successfully parsed. This method should either return a true value or have raised a ValueError with details about the parsing error. .. versionchanged:: 1.1b6 Raise the previously documented :exc:`ValueError` in more cases instead of returning a false value; this allows subclasses more opportunity to customize behaviour. """ self.requestline = raw_requestline.rstrip() words = self.requestline.split() if len(words) == 3: self.command, self.path, self.request_version = words if not self._check_http_version(): raise _InvalidClientRequest('Invalid http version: %r', raw_requestline) elif len(words) == 2: self.command, self.path = words if self.command != "GET": raise _InvalidClientRequest('Expected GET method: %r', raw_requestline) self.request_version = "HTTP/0.9" # QQQ I'm pretty sure we can drop support for HTTP/0.9 else: raise _InvalidClientRequest('Invalid HTTP method: %r', raw_requestline) self.headers = self.MessageClass(self.rfile, 0) if self.headers.status: raise _InvalidClientRequest('Invalid headers status: %r', self.headers.status) if self.headers.get("transfer-encoding", "").lower() == "chunked": try: del self.headers["content-length"] except KeyError: pass content_length = self.headers.get("content-length") if content_length is not None: content_length = int(content_length) if content_length < 0: raise _InvalidClientRequest('Invalid Content-Length: %r', content_length) if content_length and self.command in ('HEAD', ): raise _InvalidClientRequest('Unexpected Content-Length') self.content_length = content_length if self.request_version == "HTTP/1.1": conntype = self.headers.get("Connection", "").lower() if conntype == "close": self.close_connection = True else: self.close_connection = False else: self.close_connection = True return True def log_error(self, msg, *args): try: message = msg % args except Exception: traceback.print_exc() message = '%r %r' % (msg, args) try: message = '%s: %s' % (self.socket, message) except Exception: pass try: self.server.error_log.write(message + '\n') except Exception: traceback.print_exc() def read_requestline(self): """ Read and return the HTTP request line. Under both Python 2 and 3, this should return the native ``str`` type; under Python 3, this probably means the bytes read from the network need to be decoded (using the ISO-8859-1 charset, aka latin-1). """ line = self.rfile.readline(MAX_REQUEST_LINE) if PY3: line = line.decode('latin-1') return line def handle_one_request(self): """ Handles one HTTP request using ``self.socket`` and ``self.rfile``. Each invocation of this method will do several things, including (but not limited to): - Read the request line using :meth:`read_requestline`; - Read the rest of the request, including headers, with :meth:`read_request`; - Construct a new WSGI environment in ``self.environ`` using :meth:`get_environ`; - Store the application in ``self.application``, retrieving it from the server; - Handle the remainder of the request, including invoking the application, with :meth:`handle_one_response` There are several possible return values to indicate the state of the client connection: - ``None`` The client connection is already closed or should be closed because the WSGI application or client set the ``Connection: close`` header. The request handling loop should terminate and perform cleanup steps. - (status, body) An HTTP status and body tuple. The request was in error, as detailed by the status and body. The request handling loop should terminate, close the connection, and perform cleanup steps. Note that the ``body`` is the complete contents to send to the client, including all headers and the initial status line. - ``True`` The literal ``True`` value. The request was successfully handled and the response sent to the client by :meth:`handle_one_response`. The connection remains open to process more requests and the connection handling loop should call this method again. This is the typical return value. .. seealso:: :meth:`handle` .. versionchanged:: 1.1b6 Funnel exceptions having to do with invalid HTTP requests through :meth:`_handle_client_error` to allow subclasses to customize. Note that this is experimental and may change in the future. """ if self.rfile.closed: return try: self.requestline = self.read_requestline() # Account for old subclasses that haven't done this if PY3 and isinstance(self.requestline, bytes): self.requestline = self.requestline.decode('latin-1') except socket.error: # "Connection reset by peer" or other socket errors aren't interesting here return if not self.requestline: return self.response_length = 0 if len(self.requestline) >= MAX_REQUEST_LINE: return ('414', _REQUEST_TOO_LONG_RESPONSE) try: # for compatibility with older versions of pywsgi, we pass self.requestline as an argument there # NOTE: read_request is supposed to raise ValueError on invalid input; allow old # subclasses that return a False value instead. if not self.read_request(self.requestline): return ('400', _BAD_REQUEST_RESPONSE) except Exception as ex: # Notice we don't use self.handle_error because it reports # a 500 error to the client, and this is almost certainly # a client error. # Provide a hook for subclasses. return self._handle_client_error(ex) self.environ = self.get_environ() self.application = self.server.application self.handle_one_response() if self.close_connection: return if self.rfile.closed: return return True # read more requests def finalize_headers(self): if self.provided_date is None: self.response_headers.append((b'Date', format_date_time(time.time()))) if self.code not in (304, 204): # the reply will include message-body; make sure we have either Content-Length or chunked if self.provided_content_length is None: if hasattr(self.result, '__len__'): total_len = sum(len(chunk) for chunk in self.result) total_len_str = str(total_len) if PY3: total_len_str = total_len_str.encode("latin-1") self.response_headers.append((b'Content-Length', total_len_str)) else: if self.request_version != 'HTTP/1.0': self.response_use_chunked = True self.response_headers.append((b'Transfer-Encoding', b'chunked')) def _sendall(self, data): try: self.socket.sendall(data) except socket.error as ex: self.status = 'socket error: %s' % ex if self.code > 0: self.code = -self.code raise self.response_length += len(data) def _write(self, data): if not data: return if self.response_use_chunked: ## Write the chunked encoding data = ("%x\r\n" % len(data)).encode('ascii') + data + b'\r\n' self._sendall(data) def write(self, data): if self.code in (304, 204) and data: raise AssertionError('The %s response must have no body' % self.code) if self.headers_sent: self._write(data) else: if not self.status: raise AssertionError("The application did not call start_response()") self._write_with_headers(data) def _write_with_headers(self, data): towrite = bytearray() self.headers_sent = True self.finalize_headers() # self.response_headers and self.status are already in latin-1, as encoded by self.start_response towrite.extend(b'HTTP/1.1 ') towrite.extend(self.status) towrite.extend(b'\r\n') for header, value in self.response_headers: towrite.extend(header) towrite.extend(b': ') towrite.extend(value) towrite.extend(b"\r\n") towrite.extend(b'\r\n') if data: if self.response_use_chunked: ## Write the chunked encoding towrite.extend(("%x\r\n" % len(data)).encode('latin-1')) towrite.extend(data) towrite.extend(b"\r\n") else: try: towrite.extend(data) except TypeError: raise TypeError("Not a bytestring", data) self._sendall(towrite) def start_response(self, status, headers, exc_info=None): """ .. versionchanged:: 1.1b5 Pro-actively handle checking the encoding of the status line and headers during this method. On Python 2, avoid some extra encodings. """ if exc_info: try: if self.headers_sent: # Re-raise original exception if headers sent reraise(*exc_info) finally: # Avoid dangling circular ref exc_info = None # Pep 3333, "The start_response callable": # https://www.python.org/dev/peps/pep-3333/#the-start-response-callable # "Servers should check for errors in the headers at the time # start_response is called, so that an error can be raised # while the application is still running." Here, we check the encoding. # This aids debugging: headers especially are generated programatically # and an encoding error in a loop or list comprehension yields an opaque # UnicodeError without any clue which header was wrong. # Note that this results in copying the header list at this point, not modifying it, # although we are allowed to do so if needed. This slightly increases memory usage. response_headers = [] header = None value = None try: for header, value in headers: if not isinstance(header, str): raise UnicodeError("The header must be a native string", header, value) if not isinstance(value, str): raise UnicodeError("The value must be a native string", header, value) # Either we're on Python 2, in which case bytes is correct, or # we're on Python 3 and the user screwed up (because it should be a native # string). In either case, make sure that this is latin-1 compatible. Under # Python 2, bytes.encode() will take a round-trip through the system encoding, # which may be ascii, which is not really what we want. However, the latin-1 encoding # can encode everything except control characters and the block from 0x7F to 0x9F, so # explicitly round-tripping bytes through the encoding is unlikely to be of much # benefit, so we go for speed (the WSGI spec specifically calls out allowing the range # from 0x00 to 0xFF, although the HTTP spec forbids the control characters). # Note: Some Python 2 implementations, like Jython, may allow non-octet (above 255) values # in their str implementation; this is mentioned in the WSGI spec, but we don't # run on any platform like that so we can assume that a str value is pure bytes. response_headers.append((header if not PY3 else header.encode("latin-1"), value if not PY3 else value.encode("latin-1"))) except UnicodeEncodeError: # If we get here, we're guaranteed to have a header and value raise UnicodeError("Non-latin1 header", header, value) # Same as above if not isinstance(status, str): raise UnicodeError("The status string must be a native string") # don't assign to anything until the validation is complete, including parsing the # code code = int(status.split(' ', 1)[0]) self.status = status if not PY3 else status.encode("latin-1") self._orig_status = status # Preserve the native string for logging self.response_headers = response_headers self.code = code provided_connection = None self.provided_date = None self.provided_content_length = None for header, value in headers: header = header.lower() if header == 'connection': provided_connection = value elif header == 'date': self.provided_date = value elif header == 'content-length': self.provided_content_length = value if self.request_version == 'HTTP/1.0' and provided_connection is None: response_headers.append((b'Connection', b'close')) self.close_connection = True elif provided_connection == 'close': self.close_connection = True if self.code in (304, 204): if self.provided_content_length is not None and self.provided_content_length != '0': msg = 'Invalid Content-Length for %s response: %r (must be absent or zero)' % (self.code, self.provided_content_length) if PY3: msg = msg.encode('latin-1') raise AssertionError(msg) return self.write def log_request(self): self.server.log.write(self.format_request() + '\n') def format_request(self): now = datetime.now().replace(microsecond=0) length = self.response_length or '-' if self.time_finish: delta = '%.6f' % (self.time_finish - self.time_start) else: delta = '-' client_address = self.client_address[0] if isinstance(self.client_address, tuple) else self.client_address return '%s - - [%s] "%s" %s %s %s' % ( client_address or '-', now, self.requestline or '', # Use the native string version of the status, saved so we don't have to # decode. But fallback to the encoded 'status' in case of subclasses # (Is that really necessary? At least there's no overhead.) (self._orig_status or self.status or '000').split()[0], length, delta) def process_result(self): for data in self.result: if data: self.write(data) if self.status and not self.headers_sent: self.write(b'') if self.response_use_chunked: self.socket.sendall(b'0\r\n\r\n') self.response_length += 5 def run_application(self): self.result = self.application(self.environ, self.start_response) self.process_result() def handle_one_response(self): self.time_start = time.time() self.status = None self.headers_sent = False self.result = None self.response_use_chunked = False self.response_length = 0 try: try: self.run_application() finally: close = getattr(self.result, 'close', None) if close is not None: close() try: self.wsgi_input._discard() except (socket.error, IOError): # Don't let exceptions during discarding # input override any exception that may have been # raised by the application, such as our own _InvalidClientInput. # In the general case, these aren't even worth logging (see the comment # just below) pass except _InvalidClientInput: self._send_error_response_if_possible(400) except socket.error as ex: if ex.args[0] in (errno.EPIPE, errno.ECONNRESET): # Broken pipe, connection reset by peer. # Swallow these silently to avoid spewing # useless info on normal operating conditions, # bloating logfiles. See https://github.com/gevent/gevent/pull/377 # and https://github.com/gevent/gevent/issues/136. if not PY3: sys.exc_clear() self.close_connection = True else: self.handle_error(*sys.exc_info()) except: self.handle_error(*sys.exc_info()) finally: self.time_finish = time.time() self.log_request() def _send_error_response_if_possible(self, error_code): if self.response_length: self.close_connection = True else: status, headers, body = _ERRORS[error_code] self.start_response(status, headers[:]) self.write(body) def _log_error(self, t, v, tb): # TODO: Shouldn't we dump this to wsgi.errors? If we did that now, it would # wind up getting logged twice if not issubclass(t, GreenletExit): self.server.loop.handle_error(self.environ, t, v, tb) def handle_error(self, t, v, tb): # Called for internal, unexpected errors, NOT invalid client input self._log_error(t, v, tb) del tb self._send_error_response_if_possible(500) def _handle_client_error(self, ex): # Called for invalid client input # Returns the appropriate error response. if not isinstance(ex, ValueError): # XXX: Why not self._log_error to send it through the loop's # handle_error method? traceback.print_exc() if isinstance(ex, _InvalidClientRequest): # These come with good error messages, and we want to let # log_error deal with the formatting, especially to handle encoding self.log_error(*ex.args) else: self.log_error('Invalid request: %s', str(ex) or ex.__class__.__name__) return ('400', _BAD_REQUEST_RESPONSE) def _headers(self): key = None value = None for header in self.headers.headers: if key is not None and header[:1] in " \t": value += header continue if key not in (None, 'CONTENT_TYPE', 'CONTENT_LENGTH'): yield 'HTTP_' + key, value.strip() key, value = header.split(':', 1) key = key.replace('-', '_').upper() if key not in (None, 'CONTENT_TYPE', 'CONTENT_LENGTH'): yield 'HTTP_' + key, value.strip() def get_environ(self): """ Construct and return a new WSGI environment dictionary for a specific request. This should begin with asking the server for the base environment using :meth:`WSGIServer.get_environ`, and then proceed to add the request specific values. By the time this method is invoked the request line and request shall have been parsed and ``self.headers`` shall be populated. """ env = self.server.get_environ() env['REQUEST_METHOD'] = self.command env['SCRIPT_NAME'] = '' if '?' in self.path: path, query = self.path.split('?', 1) else: path, query = self.path, '' # Note that self.path contains the original str object; if it contains # encoded escapes, it will NOT match PATH_INFO. env['PATH_INFO'] = unquote_latin1(path) env['QUERY_STRING'] = query if self.headers.typeheader is not None: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length env['SERVER_PROTOCOL'] = self.request_version client_address = self.client_address if isinstance(client_address, tuple): env['REMOTE_ADDR'] = str(client_address[0]) env['REMOTE_PORT'] = str(client_address[1]) for key, value in self._headers(): if key in env: if 'COOKIE' in key: env[key] += '; ' + value else: env[key] += ',' + value else: env[key] = value if env.get('HTTP_EXPECT') == '100-continue': socket = self.socket else: socket = None chunked = env.get('HTTP_TRANSFER_ENCODING', '').lower() == 'chunked' self.wsgi_input = Input(self.rfile, self.content_length, socket=socket, chunked_input=chunked) env['wsgi.input'] = self.wsgi_input return env class _NoopLog(object): # Does nothing; implements just enough file-like methods # to pass the WSGI validator def write(self, *args, **kwargs): return def flush(self): pass def writelines(self, *args, **kwargs): pass class LoggingLogAdapter(object): """ An adapter for :class:`logging.Logger` instances to let them be used with :class:`WSGIServer`. .. warning:: Unless the entire process is monkey-patched at a very early part of the lifecycle (before logging is configured), loggers are likely to not be gevent-cooperative. For example, the socket and syslog handlers use the socket module in a way that can block, and most handlers acquire threading locks. .. warning:: It *may* be possible for the logging functions to be called in the :class:`gevent.Hub` greenlet. Code running in the hub greenlet cannot use any gevent blocking functions without triggering a ``LoopExit``. .. versionadded:: 1.1a3 .. versionchanged:: 1.1b6 Attributes not present on this object are proxied to the underlying logger instance. This permits using custom :class:`~logging.Logger` subclasses (or indeed, even duck-typed objects). .. versionchanged:: 1.1 Strip trailing newline characters on the message passed to :meth:`write` because log handlers will usually add one themselves. """ # gevent avoids importing and using logging because importing it and # creating loggers creates native locks unless monkey-patched. __slots__ = ('_logger', '_level') def __init__(self, logger, level=20): """ Write information to the *logger* at the given *level* (default to INFO). """ self._logger = logger self._level = level def write(self, msg): if msg and msg.endswith('\n'): msg = msg[:-1] self._logger.log(self._level, msg) def flush(self): "No-op; required to be a file-like object" pass def writelines(self, lines): for line in lines: self.write(line) def __getattr__(self, name): return getattr(self._logger, name) def __setattr__(self, name, value): if name not in LoggingLogAdapter.__slots__: setattr(self._logger, name, value) else: object.__setattr__(self, name, value) def __delattr__(self, name): delattr(self._logger, name) class WSGIServer(StreamServer): """ A WSGI server based on :class:`StreamServer` that supports HTTPS. :keyword log: If given, an object with a ``write`` method to which request (access) logs will be written. If not given, defaults to :obj:`sys.stderr`. You may pass ``None`` to disable request logging. You may use a wrapper, around e.g., :mod:`logging`, to support objects that don't implement a ``write`` method. (If you pass a :class:`~logging.Logger` instance, or in general something that provides a ``log`` method but not a ``write`` method, such a wrapper will automatically be created and it will be logged to at the :data:`~logging.INFO` level.) :keyword error_log: If given, a file-like object with ``write``, ``writelines`` and ``flush`` methods to which error logs will be written. If not given, defaults to :obj:`sys.stderr`. You may pass ``None`` to disable error logging (not recommended). You may use a wrapper, around e.g., :mod:`logging`, to support objects that don't implement the proper methods. This parameter will become the value for ``wsgi.errors`` in the WSGI environment (if not already set). (As with *log*, wrappers for :class:`~logging.Logger` instances and the like will be created automatically and logged to at the :data:`~logging.ERROR` level.) .. seealso:: :class:`LoggingLogAdapter` See important warnings before attempting to use :mod:`logging`. .. versionchanged:: 1.1a3 Added the ``error_log`` parameter, and set ``wsgi.errors`` in the WSGI environment to this value. .. versionchanged:: 1.1a3 Add support for passing :class:`logging.Logger` objects to the ``log`` and ``error_log`` arguments. """ #: A callable taking three arguments: (socket, address, server) and returning #: an object with a ``handle()`` method. The callable is called once for #: each incoming socket request, as is its handle method. The handle method should not #: return until all use of the socket is complete. #: #: This class uses the :class:`WSGIHandler` object as the default value. You may #: subclass this class and set a different default value, or you may pass #: a value to use in the ``handler_class`` keyword constructor argument. handler_class = WSGIHandler #: The object to which request logs will be written. #: It must never be None. Initialized from the ``log`` constructor #: parameter. log = None #: The object to which error logs will be written. #: It must never be None. Initialized from the ``error_log`` constructor #: parameter. error_log = None base_env = {'GATEWAY_INTERFACE': 'CGI/1.1', 'SERVER_SOFTWARE': 'gevent/%d.%d Python/%d.%d' % (gevent.version_info[:2] + sys.version_info[:2]), 'SCRIPT_NAME': '', 'wsgi.version': (1, 0), 'wsgi.multithread': False, # XXX: Aren't we really, though? 'wsgi.multiprocess': False, 'wsgi.run_once': False} def __init__(self, listener, application=None, backlog=None, spawn='default', log='default', error_log='default', handler_class=None, environ=None, **ssl_args): StreamServer.__init__(self, listener, backlog=backlog, spawn=spawn, **ssl_args) if application is not None: self.application = application if handler_class is not None: self.handler_class = handler_class # Note that we can't initialize these as class variables: # sys.stderr might get monkey patched at runtime. def _make_log(l, level=20): if l == 'default': return sys.stderr if l is None: return _NoopLog() if not hasattr(l, 'write') and hasattr(l, 'log'): return LoggingLogAdapter(l, level) return l self.log = _make_log(log) self.error_log = _make_log(error_log, 40) # logging.ERROR self.set_environ(environ) self.set_max_accept() def set_environ(self, environ=None): if environ is not None: self.environ = environ environ_update = getattr(self, 'environ', None) self.environ = self.base_env.copy() if self.ssl_enabled: self.environ['wsgi.url_scheme'] = 'https' else: self.environ['wsgi.url_scheme'] = 'http' if environ_update is not None: self.environ.update(environ_update) if self.environ.get('wsgi.errors') is None: self.environ['wsgi.errors'] = self.error_log def set_max_accept(self): if self.environ.get('wsgi.multiprocess'): self.max_accept = 1 def get_environ(self): return self.environ.copy() def init_socket(self): StreamServer.init_socket(self) self.update_environ() def update_environ(self): """ Called before the first request is handled to fill in WSGI environment values. This includes getting the correct server name and port. """ address = self.address if isinstance(address, tuple): if 'SERVER_NAME' not in self.environ: try: name = socket.getfqdn(address[0]) except socket.error: name = str(address[0]) if PY3 and not isinstance(name, str): name = name.decode('ascii') self.environ['SERVER_NAME'] = name self.environ.setdefault('SERVER_PORT', str(address[1])) else: self.environ.setdefault('SERVER_NAME', '') self.environ.setdefault('SERVER_PORT', '') def handle(self, socket, address): """ Create an instance of :attr:`handler_class` to handle the request. This method blocks until the handler returns. """ handler = self.handler_class(socket, address, self) handler.handle() gevent-1.1.0/gevent/queue.py0000644000076500000000000004661712666555342016543 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. """Synchronized queues. The :mod:`gevent.queue` module implements multi-producer, multi-consumer queues that work across greenlets, with the API similar to the classes found in the standard :mod:`Queue` and :class:`multiprocessing ` modules. The classes in this module implement iterator protocol. Iterating over queue means repeatedly calling :meth:`get ` until :meth:`get ` returns ``StopIteration``. >>> queue = gevent.queue.Queue() >>> queue.put(1) >>> queue.put(2) >>> queue.put(StopIteration) >>> for item in queue: ... print(item) 1 2 .. versionchanged:: 1.0 ``Queue(0)`` now means queue of infinite size, not a channel. A :exc:`DeprecationWarning` will be issued with this argument. """ from __future__ import absolute_import import sys import heapq import collections if sys.version_info[0] == 2: import Queue as __queue__ else: import queue as __queue__ Full = __queue__.Full Empty = __queue__.Empty from gevent.timeout import Timeout from gevent.hub import get_hub, Waiter, getcurrent, PY3 from gevent.hub import InvalidSwitchError __all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'JoinableQueue', 'Channel'] def _safe_remove(deq, item): # For when the item may have been removed by # Queue._unlock try: deq.remove(item) except ValueError: pass class Queue(object): """ Create a queue object with a given maximum size. If *maxsize* is less than or equal to zero or ``None``, the queue size is infinite. .. versionchanged:: 1.1b3 Queues now support :func:`len`; it behaves the same as :meth:`qsize`. .. versionchanged:: 1.1b3 Multiple greenlets that block on a call to :meth:`put` for a full queue will now be woken up to put their items into the queue in the order in which they arrived. Likewise, multiple greenlets that block on a call to :meth:`get` for an empty queue will now receive items in the order in which they blocked. An implementation quirk under CPython *usually* ensured this was roughly the case previously anyway, but that wasn't the case for PyPy. """ def __init__(self, maxsize=None, items=None): if maxsize is not None and maxsize <= 0: self.maxsize = None if maxsize == 0: import warnings warnings.warn('Queue(0) now equivalent to Queue(None); if you want a channel, use Channel', DeprecationWarning, stacklevel=2) else: self.maxsize = maxsize # Explicitly maintain order for getters and putters that block # so that callers can consistently rely on getting things out # in the apparent order they went in. This was once required by # imap_unordered. Previously these were set() objects, and the # items put in the set have default hash() and eq() methods; # under CPython, since new objects tend to have increasing # hash values, this tended to roughly maintain order anyway, # but that's not true under PyPy. An alternative to a deque # (to avoid the linear scan of remove()) might be an # OrderedDict, but it's 2.7 only; we don't expect to have so # many waiters that removing an arbitrary element is a # bottleneck, though. self.getters = collections.deque() self.putters = collections.deque() self.hub = get_hub() self._event_unlock = None if items: self._init(maxsize, items) else: self._init(maxsize) # QQQ make maxsize into a property with setter that schedules unlock if necessary def copy(self): return type(self)(self.maxsize, self.queue) def _init(self, maxsize, items=None): if items: self.queue = collections.deque(items) else: self.queue = collections.deque() def _get(self): return self.queue.popleft() def _peek(self): return self.queue[0] def _put(self, item): self.queue.append(item) def __repr__(self): return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format()) def __str__(self): return '<%s%s>' % (type(self).__name__, self._format()) def _format(self): result = [] if self.maxsize is not None: result.append('maxsize=%r' % (self.maxsize, )) if getattr(self, 'queue', None): result.append('queue=%r' % (self.queue, )) if self.getters: result.append('getters[%s]' % len(self.getters)) if self.putters: result.append('putters[%s]' % len(self.putters)) if result: return ' ' + ' '.join(result) else: return '' def qsize(self): """Return the size of the queue.""" return len(self.queue) def __len__(self): """ Return the size of the queue. This is the same as :meth:`qsize`. .. versionadded: 1.1b3 Previously, getting len() of a queue would raise a TypeError. """ return self.qsize() def __bool__(self): """ A queue object is always True. .. versionadded: 1.1b3 Now that queues support len(), they need to implement ``__bool__`` to return True for backwards compatibility. """ return True __nonzero__ = __bool__ def empty(self): """Return ``True`` if the queue is empty, ``False`` otherwise.""" return not self.qsize() def full(self): """Return ``True`` if the queue is full, ``False`` otherwise. ``Queue(None)`` is never full. """ return self.maxsize is not None and self.qsize() >= self.maxsize def put(self, item, block=True, timeout=None): """Put an item into the queue. If optional arg *block* is true and *timeout* is ``None`` (the default), block if necessary until a free slot is available. If *timeout* is a positive number, it blocks at most *timeout* seconds and raises the :class:`Full` exception if no free slot was available within that time. Otherwise (*block* is false), put an item on the queue if a free slot is immediately available, else raise the :class:`Full` exception (*timeout* is ignored in that case). """ if self.maxsize is None or self.qsize() < self.maxsize: # there's a free slot, put an item right away self._put(item) if self.getters: self._schedule_unlock() elif self.hub is getcurrent(): # We're in the mainloop, so we cannot wait; we can switch to other greenlets though. # Check if possible to get a free slot in the queue. while self.getters and self.qsize() and self.qsize() >= self.maxsize: getter = self.getters.popleft() getter.switch(getter) if self.qsize() < self.maxsize: self._put(item) return raise Full elif block: waiter = ItemWaiter(item, self) self.putters.append(waiter) timeout = Timeout._start_new_or_dummy(timeout, Full) try: if self.getters: self._schedule_unlock() result = waiter.get() if result is not waiter: raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, )) finally: timeout.cancel() _safe_remove(self.putters, waiter) else: raise Full def put_nowait(self, item): """Put an item into the queue without blocking. Only enqueue the item if a free slot is immediately available. Otherwise raise the :class:`Full` exception. """ self.put(item, False) def __get_or_peek(self, method, block, timeout): # Internal helper method. The `method` should be either # self._get when called from self.get() or self._peek when # called from self.peek(). Call this after the initial check # to see if there are items in the queue. if self.hub is getcurrent(): # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet # there are no items in the queue; try to fix the situation by unlocking putters while self.putters: # Note: get() used popleft(), peek used pop(); popleft # is almost certainly correct. self.putters.popleft().put_and_switch() if self.qsize(): return method() raise Empty() if not block: # We can't block, we're not the hub, and we have nothing # to return. No choice... raise Empty() waiter = Waiter() timeout = Timeout._start_new_or_dummy(timeout, Empty) try: self.getters.append(waiter) if self.putters: self._schedule_unlock() result = waiter.get() if result is not waiter: raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, )) return method() finally: timeout.cancel() _safe_remove(self.getters, waiter) def get(self, block=True, timeout=None): """Remove and return an item from the queue. If optional args *block* is true and *timeout* is ``None`` (the default), block if necessary until an item is available. If *timeout* is a positive number, it blocks at most *timeout* seconds and raises the :class:`Empty` exception if no item was available within that time. Otherwise (*block* is false), return an item if one is immediately available, else raise the :class:`Empty` exception (*timeout* is ignored in that case). """ if self.qsize(): if self.putters: self._schedule_unlock() return self._get() return self.__get_or_peek(self._get, block, timeout) def get_nowait(self): """Remove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the :class:`Empty` exception. """ return self.get(False) def peek(self, block=True, timeout=None): """Return an item from the queue without removing it. If optional args *block* is true and *timeout* is ``None`` (the default), block if necessary until an item is available. If *timeout* is a positive number, it blocks at most *timeout* seconds and raises the :class:`Empty` exception if no item was available within that time. Otherwise (*block* is false), return an item if one is immediately available, else raise the :class:`Empty` exception (*timeout* is ignored in that case). """ if self.qsize(): # XXX: Why doesn't this schedule an unlock like get() does? return self._peek() return self.__get_or_peek(self._peek, block, timeout) def peek_nowait(self): """Return an item from the queue without blocking. Only return an item if one is immediately available. Otherwise raise the :class:`Empty` exception. """ return self.peek(False) def _unlock(self): while True: repeat = False if self.putters and (self.maxsize is None or self.qsize() < self.maxsize): repeat = True try: putter = self.putters.popleft() self._put(putter.item) except: putter.throw(*sys.exc_info()) else: putter.switch(putter) if self.getters and self.qsize(): repeat = True getter = self.getters.popleft() getter.switch(getter) if not repeat: return def _schedule_unlock(self): if not self._event_unlock: self._event_unlock = self.hub.loop.run_callback(self._unlock) def __iter__(self): return self def next(self): result = self.get() if result is StopIteration: raise result return result if PY3: __next__ = next del next class ItemWaiter(Waiter): __slots__ = ['item', 'queue'] def __init__(self, item, queue): Waiter.__init__(self) self.item = item self.queue = queue def put_and_switch(self): self.queue._put(self.item) self.queue = None self.item = None return self.switch(self) class PriorityQueue(Queue): '''A subclass of :class:`Queue` that retrieves entries in priority order (lowest first). Entries are typically tuples of the form: ``(priority number, data)``. ''' def _init(self, maxsize, items=None): if items: self.queue = list(items) else: self.queue = [] def _put(self, item, heappush=heapq.heappush): heappush(self.queue, item) def _get(self, heappop=heapq.heappop): return heappop(self.queue) class LifoQueue(Queue): '''A subclass of :class:`Queue` that retrieves most recently added entries first.''' def _init(self, maxsize, items=None): if items: self.queue = list(items) else: self.queue = [] def _put(self, item): self.queue.append(item) def _get(self): return self.queue.pop() def _peek(self): return self.queue[-1] class JoinableQueue(Queue): """ A subclass of :class:`Queue` that additionally has :meth:`task_done` and :meth:`join` methods. """ def __init__(self, maxsize=None, items=None, unfinished_tasks=None): """ .. versionchanged:: 1.1a1 If *unfinished_tasks* is not given, then all the given *items* (if any) will be considered unfinished. """ from gevent.event import Event Queue.__init__(self, maxsize, items) self._cond = Event() self._cond.set() if unfinished_tasks: self.unfinished_tasks = unfinished_tasks elif items: self.unfinished_tasks = len(items) else: self.unfinished_tasks = 0 if self.unfinished_tasks: self._cond.clear() def copy(self): return type(self)(self.maxsize, self.queue, self.unfinished_tasks) def _format(self): result = Queue._format(self) if self.unfinished_tasks: result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond) return result def _put(self, item): Queue._put(self, item) self.unfinished_tasks += 1 self._cond.clear() def task_done(self): '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads. For each :meth:`get ` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue that the processing on the task is complete. If a :meth:`join` is currently blocking, it will resume when all items have been processed (meaning that a :meth:`task_done` call was received for every item that had been :meth:`put ` into the queue). Raises a :exc:`ValueError` if called more times than there were items placed in the queue. ''' if self.unfinished_tasks <= 0: raise ValueError('task_done() called too many times') self.unfinished_tasks -= 1 if self.unfinished_tasks == 0: self._cond.set() def join(self, timeout=None): ''' Block until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls :meth:`task_done` to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, :meth:`join` unblocks. :param float timeout: If not ``None``, then wait no more than this time in seconds for all tasks to finish. :return: ``True`` if all tasks have finished; if ``timeout`` was given and expired before all tasks finished, ``False``. .. versionchanged:: 1.1a1 Add the *timeout* parameter. ''' return self._cond.wait(timeout=timeout) class Channel(object): def __init__(self): self.getters = collections.deque() self.putters = collections.deque() self.hub = get_hub() self._event_unlock = None def __repr__(self): return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format()) def __str__(self): return '<%s %s>' % (type(self).__name__, self._format()) def _format(self): result = '' if self.getters: result += ' getters[%s]' % len(self.getters) if self.putters: result += ' putters[%s]' % len(self.putters) return result @property def balance(self): return len(self.putters) - len(self.getters) def qsize(self): return 0 def empty(self): return True def full(self): return True def put(self, item, block=True, timeout=None): if self.hub is getcurrent(): if self.getters: getter = self.getters.popleft() getter.switch(item) return raise Full if not block: timeout = 0 waiter = Waiter() item = (item, waiter) self.putters.append(item) timeout = Timeout._start_new_or_dummy(timeout, Full) try: if self.getters: self._schedule_unlock() result = waiter.get() if result is not waiter: raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, )) except: _safe_remove(self.putters, item) raise finally: timeout.cancel() def put_nowait(self, item): self.put(item, False) def get(self, block=True, timeout=None): if self.hub is getcurrent(): if self.putters: item, putter = self.putters.popleft() self.hub.loop.run_callback(putter.switch, putter) return item if not block: timeout = 0 waiter = Waiter() timeout = Timeout._start_new_or_dummy(timeout, Empty) try: self.getters.append(waiter) if self.putters: self._schedule_unlock() return waiter.get() except: self.getters.remove(waiter) raise finally: timeout.cancel() def get_nowait(self): return self.get(False) def _unlock(self): while self.putters and self.getters: getter = self.getters.popleft() item, putter = self.putters.popleft() getter.switch(item) putter.switch(putter) def _schedule_unlock(self): if not self._event_unlock: self._event_unlock = self.hub.loop.run_callback(self._unlock) def __iter__(self): return self def next(self): result = self.get() if result is StopIteration: raise result return result gevent-1.1.0/gevent/resolver_ares.py0000644000076500000000000003101412666555342020253 0ustar jmaddenwheel00000000000000# Copyright (c) 2011-2015 Denis Bilenko. See LICENSE for details. """ c-ares based hostname resolver. """ from __future__ import absolute_import import os import sys from _socket import getservbyname, getaddrinfo, gaierror, error from gevent.hub import Waiter, get_hub, string_types, text_type, integer_types, reraise, PY3 from gevent.socket import AF_UNSPEC, AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AI_NUMERICHOST, EAI_SERVICE, AI_PASSIVE from gevent.ares import channel, InvalidIP __all__ = ['Resolver'] class Resolver(object): """ Implementation of the resolver API using the `c-ares`_ library. This implementation uses the c-ares library to handle name resolution. c-ares is natively asynchronous at the socket level and so integrates well into gevent's event loop. In comparison to :class:`gevent.resolver_thread.Resolver`, the implementation is much more complex. In addition, there have been reports of it not properly honoring certain system configurations. However, because it does not use threads, it may scale better. .. caution:: This module is considered extremely experimental on PyPy, and due to its implementation in cython, it may be slower. It may also lead to interpreter crashes. .. _c-ares: http://c-ares.haxx.se """ ares_class = channel def __init__(self, hub=None, use_environ=True, **kwargs): if hub is None: hub = get_hub() self.hub = hub if use_environ: for key in os.environ: if key.startswith('GEVENTARES_'): name = key[11:].lower() if name: value = os.environ[key] kwargs.setdefault(name, value) self.ares = self.ares_class(hub.loop, **kwargs) self.pid = os.getpid() self.params = kwargs self.fork_watcher = hub.loop.fork(ref=False) self.fork_watcher.start(self._on_fork) def __repr__(self): return '' % (id(self), self.ares) def _on_fork(self): # NOTE: See comment in gevent.hub.reinit. pid = os.getpid() if pid != self.pid: self.hub.loop.run_callback(self.ares.destroy) self.ares = self.ares_class(self.hub.loop, **self.params) self.pid = pid def close(self): if self.ares is not None: self.hub.loop.run_callback(self.ares.destroy) self.ares = None self.fork_watcher.stop() def gethostbyname(self, hostname, family=AF_INET): hostname = _resolve_special(hostname, family) return self.gethostbyname_ex(hostname, family)[-1][0] def gethostbyname_ex(self, hostname, family=AF_INET): if PY3: if isinstance(hostname, str): hostname = hostname.encode('idna') elif not isinstance(hostname, (bytes, bytearray)): raise TypeError('Expected es(idna), not %s' % type(hostname).__name__) else: if isinstance(hostname, text_type): hostname = hostname.encode('ascii') elif not isinstance(hostname, str): raise TypeError('Expected string, not %s' % type(hostname).__name__) while True: ares = self.ares try: waiter = Waiter(self.hub) ares.gethostbyname(waiter, hostname, family) result = waiter.get() if not result[-1]: raise gaierror(-5, 'No address associated with hostname') return result except gaierror: if ares is self.ares: raise # "self.ares is not ares" means channel was destroyed (because we were forked) def _lookup_port(self, port, socktype): socktypes = [] if isinstance(port, string_types): try: port = int(port) except ValueError: try: if socktype == 0: origport = port try: port = getservbyname(port, 'tcp') socktypes.append(SOCK_STREAM) except error: port = getservbyname(port, 'udp') socktypes.append(SOCK_DGRAM) else: try: if port == getservbyname(origport, 'udp'): socktypes.append(SOCK_DGRAM) except error: pass elif socktype == SOCK_STREAM: port = getservbyname(port, 'tcp') elif socktype == SOCK_DGRAM: port = getservbyname(port, 'udp') else: raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype') except error as ex: if 'not found' in str(ex): raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype') else: raise gaierror(str(ex)) except UnicodeEncodeError: raise error('Int or String expected') elif port is None: port = 0 elif isinstance(port, integer_types): pass else: raise error('Int or String expected', port, type(port)) port = int(port % 65536) if not socktypes and socktype: socktypes.append(socktype) return port, socktypes def _getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0): if isinstance(host, text_type): host = host.encode('idna') elif not isinstance(host, str) or (flags & AI_NUMERICHOST): # this handles cases which do not require network access # 1) host is None # 2) host is of an invalid type # 3) AI_NUMERICHOST flag is set return getaddrinfo(host, port, family, socktype, proto, flags) # we also call _socket.getaddrinfo below if family is not one of AF_* port, socktypes = self._lookup_port(port, socktype) socktype_proto = [(SOCK_STREAM, 6), (SOCK_DGRAM, 17), (SOCK_RAW, 0)] if socktypes: socktype_proto = [(x, y) for (x, y) in socktype_proto if x in socktypes] if proto: socktype_proto = [(x, y) for (x, y) in socktype_proto if proto == y] ares = self.ares if family == AF_UNSPEC: values = Values(self.hub, 2) ares.gethostbyname(values, host, AF_INET) ares.gethostbyname(values, host, AF_INET6) elif family == AF_INET: values = Values(self.hub, 1) ares.gethostbyname(values, host, AF_INET) elif family == AF_INET6: values = Values(self.hub, 1) ares.gethostbyname(values, host, AF_INET6) else: raise gaierror(5, 'ai_family not supported: %r' % (family, )) values = values.get() if len(values) == 2 and values[0] == values[1]: values.pop() result = [] result4 = [] result6 = [] for addrs in values: if addrs.family == AF_INET: for addr in addrs[-1]: sockaddr = (addr, port) for socktype, proto in socktype_proto: result4.append((AF_INET, socktype, proto, '', sockaddr)) elif addrs.family == AF_INET6: for addr in addrs[-1]: if addr == '::1': dest = result else: dest = result6 sockaddr = (addr, port, 0, 0) for socktype, proto in socktype_proto: dest.append((AF_INET6, socktype, proto, '', sockaddr)) result += result4 + result6 if not result: raise gaierror(-5, 'No address associated with hostname') return result def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0): while True: ares = self.ares try: return self._getaddrinfo(host, port, family, socktype, proto, flags) except gaierror: if ares is self.ares: raise def _gethostbyaddr(self, ip_address): if PY3: if isinstance(ip_address, str): ip_address = ip_address.encode('idna') elif not isinstance(ip_address, (bytes, bytearray)): raise TypeError('Expected es(idna), not %s' % type(ip_address).__name__) else: if isinstance(ip_address, text_type): ip_address = ip_address.encode('ascii') elif not isinstance(ip_address, str): raise TypeError('Expected string, not %s' % type(ip_address).__name__) waiter = Waiter(self.hub) try: self.ares.gethostbyaddr(waiter, ip_address) return waiter.get() except InvalidIP: result = self._getaddrinfo(ip_address, None, family=AF_UNSPEC, socktype=SOCK_DGRAM) if not result: raise _ip_address = result[0][-1][0] if isinstance(_ip_address, text_type): _ip_address = _ip_address.encode('ascii') if _ip_address == ip_address: raise waiter.clear() self.ares.gethostbyaddr(waiter, _ip_address) return waiter.get() def gethostbyaddr(self, ip_address): ip_address = _resolve_special(ip_address, AF_UNSPEC) while True: ares = self.ares try: return self._gethostbyaddr(ip_address) except gaierror: if ares is self.ares: raise def _getnameinfo(self, sockaddr, flags): if not isinstance(flags, int): raise TypeError('an integer is required') if not isinstance(sockaddr, tuple): raise TypeError('getnameinfo() argument 1 must be a tuple') address = sockaddr[0] if not PY3 and isinstance(address, text_type): address = address.encode('ascii') if not isinstance(address, string_types): raise TypeError('sockaddr[0] must be a string, not %s' % type(address).__name__) port = sockaddr[1] if not isinstance(port, int): raise TypeError('port must be an integer, not %s' % type(port)) waiter = Waiter(self.hub) result = self._getaddrinfo(address, str(sockaddr[1]), family=AF_UNSPEC, socktype=SOCK_DGRAM) if not result: reraise(*sys.exc_info()) elif len(result) != 1: raise error('sockaddr resolved to multiple addresses') family, socktype, proto, name, address = result[0] if family == AF_INET: if len(sockaddr) != 2: raise error("IPv4 sockaddr must be 2 tuple") elif family == AF_INET6: address = address[:2] + sockaddr[2:] self.ares.getnameinfo(waiter, address, flags) node, service = waiter.get() if service is None: service = '0' return node, service def getnameinfo(self, sockaddr, flags): while True: ares = self.ares try: return self._getnameinfo(sockaddr, flags) except gaierror: if ares is self.ares: raise class Values(object): # helper to collect multiple values; ignore errors unless nothing has succeeded # QQQ could probably be moved somewhere - hub.py? __slots__ = ['count', 'values', 'error', 'waiter'] def __init__(self, hub, count): self.count = count self.values = [] self.error = None self.waiter = Waiter(hub) def __call__(self, source): self.count -= 1 if source.exception is None: self.values.append(source.value) else: self.error = source.exception if self.count <= 0: self.waiter.switch() def get(self): self.waiter.get() if self.values: return self.values else: raise self.error def _resolve_special(hostname, family): if hostname == '': result = getaddrinfo(None, 0, family, SOCK_DGRAM, 0, AI_PASSIVE) if len(result) != 1: raise error('wildcard resolved to multiple address') return result[0][4][0] return hostname gevent-1.1.0/gevent/resolver_thread.py0000644000076500000000000000470412666555342020576 0ustar jmaddenwheel00000000000000# Copyright (c) 2012-2015 Denis Bilenko. See LICENSE for details. """ Native thread-based hostname resolver. """ import _socket from gevent.hub import get_hub, text_type __all__ = ['Resolver'] # trigger import of encodings.idna to avoid https://github.com/gevent/gevent/issues/349 text_type('foo').encode('idna') class Resolver(object): """ Implementation of the resolver API using native threads and native resolution functions. Using the native resolution mechanisms ensures the highest compatibility with what a non-gevent program would return including good support for platform specific configuration mechanisms. The use of native (non-greenlet) threads ensures that a caller doesn't block other greenlets. This implementation also has the benefit of being very simple in comparison to :class:`gevent.resolver_ares.Resolver`. .. tip:: Most users find this resolver to be quite reliable in a properly monkey-patched environment. However, there have been some reports of long delays, slow performance or even hangs, particularly in long-lived programs that make many, many DNS requests. If you suspect that may be happening to you, try the ares resolver (and submit a bug report). """ def __init__(self, hub=None): if hub is None: hub = get_hub() self.pool = hub.threadpool if _socket.gaierror not in hub.NOT_ERROR: # Do not cause lookup failures to get printed by the default # error handler. This can be very noisy. hub.NOT_ERROR += (_socket.gaierror, _socket.herror) def __repr__(self): return '' % (id(self), self.pool) def close(self): pass # from briefly reading socketmodule.c, it seems that all of the functions # below are thread-safe in Python, even if they are not thread-safe in C. def gethostbyname(self, *args): return self.pool.apply(_socket.gethostbyname, args) def gethostbyname_ex(self, *args): return self.pool.apply(_socket.gethostbyname_ex, args) def getaddrinfo(self, *args, **kwargs): return self.pool.apply(_socket.getaddrinfo, args, kwargs) def gethostbyaddr(self, *args, **kwargs): return self.pool.apply(_socket.gethostbyaddr, args, kwargs) def getnameinfo(self, *args, **kwargs): return self.pool.apply(_socket.getnameinfo, args, kwargs) gevent-1.1.0/gevent/select.py0000644000076500000000000000744612666555342016673 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details. """ Waiting for I/O completion. """ from __future__ import absolute_import from gevent.event import Event from gevent.hub import get_hub from gevent.hub import integer_types try: from select import poll as original_poll from select import POLLIN, POLLOUT __implements__ = ['select', 'poll'] except ImportError: original_poll = None __implements__ = ['select'] __all__ = ['error'] + __implements__ import select as __select__ error = __select__.error def get_fileno(obj): try: fileno_f = obj.fileno except AttributeError: if not isinstance(obj, integer_types): raise TypeError('argument must be an int, or have a fileno() method: %r' % (obj,)) return obj else: return fileno_f() class SelectResult(object): __slots__ = ['read', 'write', 'event'] def __init__(self): self.read = [] self.write = [] self.event = Event() def add_read(self, socket): self.read.append(socket) self.event.set() def add_write(self, socket): self.write.append(socket) self.event.set() def select(rlist, wlist, xlist, timeout=None): """An implementation of :meth:`select.select` that blocks only the current greenlet. Note: *xlist* is ignored. """ watchers = [] loop = get_hub().loop io = loop.io MAXPRI = loop.MAXPRI result = SelectResult() try: try: for readfd in rlist: watcher = io(get_fileno(readfd), 1) watcher.priority = MAXPRI watcher.start(result.add_read, readfd) watchers.append(watcher) for writefd in wlist: watcher = io(get_fileno(writefd), 2) watcher.priority = MAXPRI watcher.start(result.add_write, writefd) watchers.append(watcher) except IOError as ex: raise error(*ex.args) result.event.wait(timeout=timeout) return result.read, result.write, [] finally: for watcher in watchers: watcher.stop() if original_poll is not None: class PollResult(object): __slots__ = ['events', 'event'] def __init__(self): self.events = set() self.event = Event() def add_event(self, events, fd): result_flags = 0 result_flags |= POLLIN if events & 1 else 0 result_flags |= POLLOUT if events & 2 else 0 self.events.add((fd, result_flags)) self.event.set() class poll(object): """ An implementation of :class:`select.poll` that blocks only the current greenlet. .. versionadded:: 1.1b1 """ def __init__(self): self.fds = {} self.loop = get_hub().loop def register(self, fd, eventmask=POLLIN | POLLOUT): flags = 0 flags |= 1 if eventmask & POLLIN else 0 flags |= 2 if eventmask & POLLOUT else 0 watcher = self.loop.io(get_fileno(fd), flags) watcher.priority = self.loop.MAXPRI self.fds[fd] = watcher def modify(self, fd, eventmask): self.register(fd, eventmask) def poll(self, timeout=None): result = PollResult() try: for fd in self.fds: self.fds[fd].start(result.add_event, get_fileno(fd), pass_events=True) if timeout is not None and -1 < timeout: timeout /= 1000.0 result.event.wait(timeout=timeout) return list(result.events) finally: for fd in self.fds: self.fds[fd].stop() def unregister(self, fd): self.fds.pop(fd, None) gevent-1.1.0/gevent/server.py0000644000076500000000000001513412666555342016713 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. """TCP/SSL server""" import sys import _socket from gevent.baseserver import BaseServer from gevent.socket import EWOULDBLOCK, socket from gevent.hub import PYPY, PY3 __all__ = ['StreamServer', 'DatagramServer'] if sys.platform == 'win32': # SO_REUSEADDR on Windows does not mean the same thing as on *nix (issue #217) DEFAULT_REUSE_ADDR = None else: DEFAULT_REUSE_ADDR = 1 class StreamServer(BaseServer): """A generic TCP server. Accepts connections on a listening socket and spawns user-provided *handle* for each connection with 2 arguments: the client socket and the client address. If any of the following keyword arguments are present, then the server assumes SSL mode and uses these arguments to create an SSL wrapper for the client socket before passing it to *handle*: - keyfile - certfile - cert_reqs - ssl_version - ca_certs - suppress_ragged_eofs - do_handshake_on_connect - ciphers Note that although the errors in a successfully spawned handler will not affect the server or other connections, the errors raised by :func:`accept` and *spawn* cause the server to stop accepting for a short amount of time. The exact period depends on the values of :attr:`min_delay` and :attr:`max_delay` attributes. The delay starts with :attr:`min_delay` and doubles with each successive error until it reaches :attr:`max_delay`. A successful :func:`accept` resets the delay to :attr:`min_delay` again. See :class:`BaseServer` for information on defining the *handle* function and important restrictions on it. """ # the default backlog to use if none was provided in __init__ backlog = 256 reuse_addr = DEFAULT_REUSE_ADDR def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args): BaseServer.__init__(self, listener, handle=handle, spawn=spawn) try: if ssl_args: ssl_args.setdefault('server_side', True) from gevent.ssl import wrap_socket self.wrap_socket = wrap_socket self.ssl_args = ssl_args else: self.ssl_args = None if backlog is not None: if hasattr(self, 'socket'): raise TypeError('backlog must be None when a socket instance is passed') self.backlog = backlog except: self.close() raise @property def ssl_enabled(self): return self.ssl_args is not None def set_listener(self, listener): BaseServer.set_listener(self, listener) try: self.socket = self.socket._sock except AttributeError: pass def init_socket(self): if not hasattr(self, 'socket'): self.socket = self.get_listener(self.address, self.backlog, self.family) self.address = self.socket.getsockname() if self.ssl_args: self._handle = self.wrap_socket_and_handle else: self._handle = self.handle @classmethod def get_listener(self, address, backlog=None, family=None): if backlog is None: backlog = self.backlog return _tcp_listener(address, backlog=backlog, reuse_addr=self.reuse_addr, family=family) if PY3: def do_read(self): sock = self.socket try: fd, address = sock._accept() except BlockingIOError: if not sock.timeout: return raise sock = socket(sock.family, sock.type, sock.proto, fileno=fd) # XXX Python issue #7995? return sock, address else: def do_read(self): try: client_socket, address = self.socket.accept() except _socket.error as err: if err.args[0] == EWOULDBLOCK: return raise sockobj = socket(_sock=client_socket) if PYPY: client_socket._drop() return sockobj, address def do_close(self, socket, *args): socket.close() def wrap_socket_and_handle(self, client_socket, address): # used in case of ssl sockets ssl_socket = self.wrap_socket(client_socket, **self.ssl_args) return self.handle(ssl_socket, address) class DatagramServer(BaseServer): """A UDP server""" reuse_addr = DEFAULT_REUSE_ADDR def __init__(self, *args, **kwargs): BaseServer.__init__(self, *args, **kwargs) from gevent.lock import Semaphore self._writelock = Semaphore() def init_socket(self): if not hasattr(self, 'socket'): self.socket = self.get_listener(self.address, self.family) self.address = self.socket.getsockname() self._socket = self.socket try: self._socket = self._socket._sock except AttributeError: pass @classmethod def get_listener(self, address, family=None): return _udp_socket(address, reuse_addr=self.reuse_addr, family=family) def do_read(self): try: data, address = self._socket.recvfrom(8192) except _socket.error as err: if err.args[0] == EWOULDBLOCK: return raise return data, address def sendto(self, *args): self._writelock.acquire() try: self.socket.sendto(*args) finally: self._writelock.release() def _tcp_listener(address, backlog=50, reuse_addr=None, family=_socket.AF_INET): """A shortcut to create a TCP socket, bind it and put it into listening state.""" sock = socket(family=family) if reuse_addr is not None: sock.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, reuse_addr) try: sock.bind(address) except _socket.error as ex: strerror = getattr(ex, 'strerror', None) if strerror is not None: ex.strerror = strerror + ': ' + repr(address) raise sock.listen(backlog) sock.setblocking(0) return sock def _udp_socket(address, backlog=50, reuse_addr=None, family=_socket.AF_INET): # we want gevent.socket.socket here sock = socket(family=family, type=_socket.SOCK_DGRAM) if reuse_addr is not None: sock.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, reuse_addr) try: sock.bind(address) except _socket.error as ex: strerror = getattr(ex, 'strerror', None) if strerror is not None: ex.strerror = strerror + ': ' + repr(address) raise return sock gevent-1.1.0/gevent/signal.py0000644000076500000000000000773112666555342016666 0ustar jmaddenwheel00000000000000""" Cooperative implementation of special cases of :func:`signal.signal`. This module is designed to work with libev's child watchers, as used by default in :func:`gevent.os.fork` Note that each ``SIGCHLD`` handler will be run in a new greenlet when the signal is delivered (just like :class:`gevent.hub.signal`) The implementations in this module are only monkey patched if :func:`gevent.os.waitpid` is being used (the default) and if :const:`signal.SIGCHLD` is available; see :func:`gevent.os.fork` for information on configuring this not to be the case for advanced uses. .. versionadded:: 1.1b4 """ from __future__ import absolute_import import signal as _signal __implements__ = [] __extensions__ = [] _INITIAL = object() _child_handler = _INITIAL _signal_signal = _signal.signal _signal_getsignal = _signal.getsignal def getsignal(signalnum): """ Exactly the same as :func:`signal.signal` except where :const:`signal.SIGCHLD` is concerned. """ if signalnum != _signal.SIGCHLD: return _signal_getsignal(signalnum) global _child_handler if _child_handler is _INITIAL: _child_handler = _signal_getsignal(_signal.SIGCHLD) return _child_handler def signal(signalnum, handler): """ Exactly the same as :func:`signal.signal` except where :const:`signal.SIGCHLD` is concerned. .. note:: A :const:`signal.SIGCHLD` handler installed with this function will only be triggered for children that are forked using :func:`gevent.os.fork` (:func:`gevent.os.fork_and_watch`); children forked before monkey patching, or otherwise by the raw :func:`os.fork`, will not trigger the handler installed by this function. (It's unlikely that a SIGCHLD handler installed with the builtin :func:`signal.signal` would be triggered either; libev typically overwrites such a handler at the C level. At the very least, it's full of race conditions.) .. note:: Use of ``SIG_IGN`` and ``SIG_DFL`` may also have race conditions with libev child watchers and the :mod:`gevent.subprocess` module. .. versionchanged:: 1.1rc2 Allow using ``SIG_IGN`` and ``SIG_DFL`` to reset and ignore ``SIGCHLD``. However, this allows the possibility of a race condition. """ if signalnum != _signal.SIGCHLD: return _signal_signal(signalnum, handler) # TODO: raise value error if not called from the main # greenlet, just like threads if handler != _signal.SIG_IGN and handler != _signal.SIG_DFL and not callable(handler): # exact same error message raised by the stdlib raise TypeError("signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object") old_handler = getsignal(signalnum) global _child_handler _child_handler = handler if handler == _signal.SIG_IGN or handler == _signal.SIG_DFL: # Allow resetting/ignoring this signal at the process level. # Note that this conflicts with gevent.subprocess and other users # of child watchers. _signal_signal(signalnum, handler) return old_handler def _on_child_hook(): # This is called in the hub greenlet. To let the function # do more useful work, like use blocking functions, # we run it in a new greenlet; see gevent.hub.signal if callable(_child_handler): # None is a valid value for the frame argument from gevent import Greenlet greenlet = Greenlet(_child_handler, _signal.SIGCHLD, None) greenlet.switch() import gevent.os if 'waitpid' in gevent.os.__implements__ and hasattr(_signal, 'SIGCHLD'): # Tightly coupled here to gevent.os and its waitpid implementation; only use these # if necessary. gevent.os._on_child_hook = _on_child_hook __implements__.append("signal") __implements__.append("getsignal") else: # XXX: This breaks test__all__ on windows __extensions__.append("signal") __extensions__.append("getsignal") __all__ = __implements__ + __extensions__ gevent-1.1.0/gevent/socket.py0000644000076500000000000000726412666555342016702 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. """Cooperative low-level networking interface. This module provides socket operations and some related functions. The API of the functions and classes matches the API of the corresponding items in the standard :mod:`socket` module exactly, but the synchronous functions in this module only block the current greenlet and let the others run. For convenience, exceptions (like :class:`error ` and :class:`timeout `) as well as the constants from the :mod:`socket` module are imported into this module. """ import sys from gevent.hub import PY3 if PY3: from gevent import _socket3 as _source else: from gevent import _socket2 as _source for key in _source.__dict__: if key.startswith('__') and key not in '__implements__ __dns__ __all__ __extensions__ __imports__ __socket__'.split(): continue globals()[key] = getattr(_source, key) # The _socket2 and _socket3 don't import things defined in # __extensions__, to help avoid confusing reference cycles in the # documentation and to prevent importing from the wrong place, but we # *do* need to expose them here. (NOTE: This may lead to some sphinx # warnings like: # WARNING: missing attribute mentioned in :members: or __all__: # module gevent._socket2, attribute cancel_wait # These can be ignored.) from gevent import _socketcommon for key in _socketcommon.__extensions__: globals()[key] = getattr(_socketcommon, key) del key try: _GLOBAL_DEFAULT_TIMEOUT = __socket__._GLOBAL_DEFAULT_TIMEOUT except AttributeError: _GLOBAL_DEFAULT_TIMEOUT = object() def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None): """Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the optional *timeout* parameter will set the timeout on the socket instance before attempting to connect. If no *timeout* is supplied, the global default timeout setting returned by :func:`getdefaulttimeout` is used. If *source_address* is set it must be a tuple of (host, port) for the socket to bind as a source address before making the connection. A host of '' or port 0 tells the OS to use the default. """ host, port = address err = None for res in getaddrinfo(host, port, 0 if has_ipv6 else AF_INET, SOCK_STREAM): af, socktype, proto, _canonname, sa = res sock = None try: sock = socket(af, socktype, proto) if timeout is not _GLOBAL_DEFAULT_TIMEOUT: sock.settimeout(timeout) if source_address: sock.bind(source_address) sock.connect(sa) return sock except error as ex: # without exc_clear(), if connect() fails once, the socket is referenced by the frame in exc_info # and the next bind() fails (see test__socket.TestCreateConnection) # that does not happen with regular sockets though, because _socket.socket.connect() is a built-in. # this is similar to "getnameinfo loses a reference" failure in test_socket.py if not PY3: sys.exc_clear() if sock is not None: sock.close() err = ex if err is not None: raise err else: raise error("getaddrinfo returns an empty list") # This is promised to be in the __all__ of the _source, but, for circularity reasons, # we implement it in this module. Mostly for documentation purposes, put it # in the _source too. _source.create_connection = create_connection gevent-1.1.0/gevent/ssl.py0000644000076500000000000000135712666555342016210 0ustar jmaddenwheel00000000000000""" Secure Sockets Layer (SSL/TLS) module. """ from gevent.hub import PY2 if PY2: if hasattr(__import__('ssl'), 'SSLContext'): # It's not sufficient to check for >= 2.7.9; some distributions # have backported most of PEP 466. Try to accommodate them. See Issue #702. # We're just about to import ssl anyway so it's fine to import it here, just # don't pollute the namespace from gevent import _sslgte279 as _source else: from gevent import _ssl2 as _source else: # Py3 from gevent import _ssl3 as _source for key in _source.__dict__: if key.startswith('__') and key not in '__implements__ __all__ __imports__'.split(): continue globals()[key] = getattr(_source, key) gevent-1.1.0/gevent/stathelper.c0000644000076500000000000001163112666555342017350 0ustar jmaddenwheel00000000000000/* copied from Python-2.7.2/Modules/posixmodule.c */ #include "structseq.h" #define STRUCT_STAT struct stat #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE #define ST_BLKSIZE_IDX 13 #else #define ST_BLKSIZE_IDX 12 #endif #ifdef HAVE_STRUCT_STAT_ST_BLOCKS #define ST_BLOCKS_IDX (ST_BLKSIZE_IDX+1) #else #define ST_BLOCKS_IDX ST_BLKSIZE_IDX #endif #ifdef HAVE_STRUCT_STAT_ST_RDEV #define ST_RDEV_IDX (ST_BLOCKS_IDX+1) #else #define ST_RDEV_IDX ST_BLOCKS_IDX #endif #ifdef HAVE_STRUCT_STAT_ST_FLAGS #define ST_FLAGS_IDX (ST_RDEV_IDX+1) #else #define ST_FLAGS_IDX ST_RDEV_IDX #endif #ifdef HAVE_STRUCT_STAT_ST_GEN #define ST_GEN_IDX (ST_FLAGS_IDX+1) #else #define ST_GEN_IDX ST_FLAGS_IDX #endif #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME #define ST_BIRTHTIME_IDX (ST_GEN_IDX+1) #else #define ST_BIRTHTIME_IDX ST_GEN_IDX #endif static PyObject* posixmodule = NULL; static PyTypeObject* pStatResultType = NULL; static PyObject* import_posixmodule(void) { if (!posixmodule) { posixmodule = PyImport_ImportModule("posix"); } return posixmodule; } static PyObject* import_StatResultType(void) { PyObject* p = NULL; if (!pStatResultType) { PyObject* module; module = import_posixmodule(); if (module) { p = PyObject_GetAttrString(module, "stat_result"); } } return p; } static void fill_time(PyObject *v, int index, time_t sec, unsigned long nsec) { PyObject *fval,*ival; #if SIZEOF_TIME_T > SIZEOF_LONG ival = PyLong_FromLongLong((PY_LONG_LONG)sec); #else ival = PyInt_FromLong((long)sec); #endif if (!ival) return; fval = PyFloat_FromDouble(sec + 1e-9*nsec); PyStructSequence_SET_ITEM(v, index, ival); PyStructSequence_SET_ITEM(v, index+3, fval); } /* pack a system stat C structure into the Python stat tuple (used by posix_stat() and posix_fstat()) */ static PyObject* _pystat_fromstructstat(STRUCT_STAT *st) { unsigned long ansec, mnsec, cnsec; PyObject *v; PyTypeObject* StatResultType = (PyTypeObject*)import_StatResultType(); if (StatResultType == NULL) { return NULL; } v = PyStructSequence_New(StatResultType); if (v == NULL) return NULL; PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st->st_mode)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 1, PyLong_FromLongLong((PY_LONG_LONG)st->st_ino)); #else PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino)); #endif #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev)); #endif PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink)); PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid)); PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 6, PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); #else PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st->st_size)); #endif #if defined(HAVE_STAT_TV_NSEC) ansec = st->st_atim.tv_nsec; mnsec = st->st_mtim.tv_nsec; cnsec = st->st_ctim.tv_nsec; #elif defined(HAVE_STAT_TV_NSEC2) ansec = st->st_atimespec.tv_nsec; mnsec = st->st_mtimespec.tv_nsec; cnsec = st->st_ctimespec.tv_nsec; #elif defined(HAVE_STAT_NSEC) ansec = st->st_atime_nsec; mnsec = st->st_mtime_nsec; cnsec = st->st_ctime_nsec; #else ansec = mnsec = cnsec = 0; #endif fill_time(v, 7, st->st_atime, ansec); fill_time(v, 8, st->st_mtime, mnsec); fill_time(v, 9, st->st_ctime, cnsec); #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX, PyInt_FromLong((long)st->st_blksize)); #endif #ifdef HAVE_STRUCT_STAT_ST_BLOCKS PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX, PyInt_FromLong((long)st->st_blocks)); #endif #ifdef HAVE_STRUCT_STAT_ST_RDEV PyStructSequence_SET_ITEM(v, ST_RDEV_IDX, PyInt_FromLong((long)st->st_rdev)); #endif #ifdef HAVE_STRUCT_STAT_ST_GEN PyStructSequence_SET_ITEM(v, ST_GEN_IDX, PyInt_FromLong((long)st->st_gen)); #endif #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME { PyObject *val; unsigned long bsec,bnsec; bsec = (long)st->st_birthtime; #ifdef HAVE_STAT_TV_NSEC2 bnsec = st->st_birthtimespec.tv_nsec; #else bnsec = 0; #endif val = PyFloat_FromDouble(bsec + 1e-9*bnsec); PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX, val); } #endif #ifdef HAVE_STRUCT_STAT_ST_FLAGS PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX, PyInt_FromLong((long)st->st_flags)); #endif if (PyErr_Occurred()) { Py_DECREF(v); return NULL; } return v; } gevent-1.1.0/gevent/subprocess.py0000644000076500000000000014572512666555342017607 0ustar jmaddenwheel00000000000000""" Cooperative ``subprocess`` module. .. caution:: On POSIX platforms, this module is not usable from native threads other than the main thread; attempting to do so will raise a :exc:`TypeError`. This module depends on libev's fork watchers. On POSIX systems, fork watchers are implemented using signals, and the thread to which process-directed signals are delivered `is not defined`_. Because each native thread has its own gevent/libev loop, this means that a fork watcher registered with one loop (thread) may never see the signal about a child it spawned if the signal is sent to a different thread. .. note:: The interface of this module is intended to match that of the standard library :mod:`subprocess` module. There are some small differences between the Python 2 and Python 3 versions of that module and between the POSIX and Windows versions. The HTML documentation here can only describe one version; for definitive documentation, see the standard library or the source code. .. _is not defined: http://www.linuxprogrammingblog.com/all-about-linux-signals?page=11 """ from __future__ import absolute_import, print_function import errno import gc import io import os import signal import sys import traceback from gevent.event import AsyncResult from gevent.hub import get_hub, linkproxy, sleep, getcurrent, integer_types, string_types, xrange from gevent.hub import PY3 from gevent.hub import reraise from gevent.fileobject import FileObject from gevent.greenlet import Greenlet, joinall spawn = Greenlet.spawn import subprocess as __subprocess__ # Standard functions and classes that this module re-implements in a gevent-aware way. __implements__ = [ 'Popen', 'call', 'check_call', 'check_output', ] if PY3 and not sys.platform.startswith('win32'): __implements__.append("_posixsubprocess") _posixsubprocess = None # Standard functions and classes that this module re-imports. __imports__ = [ 'PIPE', 'STDOUT', 'CalledProcessError', # Windows: 'CREATE_NEW_CONSOLE', 'CREATE_NEW_PROCESS_GROUP', 'STD_INPUT_HANDLE', 'STD_OUTPUT_HANDLE', 'STD_ERROR_HANDLE', 'SW_HIDE', 'STARTF_USESTDHANDLES', 'STARTF_USESHOWWINDOW', ] __extra__ = [ 'MAXFD', '_eintr_retry_call', 'STARTUPINFO', 'pywintypes', 'list2cmdline', '_subprocess', '_winapi', # Python 2.5 does not have _subprocess, so we don't use it # XXX We don't run on Py 2.5 anymore; can/could/should we use _subprocess? 'WAIT_OBJECT_0', 'WaitForSingleObject', 'GetExitCodeProcess', 'GetStdHandle', 'CreatePipe', 'DuplicateHandle', 'GetCurrentProcess', 'DUPLICATE_SAME_ACCESS', 'GetModuleFileName', 'GetVersion', 'CreateProcess', 'INFINITE', 'TerminateProcess', ] if sys.version_info[:2] >= (3, 3): __imports__ += [ 'DEVNULL', 'getstatusoutput', 'getoutput', 'SubprocessError', 'TimeoutExpired', ] if sys.version_info[:2] >= (3, 5): __imports__ += [ 'run', # in 3.5, `run` is implemented in terms of `with Popen` 'CompletedProcess', ] # Removed in Python 3.5; this is the exact code that was removed: # https://hg.python.org/cpython/rev/f98b0a5e5ef5 __extra__.remove('MAXFD') try: MAXFD = os.sysconf("SC_OPEN_MAX") except: MAXFD = 256 for name in __imports__[:]: try: value = getattr(__subprocess__, name) globals()[name] = value except AttributeError: __imports__.remove(name) __extra__.append(name) if sys.version_info[:2] <= (2, 6): __implements__.remove('check_output') __extra__.append('check_output') # In Python 3 on Windows, a lot of the functions previously # in _subprocess moved to _winapi _NONE = object() _subprocess = getattr(__subprocess__, '_subprocess', _NONE) _winapi = getattr(__subprocess__, '_winapi', _NONE) _attr_resolution_order = [__subprocess__, _subprocess, _winapi] for name in list(__extra__): if name in globals(): continue value = _NONE for place in _attr_resolution_order: value = getattr(place, name, _NONE) if value is not _NONE: break if value is _NONE: __extra__.remove(name) else: globals()[name] = value del _attr_resolution_order __all__ = __implements__ + __imports__ mswindows = sys.platform == 'win32' if mswindows: import msvcrt if PY3: class Handle(int): closed = False def Close(self): if not self.closed: self.closed = True _winapi.CloseHandle(self) def Detach(self): if not self.closed: self.closed = True return int(self) raise ValueError("already closed") def __repr__(self): return "Handle(%d)" % int(self) __del__ = Close __str__ = __repr__ else: import fcntl import pickle from gevent import monkey fork = monkey.get_original('os', 'fork') from gevent.os import fork_and_watch if PY3: def call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete or timeout, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example:: retcode = call(["ls", "-l"]) """ timeout = kwargs.pop('timeout', None) with Popen(*popenargs, **kwargs) as p: try: return p.wait(timeout=timeout) except: p.kill() p.wait() raise else: def call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example:: retcode = call(["ls", "-l"]) """ return Popen(*popenargs, **kwargs).wait() def check_call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise :exc:`CalledProcessError`. The ``CalledProcessError`` object will have the return code in the returncode attribute. The arguments are the same as for the Popen constructor. Example:: retcode = check_call(["ls", "-l"]) """ retcode = call(*popenargs, **kwargs) if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] raise CalledProcessError(retcode, cmd) return 0 if PY3: def check_output(*popenargs, **kwargs): r"""Run command with arguments and return its output. If the exit code was non-zero it raises a :exc:`CalledProcessError`. The ``CalledProcessError`` object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example:: >>> check_output(["ls", "-1", "/dev/null"]) b'/dev/null\n' The ``stdout`` argument is not allowed as it is used internally. To capture standard error in the result, use ``stderr=STDOUT``:: >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) b'ls: non_existent_file: No such file or directory\n' There is an additional optional argument, "input", allowing you to pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it too will be used internally. Example:: >>> check_output(["sed", "-e", "s/foo/bar/"], ... input=b"when in the course of fooman events\n") b'when in the course of barman events\n' If ``universal_newlines=True`` is passed, the return value will be a string rather than bytes. """ timeout = kwargs.pop('timeout', None) if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') if 'input' in kwargs: if 'stdin' in kwargs: raise ValueError('stdin and input arguments may not both be used.') inputdata = kwargs['input'] del kwargs['input'] kwargs['stdin'] = PIPE else: inputdata = None with Popen(*popenargs, stdout=PIPE, **kwargs) as process: try: output, unused_err = process.communicate(inputdata, timeout=timeout) except TimeoutExpired: process.kill() output, unused_err = process.communicate() raise TimeoutExpired(process.args, timeout, output=output) except: process.kill() process.wait() raise retcode = process.poll() if retcode: raise CalledProcessError(retcode, process.args, output=output) return output else: def check_output(*popenargs, **kwargs): r"""Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> print(check_output(["ls", "-1", "/dev/null"]).decode('ascii')) /dev/null The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT. >>> print(check_output(["/bin/sh", "-c", "echo hello world"], stderr=STDOUT).decode('ascii')) hello world """ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') process = Popen(stdout=PIPE, *popenargs, **kwargs) output = process.communicate()[0] retcode = process.poll() if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] ex = CalledProcessError(retcode, cmd) # on Python 2.6 and older CalledProcessError does not accept 'output' argument ex.output = output raise ex return output _PLATFORM_DEFAULT_CLOSE_FDS = object() class Popen(object): """ The underlying process creation and management in this module is handled by the Popen class. It offers a lot of flexibility so that developers are able to handle the less common cases not covered by the convenience functions. .. seealso:: :class:`subprocess.Popen` This class should have the same interface as the standard library class. """ def __init__(self, args, bufsize=None, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, threadpool=None, **kwargs): """Create new Popen instance. :param kwargs: *Only* allowed under Python 3; under Python 2, any unrecognized keyword arguments will result in a :exc:`TypeError`. Under Python 3, keyword arguments can include ``pass_fds``, ``start_new_session``, and ``restore_signals``. """ if not PY3 and kwargs: raise TypeError("Got unexpected keyword arguments", kwargs) pass_fds = kwargs.pop('pass_fds', ()) start_new_session = kwargs.pop('start_new_session', False) restore_signals = kwargs.pop('restore_signals', True) hub = get_hub() if bufsize is None: # bufsize has different defaults on Py3 and Py2 if PY3: bufsize = -1 else: bufsize = 0 if not isinstance(bufsize, integer_types): raise TypeError("bufsize must be an integer") if mswindows: if preexec_fn is not None: raise ValueError("preexec_fn is not supported on Windows " "platforms") any_stdio_set = (stdin is not None or stdout is not None or stderr is not None) if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: if any_stdio_set: close_fds = False else: close_fds = True elif close_fds and any_stdio_set: raise ValueError("close_fds is not supported on Windows " "platforms if you redirect stdin/stdout/stderr") if threadpool is None: threadpool = hub.threadpool self.threadpool = threadpool self._waiting = False else: # POSIX if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: # close_fds has different defaults on Py3/Py2 if PY3: close_fds = True else: close_fds = False if pass_fds and not close_fds: import warnings warnings.warn("pass_fds overriding close_fds.", RuntimeWarning) close_fds = True if startupinfo is not None: raise ValueError("startupinfo is only supported on Windows " "platforms") if creationflags != 0: raise ValueError("creationflags is only supported on Windows " "platforms") assert threadpool is None self._loop = hub.loop if PY3: self.args = args self.stdin = None self.stdout = None self.stderr = None self.pid = None self.returncode = None self.universal_newlines = universal_newlines self.result = AsyncResult() # Input and output objects. The general principle is like # this: # # Parent Child # ------ ----- # p2cwrite ---stdin---> p2cread # c2pread <--stdout--- c2pwrite # errread <--stderr--- errwrite # # On POSIX, the child objects are file descriptors. On # Windows, these are Windows file handles. The parent objects # are file descriptors on both platforms. The parent objects # are None when not using PIPEs. The child objects are None # when not redirecting. (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) = self._get_handles(stdin, stdout, stderr) # We wrap OS handles *before* launching the child, otherwise a # quickly terminating child could make our fds unwrappable # (see #8458). if mswindows: if p2cwrite is not None: p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) if c2pread is not None: c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) if errread is not None: errread = msvcrt.open_osfhandle(errread.Detach(), 0) if p2cwrite is not None: if PY3 and universal_newlines: # Under Python 3, if we left on the 'b' we'd get different results # depending on whether we used FileObjectPosix or FileObjectThread self.stdin = FileObject(p2cwrite, 'wb', bufsize) self.stdin._translate = True self.stdin.io = io.TextIOWrapper(self.stdin.io, write_through=True, line_buffering=(bufsize == 1)) else: self.stdin = FileObject(p2cwrite, 'wb', bufsize) if c2pread is not None: if universal_newlines: if PY3: # FileObjectThread doesn't support the 'U' qualifier # with a bufsize of 0 self.stdout = FileObject(c2pread, 'rb', bufsize) # NOTE: Universal Newlines are broken on Windows/Py3, at least # in some cases. This is true in the stdlib subprocess module # as well; the following line would fix the test cases in # test__subprocess.py that depend on python_universal_newlines, # but would be inconsistent with the stdlib: #msvcrt.setmode(self.stdout.fileno(), os.O_TEXT) self.stdout.io = io.TextIOWrapper(self.stdout.io) self.stdout.io.mode = 'r' self.stdout._translate = True else: self.stdout = FileObject(c2pread, 'rU', bufsize) else: self.stdout = FileObject(c2pread, 'rb', bufsize) if errread is not None: if universal_newlines: if PY3: self.stderr = FileObject(errread, 'rb', bufsize) self.stderr.io = io.TextIOWrapper(self.stderr.io) self.stderr._translate = True else: self.stderr = FileObject(errread, 'rU', bufsize) else: self.stderr = FileObject(errread, 'rb', bufsize) self._closed_child_pipe_fds = False try: self._execute_child(args, executable, preexec_fn, close_fds, pass_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) except: # Cleanup if the child failed starting. # (gevent: New in python3, but reported as gevent bug in #347. # Note that under Py2, any error raised below will replace the # original error so we have to use reraise) if not PY3: exc_info = sys.exc_info() for f in filter(None, (self.stdin, self.stdout, self.stderr)): try: f.close() except (OSError, IOError): pass # Ignore EBADF or other errors. if not self._closed_child_pipe_fds: to_close = [] if stdin == PIPE: to_close.append(p2cread) if stdout == PIPE: to_close.append(c2pwrite) if stderr == PIPE: to_close.append(errwrite) if hasattr(self, '_devnull'): to_close.append(self._devnull) for fd in to_close: try: os.close(fd) except (OSError, IOError): pass if not PY3: try: reraise(*exc_info) finally: del exc_info raise def __repr__(self): return '<%s at 0x%x pid=%r returncode=%r>' % (self.__class__.__name__, id(self), self.pid, self.returncode) def _on_child(self, watcher): watcher.stop() status = watcher.rstatus if os.WIFSIGNALED(status): self.returncode = -os.WTERMSIG(status) else: self.returncode = os.WEXITSTATUS(status) self.result.set(self.returncode) def _get_devnull(self): if not hasattr(self, '_devnull'): self._devnull = os.open(os.devnull, os.O_RDWR) return self._devnull _stdout_buffer = None _stderr_buffer = None def communicate(self, input=None, timeout=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. communicate() returns a tuple (stdout, stderr). :keyword timeout: Under Python 2, this is a gevent extension; if given and it expires, we will raise :class:`gevent.timeout.Timeout`. Under Python 3, this raises the standard :exc:`TimeoutExpired` exception. .. versionchanged:: 1.1a2 Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout` exception. Previously, we silently returned. .. versionchanged:: 1.1b5 Honor a *timeout* even if there's no way to communicate with the child (stdin, stdout, and stderr are not pipes). """ greenlets = [] if self.stdin: greenlets.append(spawn(write_and_close, self.stdin, input)) # If the timeout parameter is used, and the caller calls back after # getting a TimeoutExpired exception, we can wind up with multiple # greenlets trying to run and read from and close stdout/stderr. # That's bad because it can lead to 'RuntimeError: reentrant call in io.BufferedReader'. # We can't just kill the previous greenlets when a timeout happens, # though, because we risk losing the output collected by that greenlet # (and Python 3, where timeout is an official parameter, explicitly says # that no output should be lost in the event of a timeout.) Instead, we're # watching for the exception and ignoring it. It's not elegant, # but it works if self.stdout: def _read_out(): try: data = self.stdout.read() except RuntimeError: return if self._stdout_buffer is not None: self._stdout_buffer += data else: self._stdout_buffer = data stdout = spawn(_read_out) greenlets.append(stdout) else: stdout = None if self.stderr: def _read_err(): try: data = self.stderr.read() except RuntimeError: return if self._stderr_buffer is not None: self._stderr_buffer += data else: self._stderr_buffer = data stderr = spawn(_read_err) greenlets.append(stderr) else: stderr = None # If we were given stdin=stdout=stderr=None, we have no way to # communicate with the child, and thus no greenlets to wait # on. This is a nonsense case, but it comes up in the test # case for Python 3.5 (test_subprocess.py # RunFuncTestCase.test_timeout). Instead, we go directly to # self.wait if not greenlets and timeout is not None: result = self.wait(timeout=timeout) # Python 3 would have already raised, but Python 2 would not # so we need to do that manually if result is None: from gevent.timeout import Timeout raise Timeout(timeout) done = joinall(greenlets, timeout=timeout) if timeout is not None and len(done) != len(greenlets): if PY3: raise TimeoutExpired(self.args, timeout) from gevent.timeout import Timeout raise Timeout(timeout) if self.stdout: try: self.stdout.close() except RuntimeError: pass if self.stderr: try: self.stderr.close() except RuntimeError: pass self.wait() stdout_value = self._stdout_buffer self._stdout_buffer = None stderr_value = self._stderr_buffer self._stderr_buffer = None # XXX: Under python 3 in universal newlines mode we should be # returning str, not bytes return (None if stdout is None else stdout_value or b'', None if stderr is None else stderr_value or b'') def poll(self): """Check if child process has terminated. Set and return :attr:`returncode` attribute.""" return self._internal_poll() if PY3: def __enter__(self): return self def __exit__(self, type, value, traceback): if self.stdout: self.stdout.close() if self.stderr: self.stderr.close() try: # Flushing a BufferedWriter may raise an error if self.stdin: self.stdin.close() finally: # Wait for the process to terminate, to avoid zombies. # JAM: gevent: If the process never terminates, this # blocks forever. self.wait() if mswindows: # # Windows methods # def _get_handles(self, stdin, stdout, stderr): """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin is None and stdout is None and stderr is None: return (None, None, None, None, None, None) p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None try: DEVNULL except NameError: _devnull = object() else: _devnull = DEVNULL if stdin is None: p2cread = GetStdHandle(STD_INPUT_HANDLE) if p2cread is None: p2cread, _ = CreatePipe(None, 0) if PY3: p2cread = Handle(p2cread) _winapi.CloseHandle(_) elif stdin == PIPE: p2cread, p2cwrite = CreatePipe(None, 0) if PY3: p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite) elif stdin == _devnull: p2cread = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stdin, int): p2cread = msvcrt.get_osfhandle(stdin) else: # Assuming file-like object p2cread = msvcrt.get_osfhandle(stdin.fileno()) p2cread = self._make_inheritable(p2cread) if stdout is None: c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE) if c2pwrite is None: _, c2pwrite = CreatePipe(None, 0) if PY3: c2pwrite = Handle(c2pwrite) _winapi.CloseHandle(_) elif stdout == PIPE: c2pread, c2pwrite = CreatePipe(None, 0) if PY3: c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite) elif stdout == _devnull: c2pwrite = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stdout, int): c2pwrite = msvcrt.get_osfhandle(stdout) else: # Assuming file-like object c2pwrite = msvcrt.get_osfhandle(stdout.fileno()) c2pwrite = self._make_inheritable(c2pwrite) if stderr is None: errwrite = GetStdHandle(STD_ERROR_HANDLE) if errwrite is None: _, errwrite = CreatePipe(None, 0) if PY3: errwrite = Handle(errwrite) _winapi.CloseHandle(_) elif stderr == PIPE: errread, errwrite = CreatePipe(None, 0) if PY3: errread, errwrite = Handle(errread), Handle(errwrite) elif stderr == STDOUT: errwrite = c2pwrite elif stderr == _devnull: errwrite = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stderr, int): errwrite = msvcrt.get_osfhandle(stderr) else: # Assuming file-like object errwrite = msvcrt.get_osfhandle(stderr.fileno()) errwrite = self._make_inheritable(errwrite) return (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) def _make_inheritable(self, handle): """Return a duplicate of handle, which is inheritable""" return DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), 0, 1, DUPLICATE_SAME_ACCESS) def _find_w9xpopen(self): """Find and return absolute path to w9xpopen.exe""" w9xpopen = os.path.join(os.path.dirname(GetModuleFileName(0)), "w9xpopen.exe") if not os.path.exists(w9xpopen): # Eeek - file-not-found - possibly an embedding # situation - see if we can locate it in sys.exec_prefix w9xpopen = os.path.join(os.path.dirname(sys.exec_prefix), "w9xpopen.exe") if not os.path.exists(w9xpopen): raise RuntimeError("Cannot locate w9xpopen.exe, which is " "needed for Popen to work with your " "shell or platform.") return w9xpopen def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" assert not pass_fds, "pass_fds not supported on Windows." if not isinstance(args, string_types): args = list2cmdline(args) # Process startup details if startupinfo is None: startupinfo = STARTUPINFO() if None not in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite if shell: startupinfo.dwFlags |= STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") args = '{} /c "{}"'.format(comspec, args) if GetVersion() >= 0x80000000 or os.path.basename(comspec).lower() == "command.com": # Win9x, or using command.com on NT. We need to # use the w9xpopen intermediate program. For more # information, see KB Q150956 # (http://web.archive.org/web/20011105084002/http://support.microsoft.com/support/kb/articles/Q150/9/56.asp) w9xpopen = self._find_w9xpopen() args = '"%s" %s' % (w9xpopen, args) # Not passing CREATE_NEW_CONSOLE has been known to # cause random failures on win9x. Specifically a # dialog: "Your program accessed mem currently in # use at xxx" and a hopeful warning about the # stability of your system. Cost is Ctrl+C wont # kill children. creationflags |= CREATE_NEW_CONSOLE # Start the process try: hp, ht, pid, tid = CreateProcess(executable, args, # no special security None, None, int(not close_fds), creationflags, env, cwd, startupinfo) except IOError as e: # From 2.6 on, pywintypes.error was defined as IOError # Translate pywintypes.error to WindowsError, which is # a subclass of OSError. FIXME: We should really # translate errno using _sys_errlist (or similar), but # how can this be done from Python? if PY3: raise # don't remap here raise WindowsError(*e.args) finally: # Child is launched. Close the parent's copy of those pipe # handles that only the child should have open. You need # to make sure that no handles to the write end of the # output pipe are maintained in this process or else the # pipe will not close when the child process exits and the # ReadFile will hang. def _close(x): if x is not None and x != -1: if hasattr(x, 'Close'): x.Close() else: _winapi.CloseHandle(x) _close(p2cread) _close(c2pwrite) _close(errwrite) if hasattr(self, '_devnull'): os.close(self._devnull) # Retain the process handle, but close the thread handle self._child_created = True self._handle = Handle(hp) if not hasattr(hp, 'Close') else hp self.pid = pid _winapi.CloseHandle(ht) if not hasattr(ht, 'Close') else ht.Close() def _internal_poll(self): """Check if child process has terminated. Returns returncode attribute. """ if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) self.result.set(self.returncode) return self.returncode def rawlink(self, callback): if not self.result.ready() and not self._waiting: self._waiting = True Greenlet.spawn(self._wait) self.result.rawlink(linkproxy(callback, self)) # XXX unlink def _blocking_wait(self): WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) return self.returncode def _wait(self): self.threadpool.spawn(self._blocking_wait).rawlink(self.result) def wait(self, timeout=None): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: if not self._waiting: self._waiting = True self._wait() result = self.result.wait(timeout=timeout) if PY3 and timeout is not None and not self.result.ready(): raise TimeoutExpired(self.args, timeout) return result def send_signal(self, sig): """Send a signal to the process """ if sig == signal.SIGTERM: self.terminate() elif sig == signal.CTRL_C_EVENT: os.kill(self.pid, signal.CTRL_C_EVENT) elif sig == signal.CTRL_BREAK_EVENT: os.kill(self.pid, signal.CTRL_BREAK_EVENT) else: raise ValueError("Unsupported signal: {}".format(sig)) def terminate(self): """Terminates the process """ TerminateProcess(self._handle, 1) kill = terminate else: # # POSIX methods # def rawlink(self, callback): # Not public documented, part of the link protocol self.result.rawlink(linkproxy(callback, self)) # XXX unlink def _get_handles(self, stdin, stdout, stderr): """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None try: DEVNULL except NameError: _devnull = object() else: _devnull = DEVNULL if stdin is None: pass elif stdin == PIPE: p2cread, p2cwrite = self.pipe_cloexec() elif stdin == _devnull: p2cread = self._get_devnull() elif isinstance(stdin, int): p2cread = stdin else: # Assuming file-like object p2cread = stdin.fileno() if stdout is None: pass elif stdout == PIPE: c2pread, c2pwrite = self.pipe_cloexec() elif stdout == _devnull: c2pwrite = self._get_devnull() elif isinstance(stdout, int): c2pwrite = stdout else: # Assuming file-like object c2pwrite = stdout.fileno() if stderr is None: pass elif stderr == PIPE: errread, errwrite = self.pipe_cloexec() elif stderr == STDOUT: errwrite = c2pwrite elif stderr == _devnull: errwrite = self._get_devnull() elif isinstance(stderr, int): errwrite = stderr else: # Assuming file-like object errwrite = stderr.fileno() return (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) def _set_cloexec_flag(self, fd, cloexec=True): try: cloexec_flag = fcntl.FD_CLOEXEC except AttributeError: cloexec_flag = 1 old = fcntl.fcntl(fd, fcntl.F_GETFD) if cloexec: fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag) else: fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag) def _remove_nonblock_flag(self, fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) & (~os.O_NONBLOCK) fcntl.fcntl(fd, fcntl.F_SETFL, flags) def pipe_cloexec(self): """Create a pipe with FDs set CLOEXEC.""" # Pipes' FDs are set CLOEXEC by default because we don't want them # to be inherited by other subprocesses: the CLOEXEC flag is removed # from the child's FDs by _dup2(), between fork() and exec(). # This is not atomic: we would need the pipe2() syscall for that. r, w = os.pipe() self._set_cloexec_flag(r) self._set_cloexec_flag(w) return r, w def _close_fds(self, keep): # `keep` is a set of fds, so we # use os.closerange from 3 to min(keep) # and then from max(keep + 1) to MAXFD and # loop through filling in the gaps. # Under new python versions, we need to explicitly set # passed fds to be inheritable or they will go away on exec if hasattr(os, 'set_inheritable'): set_inheritable = os.set_inheritable else: set_inheritable = lambda i, v: True if hasattr(os, 'closerange'): keep = sorted(keep) min_keep = min(keep) max_keep = max(keep) os.closerange(3, min_keep) os.closerange(max_keep + 1, MAXFD) for i in xrange(min_keep, max_keep): if i in keep: set_inheritable(i, True) continue try: os.close(i) except: pass else: for i in xrange(3, MAXFD): if i in keep: set_inheritable(i, True) continue try: os.close(i) except: pass def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session): """Execute program (POSIX version)""" if PY3 and isinstance(args, (str, bytes)): args = [args] elif not PY3 and isinstance(args, string_types): args = [args] else: args = list(args) if shell: args = ["/bin/sh", "-c"] + args if executable: args[0] = executable if executable is None: executable = args[0] self._loop.install_sigchld() # For transferring possible exec failure from child to parent # The first char specifies the exception type: 0 means # OSError, 1 means some other error. errpipe_read, errpipe_write = self.pipe_cloexec() # errpipe_write must not be in the standard io 0, 1, or 2 fd range. low_fds_to_close = [] while errpipe_write < 3: low_fds_to_close.append(errpipe_write) errpipe_write = os.dup(errpipe_write) for low_fd in low_fds_to_close: os.close(low_fd) try: try: gc_was_enabled = gc.isenabled() # Disable gc to avoid bug where gc -> file_dealloc -> # write to stderr -> hang. http://bugs.python.org/issue1336 gc.disable() try: self.pid = fork_and_watch(self._on_child, self._loop, True, fork) except: if gc_was_enabled: gc.enable() raise if self.pid == 0: # Child try: # Close parent's pipe ends if p2cwrite is not None: os.close(p2cwrite) if c2pread is not None: os.close(c2pread) if errread is not None: os.close(errread) os.close(errpipe_read) # When duping fds, if there arises a situation # where one of the fds is either 0, 1 or 2, it # is possible that it is overwritten (#12607). if c2pwrite == 0: c2pwrite = os.dup(c2pwrite) if errwrite == 0 or errwrite == 1: errwrite = os.dup(errwrite) # Dup fds for child def _dup2(a, b): # dup2() removes the CLOEXEC flag but # we must do it ourselves if dup2() # would be a no-op (issue #10806). if a == b: self._set_cloexec_flag(a, False) elif a is not None: os.dup2(a, b) self._remove_nonblock_flag(b) _dup2(p2cread, 0) _dup2(c2pwrite, 1) _dup2(errwrite, 2) # Close pipe fds. Make sure we don't close the # same fd more than once, or standard fds. closed = set([None]) for fd in [p2cread, c2pwrite, errwrite]: if fd not in closed and fd > 2: os.close(fd) closed.add(fd) if cwd is not None: os.chdir(cwd) if preexec_fn: preexec_fn() # Close all other fds, if asked for. This must be done # after preexec_fn runs. if close_fds: fds_to_keep = set(pass_fds) fds_to_keep.add(errpipe_write) self._close_fds(fds_to_keep) elif hasattr(os, 'get_inheritable'): # close_fds was false, and we're on # Python 3.4 or newer, so "all file # descriptors except standard streams # are closed, and inheritable handles # are only inherited if the close_fds # parameter is False." for i in xrange(3, MAXFD): try: if i == errpipe_write or os.get_inheritable(i): continue os.close(i) except: pass if restore_signals: # restore the documented signals back to sig_dfl; # not all will be defined on every platform for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ': sig = getattr(signal, sig, None) if sig is not None: signal.signal(sig, signal.SIG_DFL) if start_new_session: os.setsid() if env is None: os.execvp(executable, args) else: os.execvpe(executable, args, env) except: exc_type, exc_value, tb = sys.exc_info() # Save the traceback and attach it to the exception object exc_lines = traceback.format_exception(exc_type, exc_value, tb) exc_value.child_traceback = ''.join(exc_lines) os.write(errpipe_write, pickle.dumps(exc_value)) finally: # Make sure that the process exits no matter what. # The return code does not matter much as it won't be # reported to the application os._exit(1) # Parent self._child_created = True if gc_was_enabled: gc.enable() finally: # be sure the FD is closed no matter what os.close(errpipe_write) # self._devnull is not always defined. devnull_fd = getattr(self, '_devnull', None) if p2cread is not None and p2cwrite is not None and p2cread != devnull_fd: os.close(p2cread) if c2pwrite is not None and c2pread is not None and c2pwrite != devnull_fd: os.close(c2pwrite) if errwrite is not None and errread is not None and errwrite != devnull_fd: os.close(errwrite) if devnull_fd is not None: os.close(devnull_fd) # Prevent a double close of these fds from __init__ on error. self._closed_child_pipe_fds = True # Wait for exec to fail or succeed; possibly raising exception errpipe_read = FileObject(errpipe_read, 'rb') data = errpipe_read.read() finally: if hasattr(errpipe_read, 'close'): errpipe_read.close() else: os.close(errpipe_read) if data != b"": self.wait() child_exception = pickle.loads(data) for fd in (p2cwrite, c2pread, errread): if fd is not None: os.close(fd) raise child_exception def _handle_exitstatus(self, sts): if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) elif os.WIFEXITED(sts): self.returncode = os.WEXITSTATUS(sts) else: # Should never happen raise RuntimeError("Unknown child exit status!") def _internal_poll(self): """Check if child process has terminated. Returns returncode attribute. """ if self.returncode is None: if get_hub() is not getcurrent(): sig_pending = getattr(self._loop, 'sig_pending', True) if sig_pending: sleep(0.00001) return self.returncode def wait(self, timeout=None): """Wait for child process to terminate. Returns :attr:`returncode` attribute. :keyword timeout: The floating point number of seconds to wait. Under Python 2, this is a gevent extension, and we simply return if it expires. Under Python 3, if this time elapses without finishing the process, :exc:`TimeoutExpired` is raised.""" result = self.result.wait(timeout=timeout) if PY3 and timeout is not None and not self.result.ready(): raise TimeoutExpired(self.args, timeout) return result def send_signal(self, sig): """Send a signal to the process """ os.kill(self.pid, sig) def terminate(self): """Terminate the process with SIGTERM """ self.send_signal(signal.SIGTERM) def kill(self): """Kill the process with SIGKILL """ self.send_signal(signal.SIGKILL) def write_and_close(fobj, data): try: if data: fobj.write(data) except (OSError, IOError) as ex: if ex.errno != errno.EPIPE and ex.errno != errno.EINVAL: raise finally: try: fobj.close() except EnvironmentError: pass gevent-1.1.0/gevent/thread.py0000644000076500000000000000626412666555342016660 0ustar jmaddenwheel00000000000000"""Implementation of the standard :mod:`thread` module that spawns greenlets. .. note:: This module is a helper for :mod:`gevent.monkey` and is not intended to be used directly. For spawning greenlets in your applications, prefer :class:`Greenlet` class. """ from __future__ import absolute_import import sys __implements__ = ['allocate_lock', 'get_ident', 'exit', 'LockType', 'stack_size', 'start_new_thread', '_local'] __imports__ = ['error'] if sys.version_info[0] <= 2: import thread as __thread__ else: import _thread as __thread__ __target__ = '_thread' __imports__ += ['RLock', 'TIMEOUT_MAX', 'allocate', 'exit_thread', 'interrupt_main', 'start_new'] error = __thread__.error from gevent.hub import getcurrent, GreenletExit, PY3 from gevent.greenlet import Greenlet from gevent.lock import BoundedSemaphore from gevent.local import local as _local def get_ident(gr=None): if gr is None: return id(getcurrent()) else: return id(gr) def start_new_thread(function, args=(), kwargs={}): greenlet = Greenlet.spawn(function, *args, **kwargs) return get_ident(greenlet) class LockType(BoundedSemaphore): # Change the ValueError into the appropriate thread error # and any other API changes we need to make to match behaviour _OVER_RELEASE_ERROR = __thread__.error if PY3: _TIMEOUT_MAX = __thread__.TIMEOUT_MAX def acquire(self, blocking=True, timeout=-1): # Transform the default -1 argument into the None that our # semaphore implementation expects, and raise the same error # the stdlib implementation does. if timeout == -1: timeout = None if not blocking and timeout is not None: raise ValueError("can't specify a timeout for a non-blocking call") if timeout is not None: if timeout < 0: # in C: if(timeout < 0 && timeout != -1) raise ValueError("timeout value must be strictly positive") if timeout > self._TIMEOUT_MAX: raise OverflowError('timeout value is too large') return BoundedSemaphore.acquire(self, blocking, timeout) allocate_lock = LockType def exit(): raise GreenletExit if hasattr(__thread__, 'stack_size'): _original_stack_size = __thread__.stack_size def stack_size(size=None): if size is None: return _original_stack_size() if size > _original_stack_size(): return _original_stack_size(size) else: pass # not going to decrease stack_size, because otherwise other greenlets in this thread will suffer else: __implements__.remove('stack_size') for name in __imports__[:]: try: value = getattr(__thread__, name) globals()[name] = value except AttributeError: __imports__.remove(name) __all__ = __implements__ + __imports__ __all__.remove('_local') # XXX interrupt_main # XXX _count() gevent-1.1.0/gevent/threading.py0000644000076500000000000001506112666555342017351 0ustar jmaddenwheel00000000000000from __future__ import absolute_import __implements__ = ['local', '_start_new_thread', '_allocate_lock', 'Lock', '_get_ident', '_sleep', '_DummyThread'] import threading as __threading__ _DummyThread_ = __threading__._DummyThread from gevent.local import local from gevent.thread import start_new_thread as _start_new_thread, allocate_lock as _allocate_lock, get_ident as _get_ident from gevent.hub import sleep as _sleep, getcurrent, PYPY Lock = _allocate_lock def _cleanup(g): __threading__._active.pop(id(g), None) class _DummyThread(_DummyThread_): # We avoid calling the superclass constructor. This makes us about # twice as fast (1.16 vs 0.68usec on PyPy, 29.3 vs 17.7usec on # CPython 2.7), and has the important effect of avoiding # allocation and then immediate deletion of _Thread__block, a # lock. This is especially important on PyPy where locks go # through the cpyext API and Cython, which is known to be slow and # potentially buggy (e.g., # https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22347393) # These objects are constructed quite frequently in some cases, so # the optimization matters: for example, in gunicorn, which uses # pywsgi.WSGIServer, every request is handled in a new greenlet, # and every request uses a logging.Logger to write the access log, # and every call to a log method captures the current thread (by # default). # # (Obviously we have to duplicate the effects of the constructor, # at least for external state purposes, which is potentially # slightly fragile.) # For the same reason, instances of this class will cleanup their own entry # in ``threading._active`` # Capture the static things as class vars to save on memory/ # construction time. # In Py2, they're all private; in Py3, they become protected _Thread__stopped = _is_stopped = _stopped = False _Thread__initialized = _initialized = True _Thread__daemonic = _daemonic = True _Thread__args = _args = () _Thread__kwargs = _kwargs = None _Thread__target = _target = None _Thread_ident = _ident = None _Thread__started = _started = __threading__.Event() _Thread__started.set() _tstate_lock = None def __init__(self): #_DummyThread_.__init__(self) # It'd be nice to use a pattern like "greenlet-%d", but maybe somebody out # there is checking thread names... self._name = self._Thread__name = __threading__._newname("DummyThread-%d") self._set_ident() __threading__._active[_get_ident()] = self g = getcurrent() rawlink = getattr(g, 'rawlink', None) if rawlink is not None: rawlink(_cleanup) def _Thread__stop(self): pass _stop = _Thread__stop # py3 def _wait_for_tstate_lock(self, *args, **kwargs): pass # Make sure the MainThread can be found by our current greenlet ID, # otherwise we get a new DummyThread, which cannot be joined. # Fixes tests in test_threading_2 under PyPy, and generally makes things nicer # when gevent.threading is imported before monkey patching or not at all # XXX: This assumes that the import is happening in the "main" greenlet if _get_ident() not in __threading__._active and len(__threading__._active) == 1: k, v = next(iter(__threading__._active.items())) del __threading__._active[k] v._Thread__ident = _get_ident() __threading__._active[_get_ident()] = v del k del v # Avoid printing an error on shutdown trying to remove the thread entry # we just replaced if we're not fully monkey patched in # XXX: This causes a hang on PyPy for some unknown reason (as soon as class _active # defines __delitem__, shutdown hangs. Maybe due to something with the GC? # XXX: This may be fixed in 2.6.1+ if not PYPY: _MAIN_THREAD = __threading__._get_ident() if hasattr(__threading__, '_get_ident') else __threading__.get_ident() class _active(dict): def __delitem__(self, k): if k == _MAIN_THREAD and k not in self: return dict.__delitem__(self, k) __threading__._active = _active(__threading__._active) import sys if sys.version_info[:2] >= (3, 4): # XXX: Issue 18808 breaks us on Python 3.4. # Thread objects now expect a callback from the interpreter itself # (threadmodule.c:release_sentinel). Because this never happens # when a greenlet exits, join() and friends will block forever. # The solution below involves capturing the greenlet when it is # started and deferring the known broken methods to it. class Thread(__threading__.Thread): _greenlet = None def is_alive(self): return bool(self._greenlet) isAlive = is_alive def _set_tstate_lock(self): self._greenlet = getcurrent() def run(self): try: super(Thread, self).run() finally: # avoid ref cycles, but keep in __dict__ so we can # distinguish the started/never-started case self._greenlet = None self._stop() # mark as finished def join(self, timeout=None): if '_greenlet' not in self.__dict__: raise RuntimeError("Cannot join an inactive thread") if self._greenlet is None: return self._greenlet.join(timeout=timeout) def _wait_for_tstate_lock(self, *args, **kwargs): raise NotImplementedError() __implements__.append('Thread') # The main thread is patched up with more care in monkey.py #t = __threading__.current_thread() #if isinstance(t, __threading__.Thread): # t.__class__ = Thread # t._greenlet = getcurrent() if sys.version_info[:2] >= (3, 3): __implements__.remove('_get_ident') __implements__.append('get_ident') get_ident = _get_ident __implements__.remove('_sleep') # Python 3 changed the implementation of threading.RLock # Previously it was a factory function around threading._RLock # which in turn used _allocate_lock. Now, it wants to use # threading._CRLock, which is imported from _thread.RLock and as such # is implemented in C. So it bypasses our _allocate_lock function. # Fortunately they left the Python fallback in place assert hasattr(__threading__, '_CRLock'), "Unsupported Python version" _CRLock = None __implements__.append('_CRLock') gevent-1.1.0/gevent/threadpool.py0000644000076500000000000002630712666555342017552 0ustar jmaddenwheel00000000000000# Copyright (c) 2012 Denis Bilenko. See LICENSE for details. from __future__ import absolute_import import sys import os from gevent.hub import get_hub, getcurrent, sleep, integer_types from gevent.event import AsyncResult from gevent.greenlet import Greenlet from gevent.pool import GroupMappingMixin from gevent.lock import Semaphore from gevent._threading import Lock, Queue, start_new_thread __all__ = ['ThreadPool', 'ThreadResult'] class ThreadPool(GroupMappingMixin): """ .. note:: The method :meth:`apply_async` will always return a new greenlet, bypassing the threadpool entirely. """ def __init__(self, maxsize, hub=None): if hub is None: hub = get_hub() self.hub = hub self._maxsize = 0 self.manager = None self.pid = os.getpid() self.fork_watcher = hub.loop.fork(ref=False) self._init(maxsize) def _set_maxsize(self, maxsize): if not isinstance(maxsize, integer_types): raise TypeError('maxsize must be integer: %r' % (maxsize, )) if maxsize < 0: raise ValueError('maxsize must not be negative: %r' % (maxsize, )) difference = maxsize - self._maxsize self._semaphore.counter += difference self._maxsize = maxsize self.adjust() # make sure all currently blocking spawn() start unlocking if maxsize increased self._semaphore._start_notify() def _get_maxsize(self): return self._maxsize maxsize = property(_get_maxsize, _set_maxsize) def __repr__(self): return '<%s at 0x%x %s/%s/%s>' % (self.__class__.__name__, id(self), len(self), self.size, self.maxsize) def __len__(self): # XXX just do unfinished_tasks property return self.task_queue.unfinished_tasks def _get_size(self): return self._size def _set_size(self, size): if size < 0: raise ValueError('Size of the pool cannot be negative: %r' % (size, )) if size > self._maxsize: raise ValueError('Size of the pool cannot be bigger than maxsize: %r > %r' % (size, self._maxsize)) if self.manager: self.manager.kill() while self._size < size: self._add_thread() delay = 0.0001 while self._size > size: while self._size - size > self.task_queue.unfinished_tasks: self.task_queue.put(None) if getcurrent() is self.hub: break sleep(delay) delay = min(delay * 2, .05) if self._size: self.fork_watcher.start(self._on_fork) else: self.fork_watcher.stop() size = property(_get_size, _set_size) def _init(self, maxsize): self._size = 0 self._semaphore = Semaphore(1) self._lock = Lock() self.task_queue = Queue() self._set_maxsize(maxsize) def _on_fork(self): # fork() only leaves one thread; also screws up locks; # let's re-create locks and threads. # NOTE: See comment in gevent.hub.reinit. pid = os.getpid() if pid != self.pid: self.pid = pid # Do not mix fork() and threads; since fork() only copies one thread # all objects referenced by other threads has refcount that will never # go down to 0. self._init(self._maxsize) def join(self): """Waits until all outstanding tasks have been completed.""" delay = 0.0005 while self.task_queue.unfinished_tasks > 0: sleep(delay) delay = min(delay * 2, .05) def kill(self): self.size = 0 def _adjust_step(self): # if there is a possibility & necessity for adding a thread, do it while self._size < self._maxsize and self.task_queue.unfinished_tasks > self._size: self._add_thread() # while the number of threads is more than maxsize, kill one # we do not check what's already in task_queue - it could be all Nones while self._size - self._maxsize > self.task_queue.unfinished_tasks: self.task_queue.put(None) if self._size: self.fork_watcher.start(self._on_fork) else: self.fork_watcher.stop() def _adjust_wait(self): delay = 0.0001 while True: self._adjust_step() if self._size <= self._maxsize: return sleep(delay) delay = min(delay * 2, .05) def adjust(self): self._adjust_step() if not self.manager and self._size > self._maxsize: # might need to feed more Nones into the pool self.manager = Greenlet.spawn(self._adjust_wait) def _add_thread(self): with self._lock: self._size += 1 try: start_new_thread(self._worker, ()) except: with self._lock: self._size -= 1 raise def spawn(self, func, *args, **kwargs): """ Add a new task to the threadpool that will run ``func(*args, **kwargs)``. Waits until a slot is available. Creates a new thread if necessary. :return: A :class:`gevent.event.AsyncResult`. """ while True: semaphore = self._semaphore semaphore.acquire() if semaphore is self._semaphore: break thread_result = None try: task_queue = self.task_queue result = AsyncResult() # XXX We're calling the semaphore release function in the hub, otherwise # we get LoopExit (why?). Previously it was done with a rawlink on the # AsyncResult and the comment that it is "competing for order with get(); this is not # good, just make ThreadResult release the semaphore before doing anything else" thread_result = ThreadResult(result, hub=self.hub, call_when_ready=semaphore.release) task_queue.put((func, args, kwargs, thread_result)) self.adjust() except: if thread_result is not None: thread_result.destroy() semaphore.release() raise return result def _decrease_size(self): if sys is None: return _lock = getattr(self, '_lock', None) if _lock is not None: with _lock: self._size -= 1 def _worker(self): need_decrease = True try: while True: task_queue = self.task_queue task = task_queue.get() try: if task is None: need_decrease = False self._decrease_size() # we want first to decrease size, then decrease unfinished_tasks # otherwise, _adjust might think there's one more idle thread that # needs to be killed return func, args, kwargs, thread_result = task try: value = func(*args, **kwargs) except: exc_info = getattr(sys, 'exc_info', None) if exc_info is None: return thread_result.handle_error((self, func), exc_info()) else: if sys is None: return thread_result.set(value) del value finally: del func, args, kwargs, thread_result, task finally: if sys is None: return task_queue.task_done() finally: if need_decrease: self._decrease_size() def apply_e(self, expected_errors, function, args=None, kwargs=None): """ .. deprecated:: 1.1a2 Identical to :meth:`apply`; the ``expected_errors`` argument is ignored. """ # Deprecated but never documented. In the past, before # self.apply() allowed all errors to be raised to the caller, # expected_errors allowed a caller to specify a set of errors # they wanted to be raised, through the wrap_errors function. # In practice, it always took the value Exception or # BaseException. return self.apply(function, args, kwargs) def _apply_immediately(self): # If we're being called from a different thread than the one that # created us, e.g., because a worker task is trying to use apply() # recursively, we have no choice but to run the task immediately; # if we try to AsyncResult.get() in the worker thread, it's likely to have # nothing to switch to and lead to a LoopExit. return get_hub() is not self.hub def _apply_async_cb_spawn(self, callback, result): callback(result) def _apply_async_use_greenlet(self): # Always go to Greenlet because our self.spawn uses threads return True class ThreadResult(object): exc_info = () _call_when_ready = None def __init__(self, receiver, hub=None, call_when_ready=None): if hub is None: hub = get_hub() self.receiver = receiver self.hub = hub self.value = None self.context = None self.async = hub.loop.async() self.async.start(self._on_async) if call_when_ready: self._call_when_ready = call_when_ready @property def exception(self): return self.exc_info[1] if self.exc_info else None def _on_async(self): self.async.stop() if self._call_when_ready: # Typically this is pool.semaphore.release and we have to # call this in the Hub; if we don't we get the dreaded # LoopExit (XXX: Why?) self._call_when_ready() try: if self.exc_info: self.hub.handle_error(self.context, *self.exc_info) self.context = None self.async = None self.hub = None self._call_when_ready = None if self.receiver is not None: self.receiver(self) finally: self.receiver = None self.value = None if self.exc_info: self.exc_info = (self.exc_info[0], self.exc_info[1], None) def destroy(self): if self.async is not None: self.async.stop() self.async = None self.context = None self.hub = None self._call_when_ready = None self.receiver = None def _ready(self): if self.async is not None: self.async.send() def set(self, value): self.value = value self._ready() def handle_error(self, context, exc_info): self.context = context self.exc_info = exc_info self._ready() # link protocol: def successful(self): return self.exception is None def wrap_errors(errors, function, args, kwargs): """ .. deprecated:: 1.1a2 Previously used by ThreadPool.apply_e. """ try: return True, function(*args, **kwargs) except errors as ex: return False, ex gevent-1.1.0/gevent/timeout.py0000644000076500000000000002317012666555342017072 0ustar jmaddenwheel00000000000000# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details. """ Timeouts. Many functions in :mod:`gevent` have a *timeout* argument that allows limiting the time the function will block. When that is not available, the :class:`Timeout` class and :func:`with_timeout` function in this module add timeouts to arbitrary code. .. warning:: Timeouts can only work when the greenlet switches to the hub. If a blocking function is called or an intense calculation is ongoing during which no switches occur, :class:`Timeout` is powerless. """ from gevent.hub import getcurrent, _NONE, get_hub, string_types __all__ = ['Timeout', 'with_timeout'] class _FakeTimer(object): # An object that mimics the API of get_hub().loop.timer, but # without allocating any native resources. This is useful for timeouts # that will never expire. # Also partially mimics the API of Timeout itself for use in _start_new_or_dummy pending = False active = False def start(self, *args, **kwargs): raise AssertionError("non-expiring timer cannot be started") def stop(self): return def cancel(self): return _FakeTimer = _FakeTimer() class Timeout(BaseException): """ Raise *exception* in the current greenlet after given time period:: timeout = Timeout(seconds, exception) timeout.start() try: ... # exception will be raised here, after *seconds* passed since start() call finally: timeout.cancel() .. note:: If the code that the timeout was protecting finishes executing before the timeout elapses, be sure to ``cancel`` the timeout so it is not unexpectedly raised in the future. Even if it is raised, it is a best practice to cancel it. This ``try/finally`` construct or a ``with`` statement is a recommended pattern. When *exception* is omitted or ``None``, the :class:`Timeout` instance itself is raised: >>> import gevent >>> gevent.Timeout(0.1).start() >>> gevent.sleep(0.2) #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... Timeout: 0.1 seconds To simplify starting and canceling timeouts, the ``with`` statement can be used:: with gevent.Timeout(seconds, exception) as timeout: pass # ... code block ... This is equivalent to the try/finally block above with one additional feature: if *exception* is the literal ``False``, the timeout is still raised, but the context manager suppresses it, so the code outside the with-block won't see it. This is handy for adding a timeout to the functions that don't support a *timeout* parameter themselves:: data = None with gevent.Timeout(5, False): data = mysock.makefile().readline() if data is None: ... # 5 seconds passed without reading a line else: ... # a line was read within 5 seconds .. caution:: If ``readline()`` above catches and doesn't re-raise :class:`BaseException` (for example, with a bare ``except:``), then your timeout will fail to function and control won't be returned to you when you expect. When catching timeouts, keep in mind that the one you catch may not be the one you have set (a calling function may have set its own timeout); if you going to silence a timeout, always check that it's the instance you need:: timeout = Timeout(1) timeout.start() try: ... except Timeout as t: if t is not timeout: raise # not my timeout If the *seconds* argument is not given or is ``None`` (e.g., ``Timeout()``), then the timeout will never expire and never raise *exception*. This is convenient for creating functions which take an optional timeout parameter of their own. (Note that this is not the same thing as a *seconds* value of 0.) .. caution:: A *seconds* value less than 0.0 (e.g., -1) is poorly defined. In the future, support for negative values is likely to do the same thing as a value if ``None``. .. versionchanged:: 1.1b2 If *seconds* is not given or is ``None``, no longer allocate a libev timer that will never be started. .. versionchanged:: 1.1 Add warning about negative *seconds* values. """ def __init__(self, seconds=None, exception=None, ref=True, priority=-1): BaseException.__init__(self) self.seconds = seconds self.exception = exception if seconds is None: # Avoid going through the timer codepath if no timeout is # desired; this avoids some CFFI interactions on PyPy that can lead to a # RuntimeError if this implementation is used during an `import` statement. See # https://bitbucket.org/pypy/pypy/issues/2089/crash-in-pypy-260-linux64-with-gevent-11b1 # and https://github.com/gevent/gevent/issues/618. # Plus, in general, it should be more efficient self.timer = _FakeTimer else: self.timer = get_hub().loop.timer(seconds or 0.0, ref=ref, priority=priority) def start(self): """Schedule the timeout.""" assert not self.pending, '%r is already started; to restart it, cancel it first' % self if self.seconds is None: # "fake" timeout (never expires) return if self.exception is None or self.exception is False or isinstance(self.exception, string_types): # timeout that raises self self.timer.start(getcurrent().throw, self) else: # regular timeout with user-provided exception self.timer.start(getcurrent().throw, self.exception) @classmethod def start_new(cls, timeout=None, exception=None, ref=True): """Create a started :class:`Timeout`. This is a shortcut, the exact action depends on *timeout*'s type: * If *timeout* is a :class:`Timeout`, then call its :meth:`start` method if it's not already begun. * Otherwise, create a new :class:`Timeout` instance, passing (*timeout*, *exception*) as arguments, then call its :meth:`start` method. Returns the :class:`Timeout` instance. """ if isinstance(timeout, Timeout): if not timeout.pending: timeout.start() return timeout timeout = cls(timeout, exception, ref=ref) timeout.start() return timeout @staticmethod def _start_new_or_dummy(timeout, exception=None): # Internal use only in 1.1 # Return an object with a 'cancel' method; if timeout is None, # this will be a shared instance object that does nothing. Otherwise, # return an actual Timeout. Because negative values are hard to reason about, # and are often used as sentinels in Python APIs, in the future it's likely # that a negative timeout will also return the shared instance. # This saves the previously common idiom of 'timer = Timeout.start_new(t) if t is not None else None' # followed by 'if timer is not None: timer.cancel()'. # That idiom was used to avoid any object allocations. # A staticmethod is slightly faster under CPython, compared to a classmethod; # under PyPy in synthetic benchmarks it makes no difference. if timeout is None: return _FakeTimer return Timeout.start_new(timeout, exception) @property def pending(self): """Return True if the timeout is scheduled to be raised.""" return self.timer.pending or self.timer.active def cancel(self): """If the timeout is pending, cancel it. Otherwise, do nothing.""" self.timer.stop() def __repr__(self): classname = type(self).__name__ if self.pending: pending = ' pending' else: pending = '' if self.exception is None: exception = '' else: exception = ' exception=%r' % self.exception return '<%s at %s seconds=%s%s%s>' % (classname, hex(id(self)), self.seconds, exception, pending) def __str__(self): """ >>> raise Timeout #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... Timeout """ if self.seconds is None: return '' suffix = '' if self.seconds == 1 else 's' if self.exception is None: return '%s second%s' % (self.seconds, suffix) if self.exception is False: return '%s second%s (silent)' % (self.seconds, suffix) return '%s second%s: %s' % (self.seconds, suffix, self.exception) def __enter__(self): if not self.pending: self.start() return self def __exit__(self, typ, value, tb): self.cancel() if value is self and self.exception is False: return True def with_timeout(seconds, function, *args, **kwds): """Wrap a call to *function* with a timeout; if the called function fails to return before the timeout, cancel it and return a flag value, provided by *timeout_value* keyword argument. If timeout expires but *timeout_value* is not provided, raise :class:`Timeout`. Keyword argument *timeout_value* is not passed to *function*. """ timeout_value = kwds.pop("timeout_value", _NONE) timeout = Timeout.start_new(seconds) try: try: return function(*args, **kwds) except Timeout as ex: if ex is timeout and timeout_value is not _NONE: return timeout_value raise finally: timeout.cancel() gevent-1.1.0/gevent/util.py0000644000076500000000000000341512666555342016361 0ustar jmaddenwheel00000000000000# Copyright (c) 2009 Denis Bilenko. See LICENSE for details. """ Low-level utilities. """ from __future__ import absolute_import import functools __all__ = ['wrap_errors'] class wrap_errors(object): """ Helper to make function return an exception, rather than raise it. Because every exception that is unhandled by greenlet will be logged, it is desirable to prevent non-error exceptions from leaving a greenlet. This can done with a simple ``try/except`` construct:: def wrapped_func(*args, **kwargs): try: return func(*args, **kwargs) except (TypeError, ValueError, AttributeError) as ex: return ex This class provides a shortcut to write that in one line:: wrapped_func = wrap_errors((TypeError, ValueError, AttributeError), func) It also preserves ``__str__`` and ``__repr__`` of the original function. """ # QQQ could also support using wrap_errors as a decorator def __init__(self, errors, func): """ Calling this makes a new function from *func*, such that it catches *errors* (an :exc:`BaseException` subclass, or a tuple of :exc:`BaseException` subclasses) and return it as a value. """ self.__errors = errors self.__func = func # Set __doc__, __wrapped__, etc, especially useful on Python 3. functools.update_wrapper(self, func) def __call__(self, *args, **kwargs): func = self.__func try: return func(*args, **kwargs) except self.__errors as ex: return ex def __str__(self): return str(self.__func) def __repr__(self): return repr(self.__func) def __getattr__(self, name): return getattr(self.__func, name) gevent-1.1.0/gevent/win32util.py0000644000076500000000000000712712666555342017250 0ustar jmaddenwheel00000000000000# Copyright (c) 2001-2007 Twisted Matrix Laboratories. # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """Error formatting function for Windows. The code is taken from twisted.python.win32 module. """ from __future__ import absolute_import import os __all__ = ['formatError'] class _ErrorFormatter(object): """ Formatter for Windows error messages. @ivar winError: A callable which takes one integer error number argument and returns an L{exceptions.WindowsError} instance for that error (like L{ctypes.WinError}). @ivar formatMessage: A callable which takes one integer error number argument and returns a C{str} giving the message for that error (like L{win32api.FormatMessage}). @ivar errorTab: A mapping from integer error numbers to C{str} messages which correspond to those errors (like L{socket.errorTab}). """ def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab def fromEnvironment(cls): """ Get as many of the platform-specific error translation objects as possible and return an instance of C{cls} created with them. """ try: from ctypes import WinError except ImportError: WinError = None try: from win32api import FormatMessage except ImportError: FormatMessage = None try: from socket import errorTab except ImportError: errorTab = None return cls(WinError, FormatMessage, errorTab) fromEnvironment = classmethod(fromEnvironment) def formatError(self, errorcode): """ Returns the string associated with a Windows error message, such as the ones found in socket.error. Attempts direct lookup against the win32 API via ctypes and then pywin32 if available), then in the error table in the socket module, then finally defaulting to C{os.strerror}. @param errorcode: the Windows error code @type errorcode: C{int} @return: The error message string @rtype: C{str} """ if self.winError is not None: return str(self.winError(errorcode)) if self.formatMessage is not None: return self.formatMessage(errorcode) if self.errorTab is not None: result = self.errorTab.get(errorcode) if result is not None: return result return os.strerror(errorcode) formatError = _ErrorFormatter.fromEnvironment().formatError gevent-1.1.0/gevent/wsgi.py0000644000076500000000000000067612666555342016363 0ustar jmaddenwheel00000000000000"""Backwards compatibility alias for :mod:`gevent.pywsgi`. In the past, this used libevent's http support, but that was dropped with the introduction of libev. libevent's http support had several limitations, including not supporting stream, not supporting pipelining, and not supporting SSL. .. deprecated:: 1.1 Use :mod:`gevent.pywsgi` """ from gevent.pywsgi import * import gevent.pywsgi as _pywsgi __all__ = _pywsgi.__all__ del _pywsgi gevent-1.1.0/greentest/0000755000076500000000000000000012666555432015537 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/.coveragerc0000644000076500000000000000140612666555342017661 0ustar jmaddenwheel00000000000000[run] # In coverage 4.0b3, concurrency=gevent is exactly equivalent to # concurrency=greenlet, except it causes coverage itself to import # gevent. That messes up our coverage numbers for top-level # statements, so we use greenlet instead. See https://github.com/gevent/gevent/pull/655#issuecomment-141198002 concurrency = greenlet parallel = True source = gevent omit = test_* [report] # Coverage is run on Linux under cPython 2, so # exclude branches that are windows specific or pypy/python3 # specific exclude_lines = pragma: no cover def __repr__ raise AssertionError raise NotImplementedError except ImportError: if __name__ == .__main__.: if PYPY: if PY3: if sys.platform == 'win32': if mswindows: if sys.version_info.*>=.*3 gevent-1.1.0/greentest/2.6/0000755000076500000000000000000012666555432016044 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.6/badcert.pem0000644000076500000000000000361012666555342020153 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/2.6/badkey.pem0000644000076500000000000000416212666555342020011 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.6/https_svn_python_org_root.pem0000644000076500000000000000501112666555342024107 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/2.6/keycert.pem0000644000076500000000000000336712666555342020226 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/2.6/lock_tests.py0000644000076500000000000003557212666555342020604 0ustar jmaddenwheel00000000000000""" Various tests for synchronization primitives. """ import sys import time from thread import start_new_thread, get_ident import threading import unittest from test import test_support as support def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() for i in range(n): start_new_thread(task, ()) def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children() class BaseLockTests(BaseTestCase): """ Tests for both recursive and non-recursive locks. """ def test_constructor(self): lock = self.locktype() del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) def test_with(self): lock = self.locktype() def f(): lock.acquire() lock.release() def _with(err=None): with lock: if err is not None: raise err _with() # Check the lock is unacquired Bunch(f, 1).wait_for_finished() self.assertRaises(TypeError, _with, TypeError) # Check the lock is unacquired Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. Bunch(f, 15).wait_for_finished() self.assertEqual(n, len(threading.enumerate())) class LockTests(BaseLockTests): """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def test_reacquire(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def test_different_thread(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() class RLockTests(BaseLockTests): """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_different_thread(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) class EventTests(BaseTestCase): """ Tests for Event objects. """ def test_is_set(self): evt = self.eventtype() self.assertFalse(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) def _check_notify(self, evt): # All threads get notified N = 5 results1 = [] results2 = [] def f(): evt.wait() results1.append(evt.is_set()) evt.wait() results2.append(evt.is_set()) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(results1), 0) evt.set() b.wait_for_finished() self.assertEqual(results1, [True] * N) self.assertEqual(results2, [True] * N) def test_notify(self): evt = self.eventtype() self._check_notify(evt) # Another time, after an explicit clear() evt.set() evt.clear() self._check_notify(evt) def test_timeout(self): evt = self.eventtype() results1 = [] results2 = [] N = 5 def f(): evt.wait(0.0) results1.append(evt.is_set()) t1 = time.time() evt.wait(0.2) r = evt.is_set() t2 = time.time() results2.append((r, t2 - t1)) Bunch(f, N).wait_for_finished() self.assertEqual(results1, [False] * N) for r, dt in results2: self.assertFalse(r) self.assertTrue(dt >= 0.2, dt) # The event is set results1 = [] results2 = [] evt.set() Bunch(f, N).wait_for_finished() self.assertEqual(results1, [True] * N) for r, dt in results2: self.assertTrue(r) class ConditionTests(BaseTestCase): """ Tests for condition variables. """ def test_acquire(self): cond = self.condtype() # Be default we have an RLock: the condition can be acquired multiple # times. cond.acquire() cond.acquire() cond.release() cond.release() lock = threading.Lock() cond = self.condtype(lock) cond.acquire() self.assertFalse(lock.acquire(False)) cond.release() self.assertTrue(lock.acquire(False)) self.assertFalse(cond.acquire(False)) lock.release() with cond: self.assertFalse(lock.acquire(False)) def test_unacquired_wait(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.wait) def test_unacquired_notify(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.notify) def _check_notify(self, cond): N = 5 results1 = [] results2 = [] phase_num = 0 def f(): cond.acquire() cond.wait() cond.release() results1.append(phase_num) cond.acquire() cond.wait() cond.release() results2.append(phase_num) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(results1, []) # Notify 3 threads at first cond.acquire() cond.notify(3) _wait() phase_num = 1 cond.release() while len(results1) < 3: _wait() self.assertEqual(results1, [1] * 3) self.assertEqual(results2, []) # Notify 5 threads: they might be in their first or second wait cond.acquire() cond.notify(5) _wait() phase_num = 2 cond.release() while len(results1) + len(results2) < 8: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3) # Notify all threads: they are all in their second wait cond.acquire() cond.notify_all() _wait() phase_num = 3 cond.release() while len(results2) < 5: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3 + [3] * 2) b.wait_for_finished() def test_notify(self): cond = self.condtype() self._check_notify(cond) # A second time, to check internal state is still ok. self._check_notify(cond) def test_timeout(self): cond = self.condtype() results = [] N = 5 def f(): cond.acquire() t1 = time.time() cond.wait(0.2) t2 = time.time() cond.release() results.append(t2 - t1) Bunch(f, N).wait_for_finished() self.assertEqual(len(results), 5) for dt in results: self.assertTrue(dt >= 0.2, dt) class BaseSemaphoreTests(BaseTestCase): """ Common tests for {bounded, unbounded} semaphore objects. """ def test_constructor(self): self.assertRaises(ValueError, self.semtype, value = -1) self.assertRaises(ValueError, self.semtype, value = -sys.maxint) def test_acquire(self): sem = self.semtype(1) sem.acquire() sem.release() sem = self.semtype(2) sem.acquire() sem.acquire() sem.release() sem.release() def test_acquire_destroy(self): sem = self.semtype() sem.acquire() del sem def test_acquire_contended(self): sem = self.semtype(7) sem.acquire() N = 10 results1 = [] results2 = [] phase_num = 0 def f(): sem.acquire() results1.append(phase_num) sem.acquire() results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() while len(results1) + len(results2) < 6: _wait() self.assertEqual(results1 + results2, [0] * 6) phase_num = 1 for i in range(7): sem.release() while len(results1) + len(results2) < 13: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7) phase_num = 2 for i in range(6): sem.release() while len(results1) + len(results2) < 19: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7 + [2] * 6) # The semaphore is still locked self.assertFalse(sem.acquire(False)) # Final release, to let the last thread finish sem.release() b.wait_for_finished() def test_try_acquire(self): sem = self.semtype(2) self.assertTrue(sem.acquire(False)) self.assertTrue(sem.acquire(False)) self.assertFalse(sem.acquire(False)) sem.release() self.assertTrue(sem.acquire(False)) def test_try_acquire_contended(self): sem = self.semtype(4) sem.acquire() results = [] def f(): results.append(sem.acquire(False)) results.append(sem.acquire(False)) Bunch(f, 5).wait_for_finished() # There can be a thread switch between acquiring the semaphore and # appending the result, therefore results will not necessarily be # ordered. self.assertEqual(sorted(results), [False] * 7 + [True] * 3 ) def test_default_value(self): # The default initial value is 1. sem = self.semtype() sem.acquire() def f(): sem.acquire() sem.release() b = Bunch(f, 1) b.wait_for_started() _wait() self.assertFalse(b.finished) sem.release() b.wait_for_finished() def test_with(self): sem = self.semtype(2) def _with(err=None): with sem: self.assertTrue(sem.acquire(False)) sem.release() with sem: self.assertFalse(sem.acquire(False)) if err: raise err _with() self.assertTrue(sem.acquire(False)) sem.release() self.assertRaises(TypeError, _with, TypeError) self.assertTrue(sem.acquire(False)) sem.release() class SemaphoreTests(BaseSemaphoreTests): """ Tests for unbounded semaphores. """ def test_release_unacquired(self): # Unbounded releases are allowed and increment the semaphore's value sem = self.semtype(1) sem.release() sem.acquire() sem.acquire() sem.release() class BoundedSemaphoreTests(BaseSemaphoreTests): """ Tests for bounded semaphores. """ def test_release_unacquired(self): # Cannot go past the initial value sem = self.semtype() self.assertRaises(ValueError, sem.release) sem.acquire() sem.release() self.assertRaises(ValueError, sem.release) gevent-1.1.0/greentest/2.6/nullcert.pem0000644000076500000000000000000012666555342020365 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.6/sha256.pem0000644000076500000000000000402112666555342017554 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy MTI1WjBLMQswCQYDVQQGEwJERTEXMBUGA1UEChMOc2Nob2tva2Vrcy5vcmcxIzAh BgkqhkiG9w0BCQEWFGhhbm5vQHNjaG9rb2tla3Mub3JnMIICIjANBgkqhkiG9w0B AQEFAAOCAg8AMIICCgKCAgEApJ4ODPwEooMW35dQPlBqdvcfkEvjhcsA7jmJfFqN e/1T34zT44X9+KnMBSG2InacbD7eyFgjfaENFsZ87YkEBDIFZ/SHotLJZORQ8PUj YoxPG4mjKN+yL2WthNcYbRyJreTbbDroNMuw6tkTSxeSXyYFQrKMCUfErVbZa/d5 RvfFVk+Au9dVUFhed/Stn5cv+a0ffvpyA7ygihm1kMFICbvPeI0846tmC2Ph7rM5 pYQyNBDOVpULODTk5Wu6jiiJJygvJWCZ1FdpsdBs5aKWHWdRhX++quGuflTTjH5d qaIka4op9H7XksYphTDXmV+qHnva5jbPogwutDQcVsGBQcJaLmQqhsQK13bf4khE iWJvfBLfHn8OOpY25ZwwuigJIwifNCxQeeT1FrLmyuYNhz2phPpzx065kqSUSR+A Iw8DPE6e65UqMDKqZnID3dQeiQaFrHEV+Ibo0U/tD0YSBw5p33TMh0Es33IBWMac m7x4hIFWdhl8W522u6qOrTswY3s8vB7blNWqMc9n7oWH8ybFf7EgKeDVtEN9AyBE 0WotXIEZWI+WvDbU1ACJXau9sQhYP/eerg7Zwr3iGUy4IQ5oUJibnjtcE+z8zmDN pE6YcMCLJyLjXiQ3iHG9mNXzw7wPnslTbEEEukrfSlHGgW8Dm+VrNyW0JUM1bntx vbMCAwEAAaOBrTCBqjAdBgNVHQ4EFgQUCedv7pDTuXtCxm4HTw9hUtrTvsowewYD VR0jBHQwcoAUCedv7pDTuXtCxm4HTw9hUtrTvsqhT6RNMEsxCzAJBgNVBAYTAkRF MRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYUaGFubm9A c2Nob2tva2Vrcy5vcmeCCQC55Z3+bs05CDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 DQEBCwUAA4ICAQBHKAxA7WA/MEFjet03K8ouzEOr6Jrk2fZOuRhoDZ+9gr4FtaJB P3Hh5D00kuSOvDnwsvCohxeNd1KTMAwVmVoH+NZkHERn3UXniUENlp18koI1ehlr CZbXbzzE9Te9BelliSFA63q0cq0yJN1x9GyabU34XkAouCAmOqfSpKNZWZHGBHPF bbYnZrHEMcsye6vKeTOcg1GqUHGrQM2WK0QaOwnCQv2RblI9VN+SeRoUJ44qTXdW TwIYStsIPesacNcAQTStnHgKqIPx4zCwdx5xo8zONbXJfocqwyFqiAofvb9dN1nW g1noVBcXB+oRBZW5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4 +A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw== -----END CERTIFICATE----- gevent-1.1.0/greentest/2.6/test_asyncore.py0000644000076500000000000003164612666555342021312 0ustar jmaddenwheel00000000000000import asyncore import unittest import select import os import socket import threading import sys import time import errno from test import test_support from test.test_support import TESTFN, run_unittest, unlink from StringIO import StringIO HOST = test_support.HOST class dummysocket: def __init__(self): self.closed = False def close(self): self.closed = True def fileno(self): return 42 class dummychannel: def __init__(self): self.socket = dummysocket() def close(self): self.socket.close() class exitingdummy: def __init__(self): pass def handle_read_event(self): raise asyncore.ExitNow() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event class crashingdummy: def __init__(self): self.error_handled = False def handle_read_event(self): raise Exception() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event def handle_error(self): self.error_handled = True # used when testing senders; just collects what it gets until newline is sent def capture_server(evt, buf, serv): try: serv.listen(5) conn, addr = serv.accept() except socket.timeout: pass else: n = 200 while n > 0: r, w, e = select.select([conn], [], []) if r: data = conn.recv(10) # keep everything except for the newline terminator buf.write(data.replace('\n', '')) if '\n' in data: break n -= 1 time.sleep(0.01) conn.close() finally: serv.close() evt.set() class HelperFunctionTests(unittest.TestCase): def test_readwriteexc(self): # Check exception handling behavior of read, write and _exception # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore read/write/_exception calls tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.read, tr1) self.assertRaises(asyncore.ExitNow, asyncore.write, tr1) self.assertRaises(asyncore.ExitNow, asyncore._exception, tr1) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() asyncore.read(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore.write(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore._exception(tr2) self.assertEqual(tr2.error_handled, True) # asyncore.readwrite uses constants in the select module that # are not present in Windows systems (see this thread: # http://mail.python.org/pipermail/python-list/2001-October/109973.html) # These constants should be present as long as poll is available if hasattr(select, 'poll'): def test_readwrite(self): # Check that correct methods are called by readwrite() attributes = ('read', 'expt', 'write', 'closed', 'error_handled') expected = ( (select.POLLIN, 'read'), (select.POLLPRI, 'expt'), (select.POLLOUT, 'write'), (select.POLLERR, 'closed'), (select.POLLHUP, 'closed'), (select.POLLNVAL, 'closed'), ) class testobj: def __init__(self): self.read = False self.write = False self.closed = False self.expt = False self.error_handled = False def handle_read_event(self): self.read = True def handle_write_event(self): self.write = True def handle_close(self): self.closed = True def handle_expt_event(self): self.expt = True def handle_error(self): self.error_handled = True for flag, expectedattr in expected: tobj = testobj() self.assertEqual(getattr(tobj, expectedattr), False) asyncore.readwrite(tobj, flag) # Only the attribute modified by the routine we expect to be # called should be True. for attr in attributes: self.assertEqual(getattr(tobj, attr), attr==expectedattr) # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore readwrite call tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() self.assertEqual(tr2.error_handled, False) asyncore.readwrite(tr2, flag) self.assertEqual(tr2.error_handled, True) def test_closeall(self): self.closeall_check(False) def test_closeall_default(self): self.closeall_check(True) def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True) def test_compact_traceback(self): try: raise Exception("I don't like spam!") except: real_t, real_v, real_tb = sys.exc_info() r = asyncore.compact_traceback() else: self.fail("Expected exception") (f, function, line), t, v, info = r self.assertEqual(os.path.split(f)[-1], 'test_asyncore.py') self.assertEqual(function, 'test_compact_traceback') self.assertEqual(t, real_t) self.assertEqual(v, real_v) self.assertEqual(info, '[%s|%s|%s]' % (f, function, line)) class DispatcherTests(unittest.TestCase): def setUp(self): pass def tearDown(self): asyncore.close_all() def test_basic(self): d = asyncore.dispatcher() self.assertEqual(d.readable(), True) self.assertEqual(d.writable(), True) def test_repr(self): d = asyncore.dispatcher() self.assertEqual(repr(d), '' % id(d)) def test_log(self): d = asyncore.dispatcher() # capture output of dispatcher.log() (to stderr) fp = StringIO() stderr = sys.stderr l1 = "Lovely spam! Wonderful spam!" l2 = "I don't like spam!" try: sys.stderr = fp d.log(l1) d.log(l2) finally: sys.stderr = stderr lines = fp.getvalue().splitlines() self.assertEquals(lines, ['log: %s' % l1, 'log: %s' % l2]) def test_log_info(self): d = asyncore.dispatcher() # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout l1 = "Have you got anything without spam?" l2 = "Why can't she have egg bacon spam and sausage?" l3 = "THAT'S got spam in it!" try: sys.stdout = fp d.log_info(l1, 'EGGS') d.log_info(l2) d.log_info(l3, 'SPAM') finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3] self.assertEquals(lines, expected) def test_unhandled(self): d = asyncore.dispatcher() d.ignore_log_types = () # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout try: sys.stdout = fp d.handle_expt() d.handle_read() d.handle_write() d.handle_connect() d.handle_accept() finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['warning: unhandled incoming priority event', 'warning: unhandled read event', 'warning: unhandled write event', 'warning: unhandled connect event', 'warning: unhandled accept event'] self.assertEquals(lines, expected) def test_issue_8594(self): d = asyncore.dispatcher(socket.socket()) # make sure the error message no longer refers to the socket # object but the dispatcher instance instead try: d.foo except AttributeError, err: self.assertTrue('dispatcher instance' in str(err)) else: self.fail("exception not raised") # test cheap inheritance with the underlying socket self.assertEqual(d.family, socket.AF_INET) def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) if hasattr(os, 'strerror'): self.assertEqual(err, os.strerror(errno.EPERM)) err = asyncore._strerror(-1) self.assertTrue("unknown error" in err.lower()) class dispatcherwithsend_noread(asyncore.dispatcher_with_send): def readable(self): return False def handle_connect(self): pass class DispatcherWithSendTests(unittest.TestCase): usepoll = False def setUp(self): pass def tearDown(self): asyncore.close_all() def test_send(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) self.port = test_support.bind_port(self.sock) cap = StringIO() args = (self.evt, cap, self.sock) threading.Thread(target=capture_server, args=args).start() # wait a little longer for the server to initialize (it sometimes # refuses connections on slow machines without this wait) time.sleep(0.2) data = "Suppose there isn't a 16-ton weight?" d = dispatcherwithsend_noread() d.create_socket(socket.AF_INET, socket.SOCK_STREAM) d.connect((HOST, self.port)) # give time for socket to connect time.sleep(0.1) d.send(data) d.send(data) d.send('\n') n = 1000 while d.out_buffer and n > 0: asyncore.poll() n -= 1 self.evt.wait() self.assertEqual(cap.getvalue(), data*2) class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): usepoll = True if hasattr(asyncore, 'file_wrapper'): class FileWrapperTest(unittest.TestCase): def setUp(self): self.d = "It's not dead, it's sleeping!" file(TESTFN, 'w').write(self.d) def tearDown(self): unlink(TESTFN) def test_recv(self): fd = os.open(TESTFN, os.O_RDONLY) w = asyncore.file_wrapper(fd) os.close(fd) self.assertNotEqual(w.fd, fd) self.assertNotEqual(w.fileno(), fd) self.assertEqual(w.recv(13), "It's not dead") self.assertEqual(w.read(6), ", it's") w.close() self.assertRaises(OSError, w.read, 1) def test_send(self): d1 = "Come again?" d2 = "I want to buy some cheese." fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND) w = asyncore.file_wrapper(fd) os.close(fd) w.write(d1) w.send(d2) w.close() self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) def test_dispatcher(self): fd = os.open(TESTFN, os.O_RDONLY) data = [] class FileDispatcher(asyncore.file_dispatcher): def handle_read(self): data.append(self.recv(29)) s = FileDispatcher(fd) os.close(fd) asyncore.loop(timeout=0.01, use_poll=True, count=2) self.assertEqual("".join(data), self.d) def test_main(): tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, DispatcherWithSendTests_UsePoll] if hasattr(asyncore, 'file_wrapper'): tests.append(FileWrapperTest) run_unittest(*tests) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_ftplib.py0000644000076500000000000003631712666555342020747 0ustar jmaddenwheel00000000000000"""Test script for ftplib module.""" # Modified by Giampaolo Rodola' to test FTP class and IPv6 environment import ftplib import threading import asyncore import asynchat import socket import StringIO from unittest import TestCase from test import test_support from test.test_support import HOST # the dummy data returned by server over the data channel when # RETR, LIST and NLST commands are issued RETR_DATA = 'abcde12345\r\n' * 1000 LIST_DATA = 'foo\r\nbar\r\n' NLST_DATA = 'foo\r\nbar\r\n' class DummyDTPHandler(asynchat.async_chat): def __init__(self, conn, baseclass): asynchat.async_chat.__init__(self, conn) self.baseclass = baseclass self.baseclass.last_received_data = '' def handle_read(self): self.baseclass.last_received_data += self.recv(1024) def handle_close(self): self.baseclass.push('226 transfer complete') self.close() class DummyFTPHandler(asynchat.async_chat): def __init__(self, conn): asynchat.async_chat.__init__(self, conn) self.set_terminator("\r\n") self.in_buffer = [] self.dtp = None self.last_received_cmd = None self.last_received_data = '' self.next_response = '' self.push('220 welcome') def collect_incoming_data(self, data): self.in_buffer.append(data) def found_terminator(self): line = ''.join(self.in_buffer) self.in_buffer = [] if self.next_response: self.push(self.next_response) self.next_response = '' cmd = line.split(' ')[0].lower() self.last_received_cmd = cmd space = line.find(' ') if space != -1: arg = line[space + 1:] else: arg = "" if hasattr(self, 'cmd_' + cmd): method = getattr(self, 'cmd_' + cmd) method(arg) else: self.push('550 command "%s" not understood.' %cmd) def handle_error(self): raise def push(self, data): asynchat.async_chat.push(self, data + '\r\n') def cmd_port(self, arg): addr = map(int, arg.split(',')) ip = '%d.%d.%d.%d' %tuple(addr[:4]) port = (addr[4] * 256) + addr[5] s = socket.create_connection((ip, port), timeout=2) self.dtp = DummyDTPHandler(s, baseclass=self) self.push('200 active data connection established') def cmd_pasv(self, arg): sock = socket.socket() sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(2) ip, port = sock.getsockname()[:2] ip = ip.replace('.', ',') p1, p2 = divmod(port, 256) self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = DummyDTPHandler(conn, baseclass=self) def cmd_eprt(self, arg): af, ip, port = arg.split(arg[0])[1:-1] port = int(port) s = socket.create_connection((ip, port), timeout=2) self.dtp = DummyDTPHandler(s, baseclass=self) self.push('200 active data connection established') def cmd_epsv(self, arg): sock = socket.socket(socket.AF_INET6) sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(2) port = sock.getsockname()[1] self.push('229 entering extended passive mode (|||%d|)' %port) conn, addr = sock.accept() self.dtp = DummyDTPHandler(conn, baseclass=self) def cmd_echo(self, arg): # sends back the received string (used by the test suite) self.push(arg) def cmd_user(self, arg): self.push('331 username ok') def cmd_pass(self, arg): self.push('230 password ok') def cmd_acct(self, arg): self.push('230 acct ok') def cmd_rnfr(self, arg): self.push('350 rnfr ok') def cmd_rnto(self, arg): self.push('250 rnto ok') def cmd_dele(self, arg): self.push('250 dele ok') def cmd_cwd(self, arg): self.push('250 cwd ok') def cmd_size(self, arg): self.push('250 1000') def cmd_mkd(self, arg): self.push('257 "%s"' %arg) def cmd_rmd(self, arg): self.push('250 rmd ok') def cmd_pwd(self, arg): self.push('257 "pwd ok"') def cmd_type(self, arg): self.push('200 type ok') def cmd_quit(self, arg): self.push('221 quit ok') self.close() def cmd_stor(self, arg): self.push('125 stor ok') def cmd_retr(self, arg): self.push('125 retr ok') self.dtp.push(RETR_DATA) self.dtp.close_when_done() def cmd_list(self, arg): self.push('125 list ok') self.dtp.push(LIST_DATA) self.dtp.close_when_done() def cmd_nlst(self, arg): self.push('125 nlst ok') self.dtp.push(NLST_DATA) self.dtp.close_when_done() class DummyFTPServer(asyncore.dispatcher, threading.Thread): handler = DummyFTPHandler def __init__(self, address, af=socket.AF_INET): threading.Thread.__init__(self) asyncore.dispatcher.__init__(self) self.create_socket(af, socket.SOCK_STREAM) self.bind(address) self.listen(5) self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] def start(self): assert not self.active self.__flag = threading.Event() threading.Thread.start(self) self.__flag.wait() def run(self): self.active = True self.__flag.set() while self.active and asyncore.socket_map: self.active_lock.acquire() asyncore.loop(timeout=0.1, count=1) self.active_lock.release() asyncore.close_all(ignore_all=True) def stop(self): assert self.active self.active = False self.join() def handle_accept(self): conn, addr = self.accept() self.handler = self.handler(conn) self.close() def handle_connect(self): self.close() handle_read = handle_connect def writable(self): return 0 def handle_error(self): raise class TestFTPClass(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP(timeout=2) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_getwelcome(self): self.assertEqual(self.client.getwelcome(), '220 welcome') def test_sanitize(self): self.assertEqual(self.client.sanitize('foo'), repr('foo')) self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****')) self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****')) def test_exceptions(self): self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599') self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999') def test_all_errors(self): exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm, ftplib.error_proto, ftplib.Error, IOError, EOFError) for x in exceptions: try: raise x('exception not included in all_errors set') except ftplib.all_errors: pass def test_set_pasv(self): # passive mode is supposed to be enabled by default self.assertTrue(self.client.passiveserver) self.client.set_pasv(True) self.assertTrue(self.client.passiveserver) self.client.set_pasv(False) self.assertFalse(self.client.passiveserver) def test_voidcmd(self): self.client.voidcmd('echo 200') self.client.voidcmd('echo 299') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300') def test_login(self): self.client.login() def test_acct(self): self.client.acct('passwd') def test_rename(self): self.client.rename('a', 'b') self.server.handler.next_response = '200' self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b') def test_delete(self): self.client.delete('foo') self.server.handler.next_response = '199' self.assertRaises(ftplib.error_reply, self.client.delete, 'foo') def test_size(self): self.client.size('foo') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_rmd(self): self.client.rmd('foo') def test_pwd(self): dir = self.client.pwd() self.assertEqual(dir, 'pwd ok') def test_quit(self): self.assertEqual(self.client.quit(), '221 quit ok') # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) def test_retrbinary(self): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) def test_retrlines(self): received = [] self.client.retrlines('retr', received.append) self.assertEqual(''.join(received), RETR_DATA.replace('\r\n', '')) def test_storbinary(self): f = StringIO.StringIO(RETR_DATA) self.client.storbinary('stor', f) self.assertEqual(self.server.handler.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storbinary('stor', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_storlines(self): f = StringIO.StringIO(RETR_DATA.replace('\r\n', '\n')) self.client.storlines('stor', f) self.assertEqual(self.server.handler.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1]) def test_dir(self): l = [] self.client.dir(lambda x: l.append(x)) self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', '')) def test_makeport(self): self.client.makeport() # IPv4 is in use, just make sure send_eprt has not been used self.assertEqual(self.server.handler.last_received_cmd, 'port') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 2) conn.close() # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler.last_received_cmd, 'pasv') class TestIPv6Environment(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0), af=socket.AF_INET6) self.server.start() self.client = ftplib.FTP() self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_af(self): self.assertEqual(self.client.af, socket.AF_INET6) def test_makeport(self): self.client.makeport() self.assertEqual(self.server.handler.last_received_cmd, 'eprt') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 2) conn.close() self.assertEqual(self.server.handler.last_received_cmd, 'epsv') def test_transfer(self): def retr(): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) self.client.set_pasv(True) retr() self.client.set_pasv(False) retr() class TestTimeouts(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) self.port = test_support.bind_port(self.sock) threading.Thread(target=self.server, args=(self.evt,self.sock)).start() # Wait for the server to be ready. self.evt.wait() self.evt.clear() ftplib.FTP.port = self.port def tearDown(self): self.evt.wait() def server(self, evt, serv): # This method sets the evt 3 times: # 1) when the connection is ready to be accepted. # 2) when it is safe for the caller to close the connection # 3) when we have closed the socket serv.listen(5) # (1) Signal the caller that we are ready to accept the connection. evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: conn.send("1 Hola mundo\n") # (2) Signal the caller that it is safe to close the socket. evt.set() conn.close() finally: serv.close() # (3) Signal the caller that we are done. evt.set() def testTimeoutDefault(self): # default -- use global socket timeout self.assert_(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP("localhost") finally: socket.setdefaulttimeout(None) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutNone(self): # no timeout -- do not use global socket timeout self.assert_(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP("localhost", timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(ftp.sock.gettimeout() is None) self.evt.wait() ftp.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDirectAccess(self): ftp = ftplib.FTP() ftp.timeout = 30 ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def test_main(): tests = [TestFTPClass, TestTimeouts] if socket.has_ipv6: try: DummyFTPServer((HOST, 0), af=socket.AF_INET6) except socket.error: pass else: tests.append(TestIPv6Environment) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_httplib.py0000644000076500000000000002564212666555342021134 0ustar jmaddenwheel00000000000000import array import httplib import StringIO import socket from unittest import TestCase from test import test_support HOST = test_support.HOST class FakeSocket: def __init__(self, text, fileclass=StringIO.StringIO): self.text = text self.fileclass = fileclass self.data = '' def sendall(self, data): self.data += ''.join(data) def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return self.fileclass(self.text) class NoEOFStringIO(StringIO.StringIO): """Like StringIO, but raises AssertionError on EOF. This is used below to test that httplib doesn't try to read more from the underlying file than it should. """ def read(self, n=-1): data = StringIO.StringIO.read(self, n) if data == '': raise AssertionError('caller tried to read past EOF') return data def readline(self, length=None): data = StringIO.StringIO.readline(self, length) if data == '': raise AssertionError('caller tried to read past EOF') return data class HeaderTests(TestCase): def test_auto_headers(self): # Some headers are added automatically, but should not be added by # .request() if they are explicitly set. import httplib class HeaderCountingBuffer(list): def __init__(self): self.count = {} def append(self, item): kv = item.split(':') if len(kv) > 1: # item is a 'Key: Value' header string lcKey = kv[0].lower() self.count.setdefault(lcKey, 0) self.count[lcKey] += 1 list.append(self, item) for explicit_header in True, False: for header in 'Content-length', 'Host', 'Accept-encoding': conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket('blahblahblah') conn._buffer = HeaderCountingBuffer() body = 'spamspamspam' headers = {} if explicit_header: headers[header] = str(len(body)) conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) class BasicTest(TestCase): def test_status_lines(self): # Test HTTP status lines body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(), 'Text') self.assertTrue(resp.isclosed()) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertRaises(httplib.BadStatusLine, resp.begin) def test_partial_reads(self): # if we have a lenght, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertTrue(resp.isclosed()) def test_host_port(self): # Check invalid host_port for hp in ("www.python.org:abc", "www.python.org:"): self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), ("www.python.org", "www.python.org", 80), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): http = httplib.HTTP(hp) c = http._conn if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) def test_response_headers(self): # test response with multiple message headers with the same field name. text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE";' ' Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = httplib.HTTPResponse(s) r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: self.fail("multiple headers not combined properly") def test_read_head(self): # Test that the library doesn't attempt to read any data # from a HEAD request. (Tickles SF bug #622042.) sock = FakeSocket( 'HTTP/1.1 200 OK\r\n' 'Content-Length: 14432\r\n' '\r\n', NoEOFStringIO) resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() if resp.read() != "": self.fail("Did not expect response from HEAD request") def test_send_file(self): expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 'Accept-Encoding: identity\r\nContent-Length:' body = open(__file__, 'rb') conn = httplib.HTTPConnection('example.com') sock = FakeSocket(body) conn.sock = sock conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected)) def test_send(self): expected = 'this is a test this is only a test' conn = httplib.HTTPConnection('example.com') sock = FakeSocket(None) conn.sock = sock conn.send(expected) self.assertEquals(expected, sock.data) sock.data = '' conn.send(array.array('c', expected)) self.assertEquals(expected, sock.data) sock.data = '' conn.send(StringIO.StringIO(expected)) self.assertEquals(expected, sock.data) def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello worl\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEquals(resp.read(), 'hello world') resp.close() for x in ('', 'foo\r\n'): sock = FakeSocket(chunked_start + x) resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead, i: self.assertEquals(i.partial, 'hello world') self.assertEqual(repr(i),'IncompleteRead(11 bytes read)') self.assertEqual(str(i),'IncompleteRead(11 bytes read)') else: self.fail('IncompleteRead expected') finally: resp.close() def test_chunked_head(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello world\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() self.assertEquals(resp.read(), '') self.assertEquals(resp.status, 200) self.assertEquals(resp.reason, 'OK') self.assertTrue(resp.isclosed()) def test_negative_content_length(self): sock = FakeSocket('HTTP/1.1 200 OK\r\n' 'Content-Length: -1\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEquals(resp.read(), 'Hello\r\n') resp.close() def test_incomplete_read(self): sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead as i: self.assertEquals(i.partial, 'Hello\r\n') self.assertEqual(repr(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertEqual(str(i), "IncompleteRead(7 bytes read, 3 more expected)") else: self.fail('IncompleteRead expected') finally: resp.close() class OfflineTest(TestCase): def test_responses(self): self.assertEquals(httplib.responses[httplib.NOT_FOUND], "Not Found") class TimeoutTest(TestCase): PORT = None def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) TimeoutTest.PORT = test_support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): self.serv.close() self.serv = None def testTimeoutAttribute(self): '''This will prove that the timeout gets through HTTPConnection and into the socket. ''' # default -- use global socket timeout self.assert_(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() # no timeout -- do not use global socket default self.assert_(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=None) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), None) httpConn.close() # a value httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30) httpConn.connect() self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() class HTTPSTimeoutTest(TestCase): # XXX Here should be tests for HTTPS, there isn't any right now! def test_attributes(self): # simple test to check it's storing it if hasattr(httplib, 'HTTPSConnection'): h = httplib.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30) self.assertEqual(h.timeout, 30) def test_main(verbose=None): test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTimeoutTest) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_httpservers.py0000644000076500000000000002754712666555342022065 0ustar jmaddenwheel00000000000000"""Unittests for the various HTTPServer modules. Written by Cody A.W. Somerville , Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest. """ from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler from CGIHTTPServer import CGIHTTPRequestHandler import os import sys import base64 import shutil import urllib import httplib import tempfile import threading import unittest from test import test_support class NoLogRequestHandler: def log_message(self, *args): # don't write log messages to stderr pass class TestServerThread(threading.Thread): def __init__(self, test_object, request_handler): threading.Thread.__init__(self) self.request_handler = request_handler self.test_object = test_object def run(self): self.server = HTTPServer(('', 0), self.request_handler) self.test_object.PORT = self.server.socket.getsockname()[1] self.test_object.server_started.set() self.test_object = None try: self.server.serve_forever(0.05) finally: self.server.server_close() def stop(self): self.server.shutdown() class BaseTestCase(unittest.TestCase): def setUp(self): self.server_started = threading.Event() self.thread = TestServerThread(self, self.request_handler) self.thread.start() self.server_started.wait() def tearDown(self): self.thread.stop() def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) self.connection.request(method, uri, body, headers) return self.connection.getresponse() class BaseHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' default_request_version = 'HTTP/1.1' def do_TEST(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def do_KEEP(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'keep-alive') self.end_headers() def do_KEYERROR(self): self.send_error(999) def do_CUSTOM(self): self.send_response(999) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def setUp(self): BaseTestCase.setUp(self) self.con = httplib.HTTPConnection('localhost', self.PORT) self.con.connect() def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() self.assertEquals(res.status, 501) def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 501) def test_version_bogus(self): self.con._http_vsn_str = 'FUBAR' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 400) def test_version_digits(self): self.con._http_vsn_str = 'HTTP/9.9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 400) def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 501) def test_version_none(self): self.con._http_vsn_str = '' self.con.putrequest('PUT', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 400) def test_version_invalid(self): self.con._http_vsn = 99 self.con._http_vsn_str = 'HTTP/9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 505) def test_send_blank(self): self.con._http_vsn_str = '' self.con.putrequest('', '') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 400) def test_header_close(self): self.con.putrequest('GET', '/') self.con.putheader('Connection', 'close') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 501) def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' self.con.putrequest('GET', '/') self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() self.assertEquals(res.status, 501) def test_handler(self): self.con.request('TEST', '/') res = self.con.getresponse() self.assertEquals(res.status, 204) def test_return_header_keep_alive(self): self.con.request('KEEP', '/') res = self.con.getresponse() self.assertEquals(res.getheader('Connection'), 'keep-alive') self.con.request('TEST', '/') def test_internal_key_error(self): self.con.request('KEYERROR', '/') res = self.con.getresponse() self.assertEquals(res.status, 999) def test_return_custom_status(self): self.con.request('CUSTOM', '/') res = self.con.getresponse() self.assertEquals(res.status, 999) class SimpleHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.cwd = os.getcwd() basetempdir = tempfile.gettempdir() os.chdir(basetempdir) self.data = 'We are the knights who say Ni!' self.tempdir = tempfile.mkdtemp(dir=basetempdir) self.tempdir_name = os.path.basename(self.tempdir) temp = open(os.path.join(self.tempdir, 'test'), 'wb') temp.write(self.data) temp.close() def tearDown(self): try: os.chdir(self.cwd) try: shutil.rmtree(self.tempdir) except: pass finally: BaseTestCase.tearDown(self) def check_status_and_reason(self, response, status, data=None): body = response.read() self.assert_(response) self.assertEquals(response.status, status) self.assert_(response.reason != None) if data: self.assertEqual(data, body) def test_get(self): #constructs the path relative to the root directory of the HTTPServer response = self.request(self.tempdir_name + '/test') self.check_status_and_reason(response, 200, data=self.data) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name) self.check_status_and_reason(response, 301) response = self.request('/ThisDoesNotExist') self.check_status_and_reason(response, 404) response = self.request('/' + 'ThisDoesNotExist' + '/') self.check_status_and_reason(response, 404) f = open(os.path.join(self.tempdir_name, 'index.html'), 'w') response = self.request('/' + self.tempdir_name + '/') self.check_status_and_reason(response, 200) if os.name == 'posix': # chmod won't work as expected on Windows platforms os.chmod(self.tempdir, 0) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 404) os.chmod(self.tempdir, 0755) def test_head(self): response = self.request( self.tempdir_name + '/test', method='HEAD') self.check_status_and_reason(response, 200) self.assertEqual(response.getheader('content-length'), str(len(self.data))) self.assertEqual(response.getheader('content-type'), 'application/octet-stream') def test_invalid_requests(self): response = self.request('/', method='FOO') self.check_status_and_reason(response, 501) # requests must be case sensitive,so this should fail too response = self.request('/', method='get') self.check_status_and_reason(response, 501) response = self.request('/', method='GETs') self.check_status_and_reason(response, 501) cgi_file1 = """\ #!%s print "Content-type: text/html" print print "Hello World" """ cgi_file2 = """\ #!%s import cgi print "Content-type: text/html" print form = cgi.FieldStorage() print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),\ form.getfirst("bacon")) """ class CGIHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') os.mkdir(self.cgi_dir) # The shebang line should be pure ASCII: use symlink if possible. # See issue #7668. if hasattr(os, 'symlink'): self.pythonexe = os.path.join(self.parent_dir, 'python') os.symlink(sys.executable, self.pythonexe) else: self.pythonexe = sys.executable self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: file1.write(cgi_file1 % self.pythonexe) os.chmod(self.file1_path, 0777) self.file2_path = os.path.join(self.cgi_dir, 'file2.py') with open(self.file2_path, 'w') as file2: file2.write(cgi_file2 % self.pythonexe) os.chmod(self.file2_path, 0777) self.cwd = os.getcwd() os.chdir(self.parent_dir) def tearDown(self): try: os.chdir(self.cwd) if self.pythonexe != sys.executable: os.remove(self.pythonexe) os.remove(self.file1_path) os.remove(self.file2_path) os.rmdir(self.cgi_dir) os.rmdir(self.parent_dir) finally: BaseTestCase.tearDown(self) def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEquals(('Hello World\n', 'text/html', 200), \ (res.read(), res.getheader('Content-type'), res.status)) def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} res = self.request('/cgi-bin/file2.py', 'POST', params, headers) self.assertEquals(res.read(), '1, python, 123456\n') def test_invaliduri(self): res = self.request('/cgi-bin/invalid') res.read() self.assertEquals(res.status, 404) def test_authorization(self): headers = {'Authorization' : 'Basic %s' % \ base64.b64encode('username:pass')} res = self.request('/cgi-bin/file1.py', 'GET', headers=headers) self.assertEquals(('Hello World\n', 'text/html', 200), \ (res.read(), res.getheader('Content-type'), res.status)) def test_main(verbose=None): cwd = os.getcwd() env = os.environ.copy() try: test_support.run_unittest(BaseHTTPServerTestCase, SimpleHTTPServerTestCase, CGIHTTPServerTestCase ) finally: test_support.reap_children() os.environ.clear() os.environ.update(env) os.chdir(cwd) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_queue.py0000644000076500000000000002706412666555342020612 0ustar jmaddenwheel00000000000000# Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. import Queue import sys import threading import time import unittest from test import test_support QUEUE_SIZE = 5 # A thread to run a function that unclogs a blocked Queue. class _TriggerThread(threading.Thread): def __init__(self, fn, args): self.fn = fn self.args = args self.startedEvent = threading.Event() threading.Thread.__init__(self) def run(self): # The sleep isn't necessary, but is intended to give the blocking # function in the main thread a chance at actually blocking before # we unclog it. But if the sleep is longer than the timeout-based # tests wait in their blocking functions, those tests will fail. # So we give them much longer timeout values compared to the # sleep here (I aimed at 10 seconds for blocking functions -- # they should never actually wait that long - they should make # progress as soon as we call self.fn()). time.sleep(0.1) self.startedEvent.set() self.fn(*self.args) # Execute a function that blocks, and in a separate thread, a function that # triggers the release. Returns the result of the blocking function. Caution: # block_func must guarantee to block until trigger_func is called, and # trigger_func must guarantee to change queue state so that block_func can make # enough progress to return. In particular, a block_func that just raises an # exception regardless of whether trigger_func is called will lead to # timing-dependent sporadic failures, and one of those went rarely seen but # undiagnosed for years. Now block_func must be unexceptional. If block_func # is supposed to raise an exception, call do_exceptional_blocking_test() # instead. class BlockingTestMixin: def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() self.result = block_func(*block_args) # If block_func returned before our thread made the call, we failed! if not self.t.startedEvent.is_set(): self.fail("blocking function '%r' appeared not to block" % block_func) self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) return self.result # Call this instead if block_func is supposed to raise an exception. def do_exceptional_blocking_test(self,block_func, block_args, trigger_func, trigger_args, expected_exception_class): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() try: try: block_func(*block_args) except expected_exception_class: raise else: self.fail("expected exception of kind %r" % expected_exception_class) finally: self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) if not self.t.startedEvent.is_set(): self.fail("trigger thread ended but event never set") class BaseQueueTest(unittest.TestCase, BlockingTestMixin): def setUp(self): self.cum = 0 self.cumlock = threading.Lock() def simple_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" # I guess we better check things actually queue correctly a little :) q.put(111) q.put(333) q.put(222) target_order = dict(Queue = [111, 333, 222], LifoQueue = [222, 333, 111], PriorityQueue = [111, 222, 333]) actual_order = [q.get(), q.get(), q.get()] self.assertEquals(actual_order, target_order[q.__class__.__name__], "Didn't seem to queue the correct data!") for i in range(QUEUE_SIZE-1): q.put(i) self.assert_(not q.empty(), "Queue should not be empty") self.assert_(not q.full(), "Queue should not be full") last = 2 * QUEUE_SIZE full = 3 * 2 * QUEUE_SIZE q.put(last) self.assert_(q.full(), "Queue should be full") try: q.put(full, block=0) self.fail("Didn't appear to block with a full queue") except Queue.Full: pass try: q.put(full, timeout=0.01) self.fail("Didn't appear to time-out with a full queue") except Queue.Full: pass # Test a blocking put self.do_blocking_test(q.put, (full,), q.get, ()) self.do_blocking_test(q.put, (full, True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assert_(q.empty(), "Queue should be empty") try: q.get(block=0) self.fail("Didn't appear to block with an empty queue") except Queue.Empty: pass try: q.get(timeout=0.01) self.fail("Didn't appear to time-out with an empty queue") except Queue.Empty: pass # Test a blocking get self.do_blocking_test(q.get, (), q.put, ('empty',)) self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) def worker(self, q): while True: x = q.get() if x is None: q.task_done() return with self.cumlock: self.cum += x q.task_done() def queue_join_test(self, q): self.cum = 0 for i in (0,1): threading.Thread(target=self.worker, args=(q,)).start() for i in xrange(100): q.put(i) q.join() self.assertEquals(self.cum, sum(range(100)), "q.join() did not block until all tasks were done") for i in (0,1): q.put(None) # instruct the threads to close q.join() # verify that you can join twice def test_queue_task_done(self): # Test to make sure a queue task completed successfully. q = self.type2test() try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_queue_join(self): # Test that a queue join()s successfully, and before anything else # (done twice for insurance). q = self.type2test() self.queue_join_test(q) self.queue_join_test(q) try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_simple_queue(self): # Do it a couple of times on the same queue. # Done twice to make sure works with same instance reused. q = self.type2test(QUEUE_SIZE) self.simple_queue_test(q) self.simple_queue_test(q) class QueueTest(BaseQueueTest): type2test = Queue.Queue class LifoQueueTest(BaseQueueTest): type2test = Queue.LifoQueue class PriorityQueueTest(BaseQueueTest): type2test = Queue.PriorityQueue # A Queue subclass that can provoke failure at a moment's notice :) class FailingQueueException(Exception): pass class FailingQueue(Queue.Queue): def __init__(self, *args): self.fail_next_put = False self.fail_next_get = False Queue.Queue.__init__(self, *args) def _put(self, item): if self.fail_next_put: self.fail_next_put = False raise FailingQueueException, "You Lose" return Queue.Queue._put(self, item) def _get(self): if self.fail_next_get: self.fail_next_get = False raise FailingQueueException, "You Lose" return Queue.Queue._get(self) class FailingQueueTest(unittest.TestCase, BlockingTestMixin): def failing_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" for i in range(QUEUE_SIZE-1): q.put(i) # Test a failing non-blocking put. q.fail_next_put = True try: q.put("oops", block=0) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.fail_next_put = True try: q.put("oops", timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.put("last") self.assert_(q.full(), "Queue should be full") # Test a failing blocking put q.fail_next_put = True try: self.do_blocking_test(q.put, ("full",), q.get, ()) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") # Test a failing timeout put q.fail_next_put = True try: self.do_exceptional_blocking_test(q.put, ("full", True, 10), q.get, (), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") self.assert_(q.full(), "Queue should be full") q.get() self.assert_(not q.full(), "Queue should not be full") q.put("last") self.assert_(q.full(), "Queue should be full") # Test a blocking put self.do_blocking_test(q.put, ("full",), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assert_(q.empty(), "Queue should be empty") q.put("first") q.fail_next_get = True try: q.get() self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assert_(not q.empty(), "Queue should not be empty") q.fail_next_get = True try: q.get(timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assert_(not q.empty(), "Queue should not be empty") q.get() self.assert_(q.empty(), "Queue should be empty") q.fail_next_get = True try: self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # put succeeded, but get failed. self.assert_(not q.empty(), "Queue should not be empty") q.get() self.assert_(q.empty(), "Queue should be empty") def test_failing_queue(self): # Test to make sure a queue is functioning correctly. # Done twice to the same instance. q = FailingQueue(QUEUE_SIZE) self.failing_queue_test(q) self.failing_queue_test(q) def test_main(): test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_select.py0000644000076500000000000000404612666555342020740 0ustar jmaddenwheel00000000000000from test import test_support import unittest import select import os import sys class SelectTestCase(unittest.TestCase): class Nope: pass class Almost: def fileno(self): return 'fileno' def test_error_conditions(self): self.assertRaises(TypeError, select.select, 1, 2, 3) self.assertRaises(TypeError, select.select, [self.Nope()], [], []) self.assertRaises(TypeError, select.select, [self.Almost()], [], []) self.assertRaises(TypeError, select.select, [], [], [], "not a number") def test_returned_list_identity(self): if sys.platform[:3] in ('win', 'mac', 'os2'): if test_support.verbose: print "can't easily test on this system" return # See issue #8329 r, w, x = select.select([], [], [], 1) self.assertFalse(r is w) self.assertFalse(r is x) self.assertFalse(w is x) def test_select(self): if sys.platform[:3] in ('win', 'mac', 'os2'): if test_support.verbose: print "can't easily test on this system" return cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 0.1; done' p = os.popen(cmd, 'r') for tout in (0, 0.1, 0.2, 0.4, 0.8, 1.6) + (None,)*10: if test_support.verbose: print 'timeout =', tout rfd, wfd, xfd = select.select([p], [], [], tout) if (rfd, wfd, xfd) == ([], [], []): continue if (rfd, wfd, xfd) == ([p], [], []): line = p.readline() if test_support.verbose: print repr(line) if not line: if test_support.verbose: print 'EOF' break continue self.fail('Unexpected return values from select():', rfd, wfd, xfd) p.close() def test_main(): test_support.run_unittest(SelectTestCase) test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_signal.py0000644000076500000000000004401412666555342020735 0ustar jmaddenwheel00000000000000import unittest from test import test_support from contextlib import closing, nested import gc import pickle import select import signal import subprocess import traceback import sys, os, time, errno if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos': raise test_support.TestSkipped("Can't test signal on %s" % \ sys.platform) class HandlerBCalled(Exception): pass def exit_subprocess(): """Use os._exit(0) to exit the current subprocess. Otherwise, the test catches the SystemExit and continues executing in parallel with the original test, so you wind up with an exponential number of tests running concurrently. """ os._exit(0) def ignoring_eintr(__func, *args, **kwargs): try: return __func(*args, **kwargs) except EnvironmentError as e: if e.errno != errno.EINTR: raise return None class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. def setUp(self): self.using_gc = gc.isenabled() gc.disable() def tearDown(self): if self.using_gc: gc.enable() def format_frame(self, frame, limit=None): return ''.join(traceback.format_stack(frame, limit=limit)) def handlerA(self, signum, frame): self.a_called = True if test_support.verbose: print "handlerA invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) def handlerB(self, signum, frame): self.b_called = True if test_support.verbose: print "handlerB invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) raise HandlerBCalled(signum, self.format_frame(frame)) def wait(self, child): """Wait for child to finish, ignoring EINTR.""" while True: try: child.wait() return except OSError as e: if e.errno != errno.EINTR: raise def run_test(self): # Install handlers. This function runs in a sub-process, so we # don't worry about re-setting the default handlers. signal.signal(signal.SIGHUP, self.handlerA) signal.signal(signal.SIGUSR1, self.handlerB) signal.signal(signal.SIGUSR2, signal.SIG_IGN) signal.signal(signal.SIGALRM, signal.default_int_handler) # Variables the signals will modify: self.a_called = False self.b_called = False # Let the sub-processes know who to send signals to. pid = os.getpid() if test_support.verbose: print "test runner's pid is", pid child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)]) if child: self.wait(child) if not self.a_called: time.sleep(1) # Give the signal time to be delivered. self.assertTrue(self.a_called) self.assertFalse(self.b_called) self.a_called = False # Make sure the signal isn't delivered while the previous # Popen object is being destroyed, because __del__ swallows # exceptions. del child try: child = subprocess.Popen(['kill', '-USR1', str(pid)]) # This wait should be interrupted by the signal's exception. self.wait(child) time.sleep(1) # Give the signal time to be delivered. self.fail('HandlerBCalled exception not thrown') except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) if test_support.verbose: print "HandlerBCalled exception caught" child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)]) if child: self.wait(child) # Nothing should happen. try: signal.alarm(1) # The race condition in pause doesn't matter in this case, # since alarm is going to raise a KeyboardException, which # will skip the call. signal.pause() # But if another signal arrives before the alarm, pause # may return early. time.sleep(1) except KeyboardInterrupt: if test_support.verbose: print "KeyboardInterrupt (the alarm() went off)" except: self.fail("Some other exception woke us from pause: %s" % traceback.format_exc()) else: self.fail("pause returned of its own accord, and the signal" " didn't arrive after another second.") def test_main(self): # Issue 3864, unknown if this affects earlier versions of freebsd also if sys.platform=='freebsd6': if test_support.verbose: sys.stderr.write('skipping -- inter process signals not ' 'reliable (do not mix well with threading) on freebsd6\n') return # This function spawns a child process to insulate the main # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child # throws. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with nested(closing(os.fdopen(os_done_r)), closing(os.fdopen(os_done_w, 'w'))) as (done_r, done_w): child = os.fork() if child == 0: # In the child process; run the test and report results # through the pipe. try: done_r.close() # Have to close done_w again here because # exit_subprocess() will skip the enclosing with block. with closing(done_w): try: self.run_test() except: pickle.dump(traceback.format_exc(), done_w) else: pickle.dump(None, done_w) except: print 'Uh oh, raised from pickle.' traceback.print_exc() finally: exit_subprocess() done_w.close() # Block for up to MAX_DURATION seconds for the test to finish. r, w, x = select.select([done_r], [], [], self.MAX_DURATION) if done_r in r: tb = pickle.load(done_r) if tb: self.fail(tb) else: os.kill(child, signal.SIGKILL) self.fail('Test deadlocked after %d seconds.' % self.MAX_DURATION) class BasicSignalTests(unittest.TestCase): def trivial_signal_handler(self, *args): pass def test_out_of_range_signal_number_raises_error(self): self.assertRaises(ValueError, signal.getsignal, 4242) self.assertRaises(ValueError, signal.signal, 4242, self.trivial_signal_handler) def test_setting_signal_handler_to_none_raises_error(self): self.assertRaises(TypeError, signal.signal, signal.SIGUSR1, None) def test_getsignal(self): hup = signal.signal(signal.SIGHUP, self.trivial_signal_handler) self.assertEquals(signal.getsignal(signal.SIGHUP), self.trivial_signal_handler) signal.signal(signal.SIGHUP, hup) self.assertEquals(signal.getsignal(signal.SIGHUP), hup) class WakeupSignalTests(unittest.TestCase): TIMEOUT_FULL = 10 TIMEOUT_HALF = 5 def test_wakeup_fd_early(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the sleep, # before select is called time.sleep(self.TIMEOUT_FULL) mid_time = time.time() self.assert_(mid_time - before_time < self.TIMEOUT_HALF) select.select([self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assert_(after_time - mid_time < self.TIMEOUT_HALF) def test_wakeup_fd_during(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the select call self.assertRaises(select.error, select.select, [self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assert_(after_time - before_time < self.TIMEOUT_HALF) def setUp(self): import fcntl self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None) self.read, self.write = os.pipe() flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(self.write, fcntl.F_SETFL, flags) self.old_wakeup = signal.set_wakeup_fd(self.write) def tearDown(self): signal.set_wakeup_fd(self.old_wakeup) os.close(self.read) os.close(self.write) signal.signal(signal.SIGALRM, self.alrm) class SiginterruptTest(unittest.TestCase): signum = signal.SIGUSR1 def setUp(self): """Install a no-op signal handler that can be set to allow interrupts or not, and arrange for the original signal handler to be re-installed when the test is finished. """ self._cleanups = [] oldhandler = signal.signal(self.signum, lambda x,y: None) self.addCleanup(signal.signal, self.signum, oldhandler) def tearDown(self): """Run any cleanup functions which have been registered. """ for (f, a) in self._cleanups: f(*a) def addCleanup(self, f, *a): """Register a function to be called at the end of the test method run. """ self._cleanups.append((f, a)) def readpipe_interrupted(self): """Perform a read during which a signal will arrive. Return True if the read is interrupted by the signal and raises an exception. Return False if it returns normally. """ # Create a pipe that can be used for the read. Also clean it up # when the test is over, since nothing else will (but see below for # the write end). r, w = os.pipe() self.addCleanup(os.close, r) # Create another process which can send a signal to this one to try # to interrupt the read. ppid = os.getpid() pid = os.fork() if pid == 0: # Child code: sleep to give the parent enough time to enter the # read() call (there's a race here, but it's really tricky to # eliminate it); then signal the parent process. Also, sleep # again to make it likely that the signal is delivered to the # parent process before the child exits. If the child exits # first, the write end of the pipe will be closed and the test # is invalid. try: time.sleep(0.2) os.kill(ppid, self.signum) time.sleep(0.2) finally: # No matter what, just exit as fast as possible now. exit_subprocess() else: # Parent code. # Make sure the child is eventually reaped, else it'll be a # zombie for the rest of the test suite run. self.addCleanup(os.waitpid, pid, 0) # Close the write end of the pipe. The child has a copy, so # it's not really closed until the child exits. We need it to # close when the child exits so that in the non-interrupt case # the read eventually completes, otherwise we could just close # it *after* the test. os.close(w) # Try the read and report whether it is interrupted or not to # the caller. try: d = os.read(r, 1) return False except OSError, err: if err.errno != errno.EINTR: raise return True def test_without_siginterrupt(self): """If a signal handler is installed and siginterrupt is not called at all, when that signal arrives, it interrupts a syscall that's in progress. """ i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_on(self): """If a signal handler is installed and siginterrupt is called with a true value for the second argument, when that signal arrives, it interrupts a syscall that's in progress. """ signal.siginterrupt(self.signum, 1) i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_off(self): """If a signal handler is installed and siginterrupt is called with a false value for the second argument, when that signal arrives, it does not interrupt a syscall that's in progress. """ signal.siginterrupt(self.signum, 0) i = self.readpipe_interrupted() self.assertFalse(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertFalse(i) class ItimerTest(unittest.TestCase): def setUp(self): self.hndl_called = False self.hndl_count = 0 self.itimer = None self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) def sig_alrm(self, *args): self.hndl_called = True if test_support.verbose: print("SIGALRM handler invoked", args) def sig_vtalrm(self, *args): self.hndl_called = True if self.hndl_count > 3: # it shouldn't be here, because it should have been disabled. raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL " "timer.") elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) if test_support.verbose: print("last SIGVTALRM handler call") self.hndl_count += 1 if test_support.verbose: print("SIGVTALRM handler invoked", args) def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args) def test_itimer_exc(self): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) # Negative times are treated as zero on some platforms. if 0: self.assertRaises(signal.ItimerError, signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1.0) if test_support.verbose: print("\ncall pause()...") signal.pause() self.assertEqual(self.hndl_called, True) def test_itimer_virtual(self): # Issue 3864, unknown if this affects earlier versions of freebsd also if sys.platform=='freebsd6': if test_support.verbose: sys.stderr.write('skipping -- itimer not reliable (does not ' 'mix well with threading) on freebsd6\n') return self.itimer = signal.ITIMER_VIRTUAL signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer else: # Issue 8424 sys.stderr.write("test_itimer_virtual: timeout: likely cause: " "machine too slow or load too high.\n") return # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEquals(self.hndl_called, True) def test_itimer_prof(self): # Issue 3864, unknown if this affects earlier versions of freebsd also if sys.platform=='freebsd6': if test_support.verbose: sys.stderr.write('skipping -- itimer not reliable (does not ' 'mix well with threading) on freebsd6\n') return self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 sys.stdout.write("test_itimer_prof: timeout: likely cause: " "machine too slow or load too high.\n") return # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) def test_main(): test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest, ItimerTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_smtplib.py0000644000076500000000000004157512666555342021143 0ustar jmaddenwheel00000000000000import asyncore import email.utils import socket import threading import smtpd import smtplib import StringIO import sys import time import select from unittest import TestCase from test import test_support HOST = test_support.HOST def server(evt, buf, serv): serv.listen(5) evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: n = 500 while buf and n > 0: r, w, e = select.select([], [conn], []) if w: sent = conn.send(buf) buf = buf[sent:] n -= 1 conn.close() finally: serv.close() evt.set() class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "220 Hola mundo\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() def testBasic1(self): # connects smtp = smtplib.SMTP(HOST, self.port) smtp.close() def testBasic2(self): # connects, include port in host name smtp = smtplib.SMTP("%s:%s" % (HOST, self.port)) smtp.close() def testLocalHostName(self): # check that supplied local_hostname is used smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost") self.assertEqual(smtp.local_hostname, "testhost") smtp.close() def testTimeoutDefault(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() def testTimeoutNone(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(smtp.sock.gettimeout() is None) smtp.close() def testTimeoutValue(self): smtp = smtplib.SMTP(HOST, self.port, timeout=30) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() # Test server thread using the specified SMTP server class def debugging_server(serv, serv_evt, client_evt): serv_evt.set() try: if hasattr(select, 'poll'): poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll n = 1000 while asyncore.socket_map and n > 0: poll_fun(0.01, asyncore.socket_map) # when the client conversation is finished, it will # set client_evt, and it's then ok to kill the server if client_evt.is_set(): serv.close() break n -= 1 except socket.timeout: pass finally: if not client_evt.is_set(): # allow some time for the client to read the result time.sleep(0.5) serv.close() asyncore.close_all() serv_evt.set() MSG_BEGIN = '---------- MESSAGE FOLLOWS ----------\n' MSG_END = '------------ END MESSAGE ------------\n' # NOTE: Some SMTP objects in the tests below are created with a non-default # local_hostname argument to the constructor, since (on some systems) the FQDN # lookup caused by the default local_hostname sometimes takes so long that the # test server times out, causing the test to fail. # Test behavior of smtpd.DebuggingServer class DebuggingServerTests(TestCase): def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() # restore sys.stdout sys.stdout = self.old_stdout def testBasic(self): # connect smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.quit() def testNOOP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.noop(), expected) smtp.quit() def testRSET(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.rset(), expected) smtp.quit() def testNotImplemented(self): # EHLO isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "EHLO" not implemented') self.assertEqual(smtp.ehlo(), expected) smtp.quit() def testVRFY(self): # VRFY isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "VRFY" not implemented') self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected) self.assertEqual(smtp.verify('nobody@nowhere.com'), expected) smtp.quit() def testSecondHELO(self): # check that a second HELO returns a message that it's a duplicate # (this behavior is specific to smtpd.SMTPChannel) smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.helo() expected = (503, 'Duplicate HELO/EHLO') self.assertEqual(smtp.helo(), expected) smtp.quit() def testHELP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) self.assertEqual(smtp.help(), 'Error: command "HELP" not implemented') smtp.quit() def testSend(self): # connect and send mail m = 'A test message' smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.sendmail('John', 'Sally', m) # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor # in asyncore. This sleep might help, but should really be fixed # properly by using an Event variable. time.sleep(0.01) smtp.quit() self.client_evt.set() self.serv_evt.wait() self.output.flush() mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END) self.assertEqual(self.output.getvalue(), mexpect) class NonConnectingTests(TestCase): def testNotConnected(self): # Test various operations on an unconnected SMTP object that # should raise exceptions (at present the attempt in SMTP.send # to reference the nonexistent 'sock' attribute of the SMTP object # causes an AttributeError) smtp = smtplib.SMTP() self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) self.assertRaises(smtplib.SMTPServerDisconnected, smtp.send, 'test msg') def testNonnumericPort(self): # check that non-numeric port raises socket.error self.assertRaises(socket.error, smtplib.SMTP, "localhost", "bogus") self.assertRaises(socket.error, smtplib.SMTP, "localhost:bogus") # test response of client to a non-successful HELO message class BadHELOServerTests(TestCase): def setUp(self): self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "199 no hello for you!\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() sys.stdout = self.old_stdout def testFailingHELO(self): self.assertRaises(smtplib.SMTPConnectError, smtplib.SMTP, HOST, self.port, 'localhost', 3) sim_users = {'Mr.A@somewhere.com':'John A', 'Ms.B@somewhere.com':'Sally B', 'Mrs.C@somewhereesle.com':'Ruth C', } sim_auth = ('Mr.A@somewhere.com', 'somepassword') sim_cram_md5_challenge = ('PENCeUxFREJoU0NnbmhNWitOMjNGNn' 'dAZWx3b29kLmlubm9zb2Z0LmNvbT4=') sim_auth_credentials = { 'login': 'TXIuQUBzb21ld2hlcmUuY29t', 'plain': 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ=', 'cram-md5': ('TXIUQUBZB21LD2HLCMUUY29TIDG4OWQ0MJ' 'KWZGQ4ODNMNDA4NTGXMDRLZWMYZJDMODG1'), } sim_auth_login_password = 'C29TZXBHC3N3B3JK' sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'], 'list-2':['Ms.B@somewhere.com',], } # Simulated SMTP channel & server class SimSMTPChannel(smtpd.SMTPChannel): def __init__(self, extra_features, *args, **kw): self._extrafeatures = ''.join( [ "250-{0}\r\n".format(x) for x in extra_features ]) smtpd.SMTPChannel.__init__(self, *args, **kw) def smtp_EHLO(self, arg): resp = ('250-testhost\r\n' '250-EXPN\r\n' '250-SIZE 20000000\r\n' '250-STARTTLS\r\n' '250-DELIVERBY\r\n') resp = resp + self._extrafeatures + '250 HELP' self.push(resp) def smtp_VRFY(self, arg): raw_addr = email.utils.parseaddr(arg)[1] quoted_addr = smtplib.quoteaddr(arg) if raw_addr in sim_users: self.push('250 %s %s' % (sim_users[raw_addr], quoted_addr)) else: self.push('550 No such user: %s' % arg) def smtp_EXPN(self, arg): list_name = email.utils.parseaddr(arg)[1].lower() if list_name in sim_lists: user_list = sim_lists[list_name] for n, user_email in enumerate(user_list): quoted_addr = smtplib.quoteaddr(user_email) if n < len(user_list) - 1: self.push('250-%s %s' % (sim_users[user_email], quoted_addr)) else: self.push('250 %s %s' % (sim_users[user_email], quoted_addr)) else: self.push('550 No access for you!') def smtp_AUTH(self, arg): if arg.strip().lower()=='cram-md5': self.push('334 {0}'.format(sim_cram_md5_challenge)) return mech, auth = arg.split() mech = mech.lower() if mech not in sim_auth_credentials: self.push('504 auth type unimplemented') return if mech == 'plain' and auth==sim_auth_credentials['plain']: self.push('235 plain auth ok') elif mech=='login' and auth==sim_auth_credentials['login']: self.push('334 Password:') else: self.push('550 No access for you!') class SimSMTPServer(smtpd.SMTPServer): def __init__(self, *args, **kw): self._extra_features = [] smtpd.SMTPServer.__init__(self, *args, **kw) def handle_accept(self): conn, addr = self.accept() self._SMTPchannel = SimSMTPChannel(self._extra_features, self, conn, addr) def process_message(self, peer, mailfrom, rcpttos, data): pass def add_feature(self, feature): self._extra_features.append(feature) # Test various SMTP & ESMTP commands/behaviors that require a simulated server # (i.e., something with more features than DebuggingServer) class SMTPSimTests(TestCase): def setUp(self): self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() def testBasic(self): # smoke test smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) smtp.quit() def testEHLO(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) # no features should be present before the EHLO self.assertEqual(smtp.esmtp_features, {}) # features expected from the test server expected_features = {'expn':'', 'size': '20000000', 'starttls': '', 'deliverby': '', 'help': '', } smtp.ehlo() self.assertEqual(smtp.esmtp_features, expected_features) for k in expected_features: self.assertTrue(smtp.has_extn(k)) self.assertFalse(smtp.has_extn('unsupported-feature')) smtp.quit() def testVRFY(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for email, name in sim_users.items(): expected_known = (250, '%s %s' % (name, smtplib.quoteaddr(email))) self.assertEqual(smtp.vrfy(email), expected_known) u = 'nobody@nowhere.com' expected_unknown = (550, 'No such user: %s' % smtplib.quoteaddr(u)) self.assertEqual(smtp.vrfy(u), expected_unknown) smtp.quit() def testEXPN(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for listname, members in sim_lists.items(): users = [] for m in members: users.append('%s %s' % (sim_users[m], smtplib.quoteaddr(m))) expected_known = (250, '\n'.join(users)) self.assertEqual(smtp.expn(listname), expected_known) u = 'PSU-Members-List' expected_unknown = (550, 'No access for you!') self.assertEqual(smtp.expn(u), expected_unknown) smtp.quit() def testAUTH_PLAIN(self): self.serv.add_feature("AUTH PLAIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) expected_auth_ok = (235, b'plain auth ok') self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok) # SimSMTPChannel doesn't fully support LOGIN or CRAM-MD5 auth because they # require a synchronous read to obtain the credentials...so instead smtpd # sees the credential sent by smtplib's login method as an unknown command, # which results in smtplib raising an auth error. Fortunately the error # message contains the encoded credential, so we can partially check that it # was generated correctly (partially, because the 'word' is uppercased in # the error message). def testAUTH_LOGIN(self): self.serv.add_feature("AUTH LOGIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_login_password not in str(err): raise "expected encoded password not found in error message" def testAUTH_CRAM_MD5(self): self.serv.add_feature("AUTH CRAM-MD5") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_credentials['cram-md5'] not in str(err): raise "expected encoded credentials not found in error message" #TODO: add tests for correct AUTH method fallback now that the #test infrastructure can support it. def test_main(verbose=None): test_support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests, BadHELOServerTests, SMTPSimTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_socket.py0000644000076500000000000013170212666555342020751 0ustar jmaddenwheel00000000000000#!/usr/bin/env python import unittest from test import test_support import errno import socket import select import thread, threading import time import traceback import Queue import sys import os import array from weakref import proxy import signal HOST = test_support.HOST MSG = 'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = test_support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceeded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) self.__setUp() if not self.server_ready.is_set(): self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() if not self.queue.empty(): msg = self.queue.get() self.fail(msg) def clientRun(self, test_func): self.server_ready.wait() self.client_ready.set() self.clientSetUp() with test_support._check_py3k_warnings(): if not callable(test_func): raise TypeError("test_func must be a callable function.") try: test_func() except Exception, strerror: self.queue.put(strerror) self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) class SocketConnectedTest(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def testSocketError(self): # Testing socket module exceptions def raise_error(*args, **kwargs): raise socket.error def raise_herror(*args, **kwargs): raise socket.herror def raise_gaierror(*args, **kwargs): raise socket.gaierror self.failUnlessRaises(socket.error, raise_error, "Error raising socket exception.") self.failUnlessRaises(socket.error, raise_herror, "Error raising socket exception.") self.failUnlessRaises(socket.error, raise_gaierror, "Error raising socket exception.") def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except socket.error: # Probably name lookup wasn't set up right; skip this test return self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except socket.error: # Probably a similar problem as above; skip this test return all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo if hasattr(sys, "getrefcount"): try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: self.assertEqual(sys.getrefcount(__name__), orig, "socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except socket.error: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1L< 0: self.handle_read_event() return True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except socket.error, err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() else: data = self.recv(1024) if data and data.strip() != 'over': self.send(data.lower()) def handle_close(self): self.close() if test_support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): raise def __init__(self, certfile): self.certfile = certfile asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.socket) self.listen(5) def handle_accept(self): sock_obj, addr = self.accept() if test_support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) def handle_error(self): raise def __init__(self, certfile): self.flag = None self.active = False self.server = self.EchoServer(certfile) self.port = self.server.port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.active = True if self.flag: self.flag.set() while self.active: asyncore.loop(0.05) def stop(self): self.active = False self.server.close() class SocketServerHTTPSServer(threading.Thread): class HTTPSServer(HTTPServer): def __init__(self, server_address, RequestHandlerClass, certfile): HTTPServer.__init__(self, server_address, RequestHandlerClass) # we assume the certfile contains both private key and certificate self.certfile = certfile self.allow_reuse_address = True def __str__(self): return ('<%s %s:%s>' % (self.__class__.__name__, self.server_name, self.server_port)) def get_request(self): # override this to wrap socket with SSL sock, addr = self.socket.accept() sslconn = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile) return sslconn, addr class RootedHTTPRequestHandler(SimpleHTTPRequestHandler): # need to override translate_path to get a known root, # instead of using os.curdir, since the test could be # run from anywhere server_version = "TestHTTPS/1.0" root = None def translate_path(self, path): """Translate a /-separated PATH to the local filename syntax. Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.) """ # abandon query parameters path = urlparse.urlparse(path)[2] path = os.path.normpath(urllib.unquote(path)) words = path.split('/') words = filter(None, words) path = self.root for word in words: drive, word = os.path.splitdrive(word) head, word = os.path.split(word) if word in self.root: continue path = os.path.join(path, word) return path def log_message(self, format, *args): # we override this to suppress logging unless "verbose" if test_support.verbose: sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" % (self.server.server_address, self.server.server_port, self.request.cipher(), self.log_date_time_string(), format%args)) def __init__(self, certfile): self.flag = None self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] self.server = self.HTTPSServer( (HOST, 0), self.RootedHTTPRequestHandler, certfile) self.port = self.server.server_port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): if self.flag: self.flag.set() self.server.serve_forever(0.05) def stop(self): self.server.shutdown() def bad_cert_test(certfile): """ Launch a server with CERT_REQUIRED, and check that trying to connect to it with the given client certificate fails. """ server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: try: s = ssl.wrap_socket(socket.socket(), certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError, x: if test_support.verbose: sys.stdout.write("\nSSLError is %s\n" % x[1]) except socket.error, x: if test_support.verbose: sys.stdout.write("\nsocket.error is %s\n" % x[1]) else: self.fail("Use of invalid cert should have failed!") finally: server.stop() server.join() def server_params_test(certfile, protocol, certreqs, cacertsfile, client_certfile, client_protocol=None, indata="FOO\n", chatty=True, connectionchatty=False, wrap_accepting_socket=False): """ Launch a server, connect a client to it and try various reads and writes. """ server = ThreadedEchoServer(certfile, certreqs=certreqs, ssl_version=protocol, cacerts=cacertsfile, chatty=chatty, connectionchatty=connectionchatty, wrap_accepting_socket=wrap_accepting_socket) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect if client_protocol is None: client_protocol = protocol try: s = ssl.wrap_socket(socket.socket(), certfile=client_certfile, ca_certs=cacertsfile, cert_reqs=certreqs, ssl_version=client_protocol) s.connect((HOST, server.port)) if connectionchatty: if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.write(indata) outdata = s.read() if connectionchatty: if test_support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) if outdata != indata.lower(): self.fail( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (outdata[:min(len(outdata),20)], len(outdata), indata[:min(len(indata),20)].lower(), len(indata))) s.write("over\n") if connectionchatty: if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: server.stop() server.join() def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None): if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if test_support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) try: server_params_test(CERTFILE, server_protocol, certsreqs, CERTFILE, CERTFILE, client_protocol, chatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except socket.error as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) class ThreadedTests(unittest.TestCase): def test_rude_shutdown(self): """A brutal shutdown of an SSL server should raise an IOError in the client when attempting handshake. """ listener_ready = threading.Event() listener_gone = threading.Event() s = socket.socket() port = test_support.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, # and sets Event `listener_gone` to let the main thread know # the socket is gone. def listener(): s.listen(5) listener_ready.set() s.accept() s.close() listener_gone.set() def connector(): listener_ready.wait() c = socket.socket() c.connect((HOST, port)) listener_gone.wait() try: ssl_sock = ssl.wrap_socket(c) except IOError: pass else: self.fail('connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) t.start() try: connector() finally: t.join() def test_echo(self): """Basic test of an SSL client connecting to a server""" if test_support.verbose: sys.stdout.write("\n") server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE, CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1, chatty=True, connectionchatty=True) def test_getpeercert(self): if test_support.verbose: sys.stdout.write("\n") s2 = socket.socket() server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_SSLv23, cacerts=CERTFILE, chatty=False) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: s = ssl.wrap_socket(socket.socket(), certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_SSLv23) s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() if test_support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: self.fail("No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): self.fail( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") s.close() finally: server.stop() server.join() def test_empty_cert(self): """Connecting with an empty cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "nullcert.pem")) def test_malformed_cert(self): """Connecting with a badly formatted certificate (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badcert.pem")) def test_nonexisting_cert(self): """Connecting with a non-existing cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "wrongcert.pem")) def test_malformed_key(self): """Connecting with a badly formatted key (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badkey.pem")) def test_protocol_sslv2(self): """Connecting to an SSLv2 server with various client options""" if test_support.verbose: sys.stdout.write("\ntest_protocol_sslv2 disabled, " "as it fails on OpenSSL 1.0.0+") return try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) def test_protocol_sslv23(self): """Connecting to an SSLv23 server with various client options""" if test_support.verbose: sys.stdout.write("\ntest_protocol_sslv23 disabled, " "as it fails on OpenSSL 1.0.0+") return try: try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) def test_protocol_sslv3(self): """Connecting to an SSLv3 server with various client options""" if test_support.verbose: sys.stdout.write("\ntest_protocol_sslv3 disabled, " "as it fails on OpenSSL 1.0.0+") return try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) def test_protocol_tlsv1(self): """Connecting to a TLSv1 server with various client options""" if test_support.verbose: sys.stdout.write("\ntest_protocol_tlsv1 disabled, " "as it fails on OpenSSL 1.0.0+") return try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False) def test_starttls(self): """Switching from clear text to encrypted and back again.""" msgs = ("msg 1", "MSG 2", "STARTTLS", "MSG 3", "msg 4", "ENDTLS", "msg 5", "msg 6") server = ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, starttls_server=True, chatty=True, connectionchatty=True) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect wrapped = False try: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) if test_support.verbose: sys.stdout.write("\n") for indata in msgs: if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % repr(indata)) if wrapped: conn.write(indata) outdata = conn.read() else: s.send(indata) outdata = s.recv(1024) if (indata == "STARTTLS" and outdata.strip().lower().startswith("ok")): # STARTTLS ok, switch to secure mode if test_support.verbose: sys.stdout.write( " client: read %s from server, starting TLS...\n" % repr(outdata)) conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) wrapped = True elif (indata == "ENDTLS" and outdata.strip().lower().startswith("ok")): # ENDTLS ok, switch back to clear text if test_support.verbose: sys.stdout.write( " client: read %s from server, ending TLS...\n" % repr(outdata)) s = conn.unwrap() wrapped = False else: if test_support.verbose: sys.stdout.write( " client: read %s from server\n" % repr(outdata)) if test_support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write("over\n") else: s.send("over\n") s.close() finally: server.stop() server.join() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" server = SocketServerHTTPSServer(CERTFILE) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: if test_support.verbose: sys.stdout.write('\n') with open(CERTFILE, 'rb') as f: d1 = f.read() d2 = '' # now fetch the same data from the HTTPS server url = 'https://127.0.0.1:%d/%s' % ( server.port, os.path.split(CERTFILE)[1]) with test_support._check_py3k_warnings(): f = urllib.urlopen(url) dlen = f.info().getheader("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) if test_support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) f.close() self.assertEqual(d1, d2) finally: server.stop() server.join() def test_wrapped_accept(self): """Check the accept() method on SSL sockets.""" if test_support.verbose: sys.stdout.write("\n") server_params_test(CERTFILE, ssl.PROTOCOL_SSLv23, ssl.CERT_REQUIRED, CERTFILE, CERTFILE, ssl.PROTOCOL_SSLv23, chatty=True, connectionchatty=True, wrap_accepting_socket=True) def test_asyncore_server(self): """Check the example asyncore integration.""" indata = "TEST MESSAGE of mixed case\n" if test_support.verbose: sys.stdout.write("\n") server = AsyncoreEchoServer(CERTFILE) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.write(indata) outdata = s.read() if test_support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) if outdata != indata.lower(): self.fail( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (outdata[:min(len(outdata),20)], len(outdata), indata[:min(len(indata),20)].lower(), len(indata))) s.write("over\n") if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: server.stop() # wait for server thread to end server.join() def test_recv_send(self): """Test recv(), send() and friends.""" if test_support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) try: # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray("\0"*100) count = s.recv_into(b) return b[:count] def _recvfrom_into(): b = bytearray("\0"*100) count, addr = s.recvfrom_into(b) return b[:count] # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]), ('sendall', s.sendall, True, []), ] recv_methods = [ ('recv', s.recv, True, []), ('recvfrom', s.recvfrom, False, ["some.address"]), ('recv_into', _recv_into, True, []), ('recvfrom_into', _recvfrom_into, False, []), ] data_prefix = u"PREFIX_" for meth_name, send_meth, expect_success, args in send_methods: indata = data_prefix + meth_name try: send_meth(indata.encode('ASCII', 'strict'), *args) outdata = s.read() outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): raise support.TestFailed( "While sending with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( meth_name, outdata[:20], len(outdata), indata[:20], len(indata) ) ) except ValueError as e: if expect_success: raise support.TestFailed( "Failed to send with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): raise support.TestFailed( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e ) ) for meth_name, recv_meth, expect_success, args in recv_methods: indata = data_prefix + meth_name try: s.send(indata.encode('ASCII', 'strict')) outdata = recv_meth(*args) outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): raise support.TestFailed( "While receiving with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( meth_name, outdata[:20], len(outdata), indata[:20], len(indata) ) ) except ValueError as e: if expect_success: raise support.TestFailed( "Failed to receive with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): raise support.TestFailed( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e ) ) # consume data s.read() s.write("over\n".encode("ASCII", "strict")) s.close() finally: server.stop() server.join() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = test_support.bind_port(server) started = threading.Event() finish = False def serve(): server.listen(5) started.set() conns = [] while not finish: r, w, e = select.select([server], [], [], 0.1) if server in r: # Let the socket hang around rather than having # it closed by garbage collection. conns.append(server.accept()[0]) t = threading.Thread(target=serve) t.start() started.wait() try: try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c.connect((host, port)) # Will attempt handshake and time out try: ssl.wrap_socket(c) except ssl.SSLError, e: self.assertTrue("timed out" in str(e), str(e)) else: self.fail("SSLError wasn't raised") finally: c.close() try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c = ssl.wrap_socket(c) # Will attempt handshake and time out try: c.connect((host, port)) except ssl.SSLError, e: self.assertTrue("timed out" in str(e), str(e)) else: self.fail("SSLError wasn't raised") finally: c.close() finally: finish = True t.join() server.close() def test_main(verbose=False): if skip_expected: raise test_support.TestSkipped("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) try: test_support.run_unittest(*tests) finally: if _have_threads: test_support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_subprocess.py0000644000076500000000000007744412666555342021665 0ustar jmaddenwheel00000000000000import unittest from test import test_support import subprocess import sys import signal import os import errno import tempfile import time import re mswindows = (sys.platform == "win32") # # Depends on the following external programs: Python # if mswindows: SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), ' 'os.O_BINARY);') else: SETBINARY = '' # In a debug build, stuff like "[6580 refs]" is printed to stderr at # shutdown time. That frustrates tests trying to check stderr produced # from a spawned Python process. def remove_stderr_debug_decorations(stderr): return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) class ProcessTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). if hasattr(test_support, "reap_children"): test_support.reap_children() def tearDown(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). if hasattr(test_support, "reap_children"): test_support.reap_children() def mkstemp(self): """wrapper for mkstemp, calling mktemp if mkstemp is not available""" if hasattr(tempfile, "mkstemp"): return tempfile.mkstemp() else: fname = tempfile.mktemp() return os.open(fname, os.O_RDWR|os.O_CREAT), fname # # Generic tests # def test_call_seq(self): # call() function with sequence argument rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) def test_check_call_zero(self): # check_call() function with zero return code rc = subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(0)"]) self.assertEqual(rc, 0) def test_check_call_nonzero(self): # check_call() function with non-zero return code try: subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(47)"]) except subprocess.CalledProcessError, e: self.assertEqual(e.returncode, 47) else: self.fail("Expected CalledProcessError") def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() newenv["FRUIT"] = "banana" rc = subprocess.call([sys.executable, "-c", 'import sys, os;' \ 'sys.exit(os.getenv("FRUIT")=="banana")'], env=newenv) self.assertEqual(rc, 1) def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() self.assertEqual(p.stdin, None) def test_stdout_none(self): # .stdout is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print " this bit of output is from a ' 'test of stdout in a different ' 'process ..."'], stdin=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() self.assertEqual(p.stdout, None) def test_stderr_none(self): # .stderr is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) p.wait() self.assertEqual(p.stderr, None) def test_executable(self): p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"], executable=sys.executable) p.wait() self.assertEqual(p.returncode, 47) def test_stdin_pipe(self): # stdin redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.stdin.write("pear") p.stdin.close() p.wait() self.assertEqual(p.returncode, 1) def test_stdin_filedes(self): # stdin is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() os.write(d, "pear") os.lseek(d, 0, 0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=d) p.wait() self.assertEqual(p.returncode, 1) def test_stdin_fileobj(self): # stdin is set to open file object tf = tempfile.TemporaryFile() tf.write("pear") tf.seek(0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=tf) p.wait() self.assertEqual(p.returncode, 1) def test_stdout_pipe(self): # stdout redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=subprocess.PIPE) self.assertEqual(p.stdout.read(), "orange") def test_stdout_filedes(self): # stdout is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), "orange") def test_stdout_fileobj(self): # stdout is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), "orange") def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.assertEqual(remove_stderr_debug_decorations(p.stderr.read()), "strawberry") def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(remove_stderr_debug_decorations(os.read(d, 1024)), "strawberry") def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertEqual(remove_stderr_debug_decorations(tf.read()), "strawberry") def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' \ 'sys.stdout.write("apple");' \ 'sys.stdout.flush();' \ 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.stdout.read() stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys;' \ 'sys.stdout.write("apple");' \ 'sys.stdout.flush();' \ 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) output = tf.read() stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) self.assertEquals(rc, 2) def test_cwd(self): tmpdir = tempfile.gettempdir() # We cannot use os.path.realpath to canonicalize the path, # since it doesn't expand Tru64 {memb} strings. See bug 1063571. cwd = os.getcwd() os.chdir(tmpdir) tmpdir = os.getcwd() os.chdir(cwd) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir)) def test_env(self): newenv = os.environ.copy() newenv["FRUIT"] = "orange" p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read(), "orange") def test_communicate_stdin(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.communicate("pear") self.assertEqual(p.returncode, 1) def test_communicate_stdout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("pineapple")'], stdout=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, "pineapple") self.assertEqual(stderr, None) def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(remove_stderr_debug_decorations(stderr), "pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate("banana") self.assertEqual(stdout, "banana") self.assertEqual(remove_stderr_debug_decorations(stderr), "pineapple") # This test is Linux specific for simplicity to at least have # some coverage. It is not a platform specific bug. if os.path.isdir('/proc/%d/fd' % os.getpid()): # Test for the fd leak reported in http://bugs.python.org/issue2791. def test_communicate_pipe_fd_leak(self): fd_directory = '/proc/%d/fd' % os.getpid() num_fds_before_popen = len(os.listdir(fd_directory)) p = subprocess.Popen([sys.executable, '-c', 'print()'], stdout=subprocess.PIPE) p.communicate() num_fds_after_communicate = len(os.listdir(fd_directory)) del p num_fds_after_destruction = len(os.listdir(fd_directory)) self.assertEqual(num_fds_before_popen, num_fds_after_destruction) self.assertEqual(num_fds_before_popen, num_fds_after_communicate) def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"]) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, None) def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. x, y = os.pipe() if mswindows: pipe_buf = 512 else: pipe_buf = os.fpathconf(x, "PC_PIPE_BUF") os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' \ 'sys.stderr.write("xyz"*%d);' \ 'sys.stdout.write(sys.stdin.read())' % pipe_buf], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) string_to_write = "abc"*pipe_buf (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.stdin.write("banana") (stdout, stderr) = p.communicate("split") self.assertEqual(stdout, "bananasplit") self.assertEqual(remove_stderr_debug_decorations(stderr), "") def test_universal_newlines(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, universal_newlines=1) stdout = p.stdout.read() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_universal_newlines_communicate(self): # universal newlines through communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_no_leaking(self): # Make sure we leak no resources if not hasattr(test_support, "is_resource_enabled") \ or test_support.is_resource_enabled("subprocess") and not mswindows: max_handles = 1026 # too much for most UNIX systems else: max_handles = 65 for i in range(max_handles): p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate("lime")[0] self.assertEqual(data, "lime") def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), '"a b c" d e') self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']), 'ab\\"c \\ d') self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']), 'ab\\"c " \\\\" d') self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']), 'a\\\\\\b "de fg" h') self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']), 'a\\\\\\"b c d') self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']), '"a\\\\b c" d e') self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']), '"a\\\\b\\ c" d e') self.assertEqual(subprocess.list2cmdline(['ab', '']), 'ab ""') def test_poll(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(1)"]) count = 0 while p.poll() is None: time.sleep(0.1) count += 1 # We expect that the poll loop probably went around about 10 times, # but, based on system scheduling we can't control, it's possible # poll() never returned None. It "should be" very rare that it # didn't go around at least twice. self.assert_(count >= 2) # Subsequent invocations should just return the returncode self.assertEqual(p.poll(), 0) def test_wait(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(2)"]) self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) def test_invalid_bufsize(self): # an invalid type of the bufsize argument should raise # TypeError. try: subprocess.Popen([sys.executable, "-c", "pass"], "orange") except TypeError: pass else: self.fail("Expected TypeError") def test_leaking_fds_on_error(self): # see bug #5179: Popen leaks file descriptors to PIPEs if # the child fails to execute; this will eventually exhaust # the maximum number of open fds. 1024 seems a very common # value for that limit, but Windows has 2048, so we loop # 1024 times (each call leaked two fds). for i in range(1024): try: subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Windows raises IOError except (IOError, OSError), err: if err.errno != 2: # ignore "no such file" raise # # POSIX tests # if not mswindows: def test_exceptions(self): # catched & re-raised exceptions try: p = subprocess.Popen([sys.executable, "-c", ""], cwd="/this/path/does/not/exist") except OSError, e: # The attribute child_traceback should contain "os.chdir" # somewhere. self.assertNotEqual(e.child_traceback.find("os.chdir"), -1) else: self.fail("Expected OSError") def _suppress_core_files(self): """Try to prevent core files from being created. Returns previous ulimit if successful, else None. """ if sys.platform == 'darwin': # Check if the 'Crash Reporter' on OSX was configured # in 'Developer' mode and warn that it will get triggered # when it is. # # This assumes that this context manager is used in tests # that might trigger the next manager. value = subprocess.Popen(['/usr/bin/defaults', 'read', 'com.apple.CrashReporter', 'DialogType'], stdout=subprocess.PIPE).communicate()[0] if value.strip() == b'developer': print "this tests triggers the Crash Reporter, that is intentional" sys.stdout.flush() try: import resource old_limit = resource.getrlimit(resource.RLIMIT_CORE) resource.setrlimit(resource.RLIMIT_CORE, (0,0)) return old_limit except (ImportError, ValueError, resource.error): return None def _unsuppress_core_files(self, old_limit): """Return core file behavior to default.""" if old_limit is None: return try: import resource resource.setrlimit(resource.RLIMIT_CORE, old_limit) except (ImportError, ValueError, resource.error): return def test_run_abort(self): # returncode handles signal termination old_limit = self._suppress_core_files() try: p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) finally: self._unsuppress_core_files(old_limit) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT) def test_preexec(self): # preexec function p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.assertEqual(p.stdout.read(), "apple") def test_args_string(self): # args is a string f, fname = self.mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0700) p = subprocess.Popen(fname) p.wait() os.remove(fname) self.assertEqual(p.returncode, 47) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], startupinfo=47) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], creationflags=47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen(["echo $FRUIT"], shell=1, stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read().strip(), "apple") def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen("echo $FRUIT", shell=1, stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read().strip(), "apple") def test_call_string(self): # call() function with string argument on UNIX f, fname = self.mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) def test_specific_shell(self): # Issue #9265: Incorrect name passed as arg[0]. shells = [] for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']: for name in ['bash', 'ksh']: sh = os.path.join(prefix, name) if os.path.isfile(sh): shells.append(sh) if not shells: # Will probably work for any shell but csh. return # skip test sh = '/bin/sh' if os.path.isfile(sh) and not os.path.islink(sh): # Test will fail if /bin/sh is a symlink to csh. shells.append(sh) for sh in shells: p = subprocess.Popen("echo $0", executable=sh, shell=True, stdout=subprocess.PIPE) self.assertEqual(p.stdout.read().strip(), sh) def DISABLED_test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.send_signal(signal.SIGINT) self.assertNotEqual(p.wait(), 0) def DISABLED_test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.kill() self.assertEqual(p.wait(), -signal.SIGKILL) def DISABLED_test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.terminate() self.assertEqual(p.wait(), -signal.SIGTERM) # # Windows tests # if mswindows: def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_MAXIMIZE # Since Python is a console process, it won't be affected # by wShowWindow, but the argument should be silently # ignored subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) def test_creationflags(self): # creationflags argument CREATE_NEW_CONSOLE = 16 sys.stderr.write(" a DOS box should flash briefly ...\n") subprocess.call(sys.executable + ' -c "import time; time.sleep(0.25)"', creationflags=CREATE_NEW_CONSOLE) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], stdout=subprocess.PIPE, close_fds=True) def test_close_fds(self): # close file descriptors rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"], close_fds=True) self.assertEqual(rc, 47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) self.assertNotEqual(p.stdout.read().find("physalis"), -1) def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) self.assertNotEqual(p.stdout.read().find("physalis"), -1) def test_call_string(self): # call() function with string argument on Windows rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) def DISABLED_test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.send_signal(signal.SIGTERM) self.assertNotEqual(p.wait(), 0) def DISABLED_test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.kill() self.assertNotEqual(p.wait(), 0) def DISABLED_test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) self.assert_(p.poll() is None, p.poll()) p.terminate() self.assertNotEqual(p.wait(), 0) class HelperFunctionTests(unittest.TestCase): def _test_eintr_retry_call(self): record_calls = [] def fake_os_func(*args): record_calls.append(args) if len(record_calls) == 2: raise OSError(errno.EINTR, "fake interrupted system call") return tuple(reversed(args)) self.assertEqual((999, 256), subprocess._eintr_retry_call(fake_os_func, 256, 999)) self.assertEqual([(256, 999)], record_calls) # This time there will be an EINTR so it will loop once. self.assertEqual((666,), subprocess._eintr_retry_call(fake_os_func, 666)) self.assertEqual([(256, 999), (666,), (666,)], record_calls) if not mswindows: test_eintr_retry_call = _test_eintr_retry_call def test_main(): test_support.run_unittest(ProcessTestCase, HelperFunctionTests) if hasattr(test_support, "reap_children"): test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_telnetlib.py0000644000076500000000000000416212666555342021442 0ustar jmaddenwheel00000000000000import socket import threading import telnetlib import time from unittest import TestCase from test import test_support HOST = test_support.HOST def server(evt, serv): serv.listen(5) evt.set() try: conn, addr = serv.accept() except socket.timeout: pass finally: serv.close() evt.set() class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) self.port = test_support.bind_port(self.sock) threading.Thread(target=server, args=(self.evt,self.sock)).start() self.evt.wait() self.evt.clear() time.sleep(.1) def tearDown(self): self.evt.wait() def testBasic(self): # connects telnet = telnetlib.Telnet(HOST, self.port) telnet.sock.close() def testTimeoutDefault(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet("localhost", self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutNone(self): # None, having other default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(telnet.sock.gettimeout() is None) telnet.sock.close() def testTimeoutValue(self): telnet = telnetlib.Telnet("localhost", self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutOpen(self): telnet = telnetlib.Telnet() telnet.open("localhost", self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def test_main(verbose=None): test_support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_thread.py0000644000076500000000000001471212666555342020731 0ustar jmaddenwheel00000000000000import os import unittest import random from test import test_support import thread import time import sys import lock_tests NUMTASKS = 10 NUMTRIPS = 3 _print_mutex = thread.allocate_lock() def verbose_print(arg): """Helper function for printing out debugging output.""" if test_support.verbose: with _print_mutex: print arg class BasicThreadTest(unittest.TestCase): def setUp(self): self.done_mutex = thread.allocate_lock() self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() self.created = 0 self.running = 0 self.next_ident = 0 class ThreadRunningTests(BasicThreadTest): def newtask(self): with self.running_mutex: self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) self.created += 1 self.running += 1 def task(self, ident): with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay*1e6))) time.sleep(delay) verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): # Basic test for thread creation. for i in range(NUMTASKS): self.newtask() verbose_print("waiting for tasks to complete...") self.done_mutex.acquire() verbose_print("all tasks done") def test_stack_size(self): # Various stack size tests. self.assertEquals(thread.stack_size(), 0, "intial stack size is not 0") thread.stack_size(0) self.assertEquals(thread.stack_size(), 0, "stack_size not reset to default") if os.name not in ("nt", "os2", "posix"): return tss_supported = True try: thread.stack_size(4096) except ValueError: verbose_print("caught expected ValueError setting " "stack_size(4096)") except thread.error: tss_supported = False verbose_print("platform does not support changing thread stack " "size") if tss_supported: fail_msg = "stack_size(%d) failed - should succeed" for tss in (262144, 0x100000, 0): thread.stack_size(tss) self.assertEquals(thread.stack_size(), tss, fail_msg % tss) verbose_print("successfully set stack_size(%d)" % tss) for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 self.created = 0 for i in range(NUMTASKS): self.newtask() verbose_print("waiting for all tasks to complete") self.done_mutex.acquire() verbose_print("all tasks done") thread.stack_size(0) class Barrier: def __init__(self, num_threads): self.num_threads = num_threads self.waiting = 0 self.checkin_mutex = thread.allocate_lock() self.checkout_mutex = thread.allocate_lock() self.checkout_mutex.acquire() def enter(self): self.checkin_mutex.acquire() self.waiting = self.waiting + 1 if self.waiting == self.num_threads: self.waiting = self.num_threads - 1 self.checkout_mutex.release() return self.checkin_mutex.release() self.checkout_mutex.acquire() self.waiting = self.waiting - 1 if self.waiting == 0: self.checkin_mutex.release() return self.checkout_mutex.release() class BarrierTest(BasicThreadTest): def test_barrier(self): self.bar = Barrier(NUMTASKS) self.running = NUMTASKS for i in range(NUMTASKS): thread.start_new_thread(self.task2, (i,)) verbose_print("waiting for tasks to end") self.done_mutex.acquire() verbose_print("tasks done") def task2(self, ident): for i in range(NUMTRIPS): if ident == 0: # give it a good chance to enter the next # barrier before the others are all out # of the current one delay = 0 else: with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay * 1e6))) time.sleep(delay) verbose_print("task %s entering %s" % (ident, i)) self.bar.enter() verbose_print("task %s leaving barrier" % ident) with self.running_mutex: self.running -= 1 # Must release mutex before releasing done, else the main thread can # exit and set mutex to None as part of global teardown; then # mutex.release() raises AttributeError. finished = self.running == 0 if finished: self.done_mutex.release() class LockTests(lock_tests.LockTests): locktype = thread.allocate_lock class TestForkInThread(unittest.TestCase): def setUp(self): self.read_fd, self.write_fd = os.pipe() def _test_forkinthread(self): def thread1(): try: pid = os.fork() # fork in a thread except RuntimeError: sys.exit(0) # exit the child if pid == 0: # child os.close(self.read_fd) os.write(self.write_fd, "OK") sys.exit(0) else: # parent os.close(self.write_fd) thread.start_new_thread(thread1, ()) self.assertEqual(os.read(self.read_fd, 2), "OK", "Unable to fork() in thread") if not sys.platform.startswith('win'): test_forkinthread = _test_forkinthread def tearDown(self): try: os.close(self.read_fd) except OSError: pass try: os.close(self.write_fd) except OSError: pass def test_main(): test_support.run_unittest(ThreadRunningTests, BarrierTest, LockTests, TestForkInThread) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_threading.py0000644000076500000000000004426212666555342021432 0ustar jmaddenwheel00000000000000# Very rudimentary test of threading module import test.test_support from test.test_support import verbose import random import re import sys import threading import thread import time import unittest import weakref import lock_tests # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print 'task %s will run for %.1f usec' % ( self.name, delay * 1e6) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print self.nrunning.get(), 'tasks are running' self.testcase.assert_(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print 'task', self.name, 'done' with self.mutex: self.nrunning.dec() self.testcase.assert_(self.nrunning.get() >= 0) if verbose: print '%s is finished. %d tasks are running' % ( self.name, self.nrunning.get()) class ThreadTests(unittest.TestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) self.failUnlessEqual(t.ident, None) self.assert_(re.match('', repr(t))) t.start() if verbose: print 'waiting for all tasks to complete' for t in threads: t.join(NUMTASKS) self.assert_(not t.is_alive()) self.failIfEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assert_(re.match('', repr(t))) if verbose: print 'all tasks done' self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertFalse(threading.currentThread().ident is None) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print 'with 256kB thread stack size...' try: threading.stack_size(262144) except thread.error: if verbose: print 'platform does not support changing thread stack size' return self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print 'with 1MB thread stack size...' try: threading.stack_size(0x100000) except thread.error: if verbose: print 'platform does not support changing thread stack size' return self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assert_(tid in threading._active) self.assert_(isinstance(threading._active[tid], threading._DummyThread)) del threading._active[tid] # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. def test_PyThreadState_SetAsyncExc(self): try: import ctypes except ImportError: if verbose: print "test_PyThreadState_SetAsyncExc can't import ctypes" return # can't do anything set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = thread.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print " started worker thread" # Try a thread id that doesn't make sense. if verbose: print " trying nonsensical thread id" result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print " waiting for worker thread to get started" worker_started.wait() if verbose: print " verifying worker hasn't exited" self.assert_(not t.finished) if verbose: print " attempting to raise asynch exception in worker" result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print " waiting for worker to say it caught the exception" worker_saw_exception.wait(timeout=10) self.assert_(t.finished) if verbose: print " all OK -- joining worker" if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise thread.error() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(thread.error, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. try: import ctypes except ImportError: if verbose: print("test_finalize_with_runnning_thread can't import ctypes") return # can't do anything import subprocess rc = subprocess.call([sys.executable, "-c", """if 1: import ctypes, sys, time, thread # This lock is used as a simple event variable. ready = thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """]) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown import subprocess rc = subprocess.call([sys.executable, "-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print 'program blocked; aborting' os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """]) self.failIf(rc == 2, "interpreted was blocked") self.failUnless(rc == 0, "Unexpected error") def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown import subprocess p = subprocess.Popen([sys.executable, "-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print "Woke up, sleep function is:", sleep threading.Thread(target=child).start() raise SystemExit """], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(stdout.strip(), "Woke up, sleep function is: ") stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getcheckinterval() try: for i in xrange(1, 100): # Try a couple times at each thread-switching interval # to get more interleavings. sys.setcheckinterval(i // 5) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertFalse(t in l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setcheckinterval(old_interval) def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertEquals(None, weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertEquals(None, weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) class ThreadJoinOnShutdown(unittest.TestCase): def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print 'end of thread' \n""" + script import subprocess p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().replace('\r', '') self.assertEqual(data, "end of main\nend of thread\n") self.failIf(rc == 2, "interpreter was blocked") self.failUnless(rc == 0, "Unexpected error") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print 'end of main' """ self._run_and_join(script) def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter import os if not hasattr(os, 'fork'): return script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print 'end of main' """ self._run_and_join(script) def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. import os if not hasattr(os, 'fork'): return # Skip platforms with known problems forking from a worker thread. # See http://bugs.python.org/issue3863. if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'): print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread' ' due to known OS bugs on'), sys.platform return script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print 'end of main' t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) class ThreadingExceptionTests(unittest.TestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class RLockTests(lock_tests.RLockTests): locktype = staticmethod(threading.RLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) def test_main(): test.test_support.run_unittest(LockTests, RLockTests, EventTests, ConditionAsRLockTests, ConditionTests, SemaphoreTests, BoundedSemaphoreTests, ThreadTests, ThreadJoinOnShutdown, ThreadingExceptionTests, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_threading_local.py0000644000076500000000000000721712666555342022603 0ustar jmaddenwheel00000000000000import unittest from doctest import DocTestSuite from test import test_support import threading import weakref import gc class Weak(object): pass def target(local, weaklist): weak = Weak() local.weak = weak weaklist.append(weakref.ref(weak)) class ThreadingLocalTest(unittest.TestCase): def test_local_refs(self): self._local_refs(20) self._local_refs(50) self._local_refs(100) def _local_refs(self, n): local = threading.local() weaklist = [] for i in range(n): t = threading.Thread(target=target, args=(local, weaklist)) t.start() t.join() del t gc.collect() self.assertEqual(len(weaklist), n) # XXX threading.local keeps the local of the last stopped thread alive. deadlist = [weak for weak in weaklist if weak() is None] self.assertEqual(len(deadlist), n-1) # Assignment to the same thread local frees it sometimes (!) local.someothervar = None gc.collect() deadlist = [weak for weak in weaklist if weak() is None] self.assert_(len(deadlist) in (n-1, n), (n, len(deadlist))) def test_derived(self): # Issue 3088: if there is a threads switch inside the __init__ # of a threading.local derived class, the per-thread dictionary # is created but not correctly set on the object. # The first member set may be bogus. import time class Local(threading.local): def __init__(self): time.sleep(0.01) local = Local() def f(i): local.x = i # Simply check that the variable is correctly set self.assertEqual(local.x, i) threads= [] for i in range(10): t = threading.Thread(target=f, args=(i,)) t.start() threads.append(t) for t in threads: t.join() def test_derived_cycle_dealloc(self): # http://bugs.python.org/issue6990 class Local(threading.local): pass locals = None passed = [False] e1 = threading.Event() e2 = threading.Event() def f(): # 1) Involve Local in a cycle cycle = [Local()] cycle.append(cycle) cycle[0].foo = 'bar' # 2) GC the cycle (triggers threadmodule.c::local_clear # before local_dealloc) del cycle gc.collect() e1.set() e2.wait() # 4) New Locals should be empty passed[0] = all(not hasattr(local, 'foo') for local in locals) t = threading.Thread(target=f) t.start() e1.wait() # 3) New Locals should recycle the original's address. Creating # them in the thread overwrites the thread state and avoids the # bug locals = [Local() for i in range(10)] e2.set() t.join() self.assertTrue(passed[0]) def test_main(): suite = unittest.TestSuite() suite.addTest(DocTestSuite('_threading_local')) suite.addTest(unittest.makeSuite(ThreadingLocalTest)) try: from thread import _local except ImportError: pass else: import _threading_local local_orig = _threading_local.local def setUp(test): _threading_local.local = _local def tearDown(test): _threading_local.local = local_orig suite.addTest(DocTestSuite('_threading_local', setUp=setUp, tearDown=tearDown) ) test_support.run_unittest(suite) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_timeout.py0000644000076500000000000001531512666555342021150 0ustar jmaddenwheel00000000000000"""Unit tests for socket timeout feature.""" import unittest from test import test_support # This requires the 'network' resource as given on the regrtest command line. skip_expected = not test_support.is_resource_enabled('network') import time import socket class CreationTestCase(unittest.TestCase): """Test case for socket.gettimeout() and socket.settimeout()""" def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): self.sock.close() def testObjectCreation(self): # Test Socket creation self.assertEqual(self.sock.gettimeout(), None, "timeout not disabled by default") def testFloatReturnValue(self): # Test return value of gettimeout() self.sock.settimeout(7.345) self.assertEqual(self.sock.gettimeout(), 7.345) self.sock.settimeout(3) self.assertEqual(self.sock.gettimeout(), 3) self.sock.settimeout(None) self.assertEqual(self.sock.gettimeout(), None) def testReturnType(self): # Test return type of gettimeout() self.sock.settimeout(1) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) self.sock.settimeout(3.9) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) def testTypeCheck(self): # Test type checking by settimeout() self.sock.settimeout(0) self.sock.settimeout(0L) self.sock.settimeout(0.0) self.sock.settimeout(None) self.assertRaises(TypeError, self.sock.settimeout, "") self.assertRaises(TypeError, self.sock.settimeout, u"") self.assertRaises(TypeError, self.sock.settimeout, ()) self.assertRaises(TypeError, self.sock.settimeout, []) self.assertRaises(TypeError, self.sock.settimeout, {}) self.assertRaises(TypeError, self.sock.settimeout, 0j) def testRangeCheck(self): # Test range checking by settimeout() self.assertRaises(ValueError, self.sock.settimeout, -1) self.assertRaises(ValueError, self.sock.settimeout, -1L) self.assertRaises(ValueError, self.sock.settimeout, -1.0) def testTimeoutThenBlocking(self): # Test settimeout() followed by setblocking() self.sock.settimeout(10) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.settimeout(10) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) def testBlockingThenTimeout(self): # Test setblocking() followed by settimeout() self.sock.setblocking(0) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) self.sock.setblocking(1) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) class TimeoutTestCase(unittest.TestCase): """Test case for socket.socket() timeout functions""" # There are a number of tests here trying to make sure that an operation # doesn't take too much longer than expected. But competing machine # activity makes it inevitable that such tests will fail at times. # When fuzz was at 1.0, I (tim) routinely saw bogus failures on Win2K # and Win98SE. Boosting it to 2.0 helped a lot, but isn't a real # solution. fuzz = 2.0 def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() def testConnectTimeout(self): # Choose a private address that is unlikely to exist to prevent # failures due to the connect succeeding before the timeout. # Use a dotted IP address to avoid including the DNS lookup time # with the connect time. This avoids failing the assertion that # the timeout occurred fast enough. addr = ('10.0.0.0', 12345) # Test connect() timeout _timeout = 0.001 self.sock.settimeout(_timeout) _t1 = time.time() self.failUnlessRaises(socket.error, self.sock.connect, addr) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + self.fuzz, "timeout (%g) is more than %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvTimeout(self): # Test recv() timeout _timeout = 0.02 self.sock.connect(self.addr_remote) self.sock.settimeout(_timeout) _t1 = time.time() self.failUnlessRaises(socket.error, self.sock.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testAcceptTimeout(self): # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() self.failUnlessRaises(socket.error, self.sock.accept) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvfromTimeout(self): # Test recvfrom() timeout _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) _t1 = time.time() self.failUnlessRaises(socket.error, self.sock.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testSend(self): # Test send() timeout # couldn't figure out how to test it pass def testSendto(self): # Test sendto() timeout # couldn't figure out how to test it pass def testSendall(self): # Test sendall() timeout # couldn't figure out how to test it pass def test_main(): test_support.requires('network') test_support.run_unittest(CreationTestCase, TimeoutTestCase) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_urllib.py0000644000076500000000000007114312666555342020754 0ustar jmaddenwheel00000000000000"""Regresssion tests for urllib""" import urllib import httplib import unittest from test import test_support import os import mimetools import tempfile import StringIO def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr class urlopen_FileTests(unittest.TestCase): """Test urlopen() opening a temporary file. Try to test as much functionality as possible so as to cut down on reliance on connecting to the Net for testing. """ def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ FILE = file(test_support.TESTFN, 'wb') try: FILE.write(self.text) finally: FILE.close() self.pathname = test_support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) def tearDown(self): """Shut down the open object""" self.returned_obj.close() os.remove(test_support.TESTFN) def test_interface(self): # Make sure object returned by urlopen() has the specified methods for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl", "getcode", "__iter__"): self.assert_(hasattr(self.returned_obj, attr), "object returned by urlopen() lacks %s attribute" % attr) def test_read(self): self.assertEqual(self.text, self.returned_obj.read()) def test_readline(self): self.assertEqual(self.text, self.returned_obj.readline()) self.assertEqual('', self.returned_obj.readline(), "calling readline() after exhausting the file did not" " return an empty string") def test_readlines(self): lines_list = self.returned_obj.readlines() self.assertEqual(len(lines_list), 1, "readlines() returned the wrong number of lines") self.assertEqual(lines_list[0], self.text, "readlines() returned improper text") def test_fileno(self): file_num = self.returned_obj.fileno() self.assert_(isinstance(file_num, int), "fileno() did not return an int") self.assertEqual(os.read(file_num, len(self.text)), self.text, "Reading on the file descriptor returned by fileno() " "did not return the expected text") def test_close(self): # Test close() by calling it hear and then having it be called again # by the tearDown() method for the test self.returned_obj.close() def test_info(self): self.assert_(isinstance(self.returned_obj.info(), mimetools.Message)) def test_geturl(self): self.assertEqual(self.returned_obj.geturl(), self.pathname) def test_getcode(self): self.assertEqual(self.returned_obj.getcode(), None) def test_iter(self): # Test iterator # Don't need to count number of iterations since test would fail the # instant it returned anything beyond the first line from the # comparison for line in self.returned_obj.__iter__(): self.assertEqual(line, self.text) class ProxyTests(unittest.TestCase): def setUp(self): # Records changes to env vars self.env = test_support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k) def tearDown(self): # Restore all proxy related env vars self.env.__exit__() del self.env def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEquals('localhost', proxies['no']) class urlopen_HttpTests(unittest.TestCase): """Test urlopen() opening a fake http connection.""" def fakehttp(self, fakedata): class FakeSocket(StringIO.StringIO): def sendall(self, str): pass def makefile(self, mode, name): return self def read(self, amt=None): if self.closed: return '' return StringIO.StringIO.read(self, amt) def readline(self, length=None): if self.closed: return '' return StringIO.StringIO.readline(self, length) class FakeHTTPConnection(httplib.HTTPConnection): def connect(self): self.sock = FakeSocket(fakedata) assert httplib.HTTP._connection_class == httplib.HTTPConnection httplib.HTTP._connection_class = FakeHTTPConnection def unfakehttp(self): httplib.HTTP._connection_class = httplib.HTTPConnection def test_read(self): self.fakehttp('Hello!') try: fp = urllib.urlopen("http://python.org/") self.assertEqual(fp.readline(), 'Hello!') self.assertEqual(fp.readline(), '') self.assertEqual(fp.geturl(), 'http://python.org/') self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() def test_read_bogus(self): # urlopen() should raise IOError for many error codes. self.fakehttp('''HTTP/1.1 401 Authentication Required Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Type: text/html; charset=iso-8859-1 ''') try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_invalid_redirect(self): # urlopen() should raise IOError for many error codes. self.fakehttp("""HTTP/1.1 302 Found Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Location: file:README Connection: close Content-Type: text/html; charset=iso-8859-1 """) try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_empty_socket(self): # urlopen() raises IOError if the underlying socket does not send any # data. (#1680230) self.fakehttp('') try: self.assertRaises(IOError, urllib.urlopen, 'http://something') finally: self.unfakehttp() class urlretrieve_FileTests(unittest.TestCase): """Test urllib.urlretrieve() on local files""" def setUp(self): # Create a list of temporary files. Each item in the list is a file # name (absolute path or relative to the current working directory). # All files in this list will be deleted in the tearDown method. Note, # this only helps to makes sure temporary files get deleted, but it # does nothing about trying to close files that may still be open. It # is the responsibility of the developer to properly close files even # when exceptional conditions occur. self.tempFiles = [] # Create a temporary file. self.registerFileForCleanUp(test_support.TESTFN) self.text = 'testing urllib.urlretrieve' try: FILE = file(test_support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: try: FILE.close() except: pass def tearDown(self): # Delete the temporary files. for each in self.tempFiles: try: os.remove(each) except: pass def constructLocalFileUrl(self, filePath): return "file://%s" % urllib.pathname2url(os.path.abspath(filePath)) def createNewTempFile(self, data=""): """Creates a new temporary file containing the specified data, registers the file for deletion during the test fixture tear down, and returns the absolute path of the file.""" newFd, newFilePath = tempfile.mkstemp() try: self.registerFileForCleanUp(newFilePath) newFile = os.fdopen(newFd, "wb") newFile.write(data) newFile.close() finally: try: newFile.close() except: pass return newFilePath def registerFileForCleanUp(self, fileName): self.tempFiles.append(fileName) def test_basic(self): # Make sure that a local file just gets its own location returned and # a headers value is returned. result = urllib.urlretrieve("file:%s" % test_support.TESTFN) self.assertEqual(result[0], test_support.TESTFN) self.assert_(isinstance(result[1], mimetools.Message), "did not get a mimetools.Message instance as second " "returned value") def test_copy(self): # Test that setting the filename argument works. second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) result = urllib.urlretrieve(self.constructLocalFileUrl( test_support.TESTFN), second_temp) self.assertEqual(second_temp, result[0]) self.assert_(os.path.exists(second_temp), "copy of the file was not " "made") FILE = file(second_temp, 'rb') try: text = FILE.read() FILE.close() finally: try: FILE.close() except: pass self.assertEqual(self.text, text) def test_reporthook(self): # Make sure that the reporthook works. def hooktester(count, block_size, total_size, count_holder=[0]): self.assert_(isinstance(count, int)) self.assert_(isinstance(block_size, int)) self.assert_(isinstance(total_size, int)) self.assertEqual(count, count_holder[0]) count_holder[0] = count_holder[0] + 1 second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN), second_temp, hooktester) def test_reporthook_0_bytes(self): # Test on zero length file. Should call reporthook only 1 time. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile() urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 1) self.assertEqual(report[0][2], 0) def test_reporthook_5_bytes(self): # Test on 5 byte file. Should call reporthook only 2 times (once when # the "network connection" is established and once when the block is # read). Since the block size is 8192 bytes, only one block read is # required to read the entire file. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 5) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 2) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 5) def test_reporthook_8193_bytes(self): # Test on 8193 byte file. Should call reporthook only 3 times (once # when the "network connection" is established, once for the next 8192 # bytes, and once for the last byte). report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 8193) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) class QuotingTests(unittest.TestCase): """Tests for urllib.quote() and urllib.quote_plus() According to RFC 2396 ("Uniform Resource Identifiers), to escape a character you write it as '%' + <2 character US-ASCII hex value>. The Python code of ``'%' + hex(ord())[2:]`` escapes a character properly. Case does not matter on the hex letters. The various character sets specified are: Reserved characters : ";/?:@&=+$," Have special meaning in URIs and must be escaped if not being used for their special meaning Data characters : letters, digits, and "-_.!~*'()" Unreserved and do not need to be escaped; can be, though, if desired Control characters : 0x00 - 0x1F, 0x7F Have no use in URIs so must be escaped space : 0x20 Must be escaped Delimiters : '<>#%"' Must be escaped Unwise : "{}|\^[]`" Must be escaped """ def test_never_quote(self): # Make sure quote() does not quote letters, digits, and "_,.-" do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789", "_.-"]) result = urllib.quote(do_not_quote) self.assertEqual(do_not_quote, result, "using quote(): %s != %s" % (do_not_quote, result)) result = urllib.quote_plus(do_not_quote) self.assertEqual(do_not_quote, result, "using quote_plus(): %s != %s" % (do_not_quote, result)) def test_default_safe(self): # Test '/' is default value for 'safe' parameter self.assertEqual(urllib.quote.func_defaults[0], '/') def test_safe(self): # Test setting 'safe' parameter does what it should do quote_by_default = "<>" result = urllib.quote(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote(): %s != %s" % (quote_by_default, result)) result = urllib.quote_plus(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote_plus(): %s != %s" % (quote_by_default, result)) def test_default_quoting(self): # Make sure all characters that should be quoted are by default sans # space (separate test for that). should_quote = [chr(num) for num in range(32)] # For 0x00 - 0x1F should_quote.append('<>#%"{}|\^[]`') should_quote.append(chr(127)) # For 0x7F should_quote = ''.join(should_quote) for char in should_quote: result = urllib.quote(char) self.assertEqual(hexescape(char), result, "using quote(): %s should be escaped to %s, not %s" % (char, hexescape(char), result)) result = urllib.quote_plus(char) self.assertEqual(hexescape(char), result, "using quote_plus(): " "%s should be escapes to %s, not %s" % (char, hexescape(char), result)) del should_quote partial_quote = "ab[]cd" expected = "ab%5B%5Dcd" result = urllib.quote(partial_quote) self.assertEqual(expected, result, "using quote(): %s != %s" % (expected, result)) self.assertEqual(expected, result, "using quote_plus(): %s != %s" % (expected, result)) def test_quoting_space(self): # Make sure quote() and quote_plus() handle spaces as specified in # their unique way result = urllib.quote(' ') self.assertEqual(result, hexescape(' '), "using quote(): %s != %s" % (result, hexescape(' '))) result = urllib.quote_plus(' ') self.assertEqual(result, '+', "using quote_plus(): %s != +" % result) given = "a b cd e f" expect = given.replace(' ', hexescape(' ')) result = urllib.quote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) expect = given.replace(' ', '+') result = urllib.quote_plus(given) self.assertEqual(expect, result, "using quote_plus(): %s != %s" % (expect, result)) def test_quoting_plus(self): self.assertEqual(urllib.quote_plus('alpha+beta gamma'), 'alpha%2Bbeta+gamma') self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'), 'alpha+beta+gamma') class UnquotingTests(unittest.TestCase): """Tests for unquote() and unquote_plus() See the doc string for quoting_Tests for details on quoting and such. """ def test_unquoting(self): # Make sure unquoting of all ASCII values works escape_list = [] for num in range(128): given = hexescape(chr(num)) expect = chr(num) result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) escape_list.append(given) escape_string = ''.join(escape_list) del escape_list result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using quote(): not all characters escaped; %s" % result) result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using unquote(): not all characters escaped: " "%s" % result) def test_unquoting_badpercent(self): # Test unquoting on bad percent-escapes given = '%xab' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%x' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_mixed_case(self): # Test unquoting on mixed-case hex digits in the percent-escapes given = '%Ab%eA' expect = '\xab\xea' result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_parts(self): # Make sure unquoting works when have non-quoted characters # interspersed given = 'ab%sd' % hexescape('c') expect = "abcd" result = urllib.unquote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquoting_plus(self): # Test difference between unquote() and unquote_plus() given = "are+there+spaces..." expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) expect = given.replace('+', ' ') result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquote_with_unicode(self): r = urllib.unquote(u'br%C3%BCckner_sapporo_20050930.doc') self.assertEqual(r, u'br\xc3\xbcckner_sapporo_20050930.doc') class urlencode_Tests(unittest.TestCase): """Tests for urlencode()""" def help_inputtype(self, given, test_type): """Helper method for testing different input types. 'given' must lead to only the pairs: * 1st, 1 * 2nd, 2 * 3rd, 3 Test cannot assume anything about order. Docs make no guarantee and have possible dictionary input. """ expect_somewhere = ["1st=1", "2nd=2", "3rd=3"] result = urllib.urlencode(given) for expected in expect_somewhere: self.assert_(expected in result, "testing %s: %s not found in %s" % (test_type, expected, result)) self.assertEqual(result.count('&'), 2, "testing %s: expected 2 '&'s; got %s" % (test_type, result.count('&'))) amp_location = result.index('&') on_amp_left = result[amp_location - 1] on_amp_right = result[amp_location + 1] self.assert_(on_amp_left.isdigit() and on_amp_right.isdigit(), "testing %s: '&' not located in proper place in %s" % (test_type, result)) self.assertEqual(len(result), (5 * 3) + 2, #5 chars per thing and amps "testing %s: " "unexpected number of characters: %s != %s" % (test_type, len(result), (5 * 3) + 2)) def test_using_mapping(self): # Test passing in a mapping object as an argument. self.help_inputtype({"1st":'1', "2nd":'2', "3rd":'3'}, "using dict as input type") def test_using_sequence(self): # Test passing in a sequence of two-item sequences as an argument. self.help_inputtype([('1st', '1'), ('2nd', '2'), ('3rd', '3')], "using sequence of two-item tuples as input") def test_quoting(self): # Make sure keys and values are quoted using quote_plus() given = {"&":"="} expect = "%s=%s" % (hexescape('&'), hexescape('=')) result = urllib.urlencode(given) self.assertEqual(expect, result) given = {"key name":"A bunch of pluses"} expect = "key+name=A+bunch+of+pluses" result = urllib.urlencode(given) self.assertEqual(expect, result) def test_doseq(self): # Test that passing True for 'doseq' parameter works correctly given = {'sequence':['1', '2', '3']} expect = "sequence=%s" % urllib.quote_plus(str(['1', '2', '3'])) result = urllib.urlencode(given) self.assertEqual(expect, result) result = urllib.urlencode(given, True) for value in given["sequence"]: expect = "sequence=%s" % value self.assert_(expect in result, "%s not found in %s" % (expect, result)) self.assertEqual(result.count('&'), 2, "Expected 2 '&'s, got %s" % result.count('&')) class Pathname_Tests(unittest.TestCase): """Test pathname2url() and url2pathname()""" def test_basic(self): # Make sure simple tests pass expected_path = os.path.join("parts", "of", "a", "path") expected_url = "parts/of/a/path" result = urllib.pathname2url(expected_path) self.assertEqual(expected_url, result, "pathname2url() failed; %s != %s" % (result, expected_url)) result = urllib.url2pathname(expected_url) self.assertEqual(expected_path, result, "url2pathame() failed; %s != %s" % (result, expected_path)) def test_quoting(self): # Test automatic quoting and unquoting works for pathnam2url() and # url2pathname() respectively given = os.path.join("needs", "quot=ing", "here") expect = "needs/%s/here" % urllib.quote("quot=ing") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) expect = given result = urllib.url2pathname(result) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) given = os.path.join("make sure", "using_quote") expect = "%s/using_quote" % urllib.quote("make sure") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) given = "make+sure/using_unquote" expect = os.path.join("make+sure", "using_unquote") result = urllib.url2pathname(given) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) class URLopener_Tests(unittest.TestCase): """Testcase to test the open method of URLopener class.""" def test_quoted_open(self): class DummyURLopener(urllib.URLopener): def open_spam(self, url): return url self.assertEqual(DummyURLopener().open( 'spam://example/ /'),'//example/%20/') # test the safe characters are not quoted by urlopen self.assertEqual(DummyURLopener().open( "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"), "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/") # Just commented them out. # Can't really tell why keep failing in windows and sparc. # Everywhere else they work ok, but on those machines, someteimes # fail in one of the tests, sometimes in other. I have a linux, and # the tests go ok. # If anybody has one of the problematic enviroments, please help! # . Facundo # # def server(evt): # import socket, time # serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # serv.settimeout(3) # serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # serv.bind(("", 9093)) # serv.listen(5) # try: # conn, addr = serv.accept() # conn.send("1 Hola mundo\n") # cantdata = 0 # while cantdata < 13: # data = conn.recv(13-cantdata) # cantdata += len(data) # time.sleep(.3) # conn.send("2 No more lines\n") # conn.close() # except socket.timeout: # pass # finally: # serv.close() # evt.set() # # class FTPWrapperTests(unittest.TestCase): # # def setUp(self): # import ftplib, time, threading # ftplib.FTP.port = 9093 # self.evt = threading.Event() # threading.Thread(target=server, args=(self.evt,)).start() # time.sleep(.1) # # def tearDown(self): # self.evt.wait() # # def testBasic(self): # # connects # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # ftp.close() # # def testTimeoutNone(self): # # global default timeout is ignored # import socket # self.assert_(socket.getdefaulttimeout() is None) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutDefault(self): # # global default timeout is used # import socket # self.assert_(socket.getdefaulttimeout() is None) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutValue(self): # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [], # timeout=30) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() def test_main(): import warnings with warnings.catch_warnings(): warnings.filterwarnings('ignore', ".*urllib\.urlopen.*Python 3.0", DeprecationWarning) test_support.run_unittest( urlopen_FileTests, urlopen_HttpTests, urlretrieve_FileTests, ProxyTests, QuotingTests, UnquotingTests, urlencode_Tests, Pathname_Tests, URLopener_Tests, #FTPWrapperTests, ) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.6/test_urllib2.py0000644000076500000000000014144212666555342021036 0ustar jmaddenwheel00000000000000import unittest from test import test_support import os import socket import StringIO import urllib2 from urllib2 import Request, OpenerDirector # XXX # Request # CacheFTPHandler (hard to write) # parse_keqv_list, parse_http_list, HTTPDigestAuthHandler class TrivialTests(unittest.TestCase): def test_trivial(self): # A couple trivial tests self.assertRaises(ValueError, urllib2.urlopen, 'bogus url') # XXX Name hacking to get this to work on Windows. fname = os.path.abspath(urllib2.__file__).replace('\\', '/') # And more hacking to get it to work on MacOS. This assumes # urllib.pathname2url works, unfortunately... if os.name == 'mac': fname = '/' + fname.replace(':', '/') elif os.name == 'riscos': import string fname = os.expand(fname) fname = fname.translate(string.maketrans("/.", "./")) if os.name == 'nt': file_url = "file:///%s" % fname else: file_url = "file://%s" % fname f = urllib2.urlopen(file_url) buf = f.read() f.close() def test_parse_http_list(self): tests = [('a,b,c', ['a', 'b', 'c']), ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']), ('a, b, "c", "d", "e,f", g, h', ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']), ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])] for string, list in tests: self.assertEquals(urllib2.parse_http_list(string), list) def test_request_headers_dict(): """ The Request.headers dictionary is not a documented interface. It should stay that way, because the complete set of headers are only accessible through the .get_header(), .has_header(), .header_items() interface. However, .headers pre-dates those methods, and so real code will be using the dictionary. The introduction in 2.4 of those methods was a mistake for the same reason: code that previously saw all (urllib2 user)-provided headers in .headers now sees only a subset (and the function interface is ugly and incomplete). A better change would have been to replace .headers dict with a dict subclass (or UserDict.DictMixin instance?) that preserved the .headers interface and also provided access to the "unredirected" headers. It's probably too late to fix that, though. Check .capitalize() case normalization: >>> url = "http://example.com" >>> Request(url, headers={"Spam-eggs": "blah"}).headers["Spam-eggs"] 'blah' >>> Request(url, headers={"spam-EggS": "blah"}).headers["Spam-eggs"] 'blah' Currently, Request(url, "Spam-eggs").headers["Spam-Eggs"] raises KeyError, but that could be changed in future. """ def test_request_headers_methods(): """ Note the case normalization of header names here, to .capitalize()-case. This should be preserved for backwards-compatibility. (In the HTTP case, normalization to .title()-case is done by urllib2 before sending headers to httplib). >>> url = "http://example.com" >>> r = Request(url, headers={"Spam-eggs": "blah"}) >>> r.has_header("Spam-eggs") True >>> r.header_items() [('Spam-eggs', 'blah')] >>> r.add_header("Foo-Bar", "baz") >>> items = r.header_items() >>> items.sort() >>> items [('Foo-bar', 'baz'), ('Spam-eggs', 'blah')] Note that e.g. r.has_header("spam-EggS") is currently False, and r.get_header("spam-EggS") returns None, but that could be changed in future. >>> r.has_header("Not-there") False >>> print r.get_header("Not-there") None >>> r.get_header("Not-there", "default") 'default' """ def test_password_manager(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password >>> add("Some Realm", "http://example.com/", "joe", "password") >>> add("Some Realm", "http://example.com/ni", "ni", "ni") >>> add("c", "http://example.com/foo", "foo", "ni") >>> add("c", "http://example.com/bar", "bar", "nini") >>> add("b", "http://example.com/", "first", "blah") >>> add("b", "http://example.com/", "second", "spam") >>> add("a", "http://example.com", "1", "a") >>> add("Some Realm", "http://c.example.com:3128", "3", "c") >>> add("Some Realm", "d.example.com", "4", "d") >>> add("Some Realm", "e.example.com:3128", "5", "e") >>> mgr.find_user_password("Some Realm", "example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam/spam") ('joe', 'password') >>> mgr.find_user_password("c", "http://example.com/foo") ('foo', 'ni') >>> mgr.find_user_password("c", "http://example.com/bar") ('bar', 'nini') Actually, this is really undefined ATM ## Currently, we use the highest-level path where more than one match: ## >>> mgr.find_user_password("Some Realm", "http://example.com/ni") ## ('joe', 'password') Use latest add_password() in case of conflict: >>> mgr.find_user_password("b", "http://example.com/") ('second', 'spam') No special relationship between a.example.com and example.com: >>> mgr.find_user_password("a", "http://example.com/") ('1', 'a') >>> mgr.find_user_password("a", "http://a.example.com/") (None, None) Ports: >>> mgr.find_user_password("Some Realm", "c.example.com") (None, None) >>> mgr.find_user_password("Some Realm", "c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "http://c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "d.example.com") ('4', 'd') >>> mgr.find_user_password("Some Realm", "e.example.com:3128") ('5', 'e') """ pass def test_password_manager_default_port(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password The point to note here is that we can't guess the default port if there's no scheme. This applies to both add_password and find_user_password. >>> add("f", "http://g.example.com:80", "10", "j") >>> add("g", "http://h.example.com", "11", "k") >>> add("h", "i.example.com:80", "12", "l") >>> add("i", "j.example.com", "13", "m") >>> mgr.find_user_password("f", "g.example.com:100") (None, None) >>> mgr.find_user_password("f", "g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "g.example.com") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:100") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "http://g.example.com") ('10', 'j') >>> mgr.find_user_password("g", "h.example.com") ('11', 'k') >>> mgr.find_user_password("g", "h.example.com:80") ('11', 'k') >>> mgr.find_user_password("g", "http://h.example.com:80") ('11', 'k') >>> mgr.find_user_password("h", "i.example.com") (None, None) >>> mgr.find_user_password("h", "i.example.com:80") ('12', 'l') >>> mgr.find_user_password("h", "http://i.example.com:80") ('12', 'l') >>> mgr.find_user_password("i", "j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "j.example.com:80") (None, None) >>> mgr.find_user_password("i", "http://j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "http://j.example.com:80") (None, None) """ class MockOpener: addheaders = [] def open(self, req, data=None,timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.req, self.data, self.timeout = req, data, timeout def error(self, proto, *args): self.proto, self.args = proto, args class MockFile: def read(self, count=None): pass def readline(self, count=None): pass def close(self): pass class MockHeaders(dict): def getheaders(self, name): return self.values() class MockResponse(StringIO.StringIO): def __init__(self, code, msg, headers, data, url=None): StringIO.StringIO.__init__(self, data) self.code, self.msg, self.headers, self.url = code, msg, headers, url def info(self): return self.headers def geturl(self): return self.url class MockCookieJar: def add_cookie_header(self, request): self.ach_req = request def extract_cookies(self, response, request): self.ec_req, self.ec_r = request, response class FakeMethod: def __init__(self, meth_name, action, handle): self.meth_name = meth_name self.handle = handle self.action = action def __call__(self, *args): return self.handle(self.meth_name, self.action, *args) class MockHTTPResponse: def __init__(self, fp, msg, status, reason): self.fp = fp self.msg = msg self.status = status self.reason = reason def read(self): return '' class MockHTTPClass: def __init__(self): self.req_headers = [] self.data = None self.raise_on_endheaders = False self._tunnel_headers = {} def __call__(self, host, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.host = host self.timeout = timeout return self def set_debuglevel(self, level): self.level = level def _set_tunnel(self, host, port=None, headers=None): self._tunnel_host = host self._tunnel_port = port if headers: self._tunnel_headers = headers else: self._tunnel_headers.clear() def request(self, method, url, body=None, headers=None): self.method = method self.selector = url if headers is not None: self.req_headers += headers.items() self.req_headers.sort() if body: self.data = body if self.raise_on_endheaders: import socket raise socket.error() def getresponse(self): return MockHTTPResponse(MockFile(), {}, 200, "OK") class MockHandler: # useful for testing handler machinery # see add_ordered_mock_handlers() docstring handler_order = 500 def __init__(self, methods): self._define_methods(methods) def _define_methods(self, methods): for spec in methods: if len(spec) == 2: name, action = spec else: name, action = spec, None meth = FakeMethod(name, action, self.handle) setattr(self.__class__, name, meth) def handle(self, fn_name, action, *args, **kwds): self.parent.calls.append((self, fn_name, args, kwds)) if action is None: return None elif action == "return self": return self elif action == "return response": res = MockResponse(200, "OK", {}, "") return res elif action == "return request": return Request("http://blah/") elif action.startswith("error"): code = action[action.rfind(" ")+1:] try: code = int(code) except ValueError: pass res = MockResponse(200, "OK", {}, "") return self.parent.error("http", args[0], res, code, "", {}) elif action == "raise": raise urllib2.URLError("blah") assert False def close(self): pass def add_parent(self, parent): self.parent = parent self.parent.calls = [] def __lt__(self, other): if not hasattr(other, "handler_order"): # No handler_order, leave in original order. Yuck. return True return self.handler_order < other.handler_order def add_ordered_mock_handlers(opener, meth_spec): """Create MockHandlers and add them to an OpenerDirector. meth_spec: list of lists of tuples and strings defining methods to define on handlers. eg: [["http_error", "ftp_open"], ["http_open"]] defines methods .http_error() and .ftp_open() on one handler, and .http_open() on another. These methods just record their arguments and return None. Using a tuple instead of a string causes the method to perform some action (see MockHandler.handle()), eg: [["http_error"], [("http_open", "return request")]] defines .http_error() on one handler (which simply returns None), and .http_open() on another handler, which returns a Request object. """ handlers = [] count = 0 for meths in meth_spec: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order += count h.add_parent(opener) count = count + 1 handlers.append(h) opener.add_handler(h) return handlers def build_test_opener(*handler_instances): opener = OpenerDirector() for h in handler_instances: opener.add_handler(h) return opener class MockHTTPHandler(urllib2.BaseHandler): # useful for testing redirections and auth # sends supplied headers and code as first response # sends 200 OK as second response def __init__(self, code, headers): self.code = code self.headers = headers self.reset() def reset(self): self._count = 0 self.requests = [] def http_open(self, req): import mimetools, httplib, copy from StringIO import StringIO self.requests.append(copy.deepcopy(req)) if self._count == 0: self._count = self._count + 1 name = httplib.responses[self.code] msg = mimetools.Message(StringIO(self.headers)) return self.parent.error( "http", req, MockFile(), self.code, name, msg) else: self.req = req msg = mimetools.Message(StringIO("\r\n\r\n")) return MockResponse(200, "OK", msg, "", req.get_full_url()) class MockHTTPSHandler(urllib2.AbstractHTTPHandler): # Useful for testing the Proxy-Authorization request by verifying the # properties of httpcon def __init__(self): urllib2.AbstractHTTPHandler.__init__(self) self.httpconn = MockHTTPClass() def https_open(self, req): return self.do_open(self.httpconn, req) class MockPasswordManager: def add_password(self, realm, uri, user, password): self.realm = realm self.url = uri self.user = user self.password = password def find_user_password(self, realm, authuri): self.target_realm = realm self.target_url = authuri return self.user, self.password class OpenerDirectorTests(unittest.TestCase): def test_add_non_handler(self): class NonHandler(object): pass self.assertRaises(TypeError, OpenerDirector().add_handler, NonHandler()) def test_badly_named_methods(self): # test work-around for three methods that accidentally follow the # naming conventions for handler methods # (*_open() / *_request() / *_response()) # These used to call the accidentally-named methods, causing a # TypeError in real code; here, returning self from these mock # methods would either cause no exception, or AttributeError. from urllib2 import URLError o = OpenerDirector() meth_spec = [ [("do_open", "return self"), ("proxy_open", "return self")], [("redirect_request", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) o.add_handler(urllib2.UnknownHandler()) for scheme in "do", "proxy", "redirect": self.assertRaises(URLError, o.open, scheme+"://example.com/") def test_handled(self): # handler returning non-None means no more handlers will be called o = OpenerDirector() meth_spec = [ ["http_open", "ftp_open", "http_error_302"], ["ftp_open"], [("http_open", "return self")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # Second .http_open() gets called, third doesn't, since second returned # non-None. Handlers without .http_open() never get any methods called # on them. # In fact, second mock handler defining .http_open() returns self # (instead of response), which becomes the OpenerDirector's return # value. self.assertEqual(r, handlers[2]) calls = [(handlers[0], "http_open"), (handlers[2], "http_open")] for expected, got in zip(calls, o.calls): handler, name, args, kwds = got self.assertEqual((handler, name), expected) self.assertEqual(args, (req,)) def test_handler_order(self): o = OpenerDirector() handlers = [] for meths, handler_order in [ ([("http_open", "return self")], 500), (["http_open"], 0), ]: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order = handler_order handlers.append(h) o.add_handler(h) r = o.open("http://example.com/") # handlers called in reverse order, thanks to their sort order self.assertEqual(o.calls[0][0], handlers[1]) self.assertEqual(o.calls[1][0], handlers[0]) def test_raise(self): # raising URLError stops processing of request o = OpenerDirector() meth_spec = [ [("http_open", "raise")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") self.assertRaises(urllib2.URLError, o.open, req) self.assertEqual(o.calls, [(handlers[0], "http_open", (req,), {})]) ## def test_error(self): ## # XXX this doesn't actually seem to be used in standard library, ## # but should really be tested anyway... def test_http_error(self): # XXX http_error_default # http errors are a special case o = OpenerDirector() meth_spec = [ [("http_open", "error 302")], [("http_error_400", "raise"), "http_open"], [("http_error_302", "return response"), "http_error_303", "http_error"], [("http_error_302")], ] handlers = add_ordered_mock_handlers(o, meth_spec) class Unknown: def __eq__(self, other): return True req = Request("http://example.com/") r = o.open(req) assert len(o.calls) == 2 calls = [(handlers[0], "http_open", (req,)), (handlers[2], "http_error_302", (req, Unknown(), 302, "", {}))] for expected, got in zip(calls, o.calls): handler, method_name, args = expected self.assertEqual((handler, method_name), got[:2]) self.assertEqual(args, got[2]) def test_processors(self): # *_request / *_response methods get called appropriately o = OpenerDirector() meth_spec = [ [("http_request", "return request"), ("http_response", "return response")], [("http_request", "return request"), ("http_response", "return response")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # processor methods are called on *all* handlers that define them, # not just the first handler that handles the request calls = [ (handlers[0], "http_request"), (handlers[1], "http_request"), (handlers[0], "http_response"), (handlers[1], "http_response")] for i, (handler, name, args, kwds) in enumerate(o.calls): if i < 2: # *_request self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 1) self.assert_(isinstance(args[0], Request)) else: # *_response self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 2) self.assert_(isinstance(args[0], Request)) # response from opener.open is None, because there's no # handler that defines http_open to handle it self.assert_(args[1] is None or isinstance(args[1], MockResponse)) def sanepathname2url(path): import urllib urlpath = urllib.pathname2url(path) if os.name == "nt" and urlpath.startswith("///"): urlpath = urlpath[2:] # XXX don't ask me about the mac... return urlpath class HandlerTests(unittest.TestCase): def test_ftp(self): class MockFTPWrapper: def __init__(self, data): self.data = data def retrfile(self, filename, filetype): self.filename, self.filetype = filename, filetype return StringIO.StringIO(self.data), len(self.data) class NullFTPHandler(urllib2.FTPHandler): def __init__(self, data): self.data = data def connect_ftp(self, user, passwd, host, port, dirs, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.user, self.passwd = user, passwd self.host, self.port = host, port self.dirs = dirs self.ftpwrapper = MockFTPWrapper(self.data) return self.ftpwrapper import ftplib data = "rheum rhaponicum" h = NullFTPHandler(data) o = h.parent = MockOpener() for url, host, port, type_, dirs, filename, mimetype in [ ("ftp://localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://localhost:80/foo/bar/", "localhost", 80, "D", ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "A", [], "baz.gif", None), # XXX really this should guess image/gif ]: req = Request(url) req.timeout = None r = h.ftp_open(req) # ftp authentication not yet implemented by FTPHandler self.assert_(h.user == h.passwd == "") self.assertEqual(h.host, socket.gethostbyname(host)) self.assertEqual(h.port, port) self.assertEqual(h.dirs, dirs) self.assertEqual(h.ftpwrapper.filename, filename) self.assertEqual(h.ftpwrapper.filetype, type_) headers = r.info() self.assertEqual(headers.get("Content-type"), mimetype) self.assertEqual(int(headers["Content-length"]), len(data)) def test_file(self): import rfc822, socket h = urllib2.FileHandler() o = h.parent = MockOpener() TESTFN = test_support.TESTFN urlpath = sanepathname2url(os.path.abspath(TESTFN)) towrite = "hello, world\n" urls = [ "file://localhost%s" % urlpath, "file://%s" % urlpath, "file://%s%s" % (socket.gethostbyname('localhost'), urlpath), ] try: localaddr = socket.gethostbyname(socket.gethostname()) except socket.gaierror: localaddr = '' if localaddr: urls.append("file://%s%s" % (localaddr, urlpath)) for url in urls: f = open(TESTFN, "wb") try: try: f.write(towrite) finally: f.close() r = h.file_open(Request(url)) try: data = r.read() headers = r.info() respurl = r.geturl() finally: r.close() stats = os.stat(TESTFN) modified = rfc822.formatdate(stats.st_mtime) finally: os.remove(TESTFN) self.assertEqual(data, towrite) self.assertEqual(headers["Content-type"], "text/plain") self.assertEqual(headers["Content-length"], "13") self.assertEqual(headers["Last-modified"], modified) self.assertEqual(respurl, url) for url in [ "file://localhost:80%s" % urlpath, "file:///file_does_not_exist.txt", "file://%s:80%s/%s" % (socket.gethostbyname('localhost'), os.getcwd(), TESTFN), "file://somerandomhost.ontheinternet.com%s/%s" % (os.getcwd(), TESTFN), ]: try: f = open(TESTFN, "wb") try: f.write(towrite) finally: f.close() self.assertRaises(urllib2.URLError, h.file_open, Request(url)) finally: os.remove(TESTFN) h = urllib2.FileHandler() o = h.parent = MockOpener() # XXXX why does // mean ftp (and /// mean not ftp!), and where # is file: scheme specified? I think this is really a bug, and # what was intended was to distinguish between URLs like: # file:/blah.txt (a file) # file://localhost/blah.txt (a file) # file:///blah.txt (a file) # file://ftp.example.com/blah.txt (an ftp URL) for url, ftp in [ ("file://ftp.example.com//foo.txt", True), ("file://ftp.example.com///foo.txt", False), # XXXX bug: fails with OSError, should be URLError ("file://ftp.example.com/foo.txt", False), ("file://somehost//foo/something.txt", True), ("file://localhost//foo/something.txt", False), ]: req = Request(url) try: h.file_open(req) # XXXX remove OSError when bug fixed except (urllib2.URLError, OSError): self.assert_(not ftp) else: self.assert_(o.req is req) self.assertEqual(req.type, "ftp") self.assertEqual(req.type is "ftp", ftp) def test_http(self): h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() url = "http://example.com/" for method, data in [("GET", None), ("POST", "blah")]: req = Request(url, data, {"Foo": "bar"}) req.timeout = None req.add_unredirected_header("Spam", "eggs") http = MockHTTPClass() r = h.do_open(http, req) # result attributes r.read; r.readline # wrapped MockFile methods r.info; r.geturl # addinfourl methods r.code, r.msg == 200, "OK" # added from MockHTTPClass.getreply() hdrs = r.info() hdrs.get; hdrs.has_key # r.info() gives dict from .getreply() self.assertEqual(r.geturl(), url) self.assertEqual(http.host, "example.com") self.assertEqual(http.level, 0) self.assertEqual(http.method, method) self.assertEqual(http.selector, "/") self.assertEqual(http.req_headers, [("Connection", "close"), ("Foo", "bar"), ("Spam", "eggs")]) self.assertEqual(http.data, data) # check socket.error converted to URLError http.raise_on_endheaders = True self.assertRaises(urllib2.URLError, h.do_open, http, req) # check adding of standard headers o.addheaders = [("Spam", "eggs")] for data in "", None: # POST, GET req = Request("http://example.com/", data) r = MockResponse(200, "OK", {}, "") newreq = h.do_request_(req) if data is None: # GET self.assert_("Content-length" not in req.unredirected_hdrs) self.assert_("Content-type" not in req.unredirected_hdrs) else: # POST self.assertEqual(req.unredirected_hdrs["Content-length"], "0") self.assertEqual(req.unredirected_hdrs["Content-type"], "application/x-www-form-urlencoded") # XXX the details of Host could be better tested self.assertEqual(req.unredirected_hdrs["Host"], "example.com") self.assertEqual(req.unredirected_hdrs["Spam"], "eggs") # don't clobber existing headers req.add_unredirected_header("Content-length", "foo") req.add_unredirected_header("Content-type", "bar") req.add_unredirected_header("Host", "baz") req.add_unredirected_header("Spam", "foo") newreq = h.do_request_(req) self.assertEqual(req.unredirected_hdrs["Content-length"], "foo") self.assertEqual(req.unredirected_hdrs["Content-type"], "bar") self.assertEqual(req.unredirected_hdrs["Host"], "baz") self.assertEqual(req.unredirected_hdrs["Spam"], "foo") def test_http_doubleslash(self): # Checks that the presence of an unnecessary double slash in a url doesn't break anything # Previously, a double slash directly after the host could cause incorrect parsing of the url h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() data = "" ds_urls = [ "http://example.com/foo/bar/baz.html", "http://example.com//foo/bar/baz.html", "http://example.com/foo//bar/baz.html", "http://example.com/foo/bar//baz.html", ] for ds_url in ds_urls: ds_req = Request(ds_url, data) # Check whether host is determined correctly if there is no proxy np_ds_req = h.do_request_(ds_req) self.assertEqual(np_ds_req.unredirected_hdrs["Host"],"example.com") # Check whether host is determined correctly if there is a proxy ds_req.set_proxy("someproxy:3128",None) p_ds_req = h.do_request_(ds_req) self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com") def test_errors(self): h = urllib2.HTTPErrorProcessor() o = h.parent = MockOpener() url = "http://example.com/" req = Request(url) # all 2xx are passed through r = MockResponse(200, "OK", {}, "", url) newr = h.http_response(req, r) self.assert_(r is newr) self.assert_(not hasattr(o, "proto")) # o.error not called r = MockResponse(202, "Accepted", {}, "", url) newr = h.http_response(req, r) self.assert_(r is newr) self.assert_(not hasattr(o, "proto")) # o.error not called r = MockResponse(206, "Partial content", {}, "", url) newr = h.http_response(req, r) self.assert_(r is newr) self.assert_(not hasattr(o, "proto")) # o.error not called # anything else calls o.error (and MockOpener returns None, here) r = MockResponse(502, "Bad gateway", {}, "", url) self.assert_(h.http_response(req, r) is None) self.assertEqual(o.proto, "http") # o.error called self.assertEqual(o.args, (req, r, 502, "Bad gateway", {})) def test_cookies(self): cj = MockCookieJar() h = urllib2.HTTPCookieProcessor(cj) o = h.parent = MockOpener() req = Request("http://example.com/") r = MockResponse(200, "OK", {}, "") newreq = h.http_request(req) self.assert_(cj.ach_req is req is newreq) self.assertEquals(req.get_origin_req_host(), "example.com") self.assert_(not req.is_unverifiable()) newr = h.http_response(req, r) self.assert_(cj.ec_req is req) self.assert_(cj.ec_r is r is newr) def test_redirect(self): from_url = "http://example.com/a.html" to_url = "http://example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() # ordinary redirect behaviour for code in 301, 302, 303, 307: for data in None, "blah\nblah\n": method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) req.add_header("Nonsense", "viking=withhold") req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT if data is not None: req.add_header("Content-Length", str(len(data))) req.add_unredirected_header("Spam", "spam") try: method(req, MockFile(), code, "Blah", MockHeaders({"location": to_url})) except urllib2.HTTPError: # 307 in response to POST requires user OK self.assert_(code == 307 and data is not None) self.assertEqual(o.req.get_full_url(), to_url) try: self.assertEqual(o.req.get_method(), "GET") except AttributeError: self.assert_(not o.req.has_data()) # now it's a GET, there should not be headers regarding content # (possibly dragged from before being a POST) headers = [x.lower() for x in o.req.headers] self.assertTrue("content-length" not in headers) self.assertTrue("content-type" not in headers) self.assertEqual(o.req.headers["Nonsense"], "viking=withhold") self.assert_("Spam" not in o.req.headers) self.assert_("Spam" not in o.req.unredirected_hdrs) # loop detection req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT def redirect(h, req, url=to_url): h.http_error_302(req, MockFile(), 302, "Blah", MockHeaders({"location": url})) # Note that the *original* request shares the same record of # redirections with the sub-requests caused by the redirections. # detect infinite loop redirect of a URL to itself req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/") count = count + 1 except urllib2.HTTPError: # don't stop until max_repeats, because cookies may introduce state self.assertEqual(count, urllib2.HTTPRedirectHandler.max_repeats) # detect endless non-repeating chain of redirects req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/%d" % count) count = count + 1 except urllib2.HTTPError: self.assertEqual(count, urllib2.HTTPRedirectHandler.max_redirections) def test_invalid_redirect(self): from_url = "http://example.com/a.html" valid_schemes = ['http', 'https', 'ftp'] invalid_schemes = ['file', 'imap', 'ldap'] schemeless_url = "example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT for scheme in invalid_schemes: invalid_url = scheme + '://' + schemeless_url self.assertRaises(urllib2.HTTPError, h.http_error_302, req, MockFile(), 302, "Security Loophole", MockHeaders({"location": invalid_url})) for scheme in valid_schemes: valid_url = scheme + '://' + schemeless_url h.http_error_302(req, MockFile(), 302, "That's fine", MockHeaders({"location": valid_url})) self.assertEqual(o.req.get_full_url(), valid_url) def test_cookie_redirect(self): # cookies shouldn't leak into redirected requests from cookielib import CookieJar from test_cookielib import interact_netscape cj = CookieJar() interact_netscape(cj, "http://www.example.com/", "spam=eggs") hh = MockHTTPHandler(302, "Location: http://www.cracker.com/\r\n\r\n") hdeh = urllib2.HTTPDefaultErrorHandler() hrh = urllib2.HTTPRedirectHandler() cp = urllib2.HTTPCookieProcessor(cj) o = build_test_opener(hh, hdeh, hrh, cp) o.open("http://www.example.com/") self.assert_(not hh.req.has_header("Cookie")) def test_proxy(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) o.add_handler(ph) meth_spec = [ [("http_open", "return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://acme.example.com/") self.assertEqual(req.get_host(), "acme.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) def test_proxy_no_proxy(self): os.environ['no_proxy'] = 'python.org' o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com")) o.add_handler(ph) req = Request("http://www.perl.org/") self.assertEqual(req.get_host(), "www.perl.org") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com") req = Request("http://www.python.org") self.assertEqual(req.get_host(), "www.python.org") r = o.open(req) self.assertEqual(req.get_host(), "www.python.org") del os.environ['no_proxy'] def test_proxy_https(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) meth_spec = [ [("https_open","return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("https://www.example.com/") self.assertEqual(req.get_host(), "www.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "https_open")], [tup[0:2] for tup in o.calls]) def test_proxy_https_proxy_authorization(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) https_handler = MockHTTPSHandler() o.add_handler(https_handler) req = Request("https://www.example.com/") req.add_header("Proxy-Authorization","FooBar") req.add_header("User-Agent","Grail") self.assertEqual(req.get_host(), "www.example.com") self.assertTrue(req._tunnel_host is None) r = o.open(req) # Verify Proxy-Authorization gets tunneled to request. # httpsconn req_headers do not have the Proxy-Authorization header but # the req will have. self.assertFalse(("Proxy-Authorization","FooBar") in https_handler.httpconn.req_headers) self.assertTrue(("User-Agent","Grail") in https_handler.httpconn.req_headers) self.assertFalse(req._tunnel_host is None) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual(req.get_header("Proxy-authorization"),"FooBar") def test_basic_auth(self, quote_char='"'): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm=%s%s%s\r\n\r\n' % (quote_char, realm, quote_char) ) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected", ) def test_basic_auth_with_single_quoted_realm(self): self.test_basic_auth(quote_char="'") def test_proxy_basic_auth(self): opener = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) opener.add_handler(ph) password_manager = MockPasswordManager() auth_handler = urllib2.ProxyBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Proxy-authorization", realm, http_handler, password_manager, "http://acme.example.com:3128/protected", "proxy.example.com:3128", ) def test_basic_and_digest_auth_handlers(self): # HTTPDigestAuthHandler threw an exception if it couldn't handle a 40* # response (http://python.org/sf/1479302), where it should instead # return None to allow another handler (especially # HTTPBasicAuthHandler) to handle the response. # Also (http://python.org/sf/14797027, RFC 2617 section 1.2), we must # try digest first (since it's the strongest auth scheme), so we record # order of calls here to check digest comes first: class RecordingOpenerDirector(OpenerDirector): def __init__(self): OpenerDirector.__init__(self) self.recorded = [] def record(self, info): self.recorded.append(info) class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("digest") urllib2.HTTPDigestAuthHandler.http_error_401(self, *args, **kwds) class TestBasicAuthHandler(urllib2.HTTPBasicAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("basic") urllib2.HTTPBasicAuthHandler.http_error_401(self, *args, **kwds) opener = RecordingOpenerDirector() password_manager = MockPasswordManager() digest_handler = TestDigestAuthHandler(password_manager) basic_handler = TestBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(basic_handler) opener.add_handler(digest_handler) opener.add_handler(http_handler) # check basic auth isn't blocked by digest handler failing self._test_basic_auth(opener, basic_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected", ) # check digest was tried before basic (twice, because # _test_basic_auth called .open() twice) self.assertEqual(opener.recorded, ["digest", "basic"]*2) def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): import base64 user, password = "wile", "coyote" # .add_password() fed through to password manager auth_handler.add_password(realm, request_url, user, password) self.assertEqual(realm, password_manager.realm) self.assertEqual(request_url, password_manager.url) self.assertEqual(user, password_manager.user) self.assertEqual(password, password_manager.password) r = opener.open(request_url) # should have asked the password manager for the username/password self.assertEqual(password_manager.target_realm, realm) self.assertEqual(password_manager.target_url, protected_url) # expect one request without authorization, then one with self.assertEqual(len(http_handler.requests), 2) self.assertFalse(http_handler.requests[0].has_header(auth_header)) userpass = '%s:%s' % (user, password) auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip() self.assertEqual(http_handler.requests[1].get_header(auth_header), auth_hdr_value) self.assertEqual(http_handler.requests[1].unredirected_hdrs[auth_header], auth_hdr_value) # if the password manager can't find a password, the handler won't # handle the HTTP auth error password_manager.user = password_manager.password = None http_handler.reset() r = opener.open(request_url) self.assertEqual(len(http_handler.requests), 1) self.assertFalse(http_handler.requests[0].has_header(auth_header)) class MiscTests(unittest.TestCase): def test_build_opener(self): class MyHTTPHandler(urllib2.HTTPHandler): pass class FooHandler(urllib2.BaseHandler): def foo_open(self): pass class BarHandler(urllib2.BaseHandler): def bar_open(self): pass build_opener = urllib2.build_opener o = build_opener(FooHandler, BarHandler) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # can take a mix of classes and instances o = build_opener(FooHandler, BarHandler()) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # subclasses of default handlers override default handlers o = build_opener(MyHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) # a particular case of overriding: default handlers can be passed # in explicitly o = build_opener() self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler) self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler()) self.opener_has_handler(o, urllib2.HTTPHandler) # Issue2670: multiple handlers sharing the same base class class MyOtherHTTPHandler(urllib2.HTTPHandler): pass o = build_opener(MyHTTPHandler, MyOtherHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) self.opener_has_handler(o, MyOtherHTTPHandler) def opener_has_handler(self, opener, handler_class): for h in opener.handlers: if h.__class__ == handler_class: break else: self.assert_(False) class RequestTests(unittest.TestCase): def setUp(self): self.get = urllib2.Request("http://www.python.org/~jeremy/") self.post = urllib2.Request("http://www.python.org/~jeremy/", "data", headers={"X-Test": "test"}) def test_method(self): self.assertEqual("POST", self.post.get_method()) self.assertEqual("GET", self.get.get_method()) def test_add_data(self): self.assert_(not self.get.has_data()) self.assertEqual("GET", self.get.get_method()) self.get.add_data("spam") self.assert_(self.get.has_data()) self.assertEqual("POST", self.get.get_method()) def test_get_full_url(self): self.assertEqual("http://www.python.org/~jeremy/", self.get.get_full_url()) def test_selector(self): self.assertEqual("/~jeremy/", self.get.get_selector()) req = urllib2.Request("http://www.python.org/") self.assertEqual("/", req.get_selector()) def test_get_type(self): self.assertEqual("http", self.get.get_type()) def test_get_host(self): self.assertEqual("www.python.org", self.get.get_host()) def test_get_host_unquote(self): req = urllib2.Request("http://www.%70ython.org/") self.assertEqual("www.python.org", req.get_host()) def test_proxy(self): self.assert_(not self.get.has_proxy()) self.get.set_proxy("www.perl.org", "http") self.assert_(self.get.has_proxy()) self.assertEqual("www.python.org", self.get.get_origin_req_host()) self.assertEqual("www.perl.org", self.get.get_host()) def test_main(verbose=None): import test_urllib2 test_support.run_doctest(test_urllib2, verbose) test_support.run_doctest(urllib2, verbose) tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, RequestTests) test_support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) gevent-1.1.0/greentest/2.6/test_urllib2_localnet.py0000644000076500000000000004262712666555342022724 0ustar jmaddenwheel00000000000000#!/usr/bin/env python import threading import urlparse import urllib2 import BaseHTTPServer import unittest import hashlib from test import test_support mimetools = test_support.import_module('mimetools', deprecated=True) # Loopback http server infrastructure class LoopbackHttpServer(BaseHTTPServer.HTTPServer): """HTTP server w/ a few modifications that make it useful for loopback testing purposes. """ def __init__(self, server_address, RequestHandlerClass): BaseHTTPServer.HTTPServer.__init__(self, server_address, RequestHandlerClass) # Set the timeout of our listening socket really low so # that we can stop the server easily. self.socket.settimeout(0.1) def get_request(self): """BaseHTTPServer method, overridden.""" request, client_address = self.socket.accept() # It's a loopback connection, so setting the timeout # really low shouldn't affect anything, but should make # deadlocks less likely to occur. request.settimeout(1.0) return (request, client_address) class LoopbackHttpServerThread(threading.Thread): """Stoppable thread that runs a loopback http server.""" def __init__(self, request_handler): threading.Thread.__init__(self) self._stop = False self.ready = threading.Event() request_handler.protocol_version = "HTTP/1.0" self.httpd = LoopbackHttpServer(('127.0.0.1', 0), request_handler) #print "Serving HTTP on %s port %s" % (self.httpd.server_name, # self.httpd.server_port) self.port = self.httpd.server_port def stop(self): """Stops the webserver if it's currently running.""" # Set the stop flag. self._stop = True self.join() def run(self): self.ready.set() while not self._stop: self.httpd.handle_request() # Authentication infrastructure class DigestAuthHandler: """Handler for performing digest authentication.""" def __init__(self): self._request_num = 0 self._nonces = [] self._users = {} self._realm_name = "Test Realm" self._qop = "auth" def set_qop(self, qop): self._qop = qop def set_users(self, users): assert isinstance(users, dict) self._users = users def set_realm(self, realm): self._realm_name = realm def _generate_nonce(self): self._request_num += 1 nonce = hashlib.md5(str(self._request_num)).hexdigest() self._nonces.append(nonce) return nonce def _create_auth_dict(self, auth_str): first_space_index = auth_str.find(" ") auth_str = auth_str[first_space_index+1:] parts = auth_str.split(",") auth_dict = {} for part in parts: name, value = part.split("=") name = name.strip() if value[0] == '"' and value[-1] == '"': value = value[1:-1] else: value = value.strip() auth_dict[name] = value return auth_dict def _validate_auth(self, auth_dict, password, method, uri): final_dict = {} final_dict.update(auth_dict) final_dict["password"] = password final_dict["method"] = method final_dict["uri"] = uri HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict HA1 = hashlib.md5(HA1_str).hexdigest() HA2_str = "%(method)s:%(uri)s" % final_dict HA2 = hashlib.md5(HA2_str).hexdigest() final_dict["HA1"] = HA1 final_dict["HA2"] = HA2 response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \ "%(cnonce)s:%(qop)s:%(HA2)s" % final_dict response = hashlib.md5(response_str).hexdigest() return response == auth_dict["response"] def _return_auth_challenge(self, request_handler): request_handler.send_response(407, "Proxy Authentication Required") request_handler.send_header("Content-Type", "text/html") request_handler.send_header( 'Proxy-Authenticate', 'Digest realm="%s", ' 'qop="%s",' 'nonce="%s", ' % \ (self._realm_name, self._qop, self._generate_nonce())) # XXX: Not sure if we're supposed to add this next header or # not. #request_handler.send_header('Connection', 'close') request_handler.end_headers() request_handler.wfile.write("Proxy Authentication Required.") return False def handle_request(self, request_handler): """Performs digest authentication on the given HTTP request handler. Returns True if authentication was successful, False otherwise. If no users have been set, then digest auth is effectively disabled and this method will always return True. """ if len(self._users) == 0: return True if 'Proxy-Authorization' not in request_handler.headers: return self._return_auth_challenge(request_handler) else: auth_dict = self._create_auth_dict( request_handler.headers['Proxy-Authorization'] ) if auth_dict["username"] in self._users: password = self._users[ auth_dict["username"] ] else: return self._return_auth_challenge(request_handler) if not auth_dict.get("nonce") in self._nonces: return self._return_auth_challenge(request_handler) else: self._nonces.remove(auth_dict["nonce"]) auth_validated = False # MSIE uses short_path in its validation, but Python's # urllib2 uses the full path, so we're going to see if # either of them works here. for path in [request_handler.path, request_handler.short_path]: if self._validate_auth(auth_dict, password, request_handler.command, path): auth_validated = True if not auth_validated: return self._return_auth_challenge(request_handler) return True # Proxy test infrastructure class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler): """This is a 'fake proxy' that makes it look like the entire internet has gone down due to a sudden zombie invasion. It main utility is in providing us with authentication support for testing. """ digest_auth_handler = DigestAuthHandler() def log_message(self, format, *args): # Uncomment the next line for debugging. #sys.stderr.write(format % args) pass def do_GET(self): (scm, netloc, path, params, query, fragment) = urlparse.urlparse( self.path, 'http') self.short_path = path if self.digest_auth_handler.handle_request(self): self.send_response(200, "OK") self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write("You've reached %s!
    " % self.path) self.wfile.write("Our apologies, but our server is down due to " "a sudden zombie invasion.") # Test cases class ProxyAuthTests(unittest.TestCase): URL = "http://localhost" USER = "tester" PASSWD = "test123" REALM = "TestRealm" def setUp(self): FakeProxyHandler.digest_auth_handler.set_users({ self.USER : self.PASSWD }) FakeProxyHandler.digest_auth_handler.set_realm(self.REALM) self.server = LoopbackHttpServerThread(FakeProxyHandler) self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port handler = urllib2.ProxyHandler({"http" : proxy_url}) self._digest_auth_handler = urllib2.ProxyDigestAuthHandler() self.opener = urllib2.build_opener(handler, self._digest_auth_handler) def tearDown(self): self.server.stop() def test_proxy_with_bad_password_raises_httperror(self): self._digest_auth_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD+"bad") FakeProxyHandler.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_with_no_password_raises_httperror(self): FakeProxyHandler.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_qop_auth_works(self): self._digest_auth_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) FakeProxyHandler.digest_auth_handler.set_qop("auth") result = self.opener.open(self.URL) while result.read(): pass result.close() def test_proxy_qop_auth_int_works_or_throws_urlerror(self): self._digest_auth_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) FakeProxyHandler.digest_auth_handler.set_qop("auth-int") try: result = self.opener.open(self.URL) except urllib2.URLError: # It's okay if we don't support auth-int, but we certainly # shouldn't receive any kind of exception here other than # a URLError. result = None if result: while result.read(): pass result.close() def GetRequestHandler(responses): class FakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version = "TestHTTP/" requests = [] headers_received = [] port = 80 def do_GET(self): body = self.send_head() if body: self.wfile.write(body) def do_POST(self): content_length = self.headers['Content-Length'] post_data = self.rfile.read(int(content_length)) self.do_GET() self.requests.append(post_data) def send_head(self): FakeHTTPRequestHandler.headers_received = self.headers self.requests.append(self.path) response_code, headers, body = responses.pop(0) self.send_response(response_code) for (header, value) in headers: self.send_header(header, value % self.port) if body: self.send_header('Content-type', 'text/plain') self.end_headers() return body self.end_headers() def log_message(self, *args): pass return FakeHTTPRequestHandler class TestUrlopen(unittest.TestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. """ def start_server(self, responses): handler = GetRequestHandler(responses) self.server = LoopbackHttpServerThread(handler) self.server.start() self.server.ready.wait() port = self.server.port handler.port = port return handler def test_redirection(self): expected_response = 'We got here...' responses = [ (302, [('Location', 'http://localhost:%s/somewhere_else')], ''), (200, [], expected_response) ] handler = self.start_server(responses) try: f = urllib2.urlopen('http://localhost:%s/' % handler.port) data = f.read() f.close() self.assertEquals(data, expected_response) self.assertEquals(handler.requests, ['/', '/somewhere_else']) finally: self.server.stop() def test_404(self): expected_response = 'Bad bad bad...' handler = self.start_server([(404, [], expected_response)]) try: try: urllib2.urlopen('http://localhost:%s/weeble' % handler.port) except urllib2.URLError, f: pass else: self.fail('404 should raise URLError') data = f.read() f.close() self.assertEquals(data, expected_response) self.assertEquals(handler.requests, ['/weeble']) finally: self.server.stop() def test_200(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port) data = f.read() f.close() self.assertEquals(data, expected_response) self.assertEquals(handler.requests, ['/bizarre']) finally: self.server.stop() def test_200_with_parameters(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port, 'get=with_feeling') data = f.read() f.close() self.assertEquals(data, expected_response) self.assertEquals(handler.requests, ['/bizarre', 'get=with_feeling']) finally: self.server.stop() def test_sending_headers(self): handler = self.start_server([(200, [], "we don't care")]) try: req = urllib2.Request("http://localhost:%s/" % handler.port, headers={'Range': 'bytes=20-39'}) urllib2.urlopen(req) self.assertEqual(handler.headers_received['Range'], 'bytes=20-39') finally: self.server.stop() def test_basic(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) for attr in ("read", "close", "info", "geturl"): self.assert_(hasattr(open_url, attr), "object returned from " "urlopen lacks the %s attribute" % attr) try: self.assert_(open_url.read(), "calling 'read' failed") finally: open_url.close() finally: self.server.stop() def test_info(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) info_obj = open_url.info() self.assert_(isinstance(info_obj, mimetools.Message), "object returned by 'info' is not an instance of " "mimetools.Message") self.assertEqual(info_obj.getsubtype(), "plain") finally: self.server.stop() def test_geturl(self): # Make sure same URL as opened is returned by geturl. handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) url = open_url.geturl() self.assertEqual(url, "http://localhost:%s" % handler.port) finally: self.server.stop() def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. self.assertRaises(IOError, # Given that both VeriSign and various ISPs have in # the past or are presently hijacking various invalid # domain name requests in an attempt to boost traffic # to their own sites, finding a domain name to use # for this test is difficult. RFC2606 leads one to # believe that '.invalid' should work, but experience # seemed to indicate otherwise. Single character # TLDs are likely to remain invalid, so this seems to # be the best choice. The trailing '.' prevents a # related problem: The normal DNS resolver appends # the domain names from the search path if there is # no '.' the end and, and if one of those domains # implements a '*' rule a result is returned. # However, none of this will prevent the test from # failing if the ISP hijacks all invalid domain # requests. The real solution would be to be able to # parameterize the framework with a mock resolver. urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./") def test_main(): # We will NOT depend on the network resource flag # (Lib/test/regrtest.py -u network) since all tests here are only # localhost. However, if this is a bad rationale, then uncomment # the next line. #test_support.requires("network") test_support.run_unittest(ProxyAuthTests) test_support.run_unittest(TestUrlopen) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_urllib2net.py0000644000076500000000000002301312666555342021536 0ustar jmaddenwheel00000000000000#!/usr/bin/env python import unittest from test import test_support from test_urllib2 import sanepathname2url import socket import urllib2 import sys import os import sys TIMEOUT = 60 # seconds def _retry_thrice(func, exc, *args, **kwargs): for i in range(3): try: return func(*args, **kwargs) except exc, last_exc: continue except: raise raise last_exc def _wrap_with_retry_thrice(func, exc): def wrapped(*args, **kwargs): return _retry_thrice(func, exc, *args, **kwargs) return wrapped # Connecting to remote hosts is flaky. Make it more robust by retrying # the connection several times. _urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError) class AuthTests(unittest.TestCase): """Tests urllib2 authentication features.""" ## Disabled at the moment since there is no page under python.org which ## could be used to HTTP authentication. # # def test_basic_auth(self): # import httplib # # test_url = "http://www.python.org/test/test_urllib2/basic_auth" # test_hostport = "www.python.org" # test_realm = 'Test Realm' # test_user = 'test.test_urllib2net' # test_password = 'blah' # # # failure # try: # _urlopen_with_retry(test_url) # except urllib2.HTTPError, exc: # self.assertEqual(exc.code, 401) # else: # self.fail("urlopen() should have failed with 401") # # # success # auth_handler = urllib2.HTTPBasicAuthHandler() # auth_handler.add_password(test_realm, test_hostport, # test_user, test_password) # opener = urllib2.build_opener(auth_handler) # f = opener.open('http://localhost/') # response = _urlopen_with_retry("http://www.python.org/") # # # The 'userinfo' URL component is deprecated by RFC 3986 for security # # reasons, let's not implement it! (it's already implemented for proxy # # specification strings (that is, URLs or authorities specifying a # # proxy), so we must keep that) # self.assertRaises(httplib.InvalidURL, # urllib2.urlopen, "http://evil:thing@example.com") class CloseSocketTest(unittest.TestCase): def test_close(self): import socket, httplib, gc # calling .close() on urllib2's response objects should close the # underlying socket # delve deep into response to fetch socket._socketobject response = _urlopen_with_retry("http://www.python.org/") abused_fileobject = response.fp #self.assert_(abused_fileobject.__class__ is socket._fileobject) JAM: gevent: disable httpresponse = abused_fileobject._sock self.assert_(httpresponse.__class__ is httplib.HTTPResponse) fileobject = httpresponse.fp #self.assert_(fileobject.__class__ is socket._fileobject) JAM: gevent: disable self.assert_(not fileobject.closed) response.close() self.assert_(fileobject.closed) class OtherNetworkTests(unittest.TestCase): def setUp(self): if 0: # for debugging import logging logger = logging.getLogger("test_urllib2net") logger.addHandler(logging.StreamHandler()) # XXX The rest of these tests aren't very good -- they don't check much. # They do sometimes catch some major disasters, though. def test_ftp(self): urls = [ 'ftp://ftp.kernel.org/pub/linux/kernel/README', 'ftp://ftp.kernel.org/pub/linux/kernel/non-existent-file', #'ftp://ftp.kernel.org/pub/leenox/kernel/test', 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC' '/research-reports/00README-Legal-Rules-Regs', ] self._test_urls(urls, self._extra_handlers()) def test_file(self): TESTFN = test_support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') f.close() urls = [ 'file:'+sanepathname2url(os.path.abspath(TESTFN)), ('file:///nonsensename/etc/passwd', None, urllib2.URLError), ] self._test_urls(urls, self._extra_handlers(), retry=True) finally: os.remove(TESTFN) # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes. ## def test_cnri(self): ## if socket.gethostname() == 'bitdiddle': ## localhost = 'bitdiddle.cnri.reston.va.us' ## elif socket.gethostname() == 'bitdiddle.concentric.net': ## localhost = 'localhost' ## else: ## localhost = None ## if localhost is not None: ## urls = [ ## 'file://%s/etc/passwd' % localhost, ## 'http://%s/simple/' % localhost, ## 'http://%s/digest/' % localhost, ## 'http://%s/not/found.h' % localhost, ## ] ## bauth = HTTPBasicAuthHandler() ## bauth.add_password('basic_test_realm', localhost, 'jhylton', ## 'password') ## dauth = HTTPDigestAuthHandler() ## dauth.add_password('digest_test_realm', localhost, 'jhylton', ## 'password') ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def _test_urls(self, urls, handlers, retry=True): import socket import time import logging debug = logging.getLogger("test_urllib2").debug urlopen = urllib2.build_opener(*handlers).open if retry: urlopen = _wrap_with_retry_thrice(urlopen, urllib2.URLError) for url in urls: if isinstance(url, tuple): url, req, expected_err = url else: req = expected_err = None debug(url) try: f = urlopen(url, req, TIMEOUT) except EnvironmentError, err: debug(err) if expected_err: msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" % (expected_err, url, req, type(err), err)) self.assert_(isinstance(err, expected_err), msg) except urllib2.URLError as err: if isinstance(err[0], socket.timeout): print >>sys.stderr, "" % url continue else: raise else: try: with test_support.transient_internet(): buf = f.read() debug("read %d bytes" % len(buf)) except socket.timeout: print >>sys.stderr, "" % url f.close() debug("******** next url coming up...") time.sleep(0.1) def _extra_handlers(self): handlers = [] cfh = urllib2.CacheFTPHandler() cfh.setTimeout(1) handlers.append(cfh) return handlers class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertTrue(socket.getdefaulttimeout() is None) u = _urlopen_with_retry("http://www.python.org") self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) def test_http_default_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(60) try: u = _urlopen_with_retry("http://www.python.org") finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) def test_http_no_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(60) try: u = _urlopen_with_retry("http://www.python.org", timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) def test_http_timeout(self): u = _urlopen_with_retry("http://www.python.org", timeout=120) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) FTP_HOST = "ftp://ftp.mirror.nl/pub/mirror/gnu/" def test_ftp_basic(self): self.assertTrue(socket.getdefaulttimeout() is None) u = _urlopen_with_retry(self.FTP_HOST) self.assertTrue(u.fp.fp._sock.gettimeout() is None) def test_ftp_default_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_ftp_no_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(u.fp.fp._sock.gettimeout() is None) def test_ftp_timeout(self): u = _urlopen_with_retry(self.FTP_HOST, timeout=60) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_main(): test_support.requires("network") test_support.run_unittest(AuthTests, OtherNetworkTests, CloseSocketTest, TimeoutTest, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.6/test_wsgiref.py0000755000076500000000000004331612666555342021135 0ustar jmaddenwheel00000000000000from __future__ import nested_scopes # Backward compat for 2.1 from unittest import TestCase from wsgiref.util import setup_testing_defaults from wsgiref.headers import Headers from wsgiref.handlers import BaseHandler, BaseCGIHandler from wsgiref import util from wsgiref.validate import validator from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app from wsgiref.simple_server import make_server from StringIO import StringIO from SocketServer import BaseServer import os import re import sys from test import test_support class MockServer(WSGIServer): """Non-socket HTTP server""" def __init__(self, server_address, RequestHandlerClass): BaseServer.__init__(self, server_address, RequestHandlerClass) self.server_bind() def server_bind(self): host, port = self.server_address self.server_name = host self.server_port = port self.setup_environ() class MockHandler(WSGIRequestHandler): """Non-socket HTTP handler""" def setup(self): self.connection = self.request self.rfile, self.wfile = self.connection def finish(self): pass def hello_app(environ,start_response): start_response("200 OK", [ ('Content-Type','text/plain'), ('Date','Mon, 05 Jun 2006 18:49:54 GMT') ]) return ["Hello, world!"] def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"): server = make_server("", 80, app, MockServer, MockHandler) inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr sys.stderr = err try: server.finish_request((inp,out), ("127.0.0.1",8888)) finally: sys.stderr = olderr return out.getvalue(), err.getvalue() def compare_generic_iter(make_it,match): """Utility to compare a generic 2.1/2.2+ iterator with an iterable If running under Python 2.2+, this tests the iterator using iter()/next(), as well as __getitem__. 'make_it' must be a function returning a fresh iterator to be tested (since this may test the iterator twice).""" it = make_it() n = 0 for item in match: if not it[n]==item: raise AssertionError n+=1 try: it[n] except IndexError: pass else: raise AssertionError("Too many items from __getitem__",it) try: iter, StopIteration except NameError: pass else: # Only test iter mode under 2.2+ it = make_it() if not iter(it) is it: raise AssertionError for item in match: if not it.next()==item: raise AssertionError try: it.next() except StopIteration: pass else: raise AssertionError("Too many items from .next()",it) class IntegrationTests(TestCase): def check_hello(self, out, has_length=True): self.assertEqual(out, "HTTP/1.0 200 OK\r\n" "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n" "Content-Type: text/plain\r\n" "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" + (has_length and "Content-Length: 13\r\n" or "") + "\r\n" "Hello, world!" ) def test_plain_hello(self): out, err = run_amock() self.check_hello(out) def test_validated_hello(self): out, err = run_amock(validator(hello_app)) # the middleware doesn't support len(), so content-length isn't there self.check_hello(out, has_length=False) def test_simple_validation_error(self): def bad_app(environ,start_response): start_response("200 OK", ('Content-Type','text/plain')) return ["Hello, world!"] out, err = run_amock(validator(bad_app)) self.failUnless(out.endswith( "A server error occurred. Please contact the administrator." )) self.assertEqual( err.splitlines()[-2], "AssertionError: Headers (('Content-Type', 'text/plain')) must" " be of type list: " ) class UtilityTests(TestCase): def checkShift(self,sn_in,pi_in,part,sn_out,pi_out): env = {'SCRIPT_NAME':sn_in,'PATH_INFO':pi_in} util.setup_testing_defaults(env) self.assertEqual(util.shift_path_info(env),part) self.assertEqual(env['PATH_INFO'],pi_out) self.assertEqual(env['SCRIPT_NAME'],sn_out) return env def checkDefault(self, key, value, alt=None): # Check defaulting when empty env = {} util.setup_testing_defaults(env) if isinstance(value,StringIO): self.failUnless(isinstance(env[key],StringIO)) else: self.assertEqual(env[key],value) # Check existing value env = {key:alt} util.setup_testing_defaults(env) self.failUnless(env[key] is alt) def checkCrossDefault(self,key,value,**kw): util.setup_testing_defaults(kw) self.assertEqual(kw[key],value) def checkAppURI(self,uri,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.application_uri(kw),uri) def checkReqURI(self,uri,query=1,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.request_uri(kw,query),uri) def checkFW(self,text,size,match): def make_it(text=text,size=size): return util.FileWrapper(StringIO(text),size) compare_generic_iter(make_it,match) it = make_it() self.failIf(it.filelike.closed) for item in it: pass self.failIf(it.filelike.closed) it.close() self.failUnless(it.filelike.closed) def testSimpleShifts(self): self.checkShift('','/', '', '/', '') self.checkShift('','/x', 'x', '/x', '') self.checkShift('/','', None, '/', '') self.checkShift('/a','/x/y', 'x', '/a/x', '/y') self.checkShift('/a','/x/', 'x', '/a/x', '/') def testNormalizedShifts(self): self.checkShift('/a/b', '/../y', '..', '/a', '/y') self.checkShift('', '/../y', '..', '', '/y') self.checkShift('/a/b', '//y', 'y', '/a/b/y', '') self.checkShift('/a/b', '//y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '/./y', 'y', '/a/b/y', '') self.checkShift('/a/b', '/./y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '///./..//y/.//', '..', '/a', '/y/') self.checkShift('/a/b', '///', '', '/a/b/', '') self.checkShift('/a/b', '/.//', '', '/a/b/', '') self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/') self.checkShift('/a/b', '/.', None, '/a/b', '') def testDefaults(self): for key, value in [ ('SERVER_NAME','127.0.0.1'), ('SERVER_PORT', '80'), ('SERVER_PROTOCOL','HTTP/1.0'), ('HTTP_HOST','127.0.0.1'), ('REQUEST_METHOD','GET'), ('SCRIPT_NAME',''), ('PATH_INFO','/'), ('wsgi.version', (1,0)), ('wsgi.run_once', 0), ('wsgi.multithread', 0), ('wsgi.multiprocess', 0), ('wsgi.input', StringIO("")), ('wsgi.errors', StringIO()), ('wsgi.url_scheme','http'), ]: self.checkDefault(key,value) def testCrossDefaults(self): self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="1") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="yes") self.checkCrossDefault('wsgi.url_scheme',"http",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on") def testGuessScheme(self): self.assertEqual(util.guess_scheme({}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"on"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https") def testAppURIs(self): self.checkAppURI("http://127.0.0.1/") self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkAppURI("http://spam.example.com:2071/", HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071") self.checkAppURI("http://spam.example.com/", SERVER_NAME="spam.example.com") self.checkAppURI("http://127.0.0.1/", HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com") self.checkAppURI("https://127.0.0.1/", HTTPS="on") self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000", HTTP_HOST=None) def testReqURIs(self): self.checkReqURI("http://127.0.0.1/") self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkReqURI("http://127.0.0.1/spammity/spam", SCRIPT_NAME="/spammity", PATH_INFO="/spam") self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") self.checkReqURI("http://127.0.0.1/spammity/spam", 0, SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") def testFileWrapper(self): self.checkFW("xyz"*50, 120, ["xyz"*40,"xyz"*10]) def testHopByHop(self): for hop in ( "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization " "TE Trailers Transfer-Encoding Upgrade" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.failUnless(util.is_hop_by_hop(alt)) # Not comprehensive, just a few random header names for hop in ( "Accept Cache-Control Date Pragma Trailer Via Warning" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.failIf(util.is_hop_by_hop(alt)) class HeaderTests(TestCase): def testMappingInterface(self): test = [('x','y')] self.assertEqual(len(Headers([])),0) self.assertEqual(len(Headers(test[:])),1) self.assertEqual(Headers(test[:]).keys(), ['x']) self.assertEqual(Headers(test[:]).values(), ['y']) self.assertEqual(Headers(test[:]).items(), test) self.failIf(Headers(test).items() is test) # must be copy! h=Headers([]) del h['foo'] # should not raise an error h['Foo'] = 'bar' for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__: self.failUnless(m('foo')) self.failUnless(m('Foo')) self.failUnless(m('FOO')) self.failIf(m('bar')) self.assertEqual(h['foo'],'bar') h['foo'] = 'baz' self.assertEqual(h['FOO'],'baz') self.assertEqual(h.get_all('foo'),['baz']) self.assertEqual(h.get("foo","whee"), "baz") self.assertEqual(h.get("zoo","whee"), "whee") self.assertEqual(h.setdefault("foo","whee"), "baz") self.assertEqual(h.setdefault("zoo","whee"), "whee") self.assertEqual(h["foo"],"baz") self.assertEqual(h["zoo"],"whee") def testRequireList(self): self.assertRaises(TypeError, Headers, "foo") def testExtras(self): h = Headers([]) self.assertEqual(str(h),'\r\n') h.add_header('foo','bar',baz="spam") self.assertEqual(h['foo'], 'bar; baz="spam"') self.assertEqual(str(h),'foo: bar; baz="spam"\r\n\r\n') h.add_header('Foo','bar',cheese=None) self.assertEqual(h.get_all('foo'), ['bar; baz="spam"', 'bar; cheese']) self.assertEqual(str(h), 'foo: bar; baz="spam"\r\n' 'Foo: bar; cheese\r\n' '\r\n' ) class ErrorHandler(BaseCGIHandler): """Simple handler subclass for testing BaseHandler""" # BaseHandler records the OS environment at import time, but envvars # might have been changed later by other tests, which trips up # HandlerTests.testEnviron(). os_environ = dict(os.environ.items()) def __init__(self,**kw): setup_testing_defaults(kw) BaseCGIHandler.__init__( self, StringIO(''), StringIO(), StringIO(), kw, multithread=True, multiprocess=True ) class TestHandler(ErrorHandler): """Simple handler subclass for testing BaseHandler, w/error passthru""" def handle_error(self): raise # for testing, we want to see what's happening class HandlerTests(TestCase): def checkEnvironAttrs(self, handler): env = handler.environ for attr in [ 'version','multithread','multiprocess','run_once','file_wrapper' ]: if attr=='file_wrapper' and handler.wsgi_file_wrapper is None: continue self.assertEqual(getattr(handler,'wsgi_'+attr),env['wsgi.'+attr]) def checkOSEnviron(self,handler): empty = {}; setup_testing_defaults(empty) env = handler.environ from os import environ for k,v in environ.items(): if k not in empty: self.assertEqual(env[k],v) for k,v in empty.items(): self.assertTrue(k in env) def testEnviron(self): h = TestHandler(X="Y") h.setup_environ() self.checkEnvironAttrs(h) self.checkOSEnviron(h) self.assertEqual(h.environ["X"],"Y") def testCGIEnviron(self): h = BaseCGIHandler(None,None,None,{}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': self.assertTrue(key in h.environ) def testScheme(self): h=TestHandler(HTTPS="on"); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'https') h=TestHandler(); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'http') def testAbstractMethods(self): h = BaseHandler() for name in [ '_flush','get_stdin','get_stderr','add_cgi_vars' ]: self.assertRaises(NotImplementedError, getattr(h,name)) self.assertRaises(NotImplementedError, h._write, "test") def testContentLength(self): # Demo one reason iteration is better than write()... ;) def trivial_app1(e,s): s('200 OK',[]) return [e['wsgi.url_scheme']] def trivial_app2(e,s): s('200 OK',[])(e['wsgi.url_scheme']) return [] h = TestHandler() h.run(trivial_app1) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 4\r\n" "\r\n" "http") h = TestHandler() h.run(trivial_app2) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n" "http") def testBasicErrorOutput(self): def non_error_app(e,s): s('200 OK',[]) return [] def error_app(e,s): raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(non_error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n") self.assertEqual(h.stderr.getvalue(),"") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: %s\r\n" "Content-Type: text/plain\r\n" "Content-Length: %d\r\n" "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)) self.assertTrue("AssertionError" in h.stderr.getvalue(), "AssertionError not in stderr") def testErrorAfterOutput(self): MSG = "Some output has been sent" def error_app(e,s): s("200 OK",[])(MSG) raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n"+MSG) self.assertTrue("AssertionError" in h.stderr.getvalue(), "AssertionError not in stderr") def testHeaderFormats(self): def non_error_app(e,s): s('200 OK',[]) return [] stdpat = ( r"HTTP/%s 200 OK\r\n" r"Date: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n" r"%s" r"Content-Length: 0\r\n" r"\r\n" ) shortpat = ( "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n" ) for ssw in "FooBar/1.0", None: sw = ssw and "Server: %s\r\n" % ssw or "" for version in "1.0", "1.1": for proto in "HTTP/0.9", "HTTP/1.0", "HTTP/1.1": h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = False h.http_version = version h.server_software = ssw h.run(non_error_app) self.assertEqual(shortpat,h.stdout.getvalue()) h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = True h.http_version = version h.server_software = ssw h.run(non_error_app) if proto=="HTTP/0.9": self.assertEqual(h.stdout.getvalue(),"") else: self.failUnless( re.match(stdpat%(version,sw), h.stdout.getvalue()), (stdpat%(version,sw), h.stdout.getvalue()) ) # This epilogue is needed for compatibility with the Python 2.5 regrtest module def test_main(): test_support.run_unittest(__name__) if __name__ == "__main__": test_main() # the above lines intentionally left blank gevent-1.1.0/greentest/2.6/version0000644000076500000000000000000612666555342017450 0ustar jmaddenwheel000000000000002.6.8 gevent-1.1.0/greentest/2.6/wrongcert.pem0000644000076500000000000000353012666555342020562 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw eSHj5jpC8iZKjCHBn+mAi4cQ514= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/0000755000076500000000000000000012666555432016045 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7/badcert.pem0000644000076500000000000000361012666555342020154 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/badkey.pem0000644000076500000000000000416212666555342020012 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/0000755000076500000000000000000012666555432017305 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7/capath/0e4015b9.00000644000076500000000000000167412666555342020447 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/4e1295a3.00000644000076500000000000000145612666555342020451 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/5ed36f99.00000644000076500000000000000501112666555342020541 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/6e88d7b8.00000644000076500000000000000145612666555342020553 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/99d0fa06.00000644000076500000000000000501112666555342020525 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/capath/ce7b8643.00000644000076500000000000000167412666555342020543 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/dh1024.pem0000644000076500000000000000045412666555342017455 0ustar jmaddenwheel00000000000000-----BEGIN DH PARAMETERS----- MIGHAoGBAIbzw1s9CT8SV5yv6L7esdAdZYZjPi3qWFs61CYTFFQnf2s/d09NYaJt rrvJhIzWavqnue71qXCf83/J3nz3FEwUU/L0mGyheVbsSHiI64wUo3u50wK5Igo0 RNs/LD0irs7m0icZ//hijafTU+JOBiuA8zMI+oZfU7BGuc9XrUprAgEC -----END DH PARAMETERS----- Generated with: openssl dhparam -out dh1024.pem 1024 gevent-1.1.0/greentest/2.7/https_svn_python_org_root.pem0000644000076500000000000000501112666555342024110 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/keycert.passwd.pem0000644000076500000000000000344612666555342021525 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/keycert.pem0000644000076500000000000000336712666555342020227 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/keycert2.pem0000644000076500000000000000337712666555342020312 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBANcLaMB7T/Wi9DBc PltGzgt8cxsv55m7PQPHMZvn6Ke8xmNqcmEzib8opRwKGrCV6TltKeFlNSg8dwQK Tl4ktyTkGCVweRQJ37AkBayvEBml5s+QD4vlhqkJPsL/Nsd+fnqngOGc5+59+C6r s3XpiLlF5ah/z8q92Mnw54nypw1JAgMBAAECgYBE3t2Mj7GbDLZB6rj5yKJioVfI BD6bSJEQ7bGgqdQkLFwpKMU7BiN+ekjuwvmrRkesYZ7BFgXBPiQrwhU5J28Tpj5B EOMYSIOHfzdalhxDGM1q2oK9LDFiCotTaSdEzMYadel5rmKXJ0zcK2Jho0PCuECf tf/ghRxK+h1Hm0tKgQJBAO6MdGDSmGKYX6/5kPDje7we/lSLorSDkYmV0tmVShsc JxgaGaapazceA/sHL3Myx7Eenkip+yPYDXEDFvAKNDECQQDmxsT9NOp6mo7ISvky GFr2vVHsJ745BMWoma4rFjPBVnS8RkgK+b2EpDCdZSrQ9zw2r8sKTgrEyrDiGTEg wJyZAkA8OOc0flYMJg2aHnYR6kwVjPmGHI5h5gk648EMPx0rROs1sXkiUwkHLCOz HvhCq+Iv+9vX2lnVjbiu/CmxRdIxAkA1YEfzoKeTD+hyXxTgB04Sv5sRGegfXAEz i8gC4zG5R/vcCA1lrHmvEiLEZL/QcT6WD3bQvVg0SAU9ZkI8pxARAkA7yqMSvP1l gJXy44R+rzpLYb1/PtiLkIkaKG3x9TUfPnfD2jY09fPkZlfsRU3/uS09IkhSwimV d5rWoljEfdou -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICXTCCAcagAwIBAgIJALVQzebTtrXFMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xFTATBgNVBAMMDGZha2Vob3N0bmFtZTAeFw0x NDExMjMxNzAwMDdaFw0yNDExMjAxNzAwMDdaMGIxCzAJBgNVBAYTAlhZMRcwFQYD VQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9uIFNvZnR3YXJlIEZv dW5kYXRpb24xFTATBgNVBAMMDGZha2Vob3N0bmFtZTCBnzANBgkqhkiG9w0BAQEF AAOBjQAwgYkCgYEA1wtowHtP9aL0MFw+W0bOC3xzGy/nmbs9A8cxm+fop7zGY2py YTOJvyilHAoasJXpOW0p4WU1KDx3BApOXiS3JOQYJXB5FAnfsCQFrK8QGaXmz5AP i+WGqQk+wv82x35+eqeA4Zzn7n34LquzdemIuUXlqH/Pyr3YyfDnifKnDUkCAwEA AaMbMBkwFwYDVR0RBBAwDoIMZmFrZWhvc3RuYW1lMA0GCSqGSIb3DQEBBQUAA4GB AKuay3vDKfWzt5+ch/HHBsert84ISot4fUjzXDA/oOgTOEjVcSShHxqNShMOW1oA QYBpBB/5Kx5RkD/w6imhucxt2WQPRgjX4x4bwMipVH/HvFDp03mG51/Cpi1TyZ74 El7qa/Pd4lHhOLzMKBA6503fpeYSFUIBxZbGLqylqRK7 -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/keycert3.pem0000644000076500000000000000772212666555342020311 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLgD0kAKDb5cFyP jbwNfR5CtewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM 9z2j1OlaN+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZ aggEdkj1TsSsv1zWIYKlPIjlvhuxAgMBAAECgYA0aH+T2Vf3WOPv8KdkcJg6gCRe yJKXOWgWRcicx/CUzOEsTxmFIDPLxqAWA3k7v0B+3vjGw5Y9lycV/5XqXNoQI14j y09iNsumds13u5AKkGdTJnZhQ7UKdoVHfuP44ZdOv/rJ5/VD6F4zWywpe90pcbK+ AWDVtusgGQBSieEl1QJBAOyVrUG5l2yoUBtd2zr/kiGm/DYyXlIthQO/A3/LngDW 5/ydGxVsT7lAVOgCsoT+0L4efTh90PjzW8LPQrPBWVMCQQDS3h/FtYYd5lfz+FNL 9CEe1F1w9l8P749uNUD0g317zv1tatIqVCsQWHfVHNdVvfQ+vSFw38OORO00Xqs9 1GJrAkBkoXXEkxCZoy4PteheO/8IWWLGGr6L7di6MzFl1lIqwT6D8L9oaV2vynFT DnKop0pa09Unhjyw57KMNmSE2SUJAkEArloTEzpgRmCq4IK2/NpCeGdHS5uqRlbh 1VIa/xGps7EWQl5Mn8swQDel/YP3WGHTjfx7pgSegQfkyaRtGpZ9OQJAa9Vumj8m JAAtI0Bnga8hgQx7BhTQY4CadDxyiRGOGYhwUzYVCqkb2sbVRH9HnwUaJT7cWBY3 RnJdHOMXWem7/w== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443281 (0xb09264b1f2da21d1) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:c2:e0:0f:49:00:28:36:f9:70:5c:8f:8d:bc:0d: 7d:1e:42:b5:ec:1d:5c:2f:a4:31:70:16:0f:c0:cb: c6:24:d3:be:13:16:ee:a5:67:97:03:a6:df:a9:99: 96:cc:c7:2a:fb:11:7f:4e:65:4f:8a:5e:82:21:4c: f7:3d:a3:d4:e9:5a:37:e7:22:fd:7e:cd:53:6d:93: 34:de:9c:ad:84:a2:37:be:c5:8d:82:4f:e3:ae:23: f3:be:a7:75:2c:72:0f:ea:f3:ca:cd:fc:e9:3f:b5: af:56:99:6a:08:04:76:48:f5:4e:c4:ac:bf:5c:d6: 21:82:a5:3c:88:e5:be:1b:b1 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption 2f:42:5f:a3:09:2c:fa:51:88:c7:37:7f:ea:0e:63:f0:a2:9a: e5:5a:e2:c8:20:f0:3f:60:bc:c8:0f:b6:c6:76:ce:db:83:93: f5:a3:33:67:01:8e:04:cd:00:9a:73:fd:f3:35:86:fa:d7:13: e2:46:c6:9d:c0:29:53:d4:a9:90:b8:77:4b:e6:83:76:e4:92: d6:9c:50:cf:43:d0:c6:01:77:61:9a:de:9b:70:f7:72:cd:59: 00:31:69:d9:b4:ca:06:9c:6d:c3:c7:80:8c:68:e6:b5:a2:f8: ef:1d:bb:16:9f:77:77:ef:87:62:22:9b:4d:69:a4:3a:1a:f1: 21:5e:8c:32:ac:92:fd:15:6b:18:c2:7f:15:0d:98:30:ca:75: 8f:1a:71:df:da:1d:b2:ef:9a:e8:2d:2e:02:fd:4a:3c:aa:96: 0b:06:5d:35:b3:3d:24:87:4b:e0:b0:58:60:2f:45:ac:2e:48: 8a:b0:99:10:65:27:ff:cc:b1:d8:fd:bd:26:6b:b9:0c:05:2a: f4:45:63:35:51:07:ed:83:85:fe:6f:69:cb:bb:40:a8:ae:b6: 3b:56:4a:2d:a4:ed:6d:11:2c:4d:ed:17:24:fd:47:bc:d3:41: a2:d3:06:fe:0c:90:d8:d8:94:26:c4:ff:cc:a1:d8:42:77:eb: fc:a9:94:71 -----BEGIN CERTIFICATE----- MIICpDCCAYwCCQCwkmSx8toh0TANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBfMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRIwEAYDVQQDEwlsb2NhbGhv c3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMLgD0kAKDb5cFyPjbwNfR5C tewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM9z2j1Ola N+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZaggEdkj1 TsSsv1zWIYKlPIjlvhuxAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAC9CX6MJLPpR iMc3f+oOY/CimuVa4sgg8D9gvMgPtsZ2ztuDk/WjM2cBjgTNAJpz/fM1hvrXE+JG xp3AKVPUqZC4d0vmg3bkktacUM9D0MYBd2Ga3ptw93LNWQAxadm0ygacbcPHgIxo 5rWi+O8duxafd3fvh2Iim01ppDoa8SFejDKskv0VaxjCfxUNmDDKdY8acd/aHbLv mugtLgL9SjyqlgsGXTWzPSSHS+CwWGAvRawuSIqwmRBlJ//Msdj9vSZruQwFKvRF YzVRB+2Dhf5vacu7QKiutjtWSi2k7W0RLE3tFyT9R7zTQaLTBv4MkNjYlCbE/8yh 2EJ36/yplHE= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/keycert4.pem0000644000076500000000000000773112666555342020312 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK5UQiMI5VkNs2Qv L7gUaiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2 NkX0ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1 L2OQhEx1GM6RydHdgX69G64LXcY5AgMBAAECgYAhsRMfJkb9ERLMl/oG/5sLQu9L pWDKt6+ZwdxzlZbggQ85CMYshjLKIod2DLL/sLf2x1PRXyRG131M1E3k8zkkz6de R1uDrIN/x91iuYzfLQZGh8bMY7Yjd2eoroa6R/7DjpElGejLxOAaDWO0ST2IFQy9 myTGS2jSM97wcXfsSQJBANP3jelJoS5X6BRjTSneY21wcocxVuQh8pXpErALVNsT drrFTeaBuZp7KvbtnIM5g2WRNvaxLZlAY/hXPJvi6ncCQQDSix1cebml6EmPlEZS Mm8gwI2F9ufUunwJmBJcz826Do0ZNGByWDAM/JQZH4FX4GfAFNuj8PUb+GQfadkx i1DPAkEA0lVsNHojvuDsIo8HGuzarNZQT2beWjJ1jdxh9t7HrTx7LIps6rb/fhOK Zs0R6gVAJaEbcWAPZ2tFyECInAdnsQJAUjaeXXjuxFkjOFym5PvqpvhpivEx78Bu JPTr3rAKXmfGMxxfuOa0xK1wSyshP6ZR/RBn/+lcXPKubhHQDOegwwJAJF1DBQnN +/tLmOPULtDwfP4Zixn+/8GmGOahFoRcu6VIGHmRilJTn6MOButw7Glv2YdeC6l/ e83Gq6ffLVfKNQ== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443282 (0xb09264b1f2da21d2) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=fakehostname Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:ae:54:42:23:08:e5:59:0d:b3:64:2f:2f:b8:14: 6a:20:dd:15:eb:cd:51:74:63:53:80:c7:01:ed:d9: cf:36:0b:64:d1:3a:f6:1f:60:3b:d5:42:49:2d:7a: b4:9e:5f:4f:95:44:bb:41:19:c8:6a:f4:7b:75:76: 36:45:f4:66:85:34:1d:cf:d4:69:8e:2a:c7:b2:c7: 9a:7e:52:61:9a:48:c6:12:67:91:fe:d2:c8:72:4a: d7:35:1a:1a:55:34:fc:bc:58:a8:8b:86:0a:d1:79: 76:ac:75:2f:63:90:84:4c:75:18:ce:91:c9:d1:dd: 81:7e:bd:1b:ae:0b:5d:c6:39 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption ad:45:8a:8e:ef:c6:ef:04:41:5c:2c:4a:84:dc:02:76:0c:d0: 66:0f:f0:16:04:58:4d:fd:68:b7:b8:d3:a8:41:a5:5c:3c:6f: 65:3c:d1:f8:ce:43:35:e7:41:5f:53:3d:c9:2c:c3:7d:fc:56: 4a:fa:47:77:38:9d:bb:97:28:0a:3b:91:19:7f:bc:74:ae:15: 6b:bd:20:36:67:45:a5:1e:79:d7:75:e6:89:5c:6d:54:84:d1: 95:d7:a7:b4:33:3c:af:37:c4:79:8f:5e:75:dc:75:c2:18:fb: 61:6f:2d:dc:38:65:5b:ba:67:28:d0:88:d7:8d:b9:23:5a:8e: e8:c6:bb:db:ce:d5:b8:41:2a:ce:93:08:b6:95:ad:34:20:18: d5:3b:37:52:74:50:0b:07:2c:b0:6d:a4:4c:7b:f4:e0:fd:d1: af:17:aa:20:cd:62:e3:f0:9d:37:69:db:41:bd:d4:1c:fb:53: 20:da:88:9d:76:26:67:ce:01:90:a7:80:1d:a9:5b:39:73:68: 54:0a:d1:2a:03:1b:8f:3c:43:5d:5d:c4:51:f1:a7:e7:11:da: 31:2c:49:06:af:04:f4:b8:3c:99:c4:20:b9:06:36:a2:00:92: 61:1d:0c:6d:24:05:e2:82:e1:47:db:a0:5f:ba:b9:fb:ba:fa: 49:12:1e:ce -----BEGIN CERTIFICATE----- MIICpzCCAY8CCQCwkmSx8toh0jANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBiMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRUwEwYDVQQDEwxmYWtlaG9z dG5hbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK5UQiMI5VkNs2QvL7gU aiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2NkX0 ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1L2OQ hEx1GM6RydHdgX69G64LXcY5AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAK1Fio7v xu8EQVwsSoTcAnYM0GYP8BYEWE39aLe406hBpVw8b2U80fjOQzXnQV9TPcksw338 Vkr6R3c4nbuXKAo7kRl/vHSuFWu9IDZnRaUeedd15olcbVSE0ZXXp7QzPK83xHmP XnXcdcIY+2FvLdw4ZVu6ZyjQiNeNuSNajujGu9vO1bhBKs6TCLaVrTQgGNU7N1J0 UAsHLLBtpEx79OD90a8XqiDNYuPwnTdp20G91Bz7UyDaiJ12JmfOAZCngB2pWzlz aFQK0SoDG488Q11dxFHxp+cR2jEsSQavBPS4PJnEILkGNqIAkmEdDG0kBeKC4Ufb oF+6ufu6+kkSHs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/lock_tests.py0000644000076500000000000003642412666555342020602 0ustar jmaddenwheel00000000000000""" Various tests for synchronization primitives. """ import sys import time from thread import start_new_thread, get_ident import threading import unittest from test import test_support as support def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() try: for i in range(n): start_new_thread(task, ()) except: self._can_exit = True raise def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children() class BaseLockTests(BaseTestCase): """ Tests for both recursive and non-recursive locks. """ def test_constructor(self): lock = self.locktype() del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) def test_with(self): lock = self.locktype() def f(): lock.acquire() lock.release() def _with(err=None): with lock: if err is not None: raise err _with() # Check the lock is unacquired Bunch(f, 1).wait_for_finished() self.assertRaises(TypeError, _with, TypeError) # Check the lock is unacquired Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. Bunch(f, 15).wait_for_finished() self.assertEqual(n, len(threading.enumerate())) class LockTests(BaseLockTests): """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def test_reacquire(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def test_different_thread(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() class RLockTests(BaseLockTests): """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_different_thread(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) class EventTests(BaseTestCase): """ Tests for Event objects. """ def test_is_set(self): evt = self.eventtype() self.assertFalse(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) def _check_notify(self, evt): # All threads get notified N = 5 results1 = [] results2 = [] def f(): results1.append(evt.wait()) results2.append(evt.wait()) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(results1), 0) evt.set() b.wait_for_finished() self.assertEqual(results1, [True] * N) self.assertEqual(results2, [True] * N) def test_notify(self): evt = self.eventtype() self._check_notify(evt) # Another time, after an explicit clear() evt.set() evt.clear() self._check_notify(evt) def test_timeout(self): evt = self.eventtype() results1 = [] results2 = [] N = 5 def f(): results1.append(evt.wait(0.0)) t1 = time.time() r = evt.wait(0.2) t2 = time.time() results2.append((r, t2 - t1)) Bunch(f, N).wait_for_finished() self.assertEqual(results1, [False] * N) for r, dt in results2: self.assertFalse(r) self.assertTrue(dt >= 0.2, dt) # The event is set results1 = [] results2 = [] evt.set() Bunch(f, N).wait_for_finished() self.assertEqual(results1, [True] * N) for r, dt in results2: self.assertTrue(r) def test_reset_internal_locks(self): evt = self.eventtype() if not hasattr(evt, '_Event__cond'): self.skipTest("gevent: internal impl difference") old_lock = evt._Event__cond._Condition__lock evt._reset_internal_locks() new_lock = evt._Event__cond._Condition__lock self.assertIsNot(new_lock, old_lock) self.assertIs(type(new_lock), type(old_lock)) class ConditionTests(BaseTestCase): """ Tests for condition variables. """ def test_acquire(self): cond = self.condtype() # Be default we have an RLock: the condition can be acquired multiple # times. cond.acquire() cond.acquire() cond.release() cond.release() lock = threading.Lock() cond = self.condtype(lock) cond.acquire() self.assertFalse(lock.acquire(False)) cond.release() self.assertTrue(lock.acquire(False)) self.assertFalse(cond.acquire(False)) lock.release() with cond: self.assertFalse(lock.acquire(False)) def test_unacquired_wait(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.wait) def test_unacquired_notify(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.notify) def _check_notify(self, cond): N = 5 results1 = [] results2 = [] phase_num = 0 def f(): cond.acquire() cond.wait() cond.release() results1.append(phase_num) cond.acquire() cond.wait() cond.release() results2.append(phase_num) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(results1, []) # Notify 3 threads at first cond.acquire() cond.notify(3) _wait() phase_num = 1 cond.release() while len(results1) < 3: _wait() self.assertEqual(results1, [1] * 3) self.assertEqual(results2, []) # Notify 5 threads: they might be in their first or second wait cond.acquire() cond.notify(5) _wait() phase_num = 2 cond.release() while len(results1) + len(results2) < 8: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3) # Notify all threads: they are all in their second wait cond.acquire() cond.notify_all() _wait() phase_num = 3 cond.release() while len(results2) < 5: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3 + [3] * 2) b.wait_for_finished() def test_notify(self): cond = self.condtype() self._check_notify(cond) # A second time, to check internal state is still ok. self._check_notify(cond) def test_timeout(self): cond = self.condtype() results = [] N = 5 def f(): cond.acquire() t1 = time.time() cond.wait(0.2) t2 = time.time() cond.release() results.append(t2 - t1) Bunch(f, N).wait_for_finished() self.assertEqual(len(results), 5) for dt in results: self.assertTrue(dt >= 0.2, dt) class BaseSemaphoreTests(BaseTestCase): """ Common tests for {bounded, unbounded} semaphore objects. """ def test_constructor(self): self.assertRaises(ValueError, self.semtype, value = -1) self.assertRaises(ValueError, self.semtype, value = -sys.maxint) def test_acquire(self): sem = self.semtype(1) sem.acquire() sem.release() sem = self.semtype(2) sem.acquire() sem.acquire() sem.release() sem.release() def test_acquire_destroy(self): sem = self.semtype() sem.acquire() del sem def test_acquire_contended(self): sem = self.semtype(7) sem.acquire() N = 10 results1 = [] results2 = [] phase_num = 0 def f(): sem.acquire() results1.append(phase_num) sem.acquire() results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() while len(results1) + len(results2) < 6: _wait() self.assertEqual(results1 + results2, [0] * 6) phase_num = 1 for i in range(7): sem.release() while len(results1) + len(results2) < 13: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7) phase_num = 2 for i in range(6): sem.release() while len(results1) + len(results2) < 19: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7 + [2] * 6) # The semaphore is still locked self.assertFalse(sem.acquire(False)) # Final release, to let the last thread finish sem.release() b.wait_for_finished() def test_try_acquire(self): sem = self.semtype(2) self.assertTrue(sem.acquire(False)) self.assertTrue(sem.acquire(False)) self.assertFalse(sem.acquire(False)) sem.release() self.assertTrue(sem.acquire(False)) def test_try_acquire_contended(self): sem = self.semtype(4) sem.acquire() results = [] def f(): results.append(sem.acquire(False)) results.append(sem.acquire(False)) Bunch(f, 5).wait_for_finished() # There can be a thread switch between acquiring the semaphore and # appending the result, therefore results will not necessarily be # ordered. self.assertEqual(sorted(results), [False] * 7 + [True] * 3 ) def test_default_value(self): # The default initial value is 1. sem = self.semtype() sem.acquire() def f(): sem.acquire() sem.release() b = Bunch(f, 1) b.wait_for_started() _wait() self.assertFalse(b.finished) sem.release() b.wait_for_finished() def test_with(self): sem = self.semtype(2) def _with(err=None): with sem: self.assertTrue(sem.acquire(False)) sem.release() with sem: self.assertFalse(sem.acquire(False)) if err: raise err _with() self.assertTrue(sem.acquire(False)) sem.release() self.assertRaises(TypeError, _with, TypeError) self.assertTrue(sem.acquire(False)) sem.release() class SemaphoreTests(BaseSemaphoreTests): """ Tests for unbounded semaphores. """ def test_release_unacquired(self): # Unbounded releases are allowed and increment the semaphore's value sem = self.semtype(1) sem.release() sem.acquire() sem.acquire() sem.release() class BoundedSemaphoreTests(BaseSemaphoreTests): """ Tests for bounded semaphores. """ def test_release_unacquired(self): # Cannot go past the initial value sem = self.semtype() self.assertRaises(ValueError, sem.release) sem.acquire() sem.release() self.assertRaises(ValueError, sem.release) gevent-1.1.0/greentest/2.7/nokia.pem0000644000076500000000000000360312666555342017653 0ustar jmaddenwheel00000000000000# Certificate for projects.developer.nokia.com:443 (see issue 13034) -----BEGIN CERTIFICATE----- MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/nullbytecert.pem0000644000076500000000000001247312666555342021273 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 0 (0x0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Validity Not Before: Aug 7 13:11:52 2013 GMT Not After : Aug 7 13:12:52 2013 GMT Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3: 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97: 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2: 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1: 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4: 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8: a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02: 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75: ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91: 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d: 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30: 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7: f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12: f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5: ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb: d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f: 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da: 2f:85 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C X509v3 Key Usage: Digital Signature, Non Repudiation, Key Encipherment X509v3 Subject Alternative Name: ************************************************************* WARNING: The values for DNS, email and URI are WRONG. OpenSSL doesn't print the text after a NULL byte. ************************************************************* DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 Signature Algorithm: sha1WithRSAEncryption ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5: a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44: 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37: 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3: 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86: de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac: 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4: 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60: d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5: 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60: 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6: 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d: 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e: 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6: c1:ca:a9:94 -----BEGIN CERTIFICATE----- MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL 08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/nullcert.pem0000644000076500000000000000000012666555342020366 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7/pycacert.pem0000644000076500000000000001032312666555342020361 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 12723342612721443280 (0xb09264b1f2da21d0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Jan 2 19:47:07 2023 GMT Subject: C=XY, O=Python Software Foundation CA, CN=our-ca-server Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:e7:de:e9:e3:0c:9f:00:b6:a1:fd:2b:5b:96:d2: 6f:cc:e0:be:86:b9:20:5e:ec:03:7a:55:ab:ea:a4: e9:f9:49:85:d2:66:d5:ed:c7:7a:ea:56:8e:2d:8f: e7:42:e2:62:28:a9:9f:d6:1b:8e:eb:b5:b4:9c:9f: 14:ab:df:e6:94:8b:76:1d:3e:6d:24:61:ed:0c:bf: 00:8a:61:0c:df:5c:c8:36:73:16:00:cd:47:ba:6d: a4:a4:74:88:83:23:0a:19:fc:09:a7:3c:4a:4b:d3: e7:1d:2d:e4:ea:4c:54:21:f3:26:db:89:37:18:d4: 02:bb:40:32:5f:a4:ff:2d:1c:f7:d4:bb:ec:8e:cf: 5c:82:ac:e6:7c:08:6c:48:85:61:07:7f:25:e0:5c: e0:bc:34:5f:e0:b9:04:47:75:c8:47:0b:8d:bc:d6: c8:68:5f:33:83:62:d2:20:44:35:b1:ad:81:1a:8a: cd:bc:35:b0:5c:8b:47:d6:18:e9:9c:18:97:cc:01: 3c:29:cc:e8:1e:e4:e4:c1:b8:de:e7:c2:11:18:87: 5a:93:34:d8:a6:25:f7:14:71:eb:e4:21:a2:d2:0f: 2e:2e:d4:62:00:35:d3:d6:ef:5c:60:4b:4c:a9:14: e2:dd:15:58:46:37:33:26:b7:e7:2e:5d:ed:42:e4: c5:4d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Authority Key Identifier: keyid:BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption 7d:0a:f5:cb:8d:d3:5d:bd:99:8e:f8:2b:0f:ba:eb:c2:d9:a6: 27:4f:2e:7b:2f:0e:64:d8:1c:35:50:4e:ee:fc:90:b9:8d:6d: a8:c5:c6:06:b0:af:f3:2d:bf:3b:b8:42:07:dd:18:7d:6d:95: 54:57:85:18:60:47:2f:eb:78:1b:f9:e8:17:fd:5a:0d:87:17: 28:ac:4c:6a:e6:bc:29:f4:f4:55:70:29:42:de:85:ea:ab:6c: 23:06:64:30:75:02:8e:53:bc:5e:01:33:37:cc:1e:cd:b8:a4: fd:ca:e4:5f:65:3b:83:1c:86:f1:55:02:a0:3a:8f:db:91:b7: 40:14:b4:e7:8d:d2:ee:73:ba:e3:e5:34:2d:bc:94:6f:4e:24: 06:f7:5f:8b:0e:a7:8e:6b:de:5e:75:f4:32:9a:50:b1:44:33: 9a:d0:05:e2:78:82:ff:db:da:8a:63:eb:a9:dd:d1:bf:a0:61: ad:e3:9e:8a:24:5d:62:0e:e7:4c:91:7f:ef:df:34:36:3b:2f: 5d:f5:84:b2:2f:c4:6d:93:96:1a:6f:30:28:f1:da:12:9a:64: b4:40:33:1d:bd:de:2b:53:a8:ea:be:d6:bc:4e:96:f5:44:fb: 32:18:ae:d5:1f:f6:69:af:b6:4e:7b:1d:58:ec:3b:a9:53:a3: 5e:58:c8:9e -----BEGIN CERTIFICATE----- MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/ AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni 0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx 6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2 2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4 QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1 Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf 9mmvtk57HVjsO6lTo15YyJ4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/revocation.crl0000644000076500000000000000116112666555342020717 0ustar jmaddenwheel00000000000000-----BEGIN X509 CRL----- MIIBpjCBjwIBATANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJYWTEmMCQGA1UE CgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNVBAMMDW91ci1j YS1zZXJ2ZXIXDTEzMTEyMTE3MDg0N1oXDTIzMDkzMDE3MDg0N1qgDjAMMAoGA1Ud FAQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQCNJXC2mVKauEeN3LlQ3ZtM5gkH3ExH +i4bmJjtJn497WwvvoIeUdrmVXgJQR93RtV37hZwN0SXMLlNmUZPH4rHhihayw4m unCzVj/OhCCY7/TPjKuJ1O/0XhaLBpBVjQN7R/1ujoRKbSia/CD3vcn7Fqxzw7LK fSRCKRGTj1CZiuxrphtFchwALXSiFDy9mr2ZKhImcyq1PydfgEzU78APpOkMQsIC UNJ/cf3c9emzf+dUtcMEcejQ3mynBo4eIGg1EW42bz4q4hSjzQlKcBV0muw5qXhc HOxH2iTFhQ7SrvVuK/dM14rYM4B5mSX3nRC1kNmXpS9j3wJDhuwmjHed -----END X509 CRL----- gevent-1.1.0/greentest/2.7/selfsigned_pythontestdotnet.pem0000644000076500000000000000167412666555342024422 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/sha256.pem0000644000076500000000000002023012666555342017555 0ustar jmaddenwheel00000000000000# Certificate chain for https://sha256.tbs-internet.com 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC -----BEGIN CERTIFICATE----- MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0 LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49 IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0 UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN 21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q -----END CERTIFICATE----- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root -----BEGIN CERTIFICATE----- MIIFVjCCBD6gAwIBAgIQXpDZ0ETJMV02WTx3GTnhhTANBgkqhkiG9w0BAQUFADBv MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDYyNDE5MDYzMFow gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgOkO3f7wzN6 rOjg45tR5vjBfzK7qmV9IBxb/QW9EEXxG+E7FNhZqQLtwGBKoSsHTnQqV75wWMk0 9tinWvftBkSpj5sTi/8cbzJfUvTSVYh3Qxv6AVVjMMH/ruLjE6y+4PoaPs8WoYAQ ts5R4Z1g8c/WnTepLst2x0/Wv7GmuoQi+gXvHU6YrBiu7XkeYhzc95QdviWSJRDk owhb5K43qhcvjRmBfO/paGlCliDGZp8mHwrI21mwobWpVjTxZRwYO3bd4+TGcI4G Ie5wmHwE8F7SK1tgSqbBacKjDa93j7txKkfz/Yd2n7TGqOXiHPsJpG655vrKtnXk 9vs1zoDeJQIDAQABo4IBljCCAZIwHQYDVR0OBBYEFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMCAGA1UdJQQZ MBcGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAYBgNVHSAEETAPMA0GCysGAQQBgOU3 AgQBMHsGA1UdHwR0MHIwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL0Fk ZFRydXN0RXh0ZXJuYWxDQVJvb3QuY3JsMDagNKAyhjBodHRwOi8vY3JsLmNvbW9k by5uZXQvQWRkVHJ1c3RFeHRlcm5hbENBUm9vdC5jcmwwgYAGCCsGAQUFBwEBBHQw cjA4BggrBgEFBQcwAoYsaHR0cDovL2NydC5jb21vZG9jYS5jb20vQWRkVHJ1c3RV VE5TR0NDQS5jcnQwNgYIKwYBBQUHMAKGKmh0dHA6Ly9jcnQuY29tb2RvLm5ldC9B ZGRUcnVzdFVUTlNHQ0NBLmNydDARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcN AQEFBQADggEBAK2zEzs+jcIrVK9oDkdDZNvhuBYTdCfpxfFs+OAujW0bIfJAy232 euVsnJm6u/+OrqKudD2tad2BbejLLXhMZViaCmK7D9nrXHx4te5EP8rL19SUVqLY 1pTnv5dhNgEgvA7n5lIzDSYs7yRLsr7HJsYPr6SeYSuZizyX1SNz7ooJ32/F3X98 RB0Mlc/E0OyOrkQ9/y5IrnpnaSora8CnUrV5XNOg+kyCz9edCyx4D5wXYcwZPVWz 8aDqquESrezPyjtfi4WRO4s/VD3HLZvOxzMrWAVYCDG9FxaOhF0QGuuG1F7F3GKV v6prNyCl016kRl2j1UT+a7gLd8fA25A4C9E= -----END CERTIFICATE----- 2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEZjCCA06gAwIBAgIQUSYKkxzif5zDpV954HKugjANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw0wNTA2MDcwODA5MTBaFw0xOTA2MjQxOTA2MzBaMG8xCzAJBgNVBAYT AlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0 ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB IFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39xoz5vIABC05 4E5b7R+8bA/Ntfojts7emxEzl6QpTH2Tn71KvJPtAxrjj8/lbVBa1pcplFqAsEl6 2y6V/bjKvzc4LR4+kUGtcFbH8E8/6DKedMrIkFTpxl8PeJ2aQDwOrGGqXhSPnoeh alDc15pOrwWzpnGUnHGzUGAKxxOdOAeGAqjpqGkmGJCrTLBPI6s6T4TY386f4Wlv u9dC12tE5Met7m1BX3JacQg3s3llpFmglDf3AC8NwpJy2tA4ctsUqEXEXSp9t7TW xO6szRNEt8kr3UMAJfphuWlqWCMRt6czj1Z1WfXNKddGtworZbbTQm8Vsrh7++/p XVPVNFonAgMBAAGjgdgwgdUwHwYDVR0jBBgwFoAUUzLRs89/+uDxoF2FTpLSnkUd tE8wHQYDVR0OBBYEFK29mHo0tCb3+sQmVO8DveAky1QaMA4GA1UdDwEB/wQEAwIB BjAPBgNVHRMBAf8EBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIBAjAgBgNVHSUEGTAX BgorBgEEAYI3CgMDBglghkgBhvhCBAEwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDov L2NybC51c2VydHJ1c3QuY29tL1VUTi1EQVRBQ29ycFNHQy5jcmwwDQYJKoZIhvcN AQEFBQADggEBAMbuUxdoFLJRIh6QWA2U/b3xcOWGLcM2MY9USEbnLQg3vGwKYOEO rVE04BKT6b64q7gmtOmWPSiPrmQH/uAB7MXjkesYoPF1ftsK5p+R26+udd8jkWjd FwBaS/9kbHDrARrQkNnHptZt9hPk/7XJ0h4qy7ElQyZ42TCbTg0evmnv3+r+LbPM +bDdtRTKkdSytaX7ARmjR3mfnYyVhzT4HziS2jamEfpr62vp3EV4FTkG101B5CHI 3C+H0be/SGB1pWLLJN47YaApIKa+xWycxOkKaSLvkTr6Jq/RW0GnOuL4OAdCq8Fb +M5tug8EPzI0rNwEKNdwMBQmBsTkm5jVz3g= -----END CERTIFICATE----- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6 E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK 4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv 2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3 mfnGV/TJVTl4uix5yaaIK/QI -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/ssl_cert.pem0000644000076500000000000000154312666555342020371 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7/ssl_key.passwd.pem0000644000076500000000000000170312666555342021522 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- gevent-1.1.0/greentest/2.7/ssl_key.pem0000644000076500000000000000162412666555342020224 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- gevent-1.1.0/greentest/2.7/subprocessdata/0000755000076500000000000000000012666555432021067 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7/subprocessdata/sigchild_ignore.py0000644000076500000000000000056412666555342024577 0ustar jmaddenwheel00000000000000import signal, subprocess, sys # On Linux this causes os.waitpid to fail with OSError as the OS has already # reaped our child process. The wait() passing the OSError on to the caller # and causing us to exit with an error is what we are testing against. signal.signal(signal.SIGCHLD, signal.SIG_IGN) subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() gevent-1.1.0/greentest/2.7/test_asyncore.py0000644000076500000000000005466212666555342021316 0ustar jmaddenwheel00000000000000import asyncore import unittest import select import os import socket import sys import time import warnings import errno import struct from test import test_support from test.test_support import TESTFN, run_unittest, unlink, HOST from StringIO import StringIO try: import threading except ImportError: threading = None class dummysocket: def __init__(self): self.closed = False def close(self): self.closed = True def fileno(self): return 42 class dummychannel: def __init__(self): self.socket = dummysocket() def close(self): self.socket.close() class exitingdummy: def __init__(self): pass def handle_read_event(self): raise asyncore.ExitNow() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event class crashingdummy: def __init__(self): self.error_handled = False def handle_read_event(self): raise Exception() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event def handle_error(self): self.error_handled = True # used when testing senders; just collects what it gets until newline is sent def capture_server(evt, buf, serv): try: serv.listen(5) conn, addr = serv.accept() except socket.timeout: pass else: n = 200 while n > 0: r, w, e = select.select([conn], [], []) if r: data = conn.recv(10) # keep everything except for the newline terminator buf.write(data.replace('\n', '')) if '\n' in data: break n -= 1 time.sleep(0.01) conn.close() finally: serv.close() evt.set() class HelperFunctionTests(unittest.TestCase): def test_readwriteexc(self): # Check exception handling behavior of read, write and _exception # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore read/write/_exception calls tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.read, tr1) self.assertRaises(asyncore.ExitNow, asyncore.write, tr1) self.assertRaises(asyncore.ExitNow, asyncore._exception, tr1) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() asyncore.read(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore.write(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore._exception(tr2) self.assertEqual(tr2.error_handled, True) # asyncore.readwrite uses constants in the select module that # are not present in Windows systems (see this thread: # http://mail.python.org/pipermail/python-list/2001-October/109973.html) # These constants should be present as long as poll is available @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') def test_readwrite(self): # Check that correct methods are called by readwrite() attributes = ('read', 'expt', 'write', 'closed', 'error_handled') expected = ( (select.POLLIN, 'read'), (select.POLLPRI, 'expt'), (select.POLLOUT, 'write'), (select.POLLERR, 'closed'), (select.POLLHUP, 'closed'), (select.POLLNVAL, 'closed'), ) class testobj: def __init__(self): self.read = False self.write = False self.closed = False self.expt = False self.error_handled = False def handle_read_event(self): self.read = True def handle_write_event(self): self.write = True def handle_close(self): self.closed = True def handle_expt_event(self): self.expt = True def handle_error(self): self.error_handled = True for flag, expectedattr in expected: tobj = testobj() self.assertEqual(getattr(tobj, expectedattr), False) asyncore.readwrite(tobj, flag) # Only the attribute modified by the routine we expect to be # called should be True. for attr in attributes: self.assertEqual(getattr(tobj, attr), attr==expectedattr) # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore readwrite call tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() self.assertEqual(tr2.error_handled, False) asyncore.readwrite(tr2, flag) self.assertEqual(tr2.error_handled, True) def test_closeall(self): self.closeall_check(False) def test_closeall_default(self): self.closeall_check(True) def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True) def test_compact_traceback(self): try: raise Exception("I don't like spam!") except: real_t, real_v, real_tb = sys.exc_info() r = asyncore.compact_traceback() else: self.fail("Expected exception") (f, function, line), t, v, info = r self.assertEqual(os.path.split(f)[-1], 'test_asyncore.py') self.assertEqual(function, 'test_compact_traceback') self.assertEqual(t, real_t) self.assertEqual(v, real_v) self.assertEqual(info, '[%s|%s|%s]' % (f, function, line)) class DispatcherTests(unittest.TestCase): def setUp(self): pass def tearDown(self): asyncore.close_all() def test_basic(self): d = asyncore.dispatcher() self.assertEqual(d.readable(), True) self.assertEqual(d.writable(), True) def test_repr(self): d = asyncore.dispatcher() self.assertEqual(repr(d), '' % id(d)) def test_log(self): d = asyncore.dispatcher() # capture output of dispatcher.log() (to stderr) fp = StringIO() stderr = sys.stderr l1 = "Lovely spam! Wonderful spam!" l2 = "I don't like spam!" try: sys.stderr = fp d.log(l1) d.log(l2) finally: sys.stderr = stderr lines = fp.getvalue().splitlines() self.assertEqual(lines, ['log: %s' % l1, 'log: %s' % l2]) def test_log_info(self): d = asyncore.dispatcher() # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout l1 = "Have you got anything without spam?" l2 = "Why can't she have egg bacon spam and sausage?" l3 = "THAT'S got spam in it!" try: sys.stdout = fp d.log_info(l1, 'EGGS') d.log_info(l2) d.log_info(l3, 'SPAM') finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3] self.assertEqual(lines, expected) def test_unhandled(self): d = asyncore.dispatcher() d.ignore_log_types = () # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout try: sys.stdout = fp d.handle_expt() d.handle_read() d.handle_write() d.handle_connect() d.handle_accept() finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['warning: unhandled incoming priority event', 'warning: unhandled read event', 'warning: unhandled write event', 'warning: unhandled connect event', 'warning: unhandled accept event'] self.assertEqual(lines, expected) def test_issue_8594(self): # XXX - this test is supposed to be removed in next major Python # version d = asyncore.dispatcher(socket.socket()) # make sure the error message no longer refers to the socket # object but the dispatcher instance instead self.assertRaisesRegexp(AttributeError, 'dispatcher instance', getattr, d, 'foo') # cheap inheritance with the underlying socket is supposed # to still work but a DeprecationWarning is expected with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") family = d.family self.assertEqual(family, socket.AF_INET) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) if hasattr(os, 'strerror'): self.assertEqual(err, os.strerror(errno.EPERM)) err = asyncore._strerror(-1) self.assertTrue(err != "") class dispatcherwithsend_noread(asyncore.dispatcher_with_send): def readable(self): return False def handle_connect(self): pass class DispatcherWithSendTests(unittest.TestCase): usepoll = False def setUp(self): pass def tearDown(self): asyncore.close_all() @unittest.skipUnless(threading, 'Threading required for this test.') @test_support.reap_threads def test_send(self): evt = threading.Event() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(3) port = test_support.bind_port(sock) cap = StringIO() args = (evt, cap, sock) t = threading.Thread(target=capture_server, args=args) t.start() try: # wait a little longer for the server to initialize (it sometimes # refuses connections on slow machines without this wait) time.sleep(0.2) data = "Suppose there isn't a 16-ton weight?" d = dispatcherwithsend_noread() d.create_socket(socket.AF_INET, socket.SOCK_STREAM) d.connect((HOST, port)) # give time for socket to connect time.sleep(0.1) d.send(data) d.send(data) d.send('\n') n = 1000 while d.out_buffer and n > 0: asyncore.poll() n -= 1 evt.wait() self.assertEqual(cap.getvalue(), data*2) finally: t.join() class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): usepoll = True @unittest.skipUnless(hasattr(asyncore, 'file_wrapper'), 'asyncore.file_wrapper required') class FileWrapperTest(unittest.TestCase): def setUp(self): self.d = "It's not dead, it's sleeping!" with file(TESTFN, 'w') as h: h.write(self.d) def tearDown(self): unlink(TESTFN) def test_recv(self): fd = os.open(TESTFN, os.O_RDONLY) w = asyncore.file_wrapper(fd) os.close(fd) self.assertNotEqual(w.fd, fd) self.assertNotEqual(w.fileno(), fd) self.assertEqual(w.recv(13), "It's not dead") self.assertEqual(w.read(6), ", it's") w.close() self.assertRaises(OSError, w.read, 1) def test_send(self): d1 = "Come again?" d2 = "I want to buy some cheese." fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND) w = asyncore.file_wrapper(fd) os.close(fd) w.write(d1) w.send(d2) w.close() self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'), 'asyncore.file_dispatcher required') def test_dispatcher(self): fd = os.open(TESTFN, os.O_RDONLY) data = [] class FileDispatcher(asyncore.file_dispatcher): def handle_read(self): data.append(self.recv(29)) s = FileDispatcher(fd) os.close(fd) asyncore.loop(timeout=0.01, use_poll=True, count=2) self.assertEqual(b"".join(data), self.d) class BaseTestHandler(asyncore.dispatcher): def __init__(self, sock=None): asyncore.dispatcher.__init__(self, sock) self.flag = False def handle_accept(self): raise Exception("handle_accept not supposed to be called") def handle_connect(self): raise Exception("handle_connect not supposed to be called") def handle_expt(self): raise Exception("handle_expt not supposed to be called") def handle_close(self): raise Exception("handle_close not supposed to be called") def handle_error(self): raise class TCPServer(asyncore.dispatcher): """A server which listens on an address and dispatches the connection to a handler. """ def __init__(self, handler=BaseTestHandler, host=HOST, port=0): asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.set_reuse_addr() self.bind((host, port)) self.listen(5) self.handler = handler @property def address(self): return self.socket.getsockname()[:2] def handle_accept(self): pair = self.accept() if pair is not None: self.handler(pair[0]) def handle_error(self): raise class BaseClient(BaseTestHandler): def __init__(self, address): BaseTestHandler.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.connect(address) def handle_connect(self): pass class BaseTestAPI(unittest.TestCase): def tearDown(self): asyncore.close_all() def loop_waiting_for_flag(self, instance, timeout=5): timeout = float(timeout) / 100 count = 100 while asyncore.socket_map and count > 0: asyncore.loop(timeout=0.01, count=1, use_poll=self.use_poll) if instance.flag: return count -= 1 time.sleep(timeout) self.fail("flag not set") def test_handle_connect(self): # make sure handle_connect is called on connect() class TestClient(BaseClient): def handle_connect(self): self.flag = True server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_accept(self): # make sure handle_accept() is called when a client connects class TestListener(BaseTestHandler): def __init__(self): BaseTestHandler.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.bind((HOST, 0)) self.listen(5) self.address = self.socket.getsockname()[:2] def handle_accept(self): self.flag = True server = TestListener() client = BaseClient(server.address) self.loop_waiting_for_flag(server) def test_handle_read(self): # make sure handle_read is called on data received class TestClient(BaseClient): def handle_read(self): self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.send('x' * 1024) server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_write(self): # make sure handle_write is called class TestClient(BaseClient): def handle_write(self): self.flag = True server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_close(self): # make sure handle_close is called when the other end closes # the connection class TestClient(BaseClient): def handle_read(self): # in order to make handle_close be called we are supposed # to make at least one recv() call self.recv(1024) def handle_close(self): self.flag = True self.close() class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.close() server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) @unittest.skipIf(sys.platform.startswith("sunos"), "OOB support is broken on Solaris") def test_handle_expt(self): # Make sure handle_expt is called on OOB data received. # Note: this might fail on some platforms as OOB data is # tenuously supported and rarely used. class TestClient(BaseClient): def handle_expt(self): self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.socket.send(chr(244), socket.MSG_OOB) server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_error(self): class TestClient(BaseClient): def handle_write(self): 1.0 / 0 def handle_error(self): self.flag = True try: raise except ZeroDivisionError: pass else: raise Exception("exception not raised") server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_connection_attributes(self): server = TCPServer() client = BaseClient(server.address) # we start disconnected self.assertFalse(server.connected) self.assertTrue(server.accepting) # this can't be taken for granted across all platforms #self.assertFalse(client.connected) self.assertFalse(client.accepting) # execute some loops so that client connects to server asyncore.loop(timeout=0.01, use_poll=self.use_poll, count=100) self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertTrue(client.connected) self.assertFalse(client.accepting) # disconnect the client client.close() self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertFalse(client.connected) self.assertFalse(client.accepting) # stop serving server.close() self.assertFalse(server.connected) self.assertFalse(server.accepting) def test_create_socket(self): s = asyncore.dispatcher() s.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.assertEqual(s.socket.family, socket.AF_INET) self.assertEqual(s.socket.type, socket.SOCK_STREAM) def test_bind(self): s1 = asyncore.dispatcher() s1.create_socket(socket.AF_INET, socket.SOCK_STREAM) s1.bind((HOST, 0)) s1.listen(5) port = s1.socket.getsockname()[1] s2 = asyncore.dispatcher() s2.create_socket(socket.AF_INET, socket.SOCK_STREAM) # EADDRINUSE indicates the socket was correctly bound self.assertRaises(socket.error, s2.bind, (HOST, port)) def test_set_reuse_addr(self): sock = socket.socket() try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) except socket.error: unittest.skip("SO_REUSEADDR not supported on this platform") else: # if SO_REUSEADDR succeeded for sock we expect asyncore # to do the same s = asyncore.dispatcher(socket.socket()) self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) s.create_socket(socket.AF_INET, socket.SOCK_STREAM) s.set_reuse_addr() self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) finally: sock.close() @unittest.skipUnless(threading, 'Threading required for this test.') @test_support.reap_threads def test_quick_connect(self): # see: http://bugs.python.org/issue10340 server = TCPServer() t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() self.addCleanup(t.join) for x in xrange(20): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(.2) s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0)) try: s.connect(server.address) except socket.error: pass finally: s.close() class TestAPI_UseSelect(BaseTestAPI): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') class TestAPI_UsePoll(BaseTestAPI): use_poll = True def test_main(): tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, DispatcherWithSendTests_UsePoll, TestAPI_UseSelect, TestAPI_UsePoll, FileWrapperTest] run_unittest(*tests) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_ftplib.py0000644000076500000000000006754212666555342020754 0ustar jmaddenwheel00000000000000"""Test script for ftplib module.""" # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS # environment import ftplib import asyncore import asynchat import socket import StringIO import errno import os try: import ssl except ImportError: ssl = None from unittest import TestCase, SkipTest, skipUnless from test import test_support from test.test_support import HOST, HOSTv6 threading = test_support.import_module('threading') TIMEOUT = 3 # the dummy data returned by server over the data channel when # RETR, LIST and NLST commands are issued RETR_DATA = 'abcde12345\r\n' * 1000 LIST_DATA = 'foo\r\nbar\r\n' NLST_DATA = 'foo\r\nbar\r\n' class DummyDTPHandler(asynchat.async_chat): dtp_conn_closed = False def __init__(self, conn, baseclass): asynchat.async_chat.__init__(self, conn) self.baseclass = baseclass self.baseclass.last_received_data = '' def handle_read(self): self.baseclass.last_received_data += self.recv(1024) def handle_close(self): # XXX: this method can be called many times in a row for a single # connection, including in clear-text (non-TLS) mode. # (behaviour witnessed with test_data_connection) if not self.dtp_conn_closed: self.baseclass.push('226 transfer complete') self.close() self.dtp_conn_closed = True def handle_error(self): raise class DummyFTPHandler(asynchat.async_chat): dtp_handler = DummyDTPHandler def __init__(self, conn): asynchat.async_chat.__init__(self, conn) self.set_terminator("\r\n") self.in_buffer = [] self.dtp = None self.last_received_cmd = None self.last_received_data = '' self.next_response = '' self.rest = None self.next_retr_data = RETR_DATA self.push('220 welcome') def collect_incoming_data(self, data): self.in_buffer.append(data) def found_terminator(self): line = ''.join(self.in_buffer) self.in_buffer = [] if self.next_response: self.push(self.next_response) self.next_response = '' cmd = line.split(' ')[0].lower() self.last_received_cmd = cmd space = line.find(' ') if space != -1: arg = line[space + 1:] else: arg = "" if hasattr(self, 'cmd_' + cmd): method = getattr(self, 'cmd_' + cmd) method(arg) else: self.push('550 command "%s" not understood.' %cmd) def handle_error(self): raise def push(self, data): asynchat.async_chat.push(self, data + '\r\n') def cmd_port(self, arg): addr = map(int, arg.split(',')) ip = '%d.%d.%d.%d' %tuple(addr[:4]) port = (addr[4] * 256) + addr[5] s = socket.create_connection((ip, port), timeout=10) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_pasv(self, arg): sock = socket.socket() sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(10) ip, port = sock.getsockname()[:2] ip = ip.replace('.', ',') p1, p2 = divmod(port, 256) self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_eprt(self, arg): af, ip, port = arg.split(arg[0])[1:-1] port = int(port) s = socket.create_connection((ip, port), timeout=10) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_epsv(self, arg): sock = socket.socket(socket.AF_INET6) sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(10) port = sock.getsockname()[1] self.push('229 entering extended passive mode (|||%d|)' %port) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_echo(self, arg): # sends back the received string (used by the test suite) self.push(arg) def cmd_user(self, arg): self.push('331 username ok') def cmd_pass(self, arg): self.push('230 password ok') def cmd_acct(self, arg): self.push('230 acct ok') def cmd_rnfr(self, arg): self.push('350 rnfr ok') def cmd_rnto(self, arg): self.push('250 rnto ok') def cmd_dele(self, arg): self.push('250 dele ok') def cmd_cwd(self, arg): self.push('250 cwd ok') def cmd_size(self, arg): self.push('250 1000') def cmd_mkd(self, arg): self.push('257 "%s"' %arg) def cmd_rmd(self, arg): self.push('250 rmd ok') def cmd_pwd(self, arg): self.push('257 "pwd ok"') def cmd_type(self, arg): self.push('200 type ok') def cmd_quit(self, arg): self.push('221 quit ok') self.close() def cmd_stor(self, arg): self.push('125 stor ok') def cmd_rest(self, arg): self.rest = arg self.push('350 rest ok') def cmd_retr(self, arg): self.push('125 retr ok') if self.rest is not None: offset = int(self.rest) else: offset = 0 self.dtp.push(self.next_retr_data[offset:]) self.dtp.close_when_done() self.rest = None def cmd_list(self, arg): self.push('125 list ok') self.dtp.push(LIST_DATA) self.dtp.close_when_done() def cmd_nlst(self, arg): self.push('125 nlst ok') self.dtp.push(NLST_DATA) self.dtp.close_when_done() def cmd_setlongretr(self, arg): # For testing. Next RETR will return long line. self.next_retr_data = 'x' * int(arg) self.push('125 setlongretr ok') class DummyFTPServer(asyncore.dispatcher, threading.Thread): handler = DummyFTPHandler def __init__(self, address, af=socket.AF_INET): threading.Thread.__init__(self) asyncore.dispatcher.__init__(self) self.create_socket(af, socket.SOCK_STREAM) self.bind(address) self.listen(5) self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] self.handler_instance = None def start(self): assert not self.active self.__flag = threading.Event() threading.Thread.start(self) self.__flag.wait() def run(self): self.active = True self.__flag.set() while self.active and asyncore.socket_map: self.active_lock.acquire() asyncore.loop(timeout=0.1, count=1) self.active_lock.release() asyncore.close_all(ignore_all=True) def stop(self): assert self.active self.active = False self.join() def handle_accept(self): conn, addr = self.accept() self.handler_instance = self.handler(conn) def handle_connect(self): self.close() handle_read = handle_connect def writable(self): return 0 def handle_error(self): raise if ssl is not None: CERTFILE = os.path.join(os.path.dirname(__file__), "keycert3.pem") CAFILE = os.path.join(os.path.dirname(__file__), "pycacert.pem") class SSLConnection(object, asyncore.dispatcher): """An asyncore.dispatcher subclass supporting TLS/SSL.""" _ssl_accepting = False _ssl_closing = False def secure_connection(self): socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False, certfile=CERTFILE, server_side=True, do_handshake_on_connect=False, ssl_version=ssl.PROTOCOL_SSLv23) self.del_channel() self.set_socket(socket) self._ssl_accepting = True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except socket.error as err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def _do_ssl_shutdown(self): self._ssl_closing = True try: self.socket = self.socket.unwrap() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return except socket.error as err: # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return # from OpenSSL's SSL_shutdown(), corresponding to a # closed socket condition. See also: # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html pass self._ssl_closing = False if getattr(self, '_ccc', False) is False: super(SSLConnection, self).close() else: pass def handle_read_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_read_event() def handle_write_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_write_event() def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return 0 raise def recv(self, buffer_size): try: return super(SSLConnection, self).recv(buffer_size) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return b'' if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): self.handle_close() return b'' raise def handle_error(self): raise def close(self): if (isinstance(self.socket, ssl.SSLSocket) and self.socket._sslobj is not None): self._do_ssl_shutdown() else: super(SSLConnection, self).close() class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler): """A DummyDTPHandler subclass supporting TLS/SSL.""" def __init__(self, conn, baseclass): DummyDTPHandler.__init__(self, conn, baseclass) if self.baseclass.secure_data_channel: self.secure_connection() class DummyTLS_FTPHandler(SSLConnection, DummyFTPHandler): """A DummyFTPHandler subclass supporting TLS/SSL.""" dtp_handler = DummyTLS_DTPHandler def __init__(self, conn): DummyFTPHandler.__init__(self, conn) self.secure_data_channel = False def cmd_auth(self, line): """Set up secure control channel.""" self.push('234 AUTH TLS successful') self.secure_connection() def cmd_pbsz(self, line): """Negotiate size of buffer for secure data transfer. For TLS/SSL the only valid value for the parameter is '0'. Any other value is accepted but ignored. """ self.push('200 PBSZ=0 successful.') def cmd_prot(self, line): """Setup un/secure data channel.""" arg = line.upper() if arg == 'C': self.push('200 Protection set to Clear') self.secure_data_channel = False elif arg == 'P': self.push('200 Protection set to Private') self.secure_data_channel = True else: self.push("502 Unrecognized PROT type (use C or P).") class DummyTLS_FTPServer(DummyFTPServer): handler = DummyTLS_FTPHandler class TestFTPClass(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP(timeout=10) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_getwelcome(self): self.assertEqual(self.client.getwelcome(), '220 welcome') def test_sanitize(self): self.assertEqual(self.client.sanitize('foo'), repr('foo')) self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****')) self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****')) def test_exceptions(self): self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599') self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999') def test_all_errors(self): exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm, ftplib.error_proto, ftplib.Error, IOError, EOFError) for x in exceptions: try: raise x('exception not included in all_errors set') except ftplib.all_errors: pass def test_set_pasv(self): # passive mode is supposed to be enabled by default self.assertTrue(self.client.passiveserver) self.client.set_pasv(True) self.assertTrue(self.client.passiveserver) self.client.set_pasv(False) self.assertFalse(self.client.passiveserver) def test_voidcmd(self): self.client.voidcmd('echo 200') self.client.voidcmd('echo 299') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300') def test_login(self): self.client.login() def test_acct(self): self.client.acct('passwd') def test_rename(self): self.client.rename('a', 'b') self.server.handler_instance.next_response = '200' self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b') def test_delete(self): self.client.delete('foo') self.server.handler_instance.next_response = '199' self.assertRaises(ftplib.error_reply, self.client.delete, 'foo') def test_size(self): self.client.size('foo') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_rmd(self): self.client.rmd('foo') def test_cwd(self): dir = self.client.cwd('/foo') self.assertEqual(dir, '250 cwd ok') def test_pwd(self): dir = self.client.pwd() self.assertEqual(dir, 'pwd ok') def test_quit(self): self.assertEqual(self.client.quit(), '221 quit ok') # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) def test_retrbinary(self): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) def test_retrbinary_rest(self): for rest in (0, 10, 20): received = [] self.client.retrbinary('retr', received.append, rest=rest) self.assertEqual(''.join(received), RETR_DATA[rest:], msg='rest test case %d %d %d' % (rest, len(''.join(received)), len(RETR_DATA[rest:]))) def test_retrlines(self): received = [] self.client.retrlines('retr', received.append) self.assertEqual(''.join(received), RETR_DATA.replace('\r\n', '')) def test_storbinary(self): f = StringIO.StringIO(RETR_DATA) self.client.storbinary('stor', f) self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storbinary('stor', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_storbinary_rest(self): f = StringIO.StringIO(RETR_DATA) for r in (30, '30'): f.seek(0) self.client.storbinary('stor', f, rest=r) self.assertEqual(self.server.handler_instance.rest, str(r)) def test_storlines(self): f = StringIO.StringIO(RETR_DATA.replace('\r\n', '\n')) self.client.storlines('stor', f) self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1]) def test_dir(self): l = [] self.client.dir(lambda x: l.append(x)) self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', '')) def test_makeport(self): self.client.makeport() # IPv4 is in use, just make sure send_eprt has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'port') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 10) conn.close() # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'pasv') def test_line_too_long(self): self.assertRaises(ftplib.Error, self.client.sendcmd, 'x' * self.client.maxline * 2) def test_retrlines_too_long(self): self.client.sendcmd('SETLONGRETR %d' % (self.client.maxline * 2)) received = [] self.assertRaises(ftplib.Error, self.client.retrlines, 'retr', received.append) def test_storlines_too_long(self): f = StringIO.StringIO('x' * self.client.maxline * 2) self.assertRaises(ftplib.Error, self.client.storlines, 'stor', f) @skipUnless(socket.has_ipv6, "IPv6 not enabled") class TestIPv6Environment(TestCase): @classmethod def setUpClass(cls): try: DummyFTPServer((HOST, 0), af=socket.AF_INET6) except socket.error: raise SkipTest("IPv6 not enabled") def setUp(self): self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6) self.server.start() self.client = ftplib.FTP() self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_af(self): self.assertEqual(self.client.af, socket.AF_INET6) def test_makeport(self): self.client.makeport() self.assertEqual(self.server.handler_instance.last_received_cmd, 'eprt') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 10) conn.close() self.assertEqual(self.server.handler_instance.last_received_cmd, 'epsv') def test_transfer(self): def retr(): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) self.client.set_pasv(True) retr() self.client.set_pasv(False) retr() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClassMixin(TestFTPClass): """Repeat TestFTPClass tests starting the TLS layer for both control and data connections first. """ def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=10) self.client.connect(self.server.host, self.server.port) # enable TLS self.client.auth() self.client.prot_p() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClass(TestCase): """Specific TLS_FTP class tests.""" def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_control_connection(self): self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIsInstance(self.client.sock, ssl.SSLSocket) def test_data_connection(self): # clear text sock = self.client.transfercmd('list') self.assertNotIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") # secured, after PROT P self.client.prot_p() sock = self.client.transfercmd('list') self.assertIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") # PROT C is issued, the connection must be in cleartext again self.client.prot_c() sock = self.client.transfercmd('list') self.assertNotIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") def test_login(self): # login() is supposed to implicitly secure the control connection self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.login() self.assertIsInstance(self.client.sock, ssl.SSLSocket) # make sure that AUTH TLS doesn't get issued again self.client.login() def test_auth_issued_twice(self): self.client.auth() self.assertRaises(ValueError, self.client.auth) def test_auth_ssl(self): try: self.client.ssl_version = ssl.PROTOCOL_SSLv23 self.client.auth() self.assertRaises(ValueError, self.client.auth) finally: self.client.ssl_version = ssl.PROTOCOL_TLSv1 def test_context(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, keyfile=CERTFILE, context=ctx) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIs(self.client.sock.context, ctx) self.assertIsInstance(self.client.sock, ssl.SSLSocket) self.client.prot_p() sock = self.client.transfercmd('list') try: self.assertIs(sock.context, ctx) self.assertIsInstance(sock, ssl.SSLSocket) finally: sock.close() def test_check_hostname(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.check_hostname = True ctx.load_verify_locations(CAFILE) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) # 127.0.0.1 doesn't match SAN self.client.connect(self.server.host, self.server.port) with self.assertRaises(ssl.CertificateError): self.client.auth() # exception quits connection self.client.connect(self.server.host, self.server.port) self.client.prot_p() with self.assertRaises(ssl.CertificateError): self.client.transfercmd("list").close() self.client.quit() self.client.connect("localhost", self.server.port) self.client.auth() self.client.quit() self.client.connect("localhost", self.server.port) self.client.prot_p() self.client.transfercmd("list").close() class TestTimeouts(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) threading.Thread(target=self.server, args=(self.evt,self.sock)).start() # Wait for the server to be ready. self.evt.wait() self.evt.clear() ftplib.FTP.port = self.port def tearDown(self): self.evt.wait() def server(self, evt, serv): # This method sets the evt 3 times: # 1) when the connection is ready to be accepted. # 2) when it is safe for the caller to close the connection # 3) when we have closed the socket serv.listen(5) # (1) Signal the caller that we are ready to accept the connection. evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: conn.send("1 Hola mundo\n") # (2) Signal the caller that it is safe to close the socket. evt.set() conn.close() finally: serv.close() # (3) Signal the caller that we are done. evt.set() def testTimeoutDefault(self): # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutNone(self): # no timeout -- do not use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(ftp.sock.gettimeout()) self.evt.wait() ftp.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDirectAccess(self): ftp = ftplib.FTP() ftp.timeout = 30 ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def test_main(): tests = [TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass] thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_httplib.py0000644000076500000000000010351012666555342021124 0ustar jmaddenwheel00000000000000import httplib import itertools import array import StringIO import socket import errno import os import tempfile import unittest TestCase = unittest.TestCase from test import test_support here = os.path.dirname(__file__) # Self-signed cert file for 'localhost' CERT_localhost = os.path.join(here, 'keycert.pem') # Self-signed cert file for 'fakehostname' CERT_fakehostname = os.path.join(here, 'keycert2.pem') # Self-signed cert file for self-signed.pythontest.net CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem') HOST = test_support.HOST class FakeSocket: def __init__(self, text, fileclass=StringIO.StringIO, host=None, port=None): self.text = text self.fileclass = fileclass self.data = '' self.file_closed = False self.host = host self.port = port def sendall(self, data): self.data += ''.join(data) def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() # keep the file around so we can check how much was read from it self.file = self.fileclass(self.text) self.file.close = self.file_close #nerf close () return self.file def file_close(self): self.file_closed = True def close(self): pass class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): # When sendall() is called with pipe_trigger, raise EPIPE. FakeSocket.__init__(self, text) self.pipe_trigger = pipe_trigger def sendall(self, data): if self.pipe_trigger in data: raise socket.error(errno.EPIPE, "gotcha") self.data += data def close(self): pass class NoEOFStringIO(StringIO.StringIO): """Like StringIO, but raises AssertionError on EOF. This is used below to test that httplib doesn't try to read more from the underlying file than it should. """ def read(self, n=-1): data = StringIO.StringIO.read(self, n) if data == '': raise AssertionError('caller tried to read past EOF') return data def readline(self, length=None): data = StringIO.StringIO.readline(self, length) if data == '': raise AssertionError('caller tried to read past EOF') return data class HeaderTests(TestCase): def test_auto_headers(self): # Some headers are added automatically, but should not be added by # .request() if they are explicitly set. class HeaderCountingBuffer(list): def __init__(self): self.count = {} def append(self, item): kv = item.split(':') if len(kv) > 1: # item is a 'Key: Value' header string lcKey = kv[0].lower() self.count.setdefault(lcKey, 0) self.count[lcKey] += 1 list.append(self, item) for explicit_header in True, False: for header in 'Content-length', 'Host', 'Accept-encoding': conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket('blahblahblah') conn._buffer = HeaderCountingBuffer() body = 'spamspamspam' headers = {} if explicit_header: headers[header] = str(len(body)) conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) def test_content_length_0(self): class ContentLengthChecker(list): def __init__(self): list.__init__(self) self.content_length = None def append(self, item): kv = item.split(':', 1) if len(kv) > 1 and kv[0].lower() == 'content-length': self.content_length = kv[1].strip() list.append(self, item) # Here, we're testing that methods expecting a body get a # content-length set to zero if the body is empty (either None or '') bodies = (None, '') methods_with_body = ('PUT', 'POST', 'PATCH') for method, body in itertools.product(methods_with_body, bodies): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request(method, '/', body) self.assertEqual( conn._buffer.content_length, '0', 'Header Content-Length incorrect on {}'.format(method) ) # For these methods, we make sure that content-length is not set when # the body is None because it might cause unexpected behaviour on the # server. methods_without_body = ( 'GET', 'CONNECT', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', ) for method in methods_without_body: conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request(method, '/', None) self.assertEqual( conn._buffer.content_length, None, 'Header Content-Length set for empty body on {}'.format(method) ) # If the body is set to '', that's considered to be "present but # empty" rather than "missing", so content length would be set, even # for methods that don't expect a body. for method in methods_without_body: conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request(method, '/', '') self.assertEqual( conn._buffer.content_length, '0', 'Header Content-Length incorrect on {}'.format(method) ) # If the body is set, make sure Content-Length is set. for method in itertools.chain(methods_without_body, methods_with_body): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request(method, '/', ' ') self.assertEqual( conn._buffer.content_length, '1', 'Header Content-Length incorrect on {}'.format(method) ) def test_putheader(self): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length',42) self.assertIn('Content-length: 42', conn._buffer) conn.putheader('Foo', ' bar ') self.assertIn(b'Foo: bar ', conn._buffer) conn.putheader('Bar', '\tbaz\t') self.assertIn(b'Bar: \tbaz\t', conn._buffer) conn.putheader('Authorization', 'Bearer mytoken') self.assertIn(b'Authorization: Bearer mytoken', conn._buffer) conn.putheader('IterHeader', 'IterA', 'IterB') self.assertIn(b'IterHeader: IterA\r\n\tIterB', conn._buffer) conn.putheader('LatinHeader', b'\xFF') self.assertIn(b'LatinHeader: \xFF', conn._buffer) conn.putheader('Utf8Header', b'\xc3\x80') self.assertIn(b'Utf8Header: \xc3\x80', conn._buffer) conn.putheader('C1-Control', b'next\x85line') self.assertIn(b'C1-Control: next\x85line', conn._buffer) conn.putheader('Embedded-Fold-Space', 'is\r\n allowed') self.assertIn(b'Embedded-Fold-Space: is\r\n allowed', conn._buffer) conn.putheader('Embedded-Fold-Tab', 'is\r\n\tallowed') self.assertIn(b'Embedded-Fold-Tab: is\r\n\tallowed', conn._buffer) conn.putheader('Key Space', 'value') self.assertIn(b'Key Space: value', conn._buffer) conn.putheader('KeySpace ', 'value') self.assertIn(b'KeySpace : value', conn._buffer) conn.putheader(b'Nonbreak\xa0Space', 'value') self.assertIn(b'Nonbreak\xa0Space: value', conn._buffer) conn.putheader(b'\xa0NonbreakSpace', 'value') self.assertIn(b'\xa0NonbreakSpace: value', conn._buffer) def test_ipv6host_header(self): # Default host header on IPv6 transaction should wrapped by [] if # its actual IPv6 address expected = 'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \ 'Accept-Encoding: identity\r\n\r\n' conn = httplib.HTTPConnection('[2001::]:81') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) expected = 'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \ 'Accept-Encoding: identity\r\n\r\n' conn = httplib.HTTPConnection('[2001:102A::]') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) def test_malformed_headers_coped_with(self): # Issue 19996 body = "HTTP/1.1 200 OK\r\nFirst: val\r\n: nval\r\nSecond: val\r\n\r\n" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.getheader('First'), 'val') self.assertEqual(resp.getheader('Second'), 'val') def test_invalid_headers(self): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket('') conn.putrequest('GET', '/') # http://tools.ietf.org/html/rfc7230#section-3.2.4, whitespace is no # longer allowed in header names cases = ( (b'Invalid\r\nName', b'ValidValue'), (b'Invalid\rName', b'ValidValue'), (b'Invalid\nName', b'ValidValue'), (b'\r\nInvalidName', b'ValidValue'), (b'\rInvalidName', b'ValidValue'), (b'\nInvalidName', b'ValidValue'), (b' InvalidName', b'ValidValue'), (b'\tInvalidName', b'ValidValue'), (b'Invalid:Name', b'ValidValue'), (b':InvalidName', b'ValidValue'), (b'ValidName', b'Invalid\r\nValue'), (b'ValidName', b'Invalid\rValue'), (b'ValidName', b'Invalid\nValue'), (b'ValidName', b'InvalidValue\r\n'), (b'ValidName', b'InvalidValue\r'), (b'ValidName', b'InvalidValue\n'), ) for name, value in cases: with self.assertRaisesRegexp(ValueError, 'Invalid header'): conn.putheader(name, value) class BasicTest(TestCase): def test_status_lines(self): # Test HTTP status lines body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(0), '') # Issue #20007 self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(), 'Text') self.assertTrue(resp.isclosed()) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertRaises(httplib.BadStatusLine, resp.begin) def test_bad_status_repr(self): exc = httplib.BadStatusLine('') self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''') def test_partial_reads(self): # if we have a length, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertTrue(resp.isclosed()) def test_partial_reads_no_content_length(self): # when no length is present, the socket should be gracefully closed when # all data was read body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertEqual(resp.read(1), '') self.assertTrue(resp.isclosed()) def test_partial_reads_incomplete_body(self): # if the server shuts down the connection before the whole # content-length is delivered, the socket is gracefully closed body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertEqual(resp.read(1), '') self.assertTrue(resp.isclosed()) def test_host_port(self): # Check invalid host_port # Note that httplib does not accept user:password@ in the host-port. for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), ("www.python.org", "www.python.org", 80), ("www.python.org:", "www.python.org", 80), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): http = httplib.HTTP(hp) c = http._conn if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) def test_response_headers(self): # test response with multiple message headers with the same field name. text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE";' ' Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = httplib.HTTPResponse(s) r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: self.fail("multiple headers not combined properly") def test_read_head(self): # Test that the library doesn't attempt to read any data # from a HEAD request. (Tickles SF bug #622042.) sock = FakeSocket( 'HTTP/1.1 200 OK\r\n' 'Content-Length: 14432\r\n' '\r\n', NoEOFStringIO) resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() if resp.read() != "": self.fail("Did not expect response from HEAD request") def test_too_many_headers(self): headers = '\r\n'.join('Header%d: foo' % i for i in xrange(200)) + '\r\n' text = ('HTTP/1.1 200 OK\r\n' + headers) s = FakeSocket(text) r = httplib.HTTPResponse(s) self.assertRaises(httplib.HTTPException, r.begin) def test_send_file(self): expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 'Accept-Encoding: identity\r\nContent-Length:' body = open(__file__, 'rb') conn = httplib.HTTPConnection('example.com') sock = FakeSocket(body) conn.sock = sock conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected)) self.assertIn('def test_send_file', sock.data) def test_send_tempfile(self): expected = ('GET /foo HTTP/1.1\r\nHost: example.com\r\n' 'Accept-Encoding: identity\r\nContent-Length: 9\r\n\r\n' 'fake\ndata') with tempfile.TemporaryFile() as body: body.write('fake\ndata') body.seek(0) conn = httplib.HTTPConnection('example.com') sock = FakeSocket(body) conn.sock = sock conn.request('GET', '/foo', body) self.assertEqual(sock.data, expected) def test_send(self): expected = 'this is a test this is only a test' conn = httplib.HTTPConnection('example.com') sock = FakeSocket(None) conn.sock = sock conn.send(expected) self.assertEqual(expected, sock.data) sock.data = '' conn.send(array.array('c', expected)) self.assertEqual(expected, sock.data) sock.data = '' conn.send(StringIO.StringIO(expected)) self.assertEqual(expected, sock.data) def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello worl\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), 'hello world') resp.close() for x in ('', 'foo\r\n'): sock = FakeSocket(chunked_start + x) resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead, i: self.assertEqual(i.partial, 'hello world') self.assertEqual(repr(i),'IncompleteRead(11 bytes read)') self.assertEqual(str(i),'IncompleteRead(11 bytes read)') else: self.fail('IncompleteRead expected') finally: resp.close() def test_chunked_head(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello world\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() self.assertEqual(resp.read(), '') self.assertEqual(resp.status, 200) self.assertEqual(resp.reason, 'OK') self.assertTrue(resp.isclosed()) def test_negative_content_length(self): sock = FakeSocket('HTTP/1.1 200 OK\r\n' 'Content-Length: -1\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), 'Hello\r\n') self.assertTrue(resp.isclosed()) def test_incomplete_read(self): sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead as i: self.assertEqual(i.partial, 'Hello\r\n') self.assertEqual(repr(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertEqual(str(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertTrue(resp.isclosed()) else: self.fail('IncompleteRead expected') def test_epipe(self): sock = EPipeSocket( "HTTP/1.0 401 Authorization Required\r\n" "Content-type: text/html\r\n" "WWW-Authenticate: Basic realm=\"example\"\r\n", b"Content-Length") conn = httplib.HTTPConnection("example.com") conn.sock = sock self.assertRaises(socket.error, lambda: conn.request("PUT", "/url", "body")) resp = conn.getresponse() self.assertEqual(401, resp.status) self.assertEqual("Basic realm=\"example\"", resp.getheader("www-authenticate")) def test_filenoattr(self): # Just test the fileno attribute in the HTTPResponse Object. body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertTrue(hasattr(resp,'fileno'), 'HTTPResponse should expose a fileno attribute') # Test lines overflowing the max line size (_MAXLINE in http.client) def test_overflowing_status_line(self): self.skipTest("disabled for HTTP 0.9 support") body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n" resp = httplib.HTTPResponse(FakeSocket(body)) self.assertRaises((httplib.LineTooLong, httplib.BadStatusLine), resp.begin) def test_overflowing_header_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n' ) resp = httplib.HTTPResponse(FakeSocket(body)) self.assertRaises(httplib.LineTooLong, resp.begin) def test_overflowing_chunked_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' + '0' * 65536 + 'a\r\n' 'hello world\r\n' '0\r\n' ) resp = httplib.HTTPResponse(FakeSocket(body)) resp.begin() self.assertRaises(httplib.LineTooLong, resp.read) def test_early_eof(self): # Test httpresponse with no \r\n termination, body = "HTTP/1.1 200 Ok" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(), '') self.assertTrue(resp.isclosed()) def test_error_leak(self): # Test that the socket is not leaked if getresponse() fails conn = httplib.HTTPConnection('example.com') response = [] class Response(httplib.HTTPResponse): def __init__(self, *pos, **kw): response.append(self) # Avoid garbage collector closing the socket httplib.HTTPResponse.__init__(self, *pos, **kw) conn.response_class = Response conn.sock = FakeSocket('') # Emulate server dropping connection conn.request('GET', '/') self.assertRaises(httplib.BadStatusLine, conn.getresponse) self.assertTrue(response) #self.assertTrue(response[0].closed) self.assertTrue(conn.sock.file_closed) def test_proxy_tunnel_without_status_line(self): # Issue 17849: If a proxy tunnel is created that does not return # a status code, fail. body = 'hello world' conn = httplib.HTTPConnection('example.com', strict=False) conn.set_tunnel('foo') conn.sock = FakeSocket(body) with self.assertRaisesRegexp(socket.error, "Invalid response"): conn._tunnel() class OfflineTest(TestCase): def test_responses(self): self.assertEqual(httplib.responses[httplib.NOT_FOUND], "Not Found") class TestServerMixin: """A limited socket server mixin. This is used by test cases for testing http connection end points. """ def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.source_port = test_support.find_unused_port() self.serv.listen(5) self.conn = None def tearDown(self): if self.conn: self.conn.close() self.conn = None self.serv.close() self.serv = None class SourceAddressTest(TestServerMixin, TestCase): def testHTTPConnectionSourceAddress(self): self.conn = httplib.HTTPConnection(HOST, self.port, source_address=('', self.source_port)) self.conn.connect() self.assertEqual(self.conn.sock.getsockname()[1], self.source_port) @unittest.skipIf(not hasattr(httplib, 'HTTPSConnection'), 'httplib.HTTPSConnection not defined') def testHTTPSConnectionSourceAddress(self): self.conn = httplib.HTTPSConnection(HOST, self.port, source_address=('', self.source_port)) # We don't test anything here other the constructor not barfing as # this code doesn't deal with setting up an active running SSL server # for an ssl_wrapped connect() to actually return from. class HTTPTest(TestServerMixin, TestCase): def testHTTPConnection(self): self.conn = httplib.HTTP(host=HOST, port=self.port, strict=None) self.conn.connect() self.assertEqual(self.conn._conn.host, HOST) self.assertEqual(self.conn._conn.port, self.port) def testHTTPWithConnectHostPort(self): testhost = 'unreachable.test.domain' testport = '80' self.conn = httplib.HTTP(host=testhost, port=testport) self.conn.connect(host=HOST, port=self.port) self.assertNotEqual(self.conn._conn.host, testhost) self.assertNotEqual(self.conn._conn.port, testport) self.assertEqual(self.conn._conn.host, HOST) self.assertEqual(self.conn._conn.port, self.port) class TimeoutTest(TestCase): PORT = None def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) TimeoutTest.PORT = test_support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): self.serv.close() self.serv = None def testTimeoutAttribute(self): '''This will prove that the timeout gets through HTTPConnection and into the socket. ''' # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() # no timeout -- do not use global socket default self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=None) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), None) httpConn.close() # a value httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30) httpConn.connect() self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() class HTTPSTest(TestCase): def setUp(self): if not hasattr(httplib, 'HTTPSConnection'): self.skipTest('ssl support required') def make_server(self, certfile): from test.ssl_servers import make_https_server return make_https_server(self, certfile=certfile) def test_attributes(self): # simple test to check it's storing the timeout h = httplib.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30) self.assertEqual(h.timeout, 30) def test_networked(self): # Default settings: requires a valid cert from a trusted CA import ssl test_support.requires('network') with test_support.transient_internet('self-signed.pythontest.net'): h = httplib.HTTPSConnection('self-signed.pythontest.net', 443) with self.assertRaises(ssl.SSLError) as exc_info: h.request('GET', '/') self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED') def test_networked_noverification(self): # Switch off cert verification import ssl test_support.requires('network') with test_support.transient_internet('self-signed.pythontest.net'): context = ssl._create_stdlib_context() h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context) h.request('GET', '/') resp = h.getresponse() self.assertIn('nginx', resp.getheader('server')) @test_support.system_must_validate_cert def test_networked_trusted_by_default_cert(self): # Default settings: requires a valid cert from a trusted CA test_support.requires('network') with test_support.transient_internet('www.python.org'): h = httplib.HTTPSConnection('www.python.org', 443) h.request('GET', '/') resp = h.getresponse() content_type = resp.getheader('content-type') self.assertIn('text/html', content_type) def test_networked_good_cert(self): # We feed the server's cert as a validating cert import ssl test_support.requires('network') with test_support.transient_internet('self-signed.pythontest.net'): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_selfsigned_pythontestdotnet) h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context) h.request('GET', '/') resp = h.getresponse() server_string = resp.getheader('server') self.assertIn('nginx', server_string) def test_networked_bad_cert(self): # We feed a "CA" cert that is unrelated to the server's cert import ssl test_support.requires('network') with test_support.transient_internet('self-signed.pythontest.net'): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_localhost) h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context) with self.assertRaises(ssl.SSLError) as exc_info: h.request('GET', '/') self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED') def test_local_unknown_cert(self): # The custom cert isn't known to the default trust bundle import ssl server = self.make_server(CERT_localhost) h = httplib.HTTPSConnection('localhost', server.port) with self.assertRaises(ssl.SSLError) as exc_info: h.request('GET', '/') self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED') def test_local_good_hostname(self): # The (valid) cert validates the HTTP hostname import ssl server = self.make_server(CERT_localhost) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_localhost) h = httplib.HTTPSConnection('localhost', server.port, context=context) h.request('GET', '/nonexistent') resp = h.getresponse() self.assertEqual(resp.status, 404) def test_local_bad_hostname(self): # The (valid) cert doesn't validate the HTTP hostname import ssl server = self.make_server(CERT_fakehostname) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.check_hostname = True context.load_verify_locations(CERT_fakehostname) h = httplib.HTTPSConnection('localhost', server.port, context=context) with self.assertRaises(ssl.CertificateError): h.request('GET', '/') h.close() # With context.check_hostname=False, the mismatching is ignored context.check_hostname = False h = httplib.HTTPSConnection('localhost', server.port, context=context) h.request('GET', '/nonexistent') resp = h.getresponse() self.assertEqual(resp.status, 404) h.close() def test_host_port(self): # Check invalid host_port for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(httplib.InvalidURL, httplib.HTTPSConnection, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:443", "www.python.org", 443), ("www.python.org:", "www.python.org", 443), ("www.python.org", "www.python.org", 443), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443), ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", 443)): c = httplib.HTTPSConnection(hp) self.assertEqual(h, c.host) self.assertEqual(p, c.port) class TunnelTests(TestCase): def test_connect(self): response_text = ( 'HTTP/1.0 200 OK\r\n\r\n' # Reply to CONNECT 'HTTP/1.1 200 OK\r\n' # Reply to HEAD 'Content-Length: 42\r\n\r\n' ) def create_connection(address, timeout=None, source_address=None): return FakeSocket(response_text, host=address[0], port=address[1]) conn = httplib.HTTPConnection('proxy.com') conn._create_connection = create_connection # Once connected, we should not be able to tunnel anymore conn.connect() self.assertRaises(RuntimeError, conn.set_tunnel, 'destination.com') # But if close the connection, we are good. conn.close() conn.set_tunnel('destination.com') conn.request('HEAD', '/', '') self.assertEqual(conn.sock.host, 'proxy.com') self.assertEqual(conn.sock.port, 80) self.assertIn('CONNECT destination.com', conn.sock.data) # issue22095 self.assertNotIn('Host: destination.com:None', conn.sock.data) self.assertIn('Host: destination.com', conn.sock.data) self.assertNotIn('Host: proxy.com', conn.sock.data) conn.close() conn.request('PUT', '/', '') self.assertEqual(conn.sock.host, 'proxy.com') self.assertEqual(conn.sock.port, 80) self.assertTrue('CONNECT destination.com' in conn.sock.data) self.assertTrue('Host: destination.com' in conn.sock.data) @test_support.reap_threads def test_main(verbose=None): test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPTest, HTTPSTest, SourceAddressTest, TunnelTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_httpservers.py0000644000076500000000000005245012666555342022055 0ustar jmaddenwheel00000000000000"""Unittests for the various HTTPServer modules. Written by Cody A.W. Somerville , Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest. """ import os import sys import re import base64 import shutil import urllib import httplib import tempfile import unittest import CGIHTTPServer from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler from CGIHTTPServer import CGIHTTPRequestHandler from StringIO import StringIO from test import test_support threading = test_support.import_module('threading') class NoLogRequestHandler: def log_message(self, *args): # don't write log messages to stderr pass class SocketlessRequestHandler(SimpleHTTPRequestHandler): def __init__(self): self.get_called = False self.protocol_version = "HTTP/1.1" def do_GET(self): self.get_called = True self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(b'Data\r\n') def log_message(self, fmt, *args): pass class TestServerThread(threading.Thread): def __init__(self, test_object, request_handler): threading.Thread.__init__(self) self.request_handler = request_handler self.test_object = test_object def run(self): self.server = HTTPServer(('', 0), self.request_handler) self.test_object.PORT = self.server.socket.getsockname()[1] self.test_object.server_started.set() self.test_object = None try: self.server.serve_forever(0.05) finally: self.server.server_close() def stop(self): self.server.shutdown() class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() os.environ = test_support.EnvironmentVarGuard() self.server_started = threading.Event() self.thread = TestServerThread(self, self.request_handler) self.thread.start() self.server_started.wait() def tearDown(self): self.thread.stop() os.environ.__exit__() test_support.threading_cleanup(*self._threads) def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) self.connection.request(method, uri, body, headers) return self.connection.getresponse() class BaseHTTPRequestHandlerTestCase(unittest.TestCase): """Test the functionality of the BaseHTTPServer focussing on BaseHTTPRequestHandler. """ HTTPResponseMatch = re.compile('HTTP/1.[0-9]+ 200 OK') def setUp (self): self.handler = SocketlessRequestHandler() def send_typical_request(self, message): input_msg = StringIO(message) output = StringIO() self.handler.rfile = input_msg self.handler.wfile = output self.handler.handle_one_request() output.seek(0) return output.readlines() def verify_get_called(self): self.assertTrue(self.handler.get_called) def verify_expected_headers(self, headers): for fieldName in 'Server: ', 'Date: ', 'Content-Type: ': self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1) def verify_http_server_response(self, response): match = self.HTTPResponseMatch.search(response) self.assertIsNotNone(match) def test_http_1_1(self): result = self.send_typical_request('GET / HTTP/1.1\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_http_1_0(self): result = self.send_typical_request('GET / HTTP/1.0\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_http_0_9(self): result = self.send_typical_request('GET / HTTP/0.9\r\n\r\n') self.assertEqual(len(result), 1) self.assertEqual(result[0], 'Data\r\n') self.verify_get_called() def test_with_continue_1_0(self): result = self.send_typical_request('GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_request_length(self): # Issue #10714: huge request lines are discarded, to avoid Denial # of Service attacks. result = self.send_typical_request(b'GET ' + b'x' * 65537) self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n') self.assertFalse(self.handler.get_called) class BaseHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' default_request_version = 'HTTP/1.1' def do_TEST(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def do_KEEP(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'keep-alive') self.end_headers() def do_KEYERROR(self): self.send_error(999) def do_CUSTOM(self): self.send_response(999) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def setUp(self): BaseTestCase.setUp(self) self.con = httplib.HTTPConnection('localhost', self.PORT) self.con.connect() def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() self.assertEqual(res.status, 501) def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_version_bogus(self): self.con._http_vsn_str = 'FUBAR' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_digits(self): self.con._http_vsn_str = 'HTTP/9.9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_version_none(self): # Test that a valid method is rejected when not HTTP/1.x self.con._http_vsn_str = '' self.con.putrequest('CUSTOM', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_invalid(self): self.con._http_vsn = 99 self.con._http_vsn_str = 'HTTP/9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 505) def test_send_blank(self): self.con._http_vsn_str = '' self.con.putrequest('', '') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_header_close(self): self.con.putrequest('GET', '/') self.con.putheader('Connection', 'close') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' self.con.putrequest('GET', '/') self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_handler(self): self.con.request('TEST', '/') res = self.con.getresponse() self.assertEqual(res.status, 204) def test_return_header_keep_alive(self): self.con.request('KEEP', '/') res = self.con.getresponse() self.assertEqual(res.getheader('Connection'), 'keep-alive') self.con.request('TEST', '/') self.addCleanup(self.con.close) def test_internal_key_error(self): self.con.request('KEYERROR', '/') res = self.con.getresponse() self.assertEqual(res.status, 999) def test_return_custom_status(self): self.con.request('CUSTOM', '/') res = self.con.getresponse() self.assertEqual(res.status, 999) class SimpleHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.cwd = os.getcwd() basetempdir = tempfile.gettempdir() os.chdir(basetempdir) self.data = 'We are the knights who say Ni!' self.tempdir = tempfile.mkdtemp(dir=basetempdir) self.tempdir_name = os.path.basename(self.tempdir) temp = open(os.path.join(self.tempdir, 'test'), 'wb') temp.write(self.data) temp.close() def tearDown(self): try: os.chdir(self.cwd) try: shutil.rmtree(self.tempdir) except OSError: pass finally: BaseTestCase.tearDown(self) def check_status_and_reason(self, response, status, data=None): body = response.read() self.assertTrue(response) self.assertEqual(response.status, status) self.assertIsNotNone(response.reason) if data: self.assertEqual(data, body) def test_get(self): #constructs the path relative to the root directory of the HTTPServer response = self.request(self.tempdir_name + '/test') self.check_status_and_reason(response, 200, data=self.data) # check for trailing "/" which should return 404. See Issue17324 response = self.request(self.tempdir_name + '/test/') self.check_status_and_reason(response, 404) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name) self.check_status_and_reason(response, 301) response = self.request(self.tempdir_name + '/?hi=2') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name + '?hi=1') self.check_status_and_reason(response, 301) self.assertEqual(response.getheader("Location"), self.tempdir_name + "/?hi=1") response = self.request('/ThisDoesNotExist') self.check_status_and_reason(response, 404) response = self.request('/' + 'ThisDoesNotExist' + '/') self.check_status_and_reason(response, 404) with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as fp: response = self.request('/' + self.tempdir_name + '/') self.check_status_and_reason(response, 200) # chmod() doesn't work as expected on Windows, and filesystem # permissions are ignored by root on Unix. if os.name == 'posix' and os.geteuid() != 0: os.chmod(self.tempdir, 0) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 404) os.chmod(self.tempdir, 0755) def test_head(self): response = self.request( self.tempdir_name + '/test', method='HEAD') self.check_status_and_reason(response, 200) self.assertEqual(response.getheader('content-length'), str(len(self.data))) self.assertEqual(response.getheader('content-type'), 'application/octet-stream') def test_invalid_requests(self): response = self.request('/', method='FOO') self.check_status_and_reason(response, 501) # requests must be case sensitive,so this should fail too response = self.request('/', method='custom') self.check_status_and_reason(response, 501) response = self.request('/', method='GETs') self.check_status_and_reason(response, 501) cgi_file1 = """\ #!%s print "Content-type: text/html" print print "Hello World" """ cgi_file2 = """\ #!%s import cgi print "Content-type: text/html" print form = cgi.FieldStorage() print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"), form.getfirst("bacon")) """ cgi_file4 = """\ #!%s import os print("Content-type: text/html") print() print(os.environ["%s"]) """ @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, "This test can't be run reliably as root (issue #13308).") class CGIHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') self.cgi_child_dir = os.path.join(self.cgi_dir, 'child-dir') os.mkdir(self.cgi_dir) os.mkdir(self.cgi_child_dir) # The shebang line should be pure ASCII: use symlink if possible. # See issue #7668. if hasattr(os, 'symlink'): self.pythonexe = os.path.join(self.parent_dir, 'python') os.symlink(sys.executable, self.pythonexe) else: self.pythonexe = sys.executable self.nocgi_path = os.path.join(self.parent_dir, 'nocgi.py') with open(self.nocgi_path, 'w') as fp: fp.write(cgi_file1 % self.pythonexe) os.chmod(self.nocgi_path, 0777) self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: file1.write(cgi_file1 % self.pythonexe) os.chmod(self.file1_path, 0777) self.file2_path = os.path.join(self.cgi_dir, 'file2.py') with open(self.file2_path, 'w') as file2: file2.write(cgi_file2 % self.pythonexe) os.chmod(self.file2_path, 0777) self.file3_path = os.path.join(self.cgi_child_dir, 'file3.py') with open(self.file3_path, 'w') as file3: file3.write(cgi_file1 % self.pythonexe) os.chmod(self.file3_path, 0777) self.file4_path = os.path.join(self.cgi_dir, 'file4.py') with open(self.file4_path, 'w') as file4: file4.write(cgi_file4 % (self.pythonexe, 'QUERY_STRING')) os.chmod(self.file4_path, 0o777) self.cwd = os.getcwd() os.chdir(self.parent_dir) def tearDown(self): try: os.chdir(self.cwd) if self.pythonexe != sys.executable: os.remove(self.pythonexe) os.remove(self.nocgi_path) os.remove(self.file1_path) os.remove(self.file2_path) os.remove(self.file3_path) os.remove(self.file4_path) os.rmdir(self.cgi_child_dir) os.rmdir(self.cgi_dir) os.rmdir(self.parent_dir) finally: BaseTestCase.tearDown(self) def test_url_collapse_path(self): # verify tail is the last portion and head is the rest on proper urls test_vectors = { '': '//', '..': IndexError, '/.//..': IndexError, '/': '//', '//': '//', '/\\': '//\\', '/.//': '//', 'cgi-bin/file1.py': '/cgi-bin/file1.py', '/cgi-bin/file1.py': '/cgi-bin/file1.py', 'a': '//a', '/a': '//a', '//a': '//a', './a': '//a', './C:/': '/C:/', '/a/b': '/a/b', '/a/b/': '/a/b/', '/a/b/.': '/a/b/', '/a/b/c/..': '/a/b/', '/a/b/c/../d': '/a/b/d', '/a/b/c/../d/e/../f': '/a/b/d/f', '/a/b/c/../d/e/../../f': '/a/b/f', '/a/b/c/../d/e/.././././..//f': '/a/b/f', '../a/b/c/../d/e/.././././..//f': IndexError, '/a/b/c/../d/e/../../../f': '/a/f', '/a/b/c/../d/e/../../../../f': '//f', '/a/b/c/../d/e/../../../../../f': IndexError, '/a/b/c/../d/e/../../../../f/..': '//', '/a/b/c/../d/e/../../../../f/../.': '//', } for path, expected in test_vectors.iteritems(): if isinstance(expected, type) and issubclass(expected, Exception): self.assertRaises(expected, CGIHTTPServer._url_collapse_path, path) else: actual = CGIHTTPServer._url_collapse_path(path) self.assertEqual(expected, actual, msg='path = %r\nGot: %r\nWanted: %r' % (path, actual, expected)) def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_issue19435(self): res = self.request('///////////nocgi.py/../cgi-bin/nothere.sh') self.assertEqual(res.status, 404) def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} res = self.request('/cgi-bin/file2.py', 'POST', params, headers) self.assertEqual(res.read(), '1, python, 123456\n') def test_invaliduri(self): res = self.request('/cgi-bin/invalid') res.read() self.assertEqual(res.status, 404) def test_authorization(self): headers = {'Authorization' : 'Basic %s' % base64.b64encode('username:pass')} res = self.request('/cgi-bin/file1.py', 'GET', headers=headers) self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_os_environ_is_not_altered(self): signature = "Test CGI Server" os.environ['SERVER_SOFTWARE'] = signature res = self.request('/cgi-bin/file1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) self.assertEqual(os.environ['SERVER_SOFTWARE'], signature) def test_urlquote_decoding_in_cgi_check(self): res = self.request('/cgi-bin%2ffile1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_nested_cgi_path_issue21323(self): res = self.request('/cgi-bin/child-dir/file3.py') self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_query_with_multiple_question_mark(self): res = self.request('/cgi-bin/file4.py?a=b?c=d') self.assertEqual( (b'a=b?c=d\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_query_with_continuous_slashes(self): res = self.request('/cgi-bin/file4.py?k=aa%2F%2Fbb&//q//p//=//a//b//') self.assertEqual( (b'k=aa%2F%2Fbb&//q//p//=//a//b//\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): """ Test url parsing """ def setUp(self): self.translated = os.getcwd() self.translated = os.path.join(self.translated, 'filename') self.handler = SocketlessRequestHandler() def test_query_arguments(self): path = self.handler.translate_path('/filename') self.assertEqual(path, self.translated) path = self.handler.translate_path('/filename?foo=bar') self.assertEqual(path, self.translated) path = self.handler.translate_path('/filename?a=b&spam=eggs#zot') self.assertEqual(path, self.translated) def test_start_with_double_slash(self): path = self.handler.translate_path('//filename') self.assertEqual(path, self.translated) path = self.handler.translate_path('//filename?foo=bar') self.assertEqual(path, self.translated) def test_main(verbose=None): try: cwd = os.getcwd() test_support.run_unittest(BaseHTTPRequestHandlerTestCase, SimpleHTTPRequestHandlerTestCase, BaseHTTPServerTestCase, SimpleHTTPServerTestCase, CGIHTTPServerTestCase ) finally: os.chdir(cwd) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_queue.py0000644000076500000000000002730712666555342020613 0ustar jmaddenwheel00000000000000# Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. import Queue import time import unittest from test import test_support threading = test_support.import_module('threading') QUEUE_SIZE = 5 # A thread to run a function that unclogs a blocked Queue. class _TriggerThread(threading.Thread): def __init__(self, fn, args): self.fn = fn self.args = args self.startedEvent = threading.Event() threading.Thread.__init__(self) def run(self): # The sleep isn't necessary, but is intended to give the blocking # function in the main thread a chance at actually blocking before # we unclog it. But if the sleep is longer than the timeout-based # tests wait in their blocking functions, those tests will fail. # So we give them much longer timeout values compared to the # sleep here (I aimed at 10 seconds for blocking functions -- # they should never actually wait that long - they should make # progress as soon as we call self.fn()). time.sleep(0.1) self.startedEvent.set() self.fn(*self.args) # Execute a function that blocks, and in a separate thread, a function that # triggers the release. Returns the result of the blocking function. Caution: # block_func must guarantee to block until trigger_func is called, and # trigger_func must guarantee to change queue state so that block_func can make # enough progress to return. In particular, a block_func that just raises an # exception regardless of whether trigger_func is called will lead to # timing-dependent sporadic failures, and one of those went rarely seen but # undiagnosed for years. Now block_func must be unexceptional. If block_func # is supposed to raise an exception, call do_exceptional_blocking_test() # instead. class BlockingTestMixin: def tearDown(self): self.t = None def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() self.result = block_func(*block_args) # If block_func returned before our thread made the call, we failed! if not self.t.startedEvent.is_set(): self.fail("blocking function '%r' appeared not to block" % block_func) self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) return self.result # Call this instead if block_func is supposed to raise an exception. def do_exceptional_blocking_test(self,block_func, block_args, trigger_func, trigger_args, expected_exception_class): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() try: try: block_func(*block_args) except expected_exception_class: raise else: self.fail("expected exception of kind %r" % expected_exception_class) finally: self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) if not self.t.startedEvent.is_set(): self.fail("trigger thread ended but event never set") class BaseQueueTest(BlockingTestMixin): def setUp(self): self.cum = 0 self.cumlock = threading.Lock() def simple_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" # I guess we better check things actually queue correctly a little :) q.put(111) q.put(333) q.put(222) target_order = dict(Queue = [111, 333, 222], LifoQueue = [222, 333, 111], PriorityQueue = [111, 222, 333]) actual_order = [q.get(), q.get(), q.get()] self.assertEqual(actual_order, target_order[q.__class__.__name__], "Didn't seem to queue the correct data!") for i in range(QUEUE_SIZE-1): q.put(i) self.assertTrue(not q.empty(), "Queue should not be empty") self.assertTrue(not q.full(), "Queue should not be full") last = 2 * QUEUE_SIZE full = 3 * 2 * QUEUE_SIZE q.put(last) self.assertTrue(q.full(), "Queue should be full") try: q.put(full, block=0) self.fail("Didn't appear to block with a full queue") except Queue.Full: pass try: q.put(full, timeout=0.01) self.fail("Didn't appear to time-out with a full queue") except Queue.Full: pass # Test a blocking put self.do_blocking_test(q.put, (full,), q.get, ()) self.do_blocking_test(q.put, (full, True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assertTrue(q.empty(), "Queue should be empty") try: q.get(block=0) self.fail("Didn't appear to block with an empty queue") except Queue.Empty: pass try: q.get(timeout=0.01) self.fail("Didn't appear to time-out with an empty queue") except Queue.Empty: pass # Test a blocking get self.do_blocking_test(q.get, (), q.put, ('empty',)) self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) def worker(self, q): while True: x = q.get() if x is None: q.task_done() return with self.cumlock: self.cum += x q.task_done() def queue_join_test(self, q): self.cum = 0 for i in (0,1): threading.Thread(target=self.worker, args=(q,)).start() for i in xrange(100): q.put(i) q.join() self.assertEqual(self.cum, sum(range(100)), "q.join() did not block until all tasks were done") for i in (0,1): q.put(None) # instruct the threads to close q.join() # verify that you can join twice def test_queue_task_done(self): # Test to make sure a queue task completed successfully. q = self.type2test() try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_queue_join(self): # Test that a queue join()s successfully, and before anything else # (done twice for insurance). q = self.type2test() self.queue_join_test(q) self.queue_join_test(q) try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_simple_queue(self): # Do it a couple of times on the same queue. # Done twice to make sure works with same instance reused. q = self.type2test(QUEUE_SIZE) self.simple_queue_test(q) self.simple_queue_test(q) class QueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.Queue class LifoQueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.LifoQueue class PriorityQueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.PriorityQueue # A Queue subclass that can provoke failure at a moment's notice :) class FailingQueueException(Exception): pass class FailingQueue(Queue.Queue): def __init__(self, *args): self.fail_next_put = False self.fail_next_get = False Queue.Queue.__init__(self, *args) def _put(self, item): if self.fail_next_put: self.fail_next_put = False raise FailingQueueException, "You Lose" return Queue.Queue._put(self, item) def _get(self): if self.fail_next_get: self.fail_next_get = False raise FailingQueueException, "You Lose" return Queue.Queue._get(self) class FailingQueueTest(BlockingTestMixin, unittest.TestCase): def failing_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" for i in range(QUEUE_SIZE-1): q.put(i) # Test a failing non-blocking put. q.fail_next_put = True try: q.put("oops", block=0) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.fail_next_put = True try: q.put("oops", timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.put("last") self.assertTrue(q.full(), "Queue should be full") # Test a failing blocking put q.fail_next_put = True try: self.do_blocking_test(q.put, ("full",), q.get, ()) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") # Test a failing timeout put q.fail_next_put = True try: self.do_exceptional_blocking_test(q.put, ("full", True, 10), q.get, (), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") self.assertTrue(q.full(), "Queue should be full") q.get() self.assertTrue(not q.full(), "Queue should not be full") q.put("last") self.assertTrue(q.full(), "Queue should be full") # Test a blocking put self.do_blocking_test(q.put, ("full",), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assertTrue(q.empty(), "Queue should be empty") q.put("first") q.fail_next_get = True try: q.get() self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assertTrue(not q.empty(), "Queue should not be empty") q.fail_next_get = True try: q.get(timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assertTrue(not q.empty(), "Queue should not be empty") q.get() self.assertTrue(q.empty(), "Queue should be empty") q.fail_next_get = True try: self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # put succeeded, but get failed. self.assertTrue(not q.empty(), "Queue should not be empty") q.get() self.assertTrue(q.empty(), "Queue should be empty") def test_failing_queue(self): # Test to make sure a queue is functioning correctly. # Done twice to the same instance. q = FailingQueue(QUEUE_SIZE) self.failing_queue_test(q) self.failing_queue_test(q) def test_main(): test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_select.py0000644000076500000000000000416312666555342020741 0ustar jmaddenwheel00000000000000from test import test_support import unittest import select import os import sys @unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'), "can't easily test on this system") class SelectTestCase(unittest.TestCase): class Nope: pass class Almost: def fileno(self): return 'fileno' def test_error_conditions(self): self.assertRaises(TypeError, select.select, 1, 2, 3) self.assertRaises(TypeError, select.select, [self.Nope()], [], []) self.assertRaises(TypeError, select.select, [self.Almost()], [], []) self.assertRaises(TypeError, select.select, [], [], [], "not a number") def test_returned_list_identity(self): # See issue #8329 r, w, x = select.select([], [], [], 1) self.assertIsNot(r, w) self.assertIsNot(r, x) self.assertIsNot(w, x) def test_select(self): cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: if test_support.verbose: print 'timeout =', tout rfd, wfd, xfd = select.select([p], [], [], tout) if (rfd, wfd, xfd) == ([], [], []): continue if (rfd, wfd, xfd) == ([p], [], []): line = p.readline() if test_support.verbose: print repr(line) if not line: if test_support.verbose: print 'EOF' break continue self.fail('Unexpected return values from select():', rfd, wfd, xfd) p.close() # Issue 16230: Crash on select resized list def test_select_mutated(self): a = [] class F: def fileno(self): del a[-1] return sys.__stdout__.fileno() a[:] = [F()] * 10 self.assertEqual(select.select([], a, []), ([], a[:5], [])) def test_main(): test_support.run_unittest(SelectTestCase) test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_signal.py0000644000076500000000000004473112666555342020744 0ustar jmaddenwheel00000000000000import unittest from test import test_support from contextlib import closing import gc import pickle import select import signal import subprocess import traceback import sys, os, time, errno if sys.platform in ('os2', 'riscos'): raise unittest.SkipTest("Can't test signal on %s" % sys.platform) class HandlerBCalled(Exception): pass def exit_subprocess(): """Use os._exit(0) to exit the current subprocess. Otherwise, the test catches the SystemExit and continues executing in parallel with the original test, so you wind up with an exponential number of tests running concurrently. """ os._exit(0) def ignoring_eintr(__func, *args, **kwargs): try: return __func(*args, **kwargs) except EnvironmentError as e: if e.errno != errno.EINTR: raise return None @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. def setUp(self): self.using_gc = gc.isenabled() gc.disable() def tearDown(self): if self.using_gc: gc.enable() def format_frame(self, frame, limit=None): return ''.join(traceback.format_stack(frame, limit=limit)) def handlerA(self, signum, frame): self.a_called = True if test_support.verbose: print "handlerA invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) def handlerB(self, signum, frame): self.b_called = True if test_support.verbose: print "handlerB invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) raise HandlerBCalled(signum, self.format_frame(frame)) def wait(self, child): """Wait for child to finish, ignoring EINTR.""" while True: try: child.wait() return except OSError as e: if e.errno != errno.EINTR: raise def run_test(self): # Install handlers. This function runs in a sub-process, so we # don't worry about re-setting the default handlers. signal.signal(signal.SIGHUP, self.handlerA) signal.signal(signal.SIGUSR1, self.handlerB) signal.signal(signal.SIGUSR2, signal.SIG_IGN) signal.signal(signal.SIGALRM, signal.default_int_handler) # Variables the signals will modify: self.a_called = False self.b_called = False # Let the sub-processes know who to send signals to. pid = os.getpid() if test_support.verbose: print "test runner's pid is", pid child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)]) if child: self.wait(child) if not self.a_called: time.sleep(1) # Give the signal time to be delivered. self.assertTrue(self.a_called) self.assertFalse(self.b_called) self.a_called = False # Make sure the signal isn't delivered while the previous # Popen object is being destroyed, because __del__ swallows # exceptions. del child try: child = subprocess.Popen(['kill', '-USR1', str(pid)]) # This wait should be interrupted by the signal's exception. self.wait(child) time.sleep(1) # Give the signal time to be delivered. self.fail('HandlerBCalled exception not raised') except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) if test_support.verbose: print "HandlerBCalled exception caught" child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)]) if child: self.wait(child) # Nothing should happen. try: signal.alarm(1) # The race condition in pause doesn't matter in this case, # since alarm is going to raise a KeyboardException, which # will skip the call. signal.pause() # But if another signal arrives before the alarm, pause # may return early. time.sleep(1) except KeyboardInterrupt: if test_support.verbose: print "KeyboardInterrupt (the alarm() went off)" except: self.fail("Some other exception woke us from pause: %s" % traceback.format_exc()) else: self.fail("pause returned of its own accord, and the signal" " didn't arrive after another second.") # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform=='freebsd6', 'inter process signals not reliable (do not mix well with threading) ' 'on freebsd6') def test_main(self): # This function spawns a child process to insulate the main # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child # raises. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with closing(os.fdopen(os_done_r)) as done_r, \ closing(os.fdopen(os_done_w, 'w')) as done_w: child = os.fork() if child == 0: # In the child process; run the test and report results # through the pipe. try: done_r.close() # Have to close done_w again here because # exit_subprocess() will skip the enclosing with block. with closing(done_w): try: self.run_test() except: pickle.dump(traceback.format_exc(), done_w) else: pickle.dump(None, done_w) except: print 'Uh oh, raised from pickle.' traceback.print_exc() finally: exit_subprocess() done_w.close() # Block for up to MAX_DURATION seconds for the test to finish. r, w, x = select.select([done_r], [], [], self.MAX_DURATION) if done_r in r: tb = pickle.load(done_r) if tb: self.fail(tb) else: os.kill(child, signal.SIGKILL) self.fail('Test deadlocked after %d seconds.' % self.MAX_DURATION) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class BasicSignalTests(unittest.TestCase): def trivial_signal_handler(self, *args): pass def test_out_of_range_signal_number_raises_error(self): self.assertRaises(ValueError, signal.getsignal, 4242) self.assertRaises(ValueError, signal.signal, 4242, self.trivial_signal_handler) def test_setting_signal_handler_to_none_raises_error(self): self.assertRaises(TypeError, signal.signal, signal.SIGUSR1, None) def test_getsignal(self): hup = signal.signal(signal.SIGHUP, self.trivial_signal_handler) self.assertEqual(signal.getsignal(signal.SIGHUP), self.trivial_signal_handler) signal.signal(signal.SIGHUP, hup) self.assertEqual(signal.getsignal(signal.SIGHUP), hup) @unittest.skipUnless(sys.platform == "win32", "Windows specific") class WindowsSignalTests(unittest.TestCase): def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows signal.signal(sig, signal.signal(sig, handler)) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler) class WakeupFDTests(unittest.TestCase): def test_invalid_fd(self): fd = test_support.make_bad_fd() self.assertRaises(ValueError, signal.set_wakeup_fd, fd) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): TIMEOUT_FULL = 10 TIMEOUT_HALF = 5 def test_wakeup_fd_early(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the sleep, # before select is called time.sleep(self.TIMEOUT_FULL) mid_time = time.time() self.assertTrue(mid_time - before_time < self.TIMEOUT_HALF) select.select([self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF) def test_wakeup_fd_during(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the select call self.assertRaises(select.error, select.select, [self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - before_time < self.TIMEOUT_HALF) def setUp(self): import fcntl self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None) self.read, self.write = os.pipe() flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(self.write, fcntl.F_SETFL, flags) self.old_wakeup = signal.set_wakeup_fd(self.write) def tearDown(self): signal.set_wakeup_fd(self.old_wakeup) os.close(self.read) os.close(self.write) signal.signal(signal.SIGALRM, self.alrm) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class SiginterruptTest(unittest.TestCase): def setUp(self): """Install a no-op signal handler that can be set to allow interrupts or not, and arrange for the original signal handler to be re-installed when the test is finished. """ self.signum = signal.SIGUSR1 oldhandler = signal.signal(self.signum, lambda x,y: None) self.addCleanup(signal.signal, self.signum, oldhandler) def readpipe_interrupted(self): """Perform a read during which a signal will arrive. Return True if the read is interrupted by the signal and raises an exception. Return False if it returns normally. """ # Create a pipe that can be used for the read. Also clean it up # when the test is over, since nothing else will (but see below for # the write end). r, w = os.pipe() self.addCleanup(os.close, r) # Create another process which can send a signal to this one to try # to interrupt the read. ppid = os.getpid() pid = os.fork() if pid == 0: # Child code: sleep to give the parent enough time to enter the # read() call (there's a race here, but it's really tricky to # eliminate it); then signal the parent process. Also, sleep # again to make it likely that the signal is delivered to the # parent process before the child exits. If the child exits # first, the write end of the pipe will be closed and the test # is invalid. try: time.sleep(0.2) os.kill(ppid, self.signum) time.sleep(0.2) finally: # No matter what, just exit as fast as possible now. exit_subprocess() else: # Parent code. # Make sure the child is eventually reaped, else it'll be a # zombie for the rest of the test suite run. self.addCleanup(os.waitpid, pid, 0) # Close the write end of the pipe. The child has a copy, so # it's not really closed until the child exits. We need it to # close when the child exits so that in the non-interrupt case # the read eventually completes, otherwise we could just close # it *after* the test. os.close(w) # Try the read and report whether it is interrupted or not to # the caller. try: d = os.read(r, 1) return False except OSError, err: if err.errno != errno.EINTR: raise return True def test_without_siginterrupt(self): """If a signal handler is installed and siginterrupt is not called at all, when that signal arrives, it interrupts a syscall that's in progress. """ i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_on(self): """If a signal handler is installed and siginterrupt is called with a true value for the second argument, when that signal arrives, it interrupts a syscall that's in progress. """ signal.siginterrupt(self.signum, 1) i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_off(self): """If a signal handler is installed and siginterrupt is called with a false value for the second argument, when that signal arrives, it does not interrupt a syscall that's in progress. """ signal.siginterrupt(self.signum, 0) i = self.readpipe_interrupted() self.assertFalse(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertFalse(i) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class ItimerTest(unittest.TestCase): def setUp(self): self.hndl_called = False self.hndl_count = 0 self.itimer = None self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) def sig_alrm(self, *args): self.hndl_called = True if test_support.verbose: print("SIGALRM handler invoked", args) def sig_vtalrm(self, *args): self.hndl_called = True if self.hndl_count > 3: # it shouldn't be here, because it should have been disabled. raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL " "timer.") elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) if test_support.verbose: print("last SIGVTALRM handler call") self.hndl_count += 1 if test_support.verbose: print("SIGVTALRM handler invoked", args) def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args) def test_itimer_exc(self): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) # Negative times are treated as zero on some platforms. if 0: self.assertRaises(signal.ItimerError, signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1.0) if test_support.verbose: print("\ncall pause()...") signal.pause() self.assertEqual(self.hndl_called, True) # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'), 'itimer not reliable (does not mix well with threading) on some BSDs.') def test_itimer_virtual(self): self.itimer = signal.ITIMER_VIRTUAL signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # virtual itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform=='freebsd6', 'itimer not reliable (does not mix well with threading) on freebsd6') def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) def test_main(): test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupFDTests, WakeupSignalTests, SiginterruptTest, ItimerTest, WindowsSignalTests) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_smtplib.py0000644000076500000000000004664212666555342021144 0ustar jmaddenwheel00000000000000import asyncore import email.utils import socket import smtpd import smtplib import StringIO import sys import time import select import unittest from test import test_support try: import threading except ImportError: threading = None HOST = test_support.HOST def server(evt, buf, serv): serv.listen(5) evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: n = 500 while buf and n > 0: r, w, e = select.select([], [conn], []) if w: sent = conn.send(buf) buf = buf[sent:] n -= 1 conn.close() finally: serv.close() evt.set() @unittest.skipUnless(threading, 'Threading required for this test.') class GeneralTests(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "220 Hola mundo\n", self.sock) self.thread = threading.Thread(target=server, args=servargs) self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) def testBasic1(self): # connects smtp = smtplib.SMTP(HOST, self.port) smtp.close() def testBasic2(self): # connects, include port in host name smtp = smtplib.SMTP("%s:%s" % (HOST, self.port)) smtp.close() def testLocalHostName(self): # check that supplied local_hostname is used smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost") self.assertEqual(smtp.local_hostname, "testhost") smtp.close() def testTimeoutDefault(self): self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() def testTimeoutNone(self): self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(smtp.sock.gettimeout()) smtp.close() def testTimeoutValue(self): smtp = smtplib.SMTP(HOST, self.port, timeout=30) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() # Test server thread using the specified SMTP server class def debugging_server(serv, serv_evt, client_evt): serv_evt.set() try: if hasattr(select, 'poll'): poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll n = 1000 while asyncore.socket_map and n > 0: poll_fun(0.01, asyncore.socket_map) # when the client conversation is finished, it will # set client_evt, and it's then ok to kill the server if client_evt.is_set(): serv.close() break n -= 1 except socket.timeout: pass finally: if not client_evt.is_set(): # allow some time for the client to read the result time.sleep(0.5) serv.close() asyncore.close_all() serv_evt.set() MSG_BEGIN = '---------- MESSAGE FOLLOWS ----------\n' MSG_END = '------------ END MESSAGE ------------\n' # NOTE: Some SMTP objects in the tests below are created with a non-default # local_hostname argument to the constructor, since (on some systems) the FQDN # lookup caused by the default local_hostname sometimes takes so long that the # test server times out, causing the test to fail. # Test behavior of smtpd.DebuggingServer @unittest.skipUnless(threading, 'Threading required for this test.') class DebuggingServerTests(unittest.TestCase): def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout def testBasic(self): # connect smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.quit() def testNOOP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.noop(), expected) smtp.quit() def testRSET(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.rset(), expected) smtp.quit() def testNotImplemented(self): # EHLO isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "EHLO" not implemented') self.assertEqual(smtp.ehlo(), expected) smtp.quit() def testVRFY(self): # VRFY isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "VRFY" not implemented') self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected) self.assertEqual(smtp.verify('nobody@nowhere.com'), expected) smtp.quit() def testSecondHELO(self): # check that a second HELO returns a message that it's a duplicate # (this behavior is specific to smtpd.SMTPChannel) smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.helo() expected = (503, 'Duplicate HELO/EHLO') self.assertEqual(smtp.helo(), expected) smtp.quit() def testHELP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) self.assertEqual(smtp.help(), 'Error: command "HELP" not implemented') smtp.quit() def testSend(self): # connect and send mail m = 'A test message' smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.sendmail('John', 'Sally', m) # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor # in asyncore. This sleep might help, but should really be fixed # properly by using an Event variable. time.sleep(0.01) smtp.quit() self.client_evt.set() self.serv_evt.wait() self.output.flush() mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END) self.assertEqual(self.output.getvalue(), mexpect) class NonConnectingTests(unittest.TestCase): def testNotConnected(self): # Test various operations on an unconnected SMTP object that # should raise exceptions (at present the attempt in SMTP.send # to reference the nonexistent 'sock' attribute of the SMTP object # causes an AttributeError) smtp = smtplib.SMTP() self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) self.assertRaises(smtplib.SMTPServerDisconnected, smtp.send, 'test msg') def testNonnumericPort(self): # check that non-numeric port raises socket.error self.assertRaises(socket.error, smtplib.SMTP, "localhost", "bogus") self.assertRaises(socket.error, smtplib.SMTP, "localhost:bogus") # test response of client to a non-successful HELO message @unittest.skipUnless(threading, 'Threading required for this test.') class BadHELOServerTests(unittest.TestCase): def setUp(self): self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "199 no hello for you!\n", self.sock) self.thread = threading.Thread(target=server, args=servargs) self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) sys.stdout = self.old_stdout def testFailingHELO(self): self.assertRaises(smtplib.SMTPConnectError, smtplib.SMTP, HOST, self.port, 'localhost', 3) @unittest.skipUnless(threading, 'Threading required for this test.') class TooLongLineTests(unittest.TestCase): respdata = '250 OK' + ('.' * smtplib._MAXLINE * 2) + '\n' def setUp(self): self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, self.respdata, self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() sys.stdout = self.old_stdout def testLineTooLong(self): self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP, HOST, self.port, 'localhost', 3) sim_users = {'Mr.A@somewhere.com':'John A', 'Ms.B@somewhere.com':'Sally B', 'Mrs.C@somewhereesle.com':'Ruth C', } sim_auth = ('Mr.A@somewhere.com', 'somepassword') sim_cram_md5_challenge = ('PENCeUxFREJoU0NnbmhNWitOMjNGNn' 'dAZWx3b29kLmlubm9zb2Z0LmNvbT4=') sim_auth_credentials = { 'login': 'TXIuQUBzb21ld2hlcmUuY29t', 'plain': 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ=', 'cram-md5': ('TXIUQUBZB21LD2HLCMUUY29TIDG4OWQ0MJ' 'KWZGQ4ODNMNDA4NTGXMDRLZWMYZJDMODG1'), } sim_auth_login_password = 'C29TZXBHC3N3B3JK' sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'], 'list-2':['Ms.B@somewhere.com',], } # Simulated SMTP channel & server class SimSMTPChannel(smtpd.SMTPChannel): def __init__(self, extra_features, *args, **kw): self._extrafeatures = ''.join( [ "250-{0}\r\n".format(x) for x in extra_features ]) smtpd.SMTPChannel.__init__(self, *args, **kw) def smtp_EHLO(self, arg): resp = ('250-testhost\r\n' '250-EXPN\r\n' '250-SIZE 20000000\r\n' '250-STARTTLS\r\n' '250-DELIVERBY\r\n') resp = resp + self._extrafeatures + '250 HELP' self.push(resp) def smtp_VRFY(self, arg): # For max compatibility smtplib should be sending the raw address. if arg in sim_users: self.push('250 %s %s' % (sim_users[arg], smtplib.quoteaddr(arg))) else: self.push('550 No such user: %s' % arg) def smtp_EXPN(self, arg): list_name = arg.lower() if list_name in sim_lists: user_list = sim_lists[list_name] for n, user_email in enumerate(user_list): quoted_addr = smtplib.quoteaddr(user_email) if n < len(user_list) - 1: self.push('250-%s %s' % (sim_users[user_email], quoted_addr)) else: self.push('250 %s %s' % (sim_users[user_email], quoted_addr)) else: self.push('550 No access for you!') def smtp_AUTH(self, arg): if arg.strip().lower()=='cram-md5': self.push('334 {0}'.format(sim_cram_md5_challenge)) return mech, auth = arg.split() mech = mech.lower() if mech not in sim_auth_credentials: self.push('504 auth type unimplemented') return if mech == 'plain' and auth==sim_auth_credentials['plain']: self.push('235 plain auth ok') elif mech=='login' and auth==sim_auth_credentials['login']: self.push('334 Password:') else: self.push('550 No access for you!') def handle_error(self): raise class SimSMTPServer(smtpd.SMTPServer): def __init__(self, *args, **kw): self._extra_features = [] smtpd.SMTPServer.__init__(self, *args, **kw) def handle_accept(self): conn, addr = self.accept() self._SMTPchannel = SimSMTPChannel(self._extra_features, self, conn, addr) def process_message(self, peer, mailfrom, rcpttos, data): pass def add_feature(self, feature): self._extra_features.append(feature) def handle_error(self): raise # Test various SMTP & ESMTP commands/behaviors that require a simulated server # (i.e., something with more features than DebuggingServer) @unittest.skipUnless(threading, 'Threading required for this test.') class SMTPSimTests(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) def testBasic(self): # smoke test smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) smtp.quit() def testEHLO(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) # no features should be present before the EHLO self.assertEqual(smtp.esmtp_features, {}) # features expected from the test server expected_features = {'expn':'', 'size': '20000000', 'starttls': '', 'deliverby': '', 'help': '', } smtp.ehlo() self.assertEqual(smtp.esmtp_features, expected_features) for k in expected_features: self.assertTrue(smtp.has_extn(k)) self.assertFalse(smtp.has_extn('unsupported-feature')) smtp.quit() def testVRFY(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for email, name in sim_users.items(): expected_known = (250, '%s %s' % (name, smtplib.quoteaddr(email))) self.assertEqual(smtp.vrfy(email), expected_known) u = 'nobody@nowhere.com' expected_unknown = (550, 'No such user: %s' % u) self.assertEqual(smtp.vrfy(u), expected_unknown) smtp.quit() def testEXPN(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for listname, members in sim_lists.items(): users = [] for m in members: users.append('%s %s' % (sim_users[m], smtplib.quoteaddr(m))) expected_known = (250, '\n'.join(users)) self.assertEqual(smtp.expn(listname), expected_known) u = 'PSU-Members-List' expected_unknown = (550, 'No access for you!') self.assertEqual(smtp.expn(u), expected_unknown) smtp.quit() def testAUTH_PLAIN(self): self.serv.add_feature("AUTH PLAIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) expected_auth_ok = (235, b'plain auth ok') self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok) # SimSMTPChannel doesn't fully support LOGIN or CRAM-MD5 auth because they # require a synchronous read to obtain the credentials...so instead smtpd # sees the credential sent by smtplib's login method as an unknown command, # which results in smtplib raising an auth error. Fortunately the error # message contains the encoded credential, so we can partially check that it # was generated correctly (partially, because the 'word' is uppercased in # the error message). def testAUTH_LOGIN(self): self.serv.add_feature("AUTH LOGIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_login_password not in str(err): raise "expected encoded password not found in error message" def testAUTH_CRAM_MD5(self): self.serv.add_feature("AUTH CRAM-MD5") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_credentials['cram-md5'] not in str(err): raise "expected encoded credentials not found in error message" #TODO: add tests for correct AUTH method fallback now that the #test infrastructure can support it. def test_quit_resets_greeting(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) code, message = smtp.ehlo() self.assertEqual(code, 250) self.assertIn('size', smtp.esmtp_features) smtp.quit() self.assertNotIn('size', smtp.esmtp_features) smtp.connect(HOST, self.port) self.assertNotIn('size', smtp.esmtp_features) smtp.ehlo_or_helo_if_needed() self.assertIn('size', smtp.esmtp_features) smtp.quit() def test_main(verbose=None): test_support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests, BadHELOServerTests, SMTPSimTests, TooLongLineTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_socket.py0000644000076500000000000017432112666555342020756 0ustar jmaddenwheel00000000000000import unittest from test import test_support import errno import itertools import socket import select import time import traceback import Queue import sys import os import array import contextlib import signal import math import weakref try: import _socket except ImportError: _socket = None def try_address(host, port=0, family=socket.AF_INET): """Try to bind a socket on the given host:port and return True if that has been possible.""" try: sock = socket.socket(family, socket.SOCK_STREAM) sock.bind((host, port)) except (socket.error, socket.gaierror): return False else: sock.close() return True HOST = test_support.HOST MSG = b'Michael Gilfix was here\n' SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6) try: import thread import threading except ImportError: thread = None threading = None HOST = test_support.HOST MSG = 'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = test_support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceeded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) self.__setUp() if not self.server_ready.is_set(): self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() if not self.queue.empty(): msg = self.queue.get() self.fail(msg) def clientRun(self, test_func): self.server_ready.wait() self.clientSetUp() self.client_ready.set() if not callable(test_func): raise TypeError("test_func must be a callable function.") try: test_func() except Exception, strerror: self.queue.put(strerror) self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class SocketConnectedTest(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): @unittest.skipUnless(_socket is not None, 'need _socket module') def test_csocket_repr(self): s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) try: expected = ('' % (s.fileno(), s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) finally: s.close() expected = ('' % (s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = weakref.proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def test_weakref__sock(self): s = socket.socket()._sock w = weakref.ref(s) self.assertIs(w(), s) del s test_support.gc_collect() self.assertIsNone(w()) def testSocketError(self): # Testing socket module exceptions def raise_error(*args, **kwargs): raise socket.error def raise_herror(*args, **kwargs): raise socket.herror def raise_gaierror(*args, **kwargs): raise socket.gaierror self.assertRaises(socket.error, raise_error, "Error raising socket exception.") self.assertRaises(socket.error, raise_herror, "Error raising socket exception.") self.assertRaises(socket.error, raise_gaierror, "Error raising socket exception.") def testSendtoErrors(self): # Testing that sendto doens't masks failures. See #10169. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) s.bind(('', 0)) sockname = s.getsockname() # 2 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, sockname) self.assertIn('not complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None) self.assertIn('not NoneType', str(cm.exception)) # 3 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', 0, sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, 0, sockname) self.assertIn('not complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, None) self.assertIn('not NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 'bar', sockname) self.assertIn('an integer is required', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None, None) self.assertIn('an integer is required', str(cm.exception)) # wrong number of args with self.assertRaises(TypeError) as cm: s.sendto('foo') self.assertIn('(1 given)', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, sockname, 4) self.assertIn('(4 given)', str(cm.exception)) def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except socket.error: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except socket.error: # Probably a similar problem as above; skip this test self.skipTest('address lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: self.assertEqual(sys.getrefcount(__name__), orig, "socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except socket.error: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1L<= _testcapi.ULONG_MAX: self.skipTest('needs UINT_MAX < ULONG_MAX') self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) self.serv.setblocking(_testcapi.UINT_MAX + 1) self.assertIsNone(self.serv.gettimeout()) _testSetBlocking_overflow = test_support.cpython_only(_testSetBlocking) def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) try: conn, addr = self.serv.accept() except socket.error: pass else: self.fail("Error trying to do non-blocking accept.") read, write, err = select.select([self.serv], [], []) if self.serv in read: conn, addr = self.serv.accept() conn.close() else: self.fail("Error trying to do accept after select.") def _testAccept(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) def testConnect(self): # Testing non-blocking connect conn, addr = self.serv.accept() conn.close() def _testConnect(self): self.cli.settimeout(10) self.cli.connect((HOST, self.port)) def testRecv(self): # Testing non-blocking recv conn, addr = self.serv.accept() conn.setblocking(0) try: msg = conn.recv(len(MSG)) except socket.error: pass else: self.fail("Error trying to do non-blocking recv.") read, write, err = select.select([conn], [], []) if conn in read: msg = conn.recv(len(MSG)) conn.close() self.assertEqual(msg, MSG) else: self.fail("Error during select call to non-blocking socket.") def _testRecv(self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class FileObjectClassTestCase(SocketConnectedTest): bufsize = -1 # Use default buffer size def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def setUp(self): SocketConnectedTest.setUp(self) self.serv_file = self.cli_conn.makefile('rb', self.bufsize) def tearDown(self): self.serv_file.close() self.assertTrue(self.serv_file.closed) SocketConnectedTest.tearDown(self) self.serv_file = None def clientSetUp(self): SocketConnectedTest.clientSetUp(self) self.cli_file = self.serv_conn.makefile('wb') def clientTearDown(self): self.cli_file.close() self.assertTrue(self.cli_file.closed) self.cli_file = None SocketConnectedTest.clientTearDown(self) def testSmallRead(self): # Performing small file read test first_seg = self.serv_file.read(len(MSG)-3) second_seg = self.serv_file.read(3) msg = first_seg + second_seg self.assertEqual(msg, MSG) def _testSmallRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testFullRead(self): # read until EOF msg = self.serv_file.read() self.assertEqual(msg, MSG) def _testFullRead(self): self.cli_file.write(MSG) self.cli_file.close() def testUnbufferedRead(self): # Performing unbuffered file read test buf = '' while 1: char = self.serv_file.read(1) if not char: break buf += char self.assertEqual(buf, MSG) def _testUnbufferedRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadline(self): # Performing file readline test line = self.serv_file.readline() self.assertEqual(line, MSG) def _testReadline(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterRead(self): a_baloo_is = self.serv_file.read(len("A baloo is")) self.assertEqual("A baloo is", a_baloo_is) _a_bear = self.serv_file.read(len(" a bear")) self.assertEqual(" a bear", _a_bear) line = self.serv_file.readline() self.assertEqual("\n", line) line = self.serv_file.readline() self.assertEqual("A BALOO IS A BEAR.\n", line) line = self.serv_file.readline() self.assertEqual(MSG, line) def _testReadlineAfterRead(self): self.cli_file.write("A baloo is a bear\n") self.cli_file.write("A BALOO IS A BEAR.\n") self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterReadNoNewline(self): end_of_ = self.serv_file.read(len("End Of ")) self.assertEqual("End Of ", end_of_) line = self.serv_file.readline() self.assertEqual("Line", line) def _testReadlineAfterReadNoNewline(self): self.cli_file.write("End Of Line") def testClosedAttr(self): self.assertTrue(not self.serv_file.closed) def _testClosedAttr(self): self.assertTrue(not self.cli_file.closed) class FileObjectInterruptedTestCase(unittest.TestCase): """Test that the file object correctly handles EINTR internally.""" class MockSocket(object): def __init__(self, recv_funcs=()): # A generator that returns callables that we'll call for each # call to recv(). self._recv_step = iter(recv_funcs) def recv(self, size): return self._recv_step.next()() @staticmethod def _raise_eintr(): raise socket.error(errno.EINTR) def _test_readline(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.readline(size), "This is the first line\n") self.assertEqual(fo.readline(size), "And the second line is here\n") def _test_read(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.read(size), "This is the first line\n" "And the second line is here\n") def test_default(self): self._test_readline() self._test_readline(size=100) self._test_read() self._test_read(size=100) def test_with_1k_buffer(self): self._test_readline(bufsize=1024) self._test_readline(size=100, bufsize=1024) self._test_read(bufsize=1024) self._test_read(size=100, bufsize=1024) def _test_readline_no_buffer(self, size=-1): mock_sock = self.MockSocket(recv_funcs=[ lambda : "aa", lambda : "\n", lambda : "BB", self._raise_eintr, lambda : "bb", lambda : "", ]) fo = socket._fileobject(mock_sock, bufsize=0) self.assertEqual(fo.readline(size), "aa\n") self.assertEqual(fo.readline(size), "BBbb") def test_no_buffer(self): self._test_readline_no_buffer() self._test_readline_no_buffer(size=4) self._test_read(bufsize=0) self._test_read(size=100, bufsize=0) class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): """Repeat the tests from FileObjectClassTestCase with bufsize==0. In this case (and in this case only), it should be possible to create a file object, read a line from it, create another file object, read another line from it, without loss of data in the first file object's buffer. Note that httplib relies on this when reading multiple requests from the same socket.""" bufsize = 0 # Use unbuffered mode def testUnbufferedReadline(self): # Read a line, create a new file object, read another line with it line = self.serv_file.readline() # first line self.assertEqual(line, "A. " + MSG) # first line self.serv_file = self.cli_conn.makefile('rb', 0) line = self.serv_file.readline() # second line self.assertEqual(line, "B. " + MSG) # second line def _testUnbufferedReadline(self): self.cli_file.write("A. " + MSG) self.cli_file.write("B. " + MSG) self.cli_file.flush() class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 1 # Default-buffered for reading; line-buffered for writing class SocketMemo(object): """A wrapper to keep track of sent data, needed to examine write behaviour""" def __init__(self, sock): self._sock = sock self.sent = [] def send(self, data, flags=0): n = self._sock.send(data, flags) self.sent.append(data[:n]) return n def sendall(self, data, flags=0): self._sock.sendall(data, flags) self.sent.append(data) def __getattr__(self, attr): return getattr(self._sock, attr) def getsent(self): return [e.tobytes() if isinstance(e, memoryview) else e for e in self.sent] def setUp(self): FileObjectClassTestCase.setUp(self) self.serv_file._sock = self.SocketMemo(self.serv_file._sock) def testLinebufferedWrite(self): # Write two lines, in small chunks msg = MSG.strip() print >> self.serv_file, msg, print >> self.serv_file, msg # second line: print >> self.serv_file, msg, print >> self.serv_file, msg, print >> self.serv_file, msg # third line print >> self.serv_file, '' self.serv_file.flush() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3]) def _testLinebufferedWrite(self): msg = MSG.strip() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" l1 = self.cli_file.readline() self.assertEqual(l1, msg1) l2 = self.cli_file.readline() self.assertEqual(l2, msg2) l3 = self.cli_file.readline() self.assertEqual(l3, msg3) class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code class NetworkConnectionTest(object): """Prove network connection.""" def clientSetUp(self): # We're inherited below by BasicTCPTest2, which also inherits # BasicTCPTest, which defines self.port referenced below. self.cli = socket.create_connection((HOST, self.port)) self.serv_conn = self.cli class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): """Tests that NetworkConnection does not break existing TCP functionality. """ class NetworkConnectionNoServer(unittest.TestCase): class MockSocket(socket.socket): def connect(self, *args): raise socket.timeout('timed out') @contextlib.contextmanager def mocked_socket_module(self): """Return a socket which times out on connect""" old_socket = socket.socket import gevent.socket old_g_socket = gevent.socket.socket socket.socket = self.MockSocket gevent.socket.socket = self.MockSocket try: yield finally: socket.socket = old_socket gevent.socket.socket = old_g_socket def test_connect(self): port = test_support.find_unused_port() cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(cli.close) with self.assertRaises(socket.error) as cm: cli.connect((HOST, port)) self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection(self): # Issue #9792: errors raised by create_connection() should have # a proper errno attribute. port = test_support.find_unused_port() with self.assertRaises(socket.error) as cm: socket.create_connection((HOST, port)) # Issue #16257: create_connection() calls getaddrinfo() against # 'localhost'. This may result in an IPV6 addr being returned # as well as an IPV4 one: # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), # (26, 2, 0, '', ('::1', 41230, 0, 0))] # # create_connection() enumerates through all the addresses returned # and if it doesn't successfully bind to any of them, it propagates # the last exception it encountered. # # On Solaris, ENETUNREACH is returned in this circumstance instead # of ECONNREFUSED. So, if that errno exists, add it to our list of # expected errnos. expected_errnos = [ errno.ECONNREFUSED, ] if hasattr(errno, 'ENETUNREACH'): expected_errnos.append(errno.ENETUNREACH) self.assertIn(cm.exception.errno, expected_errnos) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors # as generic socket errors. with self.mocked_socket_module(): with self.assertRaises(socket.timeout): socket.create_connection((HOST, 1234)) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.source_port = test_support.find_unused_port() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def _justAccept(self): conn, addr = self.serv.accept() conn.close() testFamily = _justAccept def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.family, 2) testSourceAddress = _justAccept def _testSourceAddress(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.addCleanup(self.cli.close) self.assertEqual(self.cli.getsockname()[1], self.source_port) # The port number being used is sufficient to show that the bind() # call happened. testTimeoutDefault = _justAccept def _testTimeoutDefault(self): # passing no explicit timeout uses socket's global default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(42) try: self.cli = socket.create_connection((HOST, self.port)) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), 42) testTimeoutNone = _justAccept def _testTimeoutNone(self): # None timeout means the same as sock.settimeout(None) self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: self.cli = socket.create_connection((HOST, self.port), timeout=None) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), None) testTimeoutValueNamed = _justAccept def _testTimeoutValueNamed(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.gettimeout(), 30) testTimeoutValueNonamed = _justAccept def _testTimeoutValueNonamed(self): self.cli = socket.create_connection((HOST, self.port), 30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.gettimeout(), 30) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send("done!") testOutsideTimeout = testInsideTimeout def _testInsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port)) data = sock.recv(5) self.assertEqual(data, "done!") def _testOutsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port), timeout=1) self.assertRaises(socket.timeout, lambda: sock.recv(5)) class Urllib2FileobjectTest(unittest.TestCase): # urllib2.HTTPHandler has "borrowed" socket._fileobject, and requires that # it close the socket if the close c'tor argument is true def testClose(self): class MockSocket: closed = False def flush(self): pass def close(self): self.closed = True # must not close unless we request it: the original use of _fileobject # by module socket requires that the underlying socket not be closed until # the _socketobject that created the _fileobject is closed s = MockSocket() f = socket._fileobject(s) f.close() self.assertTrue(not s.closed) s = MockSocket() f = socket._fileobject(s, close=True) f.close() self.assertTrue(s.closed) class TCPTimeoutTest(SocketTCPTest): def testTCPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (TCP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of error (TCP)") except socket.error: ok = True except: self.fail("caught unexpected exception (TCP)") if not ok: self.fail("accept() returned success when we did not expect it") @unittest.skipUnless(hasattr(signal, 'alarm'), 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass def alarm_handler(signal, frame): raise Alarm old_alarm = signal.signal(signal.SIGALRM, alarm_handler) try: signal.alarm(2) # POSIX allows alarm to be up to 1 second early try: foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of Alarm") except Alarm: pass except: self.fail("caught other exception instead of Alarm:" " %s(%s):\n%s" % (sys.exc_info()[:2] + (traceback.format_exc(),))) else: self.fail("nothing caught") finally: signal.alarm(0) # shut off alarm except Alarm: self.fail("got Alarm in wrong place") finally: # no alarm can be pending. Safe to restore old handler. signal.signal(signal.SIGALRM, old_alarm) class UDPTimeoutTest(SocketUDPTest): def testUDPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.recv(1024) self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (UDP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.recv(1024) except socket.timeout: self.fail("caught timeout instead of error (UDP)") except socket.error: ok = True except: self.fail("caught unexpected exception (UDP)") if not ok: self.fail("recv() returned success when we did not expect it") class TestExceptions(unittest.TestCase): def testExceptionTree(self): self.assertTrue(issubclass(socket.error, Exception)) self.assertTrue(issubclass(socket.herror, socket.error)) self.assertTrue(issubclass(socket.gaierror, socket.error)) self.assertTrue(issubclass(socket.timeout, socket.error)) @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 def testLinuxAbstractNamespace(self): address = "\x00python-test-hello\x00\xff" s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s1.bind(address) s1.listen(1) s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s2.connect(s1.getsockname()) s1.accept() self.assertEqual(s1.getsockname(), address) self.assertEqual(s2.getpeername(), address) def testMaxName(self): address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.bind(address) self.assertEqual(s.getsockname(), address) def testNameOverflow(self): address = "\x00" + "h" * self.UNIX_PATH_MAX s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.assertRaises(socket.error, s.bind, address) @unittest.skipUnless(thread, 'Threading required for this test.') class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). """ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecvIntoArray(self): buf = array.array('c', ' '*1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvIntoBytearray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoBytearray = _testRecvIntoArray def testRecvIntoMemoryview(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoMemoryview = _testRecvIntoArray def testRecvFromIntoArray(self): buf = array.array('c', ' '*1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFromIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoBytearray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoBytearray = _testRecvFromIntoArray def testRecvFromIntoMemoryview(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoMemoryview = _testRecvFromIntoArray def testRecvFromIntoSmallBuffer(self): # See issue #20246. buf = bytearray(8) self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) def _testRecvFromIntoSmallBuffer(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoEmptyBuffer(self): buf = bytearray() self.cli_conn.recvfrom_into(buf) self.cli_conn.recvfrom_into(buf, 0) _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray TIPC_STYPE = 2000 TIPC_LOWER = 200 TIPC_UPPER = 210 def isTipcAvailable(): """Check if the TIPC module is loaded The TIPC module is not loaded automatically on Ubuntu and probably other Linux distros. """ if not hasattr(socket, "AF_TIPC"): return False if not os.path.isfile("/proc/modules"): return False with open("/proc/modules") as f: for line in f: if line.startswith("tipc "): return True return False @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCTest(unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) srv.bind(srvaddr) sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) cli.sendto(MSG, sendaddr) msg, recvaddr = srv.recvfrom(1024) self.assertEqual(cli.getsockname(), recvaddr) self.assertEqual(msg, MSG) @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCThreadableTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) def setUp(self): self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) self.srv.bind(srvaddr) self.srv.listen(5) self.serverExplicitReady() self.conn, self.connaddr = self.srv.accept() def clientSetUp(self): # The is a hittable race between serverExplicitReady() and the # accept() call; sleep a little while to avoid it, otherwise # we could get an exception time.sleep(0.1) self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) self.cli.connect(addr) self.cliaddr = self.cli.getsockname() def testStream(self): msg = self.conn.recv(1024) self.assertEqual(msg, MSG) self.assertEqual(self.cliaddr, self.connaddr) def _testStream(self): self.cli.send(MSG) self.cli.close() def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_socketserver.py0000644000076500000000000002637412666555342022211 0ustar jmaddenwheel00000000000000""" Test suite for SocketServer.py. """ import contextlib import imp import os import select import signal import socket import select import errno import tempfile import unittest import SocketServer import test.test_support from test.test_support import reap_children, reap_threads, verbose try: import threading except ImportError: threading = None test.test_support.requires("network") TEST_STR = "hello world\n" HOST = test.test_support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") requires_unix_sockets = unittest.skipUnless(HAVE_UNIX_SOCKETS, 'requires Unix sockets') HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" requires_forking = unittest.skipUnless(HAVE_FORKING, 'requires forking') def signal_alarm(n): """Call signal.alarm when it exists (i.e. not on Windows).""" if hasattr(signal, 'alarm'): signal.alarm(n) # Remember real select() to avoid interferences with mocking _real_select = select.select def receive(sock, n, timeout=20): r, w, x = _real_select([sock], [], [], timeout) if sock in r: return sock.recv(n) else: raise RuntimeError, "timed out on %r" % (sock,) if HAVE_UNIX_SOCKETS: class ForkingUnixStreamServer(SocketServer.ForkingMixIn, SocketServer.UnixStreamServer): pass class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, SocketServer.UnixDatagramServer): pass @contextlib.contextmanager def simple_subprocess(testcase): pid = os.fork() if pid == 0: # Don't raise an exception; it would be caught by the test harness. os._exit(72) yield None pid2, status = os.waitpid(pid, 0) testcase.assertEqual(pid2, pid) testcase.assertEqual(72 << 8, status) @unittest.skipUnless(threading, 'Threading required for this test.') class SocketServerTest(unittest.TestCase): """Test all socket servers.""" def setUp(self): signal_alarm(60) # Kill deadlocks after 60 seconds. self.port_seed = 0 self.test_files = [] def tearDown(self): signal_alarm(0) # Didn't deadlock. reap_children() for fn in self.test_files: try: os.remove(fn) except os.error: pass self.test_files[:] = [] def pickaddr(self, proto): if proto == socket.AF_INET: return (HOST, 0) else: # XXX: We need a way to tell AF_UNIX to pick its own name # like AF_INET provides port==0. dir = None if os.name == 'os2': dir = '\socket' fn = tempfile.mktemp(prefix='unix_socket.', dir=dir) if os.name == 'os2': # AF_UNIX socket names on OS/2 require a specific prefix # which can't include a drive letter and must also use # backslashes as directory separators if fn[1] == ':': fn = fn[2:] if fn[0] in (os.sep, os.altsep): fn = fn[1:] if os.sep == '/': fn = fn.replace(os.sep, os.altsep) else: fn = fn.replace(os.altsep, os.sep) self.test_files.append(fn) return fn def make_server(self, addr, svrcls, hdlrbase): class MyServer(svrcls): def handle_error(self, request, client_address): self.close_request(request) self.server_close() raise class MyHandler(hdlrbase): def handle(self): line = self.rfile.readline() self.wfile.write(line) if verbose: print "creating server" server = MyServer(addr, MyHandler) self.assertEqual(server.server_address, server.socket.getsockname()) return server @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) # We had the OS pick a port, so pull the real address out of # the server. addr = server.server_address if verbose: print "server created" print "ADDR =", addr print "CLASS =", svrcls t = threading.Thread( name='%s serving' % svrcls, target=server.serve_forever, # Short poll interval to make the test finish quickly. # Time between requests is short enough that we won't wake # up spuriously too many times. kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. t.start() if verbose: print "server running" for i in range(3): if verbose: print "test client", i testfunc(svrcls.address_family, addr) if verbose: print "waiting for server" server.shutdown() t.join() server.server_close() self.assertRaises(socket.error, server.socket.fileno) if verbose: print "done" def stream_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_STREAM) s.connect(addr) s.sendall(TEST_STR) buf = data = receive(s, 100) while data and '\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and '\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def test_TCPServer(self): self.run_server(SocketServer.TCPServer, SocketServer.StreamRequestHandler, self.stream_examine) def test_ThreadingTCPServer(self): self.run_server(SocketServer.ThreadingTCPServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_forking def test_ForkingTCPServer(self): with simple_subprocess(self): self.run_server(SocketServer.ForkingTCPServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_UnixStreamServer(self): self.run_server(SocketServer.UnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_ThreadingUnixStreamServer(self): self.run_server(SocketServer.ThreadingUnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets @requires_forking def test_ForkingUnixStreamServer(self): with simple_subprocess(self): self.run_server(ForkingUnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) def test_UDPServer(self): self.run_server(SocketServer.UDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) def test_ThreadingUDPServer(self): self.run_server(SocketServer.ThreadingUDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) @requires_forking def test_ForkingUDPServer(self): with simple_subprocess(self): self.run_server(SocketServer.ForkingUDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) @contextlib.contextmanager def mocked_select_module(self): """Mocks the select.select() call to raise EINTR for first call""" old_select = select.select class MockSelect: def __init__(self): self.called = 0 def __call__(self, *args): self.called += 1 if self.called == 1: # raise the exception on first call raise select.error(errno.EINTR, os.strerror(errno.EINTR)) else: # Return real select value for consecutive calls return old_select(*args) select.select = MockSelect() try: yield select.select finally: select.select = old_select def test_InterruptServerSelectCall(self): with self.mocked_select_module() as mock_select: pid = self.run_server(SocketServer.TCPServer, SocketServer.StreamRequestHandler, self.stream_examine) # Make sure select was called again: self.assertGreater(mock_select.called, 1) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: # @requires_unix_sockets # def test_UnixDatagramServer(self): # self.run_server(SocketServer.UnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # @requires_unix_sockets # def test_ThreadingUnixDatagramServer(self): # self.run_server(SocketServer.ThreadingUnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # @requires_unix_sockets # @requires_forking # def test_ForkingUnixDatagramServer(self): # self.run_server(SocketServer.ForkingUnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) @reap_threads def test_shutdown(self): # Issue #2302: shutdown() should always succeed in making an # other thread leave serve_forever(). class MyServer(SocketServer.TCPServer): pass class MyHandler(SocketServer.StreamRequestHandler): pass threads = [] for i in range(20): s = MyServer((HOST, 0), MyHandler) t = threading.Thread( name='MyServer serving', target=s.serve_forever, kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. threads.append((t, s)) for t, s in threads: t.start() s.shutdown() for t, s in threads: t.join() def test_tcpserver_bind_leak(self): # Issue #22435: the server socket wouldn't be closed if bind()/listen() # failed. # Create many servers for which bind() will fail, to see if this result # in FD exhaustion. for i in range(1024): with self.assertRaises(OverflowError): SocketServer.TCPServer((HOST, -1), SocketServer.StreamRequestHandler) def test_main(): if imp.lock_held(): # If the import lock is held, the threads will hang raise unittest.SkipTest("can't run when import lock is held") test.test_support.run_unittest(SocketServerTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_ssl.py0000644000076500000000000041732312666555342020271 0ustar jmaddenwheel00000000000000# -*- coding: utf-8 -*- # Test the support for SSL and sockets import sys import unittest from test import test_support as support import asyncore import socket import select import time import datetime import gc import os import errno import pprint import tempfile import urllib2 import traceback import weakref import platform import functools from contextlib import closing ssl = support.import_module("ssl") PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) HOST = support.HOST def data_file(*name): return os.path.join(os.path.dirname(__file__), *name) # The custom key and certificate files used in test_ssl are generated # using Lib/test/make_ssl_certs.py. # Other certificates are simply fetched from the Internet servers they # are meant to authenticate. CERTFILE = data_file("keycert.pem") BYTES_CERTFILE = CERTFILE.encode(sys.getfilesystemencoding()) ONLYCERT = data_file("ssl_cert.pem") ONLYKEY = data_file("ssl_key.pem") BYTES_ONLYCERT = ONLYCERT.encode(sys.getfilesystemencoding()) BYTES_ONLYKEY = ONLYKEY.encode(sys.getfilesystemencoding()) CERTFILE_PROTECTED = data_file("keycert.passwd.pem") ONLYKEY_PROTECTED = data_file("ssl_key.passwd.pem") KEY_PASSWORD = "somepass" CAPATH = data_file("capath") BYTES_CAPATH = CAPATH.encode(sys.getfilesystemencoding()) CAFILE_NEURONIO = data_file("capath", "4e1295a3.0") CAFILE_CACERT = data_file("capath", "5ed36f99.0") # empty CRL CRLFILE = data_file("revocation.crl") # Two keys and certs signed by the same CA (for SNI tests) SIGNED_CERTFILE = data_file("keycert3.pem") SIGNED_CERTFILE2 = data_file("keycert4.pem") SIGNING_CA = data_file("pycacert.pem") REMOTE_HOST = "self-signed.pythontest.net" REMOTE_ROOT_CERT = data_file("selfsigned_pythontestdotnet.pem") EMPTYCERT = data_file("nullcert.pem") BADCERT = data_file("badcert.pem") NONEXISTINGCERT = data_file("XXXnonexisting.pem") BADKEY = data_file("badkey.pem") NOKIACERT = data_file("nokia.pem") NULLBYTECERT = data_file("nullbytecert.pem") DHFILE = data_file("dh1024.pem") BYTES_DHFILE = DHFILE.encode(sys.getfilesystemencoding()) def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) if support.verbose: sys.stdout.write(prefix + exc_format) class BasicTests(unittest.TestCase): def test_sslwrap_simple(self): # A crude test for the legacy API try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise def can_clear_options(): # 0.9.8m or higher return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15) def no_sslv2_implies_sslv3_hello(): # 0.9.7h or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15) def have_verify_flags(): # 0.9.8 or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 0, 15) def utc_offset(): #NOTE: ignore issues like #1647654 # local time = utc time + utc offset if time.daylight and time.localtime().tm_isdst > 0: return -time.altzone # seconds return -time.timezone def asn1time(cert_time): # Some versions of OpenSSL ignore seconds, see #18207 # 0.9.8.i if ssl._OPENSSL_API_VERSION == (0, 9, 8, 9, 15): fmt = "%b %d %H:%M:%S %Y GMT" dt = datetime.datetime.strptime(cert_time, fmt) dt = dt.replace(second=0) cert_time = dt.strftime(fmt) # %d adds leading zero but ASN1_TIME_print() uses leading space if cert_time[4] == "0": cert_time = cert_time[:4] + " " + cert_time[5:] return cert_time # Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2 def skip_if_broken_ubuntu_ssl(func): if hasattr(ssl, 'PROTOCOL_SSLv2'): @functools.wraps(func) def f(*args, **kwargs): try: ssl.SSLContext(ssl.PROTOCOL_SSLv2) except ssl.SSLError: if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and platform.linux_distribution() == ('debian', 'squeeze/sid', '')): raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour") return func(*args, **kwargs) return f else: return func needs_sni = unittest.skipUnless(ssl.HAS_SNI, "SNI support needed for this test") class BasicSocketTests(unittest.TestCase): def test_constants(self): ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED ssl.OP_CIPHER_SERVER_PREFERENCE ssl.OP_SINGLE_DH_USE if ssl.HAS_ECDH: ssl.OP_SINGLE_ECDH_USE if ssl.OPENSSL_VERSION_INFO >= (1, 0): ssl.OP_NO_COMPRESSION self.assertIn(ssl.HAS_SNI, {True, False}) self.assertIn(ssl.HAS_ECDH, {True, False}) def test_random(self): v = ssl.RAND_status() if support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) if hasattr(ssl, 'RAND_egd'): self.assertRaises(TypeError, ssl.RAND_egd, 1) self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) ssl.RAND_add("this is a random string", 75.0) def test_parse_cert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['issuer'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) # Note the next three asserts will fail if the keys are regenerated self.assertEqual(p['notAfter'], asn1time('Oct 5 23:01:56 2020 GMT')) self.assertEqual(p['notBefore'], asn1time('Oct 8 23:01:56 2010 GMT')) self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') self.assertEqual(p['subject'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) # Issue #13034: the subjectAltName in some certificates # (notably projects.developer.nokia.com:443) wasn't parsed p = ssl._ssl._test_decode_cert(NOKIACERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subjectAltName'], (('DNS', 'projects.developer.nokia.com'), ('DNS', 'projects.forum.nokia.com')) ) # extra OCSP and AIA fields self.assertEqual(p['OCSP'], ('http://ocsp.verisign.com',)) self.assertEqual(p['caIssuers'], ('http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cer',)) self.assertEqual(p['crlDistributionPoints'], ('http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl',)) def test_parse_cert_CVE_2013_4238(self): p = ssl._ssl._test_decode_cert(NULLBYTECERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") subject = ((('countryName', 'US'),), (('stateOrProvinceName', 'Oregon'),), (('localityName', 'Beaverton'),), (('organizationName', 'Python Software Foundation'),), (('organizationalUnitName', 'Python Core Development'),), (('commonName', 'null.python.org\x00example.org'),), (('emailAddress', 'python-dev@python.org'),)) self.assertEqual(p['subject'], subject) self.assertEqual(p['issuer'], subject) if ssl._OPENSSL_API_VERSION >= (0, 9, 8): san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '2001:DB8:0:0:0:0:0:1\n')) else: # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '')) self.assertEqual(p['subjectAltName'], san) def test_DER_to_PEM(self): with open(CAFILE_CACERT, 'r') as f: pem = f.read() d1 = ssl.PEM_cert_to_DER_cert(pem) p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) self.assertEqual(d1, d2) if not p2.startswith(ssl.PEM_HEADER + '\n'): self.fail("DER-to-PEM didn't include correct header:\n%r\n" % p2) if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'): self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2) def test_openssl_version(self): n = ssl.OPENSSL_VERSION_NUMBER t = ssl.OPENSSL_VERSION_INFO s = ssl.OPENSSL_VERSION self.assertIsInstance(n, (int, long)) self.assertIsInstance(t, tuple) self.assertIsInstance(s, str) # Some sanity checks follow # >= 0.9 self.assertGreaterEqual(n, 0x900000) # < 3.0 self.assertLess(n, 0x30000000) major, minor, fix, patch, status = t self.assertGreaterEqual(major, 0) self.assertLess(major, 3) self.assertGreaterEqual(minor, 0) self.assertLess(minor, 256) self.assertGreaterEqual(fix, 0) self.assertLess(fix, 256) self.assertGreaterEqual(patch, 0) self.assertLessEqual(patch, 63) self.assertGreaterEqual(status, 0) self.assertLessEqual(status, 15) # Version string as returned by {Open,Libre}SSL, the format might change if "LibreSSL" in s: self.assertTrue(s.startswith("LibreSSL {:d}.{:d}".format(major, minor)), (s, t)) else: self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), (s, t)) @support.cpython_only def test_refcycle(self): # Issue #7943: an SSL object doesn't create reference cycles with # itself. s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) del ss self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # Methods on an unconnected SSLSocket propagate the original # socket.error raise by the underlying socket object. s = socket.socket(socket.AF_INET) with closing(ssl.wrap_socket(s)) as ss: self.assertRaises(socket.error, ss.recv, 1) self.assertRaises(socket.error, ss.recv_into, bytearray(b'x')) self.assertRaises(socket.error, ss.recvfrom, 1) self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1) self.assertRaises(socket.error, ss.send, b'x') self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0)) def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the # original socket should be retained. for timeout in (None, 0.0, 5.0): s = socket.socket(socket.AF_INET) s.settimeout(timeout) with closing(ssl.wrap_socket(s)) as ss: self.assertEqual(timeout, ss.gettimeout()) def test_errors(self): sock = socket.socket() self.assertRaisesRegexp(ValueError, "certfile must be specified", ssl.wrap_socket, sock, keyfile=CERTFILE) self.assertRaisesRegexp(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True) self.assertRaisesRegexp(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True, certfile="") with closing(ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)) as s: self.assertRaisesRegexp(ValueError, "can't connect in server-side mode", s.connect, (HOST, 8080)) with self.assertRaises(IOError) as cm: with closing(socket.socket()) as sock: ssl.wrap_socket(sock, certfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(IOError) as cm: with closing(socket.socket()) as sock: ssl.wrap_socket(sock, certfile=CERTFILE, keyfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(IOError) as cm: with closing(socket.socket()) as sock: ssl.wrap_socket(sock, certfile=NONEXISTINGCERT, keyfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) def bad_cert_test(self, certfile): """Check that trying to use the given client certificate fails""" certfile = os.path.join(os.path.dirname(__file__) or os.curdir, certfile) sock = socket.socket() self.addCleanup(sock.close) with self.assertRaises(ssl.SSLError): ssl.wrap_socket(sock, certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) def test_empty_cert(self): """Wrapping with an empty cert file""" self.bad_cert_test("nullcert.pem") def test_malformed_cert(self): """Wrapping with a badly formatted certificate (syntax error)""" self.bad_cert_test("badcert.pem") def test_malformed_key(self): """Wrapping with a badly formatted key (syntax error)""" self.bad_cert_test("badkey.pem") def test_match_hostname(self): def ok(cert, hostname): ssl.match_hostname(cert, hostname) def fail(cert, hostname): self.assertRaises(ssl.CertificateError, ssl.match_hostname, cert, hostname) cert = {'subject': ((('commonName', 'example.com'),),)} ok(cert, 'example.com') ok(cert, 'ExAmple.cOm') fail(cert, 'www.example.com') fail(cert, '.example.com') fail(cert, 'example.org') fail(cert, 'exampleXcom') cert = {'subject': ((('commonName', '*.a.com'),),)} ok(cert, 'foo.a.com') fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') # only match one left-most wildcard cert = {'subject': ((('commonName', 'f*.com'),),)} ok(cert, 'foo.com') ok(cert, 'f.com') fail(cert, 'bar.com') fail(cert, 'foo.a.com') fail(cert, 'bar.foo.com') # NULL bytes are bad, CVE-2013-4073 cert = {'subject': ((('commonName', 'null.python.org\x00example.org'),),)} ok(cert, 'null.python.org\x00example.org') # or raise an error? fail(cert, 'example.org') fail(cert, 'null.python.org') # error cases with wildcards cert = {'subject': ((('commonName', '*.*.a.com'),),)} fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') cert = {'subject': ((('commonName', 'a.*.com'),),)} fail(cert, 'a.foo.com') fail(cert, 'a..com') fail(cert, 'a.com') # wildcard doesn't match IDNA prefix 'xn--' idna = u'püthon.python.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, idna) cert = {'subject': ((('commonName', 'x*.python.org'),),)} fail(cert, idna) cert = {'subject': ((('commonName', 'xn--p*.python.org'),),)} fail(cert, idna) # wildcard in first fragment and IDNA A-labels in sequent fragments # are supported. idna = u'www*.pythön.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, u'www.pythön.org'.encode("idna").decode("ascii")) ok(cert, u'www1.pythön.org'.encode("idna").decode("ascii")) fail(cert, u'ftp.pythön.org'.encode("idna").decode("ascii")) fail(cert, u'pythön.org'.encode("idna").decode("ascii")) # Slightly fake real-world example cert = {'notAfter': 'Jun 26 21:41:46 2011 GMT', 'subject': ((('commonName', 'linuxfrz.org'),),), 'subjectAltName': (('DNS', 'linuxfr.org'), ('DNS', 'linuxfr.com'), ('othername', ''))} ok(cert, 'linuxfr.org') ok(cert, 'linuxfr.com') # Not a "DNS" entry fail(cert, '') # When there is a subjectAltName, commonName isn't used fail(cert, 'linuxfrz.org') # A pristine real-world example cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),), (('commonName', 'mail.google.com'),))} ok(cert, 'mail.google.com') fail(cert, 'gmail.com') # Only commonName is considered fail(cert, 'California') # Neither commonName nor subjectAltName cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),))} fail(cert, 'mail.google.com') # No DNS entry in subjectAltName but a commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('commonName', 'mail.google.com'),)), 'subjectAltName': (('othername', 'blabla'), )} ok(cert, 'mail.google.com') # No DNS entry subjectAltName and no commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),)), 'subjectAltName': (('othername', 'blabla'),)} fail(cert, 'google.com') # Empty cert / no cert self.assertRaises(ValueError, ssl.match_hostname, None, 'example.com') self.assertRaises(ValueError, ssl.match_hostname, {}, 'example.com') # Issue #17980: avoid denials of service by refusing more than one # wildcard per fragment. cert = {'subject': ((('commonName', 'a*b.com'),),)} ok(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b.co*'),),)} fail(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b*.com'),),)} with self.assertRaises(ssl.CertificateError) as cm: ssl.match_hostname(cert, 'axxbxxc.com') self.assertIn("too many wildcards", str(cm.exception)) def test_server_side(self): # server_hostname doesn't work for server sockets ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with closing(socket.socket()) as sock: self.assertRaises(ValueError, ctx.wrap_socket, sock, True, server_hostname="some.hostname") def test_unknown_channel_binding(self): # should raise ValueError for unknown type s = socket.socket(socket.AF_INET) with closing(ssl.wrap_socket(s)) as ss: with self.assertRaises(ValueError): ss.get_channel_binding("unknown-type") @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): # unconnected should return None for known type s = socket.socket(socket.AF_INET) with closing(ssl.wrap_socket(s)) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) # the same for server-side s = socket.socket(socket.AF_INET) with closing(ssl.wrap_socket(s, server_side=True, certfile=CERTFILE)) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) def test_get_default_verify_paths(self): paths = ssl.get_default_verify_paths() self.assertEqual(len(paths), 6) self.assertIsInstance(paths, ssl.DefaultVerifyPaths) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE paths = ssl.get_default_verify_paths() self.assertEqual(paths.cafile, CERTFILE) self.assertEqual(paths.capath, CAPATH) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_certificates(self): self.assertTrue(ssl.enum_certificates("CA")) self.assertTrue(ssl.enum_certificates("ROOT")) self.assertRaises(TypeError, ssl.enum_certificates) self.assertRaises(WindowsError, ssl.enum_certificates, "") trust_oids = set() for storename in ("CA", "ROOT"): store = ssl.enum_certificates(storename) self.assertIsInstance(store, list) for element in store: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 3) cert, enc, trust = element self.assertIsInstance(cert, bytes) self.assertIn(enc, {"x509_asn", "pkcs_7_asn"}) self.assertIsInstance(trust, (set, bool)) if isinstance(trust, set): trust_oids.update(trust) serverAuth = "1.3.6.1.5.5.7.3.1" self.assertIn(serverAuth, trust_oids) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_crls(self): self.assertTrue(ssl.enum_crls("CA")) self.assertRaises(TypeError, ssl.enum_crls) self.assertRaises(WindowsError, ssl.enum_crls, "") crls = ssl.enum_crls("CA") self.assertIsInstance(crls, list) for element in crls: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 2) self.assertIsInstance(element[0], bytes) self.assertIn(element[1], {"x509_asn", "pkcs_7_asn"}) def test_asn1object(self): expected = (129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertEqual(val, expected) self.assertEqual(val.nid, 129) self.assertEqual(val.shortname, 'serverAuth') self.assertEqual(val.longname, 'TLS Web Server Authentication') self.assertEqual(val.oid, '1.3.6.1.5.5.7.3.1') self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object, 'serverAuth') val = ssl._ASN1Object.fromnid(129) self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object.fromnid, -1) with self.assertRaisesRegexp(ValueError, "unknown NID 100000"): ssl._ASN1Object.fromnid(100000) for i in range(1000): try: obj = ssl._ASN1Object.fromnid(i) except ValueError: pass else: self.assertIsInstance(obj.nid, int) self.assertIsInstance(obj.shortname, str) self.assertIsInstance(obj.longname, str) self.assertIsInstance(obj.oid, (str, type(None))) val = ssl._ASN1Object.fromname('TLS Web Server Authentication') self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertEqual(ssl._ASN1Object.fromname('serverAuth'), expected) self.assertEqual(ssl._ASN1Object.fromname('1.3.6.1.5.5.7.3.1'), expected) with self.assertRaisesRegexp(ValueError, "unknown object 'serverauth'"): ssl._ASN1Object.fromname('serverauth') def test_purpose_enum(self): val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertIsInstance(ssl.Purpose.SERVER_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.SERVER_AUTH, val) self.assertEqual(ssl.Purpose.SERVER_AUTH.nid, 129) self.assertEqual(ssl.Purpose.SERVER_AUTH.shortname, 'serverAuth') self.assertEqual(ssl.Purpose.SERVER_AUTH.oid, '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.2') self.assertIsInstance(ssl.Purpose.CLIENT_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.CLIENT_AUTH, val) self.assertEqual(ssl.Purpose.CLIENT_AUTH.nid, 130) self.assertEqual(ssl.Purpose.CLIENT_AUTH.shortname, 'clientAuth') self.assertEqual(ssl.Purpose.CLIENT_AUTH.oid, '1.3.6.1.5.5.7.3.2') def test_unsupported_dtls(self): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) with self.assertRaises(NotImplementedError) as cx: ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE) self.assertEqual(str(cx.exception), "only stream sockets are supported") ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with self.assertRaises(NotImplementedError) as cx: ctx.wrap_socket(s) self.assertEqual(str(cx.exception), "only stream sockets are supported") def cert_time_ok(self, timestring, timestamp): self.assertEqual(ssl.cert_time_to_seconds(timestring), timestamp) def cert_time_fail(self, timestring): with self.assertRaises(ValueError): ssl.cert_time_to_seconds(timestring) @unittest.skipUnless(utc_offset(), 'local time needs to be different from UTC') def test_cert_time_to_seconds_timezone(self): # Issue #19940: ssl.cert_time_to_seconds() returns wrong # results if local timezone is not UTC self.cert_time_ok("May 9 00:00:00 2007 GMT", 1178668800.0) self.cert_time_ok("Jan 5 09:34:43 2018 GMT", 1515144883.0) def test_cert_time_to_seconds(self): timestring = "Jan 5 09:34:43 2018 GMT" ts = 1515144883.0 self.cert_time_ok(timestring, ts) # accept keyword parameter, assert its name self.assertEqual(ssl.cert_time_to_seconds(cert_time=timestring), ts) # accept both %e and %d (space or zero generated by strftime) self.cert_time_ok("Jan 05 09:34:43 2018 GMT", ts) # case-insensitive self.cert_time_ok("JaN 5 09:34:43 2018 GmT", ts) self.cert_time_fail("Jan 5 09:34 2018 GMT") # no seconds self.cert_time_fail("Jan 5 09:34:43 2018") # no GMT self.cert_time_fail("Jan 5 09:34:43 2018 UTC") # not GMT timezone self.cert_time_fail("Jan 35 09:34:43 2018 GMT") # invalid day self.cert_time_fail("Jon 5 09:34:43 2018 GMT") # invalid month self.cert_time_fail("Jan 5 24:00:00 2018 GMT") # invalid hour self.cert_time_fail("Jan 5 09:60:43 2018 GMT") # invalid minute newyear_ts = 1230768000.0 # leap seconds self.cert_time_ok("Dec 31 23:59:60 2008 GMT", newyear_ts) # same timestamp self.cert_time_ok("Jan 1 00:00:00 2009 GMT", newyear_ts) self.cert_time_ok("Jan 5 09:34:59 2018 GMT", 1515144899) # allow 60th second (even if it is not a leap second) self.cert_time_ok("Jan 5 09:34:60 2018 GMT", 1515144900) # allow 2nd leap second for compatibility with time.strptime() self.cert_time_ok("Jan 5 09:34:61 2018 GMT", 1515144901) self.cert_time_fail("Jan 5 09:34:62 2018 GMT") # invalid seconds # no special treatement for the special value: # 99991231235959Z (rfc 5280) self.cert_time_ok("Dec 31 23:59:59 9999 GMT", 253402300799.0) @support.run_with_locale('LC_ALL', '') def test_cert_time_to_seconds_locale(self): # `cert_time_to_seconds()` should be locale independent def local_february_name(): return time.strftime('%b', (1, 2, 3, 4, 5, 6, 0, 0, 0)) if local_february_name().lower() == 'feb': self.skipTest("locale-specific month name needs to be " "different from C locale") # locale-independent self.cert_time_ok("Feb 9 00:00:00 2007 GMT", 1170979200.0) self.cert_time_fail(local_february_name() + " 9 00:00:00 2007 GMT") class ContextTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_constructor(self): for protocol in PROTOCOLS: ssl.SSLContext(protocol) self.assertRaises(TypeError, ssl.SSLContext) self.assertRaises(ValueError, ssl.SSLContext, -1) self.assertRaises(ValueError, ssl.SSLContext, 42) @skip_if_broken_ubuntu_ssl def test_protocol(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.protocol, proto) def test_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") @skip_if_broken_ubuntu_ssl def test_options(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3, ctx.options) ctx.options |= ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1, ctx.options) if can_clear_options(): ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3, ctx.options) ctx.options = 0 self.assertEqual(0, ctx.options) else: with self.assertRaises(ValueError): ctx.options = 0 def test_verify_mode(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Default value self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) ctx.verify_mode = ssl.CERT_OPTIONAL self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL) ctx.verify_mode = ssl.CERT_REQUIRED self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) ctx.verify_mode = ssl.CERT_NONE self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) with self.assertRaises(TypeError): ctx.verify_mode = None with self.assertRaises(ValueError): ctx.verify_mode = 42 @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_verify_flags(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # default value tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT | tf) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_CHAIN self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_CHAIN) ctx.verify_flags = ssl.VERIFY_DEFAULT self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT) # supports any value ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT) with self.assertRaises(TypeError): ctx.verify_flags = None def test_load_cert_chain(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Combined key and cert in a single file ctx.load_cert_chain(CERTFILE, keyfile=None) ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE) self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE) with self.assertRaises(IOError) as cm: ctx.load_cert_chain(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(BADCERT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(EMPTYCERT) # Separate key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_cert_chain(ONLYCERT, ONLYKEY) ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY) ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYCERT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYKEY) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT) # Mismatching key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaisesRegexp(ssl.SSLError, "key values mismatch"): ctx.load_cert_chain(CAFILE_CACERT, ONLYKEY) # Password protected key and cert ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD) ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD.encode()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=bytearray(KEY_PASSWORD.encode())) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD.encode()) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, bytearray(KEY_PASSWORD.encode())) with self.assertRaisesRegexp(TypeError, "should be a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=True) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password="badpass") with self.assertRaisesRegexp(ValueError, "cannot be longer"): # openssl has a fixed limit on the password buffer. # PEM_BUFSIZE is generally set to 1kb. # Return a string larger than this. ctx.load_cert_chain(CERTFILE_PROTECTED, password=b'a' * 102400) # Password callback def getpass_unicode(): return KEY_PASSWORD def getpass_bytes(): return KEY_PASSWORD.encode() def getpass_bytearray(): return bytearray(KEY_PASSWORD.encode()) def getpass_badpass(): return "badpass" def getpass_huge(): return b'a' * (1024 * 1024) def getpass_bad_type(): return 9 def getpass_exception(): raise Exception('getpass error') class GetPassCallable: def __call__(self): return KEY_PASSWORD def getpass(self): return KEY_PASSWORD ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_unicode) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytes) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytearray) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable().getpass) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_badpass) with self.assertRaisesRegexp(ValueError, "cannot be longer"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_huge) with self.assertRaisesRegexp(TypeError, "must return a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bad_type) with self.assertRaisesRegexp(Exception, "getpass error"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_exception) # Make sure the password function isn't called if it isn't needed ctx.load_cert_chain(CERTFILE, password=getpass_exception) def test_load_verify_locations(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(CERTFILE) ctx.load_verify_locations(cafile=CERTFILE, capath=None) ctx.load_verify_locations(BYTES_CERTFILE) ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None) ctx.load_verify_locations(cafile=BYTES_CERTFILE.decode('utf-8')) self.assertRaises(TypeError, ctx.load_verify_locations) self.assertRaises(TypeError, ctx.load_verify_locations, None, None, None) with self.assertRaises(IOError) as cm: ctx.load_verify_locations(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(IOError): ctx.load_verify_locations(u'') with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_verify_locations(BADCERT) ctx.load_verify_locations(CERTFILE, CAPATH) ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH) # Issue #10989: crash if the second argument type is invalid self.assertRaises(TypeError, ctx.load_verify_locations, None, True) def test_load_verify_cadata(self): # test cadata with open(CAFILE_CACERT) as f: cacert_pem = f.read().decode("ascii") cacert_der = ssl.PEM_cert_to_DER_cert(cacert_pem) with open(CAFILE_NEURONIO) as f: neuronio_pem = f.read().decode("ascii") neuronio_der = ssl.PEM_cert_to_DER_cert(neuronio_pem) # test PEM ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 0) ctx.load_verify_locations(cadata=cacert_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 1) ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = "\n".join((cacert_pem, neuronio_pem)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # with junk around the certs ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = ["head", cacert_pem, "other", neuronio_pem, "again", neuronio_pem, "tail"] ctx.load_verify_locations(cadata="\n".join(combined)) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # test DER ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(cadata=cacert_der) ctx.load_verify_locations(cadata=neuronio_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=cacert_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = b"".join((cacert_der, neuronio_der)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # error cases ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_verify_locations, cadata=object) with self.assertRaisesRegexp(ssl.SSLError, "no start line"): ctx.load_verify_locations(cadata=u"broken") with self.assertRaisesRegexp(ssl.SSLError, "not enough data"): ctx.load_verify_locations(cadata=b"broken") def test_load_dh_params(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_dh_params(DHFILE) if os.name != 'nt': ctx.load_dh_params(BYTES_DHFILE) self.assertRaises(TypeError, ctx.load_dh_params) self.assertRaises(TypeError, ctx.load_dh_params, None) with self.assertRaises(IOError) as cm: ctx.load_dh_params(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) @skip_if_broken_ubuntu_ssl def test_session_stats(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.session_stats(), { 'number': 0, 'connect': 0, 'connect_good': 0, 'connect_renegotiate': 0, 'accept': 0, 'accept_good': 0, 'accept_renegotiate': 0, 'hits': 0, 'misses': 0, 'timeouts': 0, 'cache_full': 0, }) def test_set_default_verify_paths(self): # There's not much we can do to test that it acts as expected, # so just check it doesn't crash or raise an exception. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_default_verify_paths() @unittest.skipUnless(ssl.HAS_ECDH, "ECDH disabled on this OpenSSL build") def test_set_ecdh_curve(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ecdh_curve("prime256v1") ctx.set_ecdh_curve(b"prime256v1") self.assertRaises(TypeError, ctx.set_ecdh_curve) self.assertRaises(TypeError, ctx.set_ecdh_curve, None) self.assertRaises(ValueError, ctx.set_ecdh_curve, "foo") self.assertRaises(ValueError, ctx.set_ecdh_curve, b"foo") @needs_sni def test_sni_callback(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # set_servername_callback expects a callable, or None self.assertRaises(TypeError, ctx.set_servername_callback) self.assertRaises(TypeError, ctx.set_servername_callback, 4) self.assertRaises(TypeError, ctx.set_servername_callback, "") self.assertRaises(TypeError, ctx.set_servername_callback, ctx) def dummycallback(sock, servername, ctx): pass ctx.set_servername_callback(None) ctx.set_servername_callback(dummycallback) @needs_sni def test_sni_callback_refcycle(self): # Reference cycles through the servername callback are detected # and cleared. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) def dummycallback(sock, servername, ctx, cycle=ctx): pass ctx.set_servername_callback(dummycallback) wr = weakref.ref(ctx) del ctx, dummycallback gc.collect() self.assertIs(wr(), None) def test_cert_store_stats(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_cert_chain(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 1}) ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 1, 'crl': 0, 'x509': 2}) def test_get_ca_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.get_ca_certs(), []) # CERTFILE is not flagged as X509v3 Basic Constraints: CA:TRUE ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.get_ca_certs(), []) # but CAFILE_CACERT is a CA cert ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.get_ca_certs(), [{'issuer': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'notAfter': asn1time('Mar 29 12:29:49 2033 GMT'), 'notBefore': asn1time('Mar 30 12:29:49 2003 GMT'), 'serialNumber': '00', 'crlDistributionPoints': ('https://www.cacert.org/revoke.crl',), 'subject': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'version': 3}]) with open(CAFILE_CACERT) as f: pem = f.read() der = ssl.PEM_cert_to_DER_cert(pem) self.assertEqual(ctx.get_ca_certs(True), [der]) def test_load_default_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.SERVER_AUTH) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.CLIENT_AUTH) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_default_certs, None) self.assertRaises(TypeError, ctx.load_default_certs, 'SERVER_AUTH') @unittest.skipIf(sys.platform == "win32", "not-Windows specific") def test_load_default_certs_env(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() self.assertEqual(ctx.cert_store_stats(), {"crl": 0, "x509": 1, "x509_ca": 0}) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_load_default_certs_env_windows(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() stats = ctx.cert_store_stats() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() stats["x509"] += 1 self.assertEqual(ctx.cert_store_stats(), stats) def test_create_default_context(self): ctx = ssl.create_default_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) with open(SIGNING_CA) as f: cadata = f.read().decode("ascii") ctx = ssl.create_default_context(cafile=SIGNING_CA, capath=CAPATH, cadata=cadata) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_DH_USE", 0), getattr(ssl, "OP_SINGLE_DH_USE", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_ECDH_USE", 0), getattr(ssl, "OP_SINGLE_ECDH_USE", 0), ) def test__create_stdlib_context(self): ctx = ssl._create_stdlib_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertFalse(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1, cert_reqs=ssl.CERT_REQUIRED, check_hostname=True) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(purpose=ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) def test_check_hostname(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertFalse(ctx.check_hostname) # Requires CERT_REQUIRED or CERT_OPTIONAL with self.assertRaises(ValueError): ctx.check_hostname = True ctx.verify_mode = ssl.CERT_REQUIRED self.assertFalse(ctx.check_hostname) ctx.check_hostname = True self.assertTrue(ctx.check_hostname) ctx.verify_mode = ssl.CERT_OPTIONAL ctx.check_hostname = True self.assertTrue(ctx.check_hostname) # Cannot set CERT_NONE with check_hostname enabled with self.assertRaises(ValueError): ctx.verify_mode = ssl.CERT_NONE ctx.check_hostname = False self.assertFalse(ctx.check_hostname) class SSLErrorTests(unittest.TestCase): def test_str(self): # The str() of a SSLError doesn't include the errno e = ssl.SSLError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) # Same for a subclass e = ssl.SSLZeroReturnError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) def test_lib_reason(self): # Test the library and reason attributes ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) self.assertEqual(cm.exception.library, 'PEM') self.assertEqual(cm.exception.reason, 'NO_START_LINE') s = str(cm.exception) self.assertTrue(s.startswith("[PEM: NO_START_LINE] no start line"), s) def test_subclass(self): # Check that the appropriate SSLError subclass is raised # (this only tests one of them) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with closing(socket.socket()) as s: s.bind(("127.0.0.1", 0)) s.listen(5) c = socket.socket() c.connect(s.getsockname()) c.setblocking(False) with closing(ctx.wrap_socket(c, False, do_handshake_on_connect=False)) as c: with self.assertRaises(ssl.SSLWantReadError) as cm: c.do_handshake() s = str(cm.exception) self.assertTrue(s.startswith("The operation did not complete (read)"), s) # For compatibility self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ) class NetworkedTests(unittest.TestCase): def test_connect(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) try: s.connect((REMOTE_HOST, 443)) self.assertEqual({}, s.getpeercert()) finally: s.close() # this should fail because we have no verification certs s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED) self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # this should succeed because we specify the root cert s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: s.connect((REMOTE_HOST, 443)) self.assertTrue(s.getpeercert()) finally: s.close() def test_connect_ex(self): # Issue #11326: check connect_ex() implementation with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: self.assertEqual(0, s.connect_ex((REMOTE_HOST, 443))) self.assertTrue(s.getpeercert()) finally: s.close() def test_non_blocking_connect_ex(self): # Issue #11326: non-blocking connect_ex() should allow handshake # to proceed after the socket gets ready. with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.setblocking(False) rc = s.connect_ex((REMOTE_HOST, 443)) # EWOULDBLOCK under Windows, EINPROGRESS elsewhere self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK)) # Wait for connect to finish select.select([], [s], [], 5.0) # Non-blocking handshake while True: try: s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], [], 5.0) except ssl.SSLWantWriteError: select.select([], [s], [], 5.0) # SSL established self.assertTrue(s.getpeercert()) finally: s.close() def test_timeout_connect_ex(self): # Issue #12065: on a timeout, connect_ex() should return the original # errno (mimicking the behaviour of non-SSL sockets). with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.settimeout(0.0000001) rc = s.connect_ex((REMOTE_HOST, 443)) if rc == 0: self.skipTest("REMOTE_HOST responded too quickly") self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) finally: s.close() def test_connect_ex_error(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: rc = s.connect_ex((REMOTE_HOST, 444)) # Issue #19919: Windows machines or VMs hosted on Windows # machines sometimes return EWOULDBLOCK. errors = ( errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.ETIMEDOUT, errno.EWOULDBLOCK, ) self.assertIn(rc, errors) finally: s.close() def test_connect_with_context(self): with support.transient_internet(REMOTE_HOST): # Same as test_connect, but with a separately created context ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: self.assertEqual({}, s.getpeercert()) finally: s.close() # Same with a server hostname s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname=REMOTE_HOST) s.connect((REMOTE_HOST, 443)) s.close() # This should fail because we have no verification certs ctx.verify_mode = ssl.CERT_REQUIRED s = ctx.wrap_socket(socket.socket(socket.AF_INET)) self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # This should succeed because we specify the root cert ctx.load_verify_locations(REMOTE_ROOT_CERT) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_capath(self): # Verify server certificates using the `capath` argument # NOTE: the subject hashing algorithm has been changed between # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must # contain both versions of each certificate (same content, different # filename) for this test to be portable across OpenSSL releases. with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() # Same with a bytes `capath` argument ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=BYTES_CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_cadata(self): with open(REMOTE_ROOT_CERT) as f: pem = f.read().decode('ascii') der = ssl.PEM_cert_to_DER_cert(pem) with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=pem) with closing(ctx.wrap_socket(socket.socket(socket.AF_INET))) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) # same with DER ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=der) with closing(ctx.wrap_socket(socket.socket(socket.AF_INET))) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't # delay closing the underlying "real socket" (here tested with its # file descriptor, hence skipping the test under Windows). with support.transient_internet(REMOTE_HOST): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) ss.connect((REMOTE_HOST, 443)) fd = ss.fileno() f = ss.makefile() f.close() # The fd is still open os.read(fd, 0) # Closing the SSL socket should close the fd too ss.close() gc.collect() with self.assertRaises(OSError) as e: os.read(fd, 0) self.assertEqual(e.exception.errno, errno.EBADF) def test_non_blocking_handshake(self): with support.transient_internet(REMOTE_HOST): s = socket.socket(socket.AF_INET) s.connect((REMOTE_HOST, 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], []) except ssl.SSLWantWriteError: select.select([], [s], []) s.close() if support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) def test_get_server_certificate(self): def _test_get_server_certificate(host, port, cert=None): with support.transient_internet(host): pem = ssl.get_server_certificate((host, port)) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) try: pem = ssl.get_server_certificate((host, port), ca_certs=CERTFILE) except ssl.SSLError as x: #should fail if support.verbose: sys.stdout.write("%s\n" % x) else: self.fail("Got server certificate %s for %s:%s!" % (pem, host, port)) pem = ssl.get_server_certificate((host, port), ca_certs=cert) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) if support.verbose: sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem)) _test_get_server_certificate(REMOTE_HOST, 443, REMOTE_ROOT_CERT) if support.IPV6_ENABLED: _test_get_server_certificate('ipv6.google.com', 443) def test_ciphers(self): remote = (REMOTE_HOST, 443) with support.transient_internet(remote[0]): with closing(ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL")) as s: s.connect(remote) with closing(ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")) as s: s.connect(remote) # Error checking can happen at instantiation or when connecting with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): with closing(socket.socket(socket.AF_INET)) as sock: s = ssl.wrap_socket(sock, cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx") s.connect(remote) def test_algorithms(self): # Issue #8484: all algorithms should be available when verifying a # certificate. # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) # sha256.tbs-internet.com needs SNI to use the correct certificate if not ssl.HAS_SNI: self.skipTest("SNI needed for this test") # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host) remote = ("sha256.tbs-internet.com", 443) sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") with support.transient_internet("sha256.tbs-internet.com"): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(sha256_cert) s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname="sha256.tbs-internet.com") try: s.connect(remote) if support.verbose: sys.stdout.write("\nCipher with %r is %r\n" % (remote, s.cipher())) sys.stdout.write("Certificate is:\n%s\n" % pprint.pformat(s.getpeercert())) finally: s.close() def test_get_ca_certs_capath(self): # capath certs are loaded on request with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) self.assertEqual(ctx.get_ca_certs(), []) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() self.assertEqual(len(ctx.get_ca_certs()), 1) @needs_sni def test_context_setget(self): # Check that the context of a connected socket can be replaced. with support.transient_internet(REMOTE_HOST): ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = socket.socket(socket.AF_INET) with closing(ctx1.wrap_socket(s)) as ss: ss.connect((REMOTE_HOST, 443)) self.assertIs(ss.context, ctx1) self.assertIs(ss._sslobj.context, ctx1) ss.context = ctx2 self.assertIs(ss.context, ctx2) self.assertIs(ss._sslobj.context, ctx2) try: import threading except ImportError: _have_threads = False else: _have_threads = True from test.ssl_servers import make_https_server class ThreadedEchoServer(threading.Thread): class ConnectionHandler(threading.Thread): """A mildly complicated class, because we want it to work both with and without the SSL wrapper around the socket connection, so that we can test the STARTTLS functionality.""" def __init__(self, server, connsock, addr): self.server = server self.running = False self.sock = connsock self.addr = addr self.sock.setblocking(1) self.sslconn = None threading.Thread.__init__(self) self.daemon = True def wrap_conn(self): try: self.sslconn = self.server.context.wrap_socket( self.sock, server_side=True) self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol()) self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol()) except socket.error as e: # We treat ConnectionResetError as though it were an # SSLError - OpenSSL on Ubuntu abruptly closes the # connection when asked to use an unsupported protocol. # # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. if not isinstance(e, ssl.SSLError) and e.errno != errno.ECONNRESET: raise self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n") self.running = False self.server.stop() self.close() return False else: if self.server.context.verify_mode == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") sys.stdout.write(" server: selected protocol is now " + str(self.sslconn.selected_npn_protocol()) + "\n") return True def read(self): if self.sslconn: return self.sslconn.read() else: return self.sock.recv(1024) def write(self, bytes): if self.sslconn: return self.sslconn.write(bytes) else: return self.sock.send(bytes) def close(self): if self.sslconn: self.sslconn.close() else: self.sock.close() def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif (self.server.starttls_server and stripped == b'STARTTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write(b"OK\n") if not self.wrap_conn(): return elif (self.server.starttls_server and self.sslconn and stripped == b'ENDTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read ENDTLS from client, sending OK...\n") self.write(b"OK\n") self.sock = self.sslconn.unwrap() self.sslconn = None if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: connection is now unencrypted...\n") elif stripped == b'CB tls-unique': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read CB tls-unique from client, sending our CB data...\n") data = self.sslconn.get_channel_binding("tls-unique") self.write(repr(data).encode("us-ascii") + b"\n") else: if (support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n" % (msg, ctype, msg.lower(), ctype)) self.write(msg.lower()) except ssl.SSLError: if self.server.chatty: handle_error("Test server failure:\n") self.close() self.running = False # normally, we'd just stop here, but for the test # harness, we want to stop the server self.server.stop() def __init__(self, certificate=None, ssl_version=None, certreqs=None, cacerts=None, chatty=True, connectionchatty=False, starttls_server=False, npn_protocols=None, alpn_protocols=None, ciphers=None, context=None): if context: self.context = context else: self.context = ssl.SSLContext(ssl_version if ssl_version is not None else ssl.PROTOCOL_TLSv1) self.context.verify_mode = (certreqs if certreqs is not None else ssl.CERT_NONE) if cacerts: self.context.load_verify_locations(cacerts) if certificate: self.context.load_cert_chain(certificate) if npn_protocols: self.context.set_npn_protocols(npn_protocols) if alpn_protocols: self.context.set_alpn_protocols(alpn_protocols) if ciphers: self.context.set_ciphers(ciphers) self.chatty = chatty self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() self.port = support.bind_port(self.sock) self.flag = None self.active = False self.selected_npn_protocols = [] self.selected_alpn_protocols = [] self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): self.stop() self.join() def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.sock.settimeout(0.05) self.sock.listen(5) self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + repr(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn, connaddr) handler.start() handler.join() except socket.timeout: pass except KeyboardInterrupt: self.stop() self.sock.close() def stop(self): self.active = False class AsyncoreEchoServer(threading.Thread): class EchoServer(asyncore.dispatcher): class ConnectionHandler(asyncore.dispatcher_with_send): def __init__(self, conn, certfile): self.socket = ssl.wrap_socket(conn, server_side=True, certfile=certfile, do_handshake_on_connect=False) asyncore.dispatcher_with_send.__init__(self, self.socket) self._ssl_accepting = True self._do_ssl_handshake() def readable(self): if isinstance(self.socket, ssl.SSLSocket): while self.socket.pending() > 0: self.handle_read_event() return True def _do_ssl_handshake(self): try: self.socket.do_handshake() except (ssl.SSLWantReadError, ssl.SSLWantWriteError): return except ssl.SSLEOFError: return self.handle_close() except ssl.SSLError: raise except socket.error, err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() else: data = self.recv(1024) if support.verbose: sys.stdout.write(" server: read %s from client\n" % repr(data)) if not data: self.close() else: self.send(data.lower()) def handle_close(self): self.close() if support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): raise def __init__(self, certfile): self.certfile = certfile sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(sock, '') asyncore.dispatcher.__init__(self, sock) self.listen(5) def handle_accept(self): sock_obj, addr = self.accept() if support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) def handle_error(self): raise def __init__(self, certfile): self.flag = None self.active = False self.server = self.EchoServer(certfile) self.port = self.server.port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): if support.verbose: sys.stdout.write(" cleanup: stopping server.\n") self.stop() if support.verbose: sys.stdout.write(" cleanup: joining server thread.\n") self.join() if support.verbose: sys.stdout.write(" cleanup: successfully joined.\n") def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.active = True if self.flag: self.flag.set() while self.active: try: asyncore.loop(1) except: pass def stop(self): self.active = False self.server.close() def server_params_test(client_context, server_context, indata=b"FOO\n", chatty=True, connectionchatty=False, sni_name=None): """ Launch a server, connect a client to it and try various reads and writes. """ stats = {} server = ThreadedEchoServer(context=server_context, chatty=chatty, connectionchatty=False) with server: with closing(client_context.wrap_socket(socket.socket(), server_hostname=sni_name)) as s: s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(arg) outdata = s.read() if connectionchatty: if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): raise AssertionError( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if connectionchatty: if support.verbose: sys.stdout.write(" client: closing connection.\n") stats.update({ 'compression': s.compression(), 'cipher': s.cipher(), 'peercert': s.getpeercert(), 'client_alpn_protocol': s.selected_alpn_protocol(), 'client_npn_protocol': s.selected_npn_protocol(), 'version': s.version(), }) s.close() stats['server_alpn_protocols'] = server.selected_alpn_protocols stats['server_npn_protocols'] = server.selected_npn_protocols return stats def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None, server_options=0, client_options=0): """ Try to SSL-connect using *client_protocol* to *server_protocol*. If *expect_success* is true, assert that the connection succeeds, if it's false, assert that the connection fails. Also, if *expect_success* is a string, assert that it is the protocol version actually used by the connection. """ if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) client_context = ssl.SSLContext(client_protocol) client_context.options |= client_options server_context = ssl.SSLContext(server_protocol) server_context.options |= server_options # NOTE: we must enable "ALL" ciphers on the client, otherwise an # SSLv23 client will send an SSLv3 hello (rather than SSLv2) # starting from OpenSSL 1.0.0 (see issue #8322). if client_context.protocol == ssl.PROTOCOL_SSLv23: client_context.set_ciphers("ALL") for ctx in (client_context, server_context): ctx.verify_mode = certsreqs ctx.load_cert_chain(CERTFILE) ctx.load_verify_locations(CERTFILE) try: stats = server_params_test(client_context, server_context, chatty=False, connectionchatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except socket.error as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) elif (expect_success is not True and expect_success != stats['version']): raise AssertionError("version mismatch: expected %r, got %r" % (expect_success, stats['version'])) class ThreadedTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_echo(self): """Basic test of an SSL client connecting to a server""" if support.verbose: sys.stdout.write("\n") for protocol in PROTOCOLS: context = ssl.SSLContext(protocol) context.load_cert_chain(CERTFILE) server_params_test(context, context, chatty=True, connectionchatty=True) def test_getpeercert(self): if support.verbose: sys.stdout.write("\n") context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket(), do_handshake_on_connect=False) s.connect((HOST, server.port)) # getpeercert() raise ValueError while the handshake isn't # done. with self.assertRaises(ValueError): s.getpeercert() s.do_handshake() cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() if support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: self.fail("No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): self.fail( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") self.assertIn('notBefore', cert) self.assertIn('notAfter', cert) before = ssl.cert_time_to_seconds(cert['notBefore']) after = ssl.cert_time_to_seconds(cert['notAfter']) self.assertLess(before, after) s.close() @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_crl_check(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(SIGNING_CA) tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(context.verify_flags, ssl.VERIFY_DEFAULT | tf) # VERIFY_DEFAULT should pass server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(context.wrap_socket(socket.socket())) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # VERIFY_CRL_CHECK_LEAF without a loaded CRL file fails context.verify_flags |= ssl.VERIFY_CRL_CHECK_LEAF server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(context.wrap_socket(socket.socket())) as s: with self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed"): s.connect((HOST, server.port)) # now load a CRL file. The CRL file is signed by the CA. context.load_verify_locations(CRLFILE) server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(context.wrap_socket(socket.socket())) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") def test_check_hostname(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.check_hostname = True context.load_verify_locations(SIGNING_CA) # correct hostname should verify server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(context.wrap_socket(socket.socket(), server_hostname="localhost")) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # incorrect hostname should raise an exception server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(context.wrap_socket(socket.socket(), server_hostname="invalid")) as s: with self.assertRaisesRegexp(ssl.CertificateError, "hostname 'invalid' doesn't match u?'localhost'"): s.connect((HOST, server.port)) # missing server_hostname arg should cause an exception, too server = ThreadedEchoServer(context=server_context, chatty=True) with server: with closing(socket.socket()) as s: with self.assertRaisesRegexp(ValueError, "check_hostname requires server_hostname"): context.wrap_socket(s) def test_wrong_cert(self): """Connecting when the server rejects the client's certificate Launch a server with CERT_REQUIRED, and check that trying to connect to it with a wrong client certificate fails. """ certfile = os.path.join(os.path.dirname(__file__) or os.curdir, "wrongcert.pem") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False, connectionchatty=False) with server, \ closing(socket.socket()) as sock, \ closing(ssl.wrap_socket(sock, certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1)) as s: try: # Expect either an SSL error about the server rejecting # the connection, or a low-level connection reset (which # sometimes happens on Windows) s.connect((HOST, server.port)) except ssl.SSLError as e: if support.verbose: sys.stdout.write("\nSSLError is %r\n" % e) except socket.error as e: if e.errno != errno.ECONNRESET: raise if support.verbose: sys.stdout.write("\nsocket.error is %r\n" % e) else: self.fail("Use of invalid cert should have failed!") def test_rude_shutdown(self): """A brutal shutdown of an SSL server should raise an OSError in the client when attempting handshake. """ listener_ready = threading.Event() listener_gone = threading.Event() s = socket.socket() port = support.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, # and sets Event `listener_gone` to let the main thread know # the socket is gone. def listener(): s.listen(5) listener_ready.set() newsock, addr = s.accept() newsock.close() s.close() listener_gone.set() def connector(): listener_ready.wait() with closing(socket.socket()) as c: c.connect((HOST, port)) listener_gone.wait() try: ssl_sock = ssl.wrap_socket(c) except socket.error: pass else: self.fail('connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) t.start() try: connector() finally: t.join() @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv2'), "OpenSSL is compiled without SSLv2 support") def test_protocol_sslv2(self): """Connecting to an SSLv2 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) # SSLv23 client with specific SSL options if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl def test_protocol_sslv23(self): """Connecting to an SSLv23 server with various client options""" if support.verbose: sys.stdout.write("\n") if hasattr(ssl, 'PROTOCOL_SSLv2'): try: try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except socket.error as x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1') if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED) # Server with specific SSL options if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, server_options=ssl.OP_NO_SSLv3) # Will choose TLSv1 try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False, server_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv3'), "OpenSSL is compiled without SSLv3 support") def test_protocol_sslv3(self): """Connecting to an SSLv3 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3') try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) @skip_if_broken_ubuntu_ssl def test_protocol_tlsv1(self): """Connecting to a TLSv1 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1') try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_1"), "TLS version 1.1 not supported.") def test_protocol_tlsv1_1(self): """Connecting to a TLSv1.1 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1') if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_1) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1') try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_2"), "TLS version 1.2 not supported.") def test_protocol_tlsv1_2(self): """Connecting to a TLSv1.2 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2', server_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2, client_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2,) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_2) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2') try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_2, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_2, False) def test_starttls(self): """Switching from clear text to encrypted and back again.""" msgs = (b"msg 1", b"MSG 2", b"STARTTLS", b"MSG 3", b"msg 4", b"ENDTLS", b"msg 5", b"msg 6") server = ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, starttls_server=True, chatty=True, connectionchatty=True) wrapped = False with server: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) if support.verbose: sys.stdout.write("\n") for indata in msgs: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) if wrapped: conn.write(indata) outdata = conn.read() else: s.send(indata) outdata = s.recv(1024) msg = outdata.strip().lower() if indata == b"STARTTLS" and msg.startswith(b"ok"): # STARTTLS ok, switch to secure mode if support.verbose: sys.stdout.write( " client: read %r from server, starting TLS...\n" % msg) conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) wrapped = True elif indata == b"ENDTLS" and msg.startswith(b"ok"): # ENDTLS ok, switch back to clear text if support.verbose: sys.stdout.write( " client: read %r from server, ending TLS...\n" % msg) s = conn.unwrap() wrapped = False else: if support.verbose: sys.stdout.write( " client: read %r from server\n" % msg) if support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write(b"over\n") else: s.send(b"over\n") if wrapped: conn.close() else: s.close() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" server = make_https_server(self, certfile=CERTFILE) # try to connect if support.verbose: sys.stdout.write('\n') with open(CERTFILE, 'rb') as f: d1 = f.read() d2 = '' # now fetch the same data from the HTTPS server url = 'https://localhost:%d/%s' % ( server.port, os.path.split(CERTFILE)[1]) context = ssl.create_default_context(cafile=CERTFILE) f = urllib2.urlopen(url, context=context) try: dlen = f.info().getheader("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) if support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) finally: f.close() self.assertEqual(d1, d2) def test_asyncore_server(self): """Check the example asyncore integration.""" indata = "TEST MESSAGE of mixed case\n" if support.verbose: sys.stdout.write("\n") indata = b"FOO\n" server = AsyncoreEchoServer(CERTFILE) with server: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(indata) outdata = s.read() if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): self.fail( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() if support.verbose: sys.stdout.write(" client: connection closed.\n") def test_recv_send(self): """Test recv(), send() and friends.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray(b"\0"*100) count = s.recv_into(b) return b[:count] def _recvfrom_into(): b = bytearray(b"\0"*100) count, addr = s.recvfrom_into(b) return b[:count] # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]), ('sendall', s.sendall, True, []), ] recv_methods = [ ('recv', s.recv, True, []), ('recvfrom', s.recvfrom, False, ["some.address"]), ('recv_into', _recv_into, True, []), ('recvfrom_into', _recvfrom_into, False, []), ] data_prefix = u"PREFIX_" for meth_name, send_meth, expect_success, args in send_methods: indata = (data_prefix + meth_name).encode('ascii') try: send_meth(indata, *args) outdata = s.read() if outdata != indata.lower(): self.fail( "While sending with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to send with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) for meth_name, recv_meth, expect_success, args in recv_methods: indata = (data_prefix + meth_name).encode('ascii') try: s.send(indata) outdata = recv_meth(*args) if outdata != indata.lower(): self.fail( "While receiving with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to receive with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) # consume data s.read() s.write(b"over\n") s.close() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) started = threading.Event() finish = False def serve(): server.listen(5) started.set() conns = [] while not finish: r, w, e = select.select([server], [], [], 0.1) if server in r: # Let the socket hang around rather than having # it closed by garbage collection. conns.append(server.accept()[0]) for sock in conns: sock.close() t = threading.Thread(target=serve) t.start() started.wait() try: try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c.connect((host, port)) # Will attempt handshake and time out self.assertRaisesRegexp(ssl.SSLError, "timed out", ssl.wrap_socket, c) finally: c.close() try: c = socket.socket(socket.AF_INET) c = ssl.wrap_socket(c) c.settimeout(0.2) # Will attempt handshake and time out self.assertRaisesRegexp(ssl.SSLError, "timed out", c.connect, (host, port)) finally: c.close() finally: finish = True t.join() server.close() def test_server_accept(self): # Issue #16357: accept() on a SSLSocket created through # SSLContext.wrap_socket(). context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) server = context.wrap_socket(server, server_side=True) evt = threading.Event() remote = [None] peer = [None] def serve(): server.listen(5) # Block on the accept and wait on the connection to close. evt.set() remote[0], peer[0] = server.accept() remote[0].recv(1) t = threading.Thread(target=serve) t.start() # Client wait until server setup and perform a connect. evt.wait() client = context.wrap_socket(socket.socket()) client.connect((host, port)) client_addr = client.getsockname() client.close() t.join() remote[0].close() server.close() # Sanity checks. self.assertIsInstance(remote[0], ssl.SSLSocket) self.assertEqual(peer[0], client_addr) def test_getpeercert_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with closing(context.wrap_socket(socket.socket())) as sock: with self.assertRaises(socket.error) as cm: sock.getpeercert() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_do_handshake_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with closing(context.wrap_socket(socket.socket())) as sock: with self.assertRaises(socket.error) as cm: sock.do_handshake() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_default_ciphers(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) try: # Force a set of weak ciphers on our client context context.set_ciphers("DES") except ssl.SSLError: self.skipTest("no DES cipher available") with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: with closing(context.wrap_socket(socket.socket())) as s: with self.assertRaises(ssl.SSLError): s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0])) def test_version_basic(self): """ Basic tests for SSLSocket.version(). More tests are done in the test_protocol_*() methods. """ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, chatty=False) as server: with closing(context.wrap_socket(socket.socket())) as s: self.assertIs(s.version(), None) s.connect((HOST, server.port)) self.assertEqual(s.version(), "TLSv1") self.assertIs(s.version(), None) @unittest.skipUnless(ssl.HAS_ECDH, "test requires ECDH-enabled OpenSSL") def test_default_ecdh_curve(self): # Issue #21015: elliptic curve-based Diffie Hellman key exchange # should be enabled by default on SSL contexts. context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.load_cert_chain(CERTFILE) # Prior to OpenSSL 1.0.0, ECDH ciphers have to be enabled # explicitly using the 'ECCdraft' cipher alias. Otherwise, # our default cipher list should prefer ECDH-based ciphers # automatically. if ssl.OPENSSL_VERSION_INFO < (1, 0, 0): context.set_ciphers("ECCdraft:ECDH") with ThreadedEchoServer(context=context) as server: with closing(context.wrap_socket(socket.socket())) as s: s.connect((HOST, server.port)) self.assertIn("ECDH", s.cipher()[0]) @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): """Test tls-unique channel binding.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # get the data cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got channel binding data: {0!r}\n" .format(cb_data)) # check if it is sane self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 # and compare with the peers version s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(cb_data).encode("us-ascii")) s.close() # now, again s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) new_cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got another channel binding data: {0!r}\n" .format(new_cb_data)) # is it really unique self.assertNotEqual(cb_data, new_cb_data) self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(new_cb_data).encode("us-ascii")) s.close() def test_compression(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) if support.verbose: sys.stdout.write(" got compression: {!r}\n".format(stats['compression'])) self.assertIn(stats['compression'], { None, 'ZLIB', 'RLE' }) @unittest.skipUnless(hasattr(ssl, 'OP_NO_COMPRESSION'), "ssl.OP_NO_COMPRESSION needed for this test") def test_compression_disabled(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.options |= ssl.OP_NO_COMPRESSION stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['compression'], None) def test_dh_params(self): # Check we can get a connection with ephemeral Diffie-Hellman context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.load_dh_params(DHFILE) context.set_ciphers("kEDH") stats = server_params_test(context, context, chatty=True, connectionchatty=True) cipher = stats["cipher"][0] parts = cipher.split("-") if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts: self.fail("Non-DH cipher: " + cipher[0]) def test_selected_alpn_protocol(self): # selected_alpn_protocol() is None unless ALPN is used. context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['client_alpn_protocol'], None) @unittest.skipUnless(ssl.HAS_ALPN, "ALPN support required") def test_selected_alpn_protocol_if_server_uses_alpn(self): # selected_alpn_protocol() is None unless ALPN is used by the client. client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_verify_locations(CERTFILE) server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_alpn_protocols(['foo', 'bar']) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) self.assertIs(stats['client_alpn_protocol'], None) @unittest.skipUnless(ssl.HAS_ALPN, "ALPN support needed for this test") def test_alpn_protocols(self): server_protocols = ['foo', 'bar', 'milkshake'] protocol_tests = [ (['foo', 'bar'], 'foo'), (['bar', 'foo'], 'foo'), (['milkshake'], 'milkshake'), (['http/3.0', 'http/4.0'], None) ] for client_protocols, expected in protocol_tests: server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_alpn_protocols(server_protocols) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_alpn_protocols(client_protocols) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) msg = "failed trying %s (s) and %s (c).\n" \ "was expecting %s, but got %%s from the %%s" \ % (str(server_protocols), str(client_protocols), str(expected)) client_result = stats['client_alpn_protocol'] self.assertEqual(client_result, expected, msg % (client_result, "client")) server_result = stats['server_alpn_protocols'][-1] \ if len(stats['server_alpn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) def test_selected_npn_protocol(self): # selected_npn_protocol() is None unless NPN is used context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['client_npn_protocol'], None) @unittest.skipUnless(ssl.HAS_NPN, "NPN support needed for this test") def test_npn_protocols(self): server_protocols = ['http/1.1', 'spdy/2'] protocol_tests = [ (['http/1.1', 'spdy/2'], 'http/1.1'), (['spdy/2', 'http/1.1'], 'http/1.1'), (['spdy/2', 'test'], 'spdy/2'), (['abc', 'def'], 'abc') ] for client_protocols, expected in protocol_tests: server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_npn_protocols(server_protocols) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_npn_protocols(client_protocols) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) msg = "failed trying %s (s) and %s (c).\n" \ "was expecting %s, but got %%s from the %%s" \ % (str(server_protocols), str(client_protocols), str(expected)) client_result = stats['client_npn_protocol'] self.assertEqual(client_result, expected, msg % (client_result, "client")) server_result = stats['server_npn_protocols'][-1] \ if len(stats['server_npn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) def sni_contexts(self): server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) other_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) other_context.load_cert_chain(SIGNED_CERTFILE2) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.verify_mode = ssl.CERT_REQUIRED client_context.load_verify_locations(SIGNING_CA) return server_context, other_context, client_context def check_common_name(self, stats, name): cert = stats['peercert'] self.assertIn((('commonName', name),), cert['subject']) @needs_sni def test_sni_callback(self): calls = [] server_context, other_context, client_context = self.sni_contexts() def servername_cb(ssl_sock, server_name, initial_context): calls.append((server_name, initial_context)) if server_name is not None: ssl_sock.context = other_context server_context.set_servername_callback(servername_cb) stats = server_params_test(client_context, server_context, chatty=True, sni_name='supermessage') # The hostname was fetched properly, and the certificate was # changed for the connection. self.assertEqual(calls, [("supermessage", server_context)]) # CERTFILE4 was selected self.check_common_name(stats, 'fakehostname') calls = [] # The callback is called with server_name=None stats = server_params_test(client_context, server_context, chatty=True, sni_name=None) self.assertEqual(calls, [(None, server_context)]) self.check_common_name(stats, 'localhost') # Check disabling the callback calls = [] server_context.set_servername_callback(None) stats = server_params_test(client_context, server_context, chatty=True, sni_name='notfunny') # Certificate didn't change self.check_common_name(stats, 'localhost') self.assertEqual(calls, []) @needs_sni def test_sni_callback_alert(self): # Returning a TLS alert is reflected to the connecting client server_context, other_context, client_context = self.sni_contexts() def cb_returning_alert(ssl_sock, server_name, initial_context): return ssl.ALERT_DESCRIPTION_ACCESS_DENIED server_context.set_servername_callback(cb_returning_alert) with self.assertRaises(ssl.SSLError) as cm: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED') @needs_sni def test_sni_callback_raising(self): # Raising fails the connection with a TLS handshake failure alert. server_context, other_context, client_context = self.sni_contexts() def cb_raising(ssl_sock, server_name, initial_context): 1.0/0.0 server_context.set_servername_callback(cb_raising) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'SSLV3_ALERT_HANDSHAKE_FAILURE') self.assertIn("ZeroDivisionError", stderr.getvalue()) @needs_sni def test_sni_callback_wrong_return_type(self): # Returning the wrong return type terminates the TLS connection # with an internal error alert. server_context, other_context, client_context = self.sni_contexts() def cb_wrong_return_type(ssl_sock, server_name, initial_context): return "foo" server_context.set_servername_callback(cb_wrong_return_type) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_INTERNAL_ERROR') self.assertIn("TypeError", stderr.getvalue()) def test_read_write_after_close_raises_valuerror(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket()) s.connect((HOST, server.port)) s.close() self.assertRaises(ValueError, s.read, 1024) self.assertRaises(ValueError, s.write, b'hello') def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_subprocess.py0000644000076500000000000016223712666555342021661 0ustar jmaddenwheel00000000000000import unittest from test import test_support import subprocess import sys import signal import os import errno import tempfile import time import re import sysconfig try: import resource except ImportError: resource = None try: import threading except ImportError: threading = None mswindows = (sys.platform == "win32") # # Depends on the following external programs: Python # if mswindows: SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), ' 'os.O_BINARY);') else: SETBINARY = '' class BaseTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). test_support.reap_children() def tearDown(self): for inst in subprocess._active: inst.wait() subprocess._cleanup() self.assertFalse(subprocess._active, "subprocess._active not empty") def assertStderrEqual(self, stderr, expected, msg=None): # In a debug build, stuff like "[6580 refs]" is printed to stderr at # shutdown time. That frustrates tests trying to check stderr produced # from a spawned Python process. actual = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) self.assertEqual(actual, expected, msg) class PopenTestException(Exception): pass class PopenExecuteChildRaises(subprocess.Popen): """Popen subclass for testing cleanup of subprocess.PIPE filehandles when _execute_child fails. """ def _execute_child(self, *args, **kwargs): raise PopenTestException("Forced Exception for Test") class ProcessTestCase(BaseTestCase): def test_call_seq(self): # call() function with sequence argument rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) def test_check_call_zero(self): # check_call() function with zero return code rc = subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(0)"]) self.assertEqual(rc, 0) def test_check_call_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(c.exception.returncode, 47) def test_check_output(self): # check_output() function with zero return code output = subprocess.check_output( [sys.executable, "-c", "print 'BDFL'"]) self.assertIn('BDFL', output) def test_check_output_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_output( [sys.executable, "-c", "import sys; sys.exit(5)"]) self.assertEqual(c.exception.returncode, 5) def test_check_output_stderr(self): # check_output() function stderr redirected to stdout output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"], stderr=subprocess.STDOUT) self.assertIn('BDFL', output) def test_check_output_stdout_arg(self): # check_output() function stderr redirected to stdout with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print 'will not be run'"], stdout=sys.stdout) self.fail("Expected ValueError when stdout arg supplied.") self.assertIn('stdout', c.exception.args[0]) def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() newenv["FRUIT"] = "banana" rc = subprocess.call([sys.executable, "-c", 'import sys, os;' 'sys.exit(os.getenv("FRUIT")=="banana")'], env=newenv) self.assertEqual(rc, 1) def test_invalid_args(self): # Popen() called with invalid arguments should raise TypeError # but Popen.__del__ should not complain (issue #12085) with test_support.captured_stderr() as s: self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1) argcount = subprocess.Popen.__init__.__code__.co_argcount too_many_args = [0] * (argcount + 1) self.assertRaises(TypeError, subprocess.Popen, *too_many_args) self.assertEqual(s.getvalue(), '') def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) p.wait() self.assertEqual(p.stdin, None) def test_stdout_none(self): # .stdout is None when not redirected, and the child's stdout will # be inherited from the parent. In order to test this we run a # subprocess in a subprocess: # this_test # \-- subprocess created by this test (parent) # \-- subprocess created by the parent subprocess (child) # The parent doesn't specify stdout, so the child will use the # parent's stdout. This test checks that the message printed by the # child goes to the parent stdout. The parent also checks that the # child's stdout is None. See #11963. code = ('import sys; from subprocess import Popen, PIPE;' 'p = Popen([sys.executable, "-c", "print \'test_stdout_none\'"],' ' stdin=PIPE, stderr=PIPE);' 'p.wait(); assert p.stdout is None;') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), 'test_stdout_none') def test_stderr_none(self): # .stderr is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stdin.close) p.wait() self.assertEqual(p.stderr, None) def test_executable_with_cwd(self): python_dir = os.path.dirname(os.path.realpath(sys.executable)) p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"], executable=sys.executable, cwd=python_dir) p.wait() self.assertEqual(p.returncode, 47) @unittest.skipIf(sysconfig.is_python_build(), "need an installed Python. See #7774") def test_executable_without_cwd(self): # For a normal installation, it should work without 'cwd' # argument. For test runs in the build directory, see #7774. p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"], executable=sys.executable) p.wait() self.assertEqual(p.returncode, 47) def test_stdin_pipe(self): # stdin redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.stdin.write("pear") p.stdin.close() p.wait() self.assertEqual(p.returncode, 1) def test_stdin_filedes(self): # stdin is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() os.write(d, "pear") os.lseek(d, 0, 0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=d) p.wait() self.assertEqual(p.returncode, 1) def test_stdin_fileobj(self): # stdin is set to open file object tf = tempfile.TemporaryFile() tf.write("pear") tf.seek(0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=tf) p.wait() self.assertEqual(p.returncode, 1) def test_stdout_pipe(self): # stdout redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "orange") def test_stdout_filedes(self): # stdout is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), "orange") def test_stdout_fileobj(self): # stdout is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), "orange") def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.addCleanup(p.stderr.close) self.assertStderrEqual(p.stderr.read(), "strawberry") def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertStderrEqual(os.read(d, 1024), "strawberry") def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), "strawberry") def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.addCleanup(p.stdout.close) self.assertStderrEqual(p.stdout.read(), "appleorange") def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), "appleorange") def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). # To avoid printing the text on stdout, we do something similar to # test_stdout_none (see above). The parent subprocess calls the child # subprocess passing stdout=1, and this test uses stdout=PIPE in # order to capture and check the output of the parent. See #11963. code = ('import sys, subprocess; ' 'rc = subprocess.call([sys.executable, "-c", ' ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), ' '\'test with stdout=1\'))"], stdout=1); ' 'assert rc == 18') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), 'test with stdout=1') def test_cwd(self): tmpdir = tempfile.gettempdir() # We cannot use os.path.realpath to canonicalize the path, # since it doesn't expand Tru64 {memb} strings. See bug 1063571. cwd = os.getcwd() os.chdir(tmpdir) tmpdir = os.getcwd() os.chdir(cwd) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) self.addCleanup(p.stdout.close) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir)) def test_env(self): newenv = os.environ.copy() newenv["FRUIT"] = "orange" p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "orange") def test_communicate_stdin(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.communicate("pear") self.assertEqual(p.returncode, 1) def test_communicate_stdout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("pineapple")'], stdout=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, "pineapple") self.assertEqual(stderr, None) def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertStderrEqual(stderr, "pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) (stdout, stderr) = p.communicate("banana") self.assertEqual(stdout, "banana") self.assertStderrEqual(stderr, "pineapple") # This test is Linux specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") # Test for the fd leak reported in http://bugs.python.org/issue2791. def test_communicate_pipe_fd_leak(self): fd_directory = '/proc/%d/fd' % os.getpid() num_fds_before_popen = len(os.listdir(fd_directory)) p = subprocess.Popen([sys.executable, "-c", "print()"], stdout=subprocess.PIPE) p.communicate() num_fds_after_communicate = len(os.listdir(fd_directory)) del p num_fds_after_destruction = len(os.listdir(fd_directory)) self.assertEqual(num_fds_before_popen, num_fds_after_destruction) self.assertEqual(num_fds_before_popen, num_fds_after_communicate) def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"]) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, None) def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. x, y = os.pipe() if mswindows: pipe_buf = 512 else: pipe_buf = os.fpathconf(x, "PC_PIPE_BUF") os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' 'sys.stderr.write("xyz"*%d);' 'sys.stdout.write(sys.stdin.read())' % pipe_buf], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) string_to_write = "abc"*pipe_buf (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.stdin.write("banana") (stdout, stderr) = p.communicate("split") self.assertEqual(stdout, "bananasplit") self.assertStderrEqual(stderr, "") def test_universal_newlines(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) stdout = p.stdout.read() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_universal_newlines_communicate(self): # universal newlines through communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_no_leaking(self): # Make sure we leak no resources if not mswindows: max_handles = 1026 # too much for most UNIX systems else: max_handles = 2050 # too much for (at least some) Windows setups handles = [] try: for i in range(max_handles): try: handles.append(os.open(test_support.TESTFN, os.O_WRONLY | os.O_CREAT)) except OSError as e: if e.errno != errno.EMFILE: raise break else: self.skipTest("failed to reach the file descriptor limit " "(tried %d)" % max_handles) # Close a couple of them (should be enough for a subprocess) for i in range(10): os.close(handles.pop()) # Loop creating some subprocesses. If one of them leaks some fds, # the next loop iteration will fail by reaching the max fd limit. for i in range(15): p = subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate(b"lime")[0] self.assertEqual(data, b"lime") finally: for h in handles: os.close(h) test_support.unlink(test_support.TESTFN) def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), '"a b c" d e') self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']), 'ab\\"c \\ d') self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']), 'ab\\"c " \\\\" d') self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']), 'a\\\\\\b "de fg" h') self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']), 'a\\\\\\"b c d') self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']), '"a\\\\b c" d e') self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']), '"a\\\\b\\ c" d e') self.assertEqual(subprocess.list2cmdline(['ab', '']), 'ab ""') def test_poll(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(1)"]) count = 0 while p.poll() is None: time.sleep(0.1) count += 1 # We expect that the poll loop probably went around about 10 times, # but, based on system scheduling we can't control, it's possible # poll() never returned None. It "should be" very rare that it # didn't go around at least twice. self.assertGreaterEqual(count, 2) # Subsequent invocations should just return the returncode self.assertEqual(p.poll(), 0) def test_wait(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(2)"]) self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) def test_invalid_bufsize(self): # an invalid type of the bufsize argument should raise # TypeError. with self.assertRaises(TypeError): subprocess.Popen([sys.executable, "-c", "pass"], "orange") def test_leaking_fds_on_error(self): # see bug #5179: Popen leaks file descriptors to PIPEs if # the child fails to execute; this will eventually exhaust # the maximum number of open fds. 1024 seems a very common # value for that limit, but Windows has 2048, so we loop # 1024 times (each call leaked two fds). for i in range(1024): # Windows raises IOError. Others raise OSError. with self.assertRaises(EnvironmentError) as c: subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # ignore errors that indicate the command was not found if c.exception.errno not in (errno.ENOENT, errno.EACCES): raise c.exception @unittest.skipIf(threading is None, "threading required") def test_double_close_on_error(self): # Issue #18851 fds = [] def open_fds(): for i in range(20): fds.extend(os.pipe()) time.sleep(0.001) t = threading.Thread(target=open_fds) t.start() try: with self.assertRaises(EnvironmentError): subprocess.Popen(['nonexisting_i_hope'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: t.join() exc = None for fd in fds: # If a double close occurred, some of those fds will # already have been closed by mistake, and os.close() # here will raise. try: os.close(fd) except OSError as e: exc = e if exc is not None: raise exc def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released ifhandle, ifname = tempfile.mkstemp() ofhandle, ofname = tempfile.mkstemp() efhandle, efname = tempfile.mkstemp() try: subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle, stderr=efhandle) except OSError: os.close(ifhandle) os.remove(ifname) os.close(ofhandle) os.remove(ofname) os.close(efhandle) os.remove(efname) self.assertFalse(os.path.exists(ifname)) self.assertFalse(os.path.exists(ofname)) self.assertFalse(os.path.exists(efname)) def test_communicate_epipe(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.communicate("x" * 2**20) def test_communicate_epipe_only_stdin(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) time.sleep(2) p.communicate("x" * 2**20) # This test is Linux-ish specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") def test_failed_child_execute_fd_leak(self): """Test for the fork() failure fd leak reported in issue16327.""" fd_directory = '/proc/%d/fd' % os.getpid() fds_before_popen = os.listdir(fd_directory) with self.assertRaises(PopenTestException): PopenExecuteChildRaises( [sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # NOTE: This test doesn't verify that the real _execute_child # does not close the file descriptors itself on the way out # during an exception. Code inspection has confirmed that. fds_after_exception = os.listdir(fd_directory) self.assertEqual(fds_before_popen, fds_after_exception) # context manager class _SuppressCoreFiles(object): """Try to prevent core files from being created.""" old_limit = None def __enter__(self): """Try to save previous ulimit, then set it to (0, 0).""" if resource is not None: try: self.old_limit = resource.getrlimit(resource.RLIMIT_CORE) resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) except (ValueError, resource.error): pass if sys.platform == 'darwin': # Check if the 'Crash Reporter' on OSX was configured # in 'Developer' mode and warn that it will get triggered # when it is. # # This assumes that this context manager is used in tests # that might trigger the next manager. value = subprocess.Popen(['/usr/bin/defaults', 'read', 'com.apple.CrashReporter', 'DialogType'], stdout=subprocess.PIPE).communicate()[0] if value.strip() == b'developer': print "this tests triggers the Crash Reporter, that is intentional" sys.stdout.flush() def __exit__(self, *args): """Return core file behavior to default.""" if self.old_limit is None: return if resource is not None: try: resource.setrlimit(resource.RLIMIT_CORE, self.old_limit) except (ValueError, resource.error): pass @unittest.skipUnless(hasattr(signal, 'SIGALRM'), "Requires signal.SIGALRM") def test_communicate_eintr(self): # Issue #12493: communicate() should handle EINTR def handler(signum, frame): pass old_handler = signal.signal(signal.SIGALRM, handler) self.addCleanup(signal.signal, signal.SIGALRM, old_handler) # the process is running for 2 seconds args = [sys.executable, "-c", 'import time; time.sleep(2)'] for stream in ('stdout', 'stderr'): kw = {stream: subprocess.PIPE} with subprocess.Popen(args, **kw) as process: signal.alarm(1) # communicate() will be interrupted by SIGALRM process.communicate() @unittest.skipIf(mswindows, "POSIX specific tests") class POSIXProcessTestCase(BaseTestCase): def test_exceptions(self): # caught & re-raised exceptions with self.assertRaises(OSError) as c: p = subprocess.Popen([sys.executable, "-c", ""], cwd="/this/path/does/not/exist") # The attribute child_traceback should contain "os.chdir" somewhere. self.assertIn("os.chdir", c.exception.child_traceback) def test_run_abort(self): # returncode handles signal termination with _SuppressCoreFiles(): p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT) def test_preexec(self): # preexec function p = subprocess.Popen([sys.executable, "-c", "import sys, os;" "sys.stdout.write(os.getenv('FRUIT'))"], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "apple") class _TestExecuteChildPopen(subprocess.Popen): """Used to test behavior at the end of _execute_child.""" def __init__(self, testcase, *args, **kwargs): self._testcase = testcase subprocess.Popen.__init__(self, *args, **kwargs) def _execute_child( self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): try: subprocess.Popen._execute_child( self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) finally: # Open a bunch of file descriptors and verify that # none of them are the same as the ones the Popen # instance is using for stdin/stdout/stderr. devzero_fds = [os.open("/dev/zero", os.O_RDONLY) for _ in range(8)] try: for fd in devzero_fds: self._testcase.assertNotIn( fd, (p2cwrite, c2pread, errread)) finally: for fd in devzero_fds: os.close(fd) @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") def test_preexec_errpipe_does_not_double_close_pipes(self): """Issue16140: Don't double close pipes on preexec error.""" def raise_it(): raise RuntimeError("force the _execute_child() errpipe_data path.") with self.assertRaises(RuntimeError): self._TestExecuteChildPopen( self, [sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=raise_it) def test_args_string(self): # args is a string f, fname = tempfile.mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) self.assertEqual(p.returncode, 47) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], startupinfo=47) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], creationflags=47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen(["echo $FRUIT"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), "apple") def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen("echo $FRUIT", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), "apple") def test_call_string(self): # call() function with string argument on UNIX f, fname = tempfile.mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) def test_specific_shell(self): # Issue #9265: Incorrect name passed as arg[0]. shells = [] for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']: for name in ['bash', 'ksh']: sh = os.path.join(prefix, name) if os.path.isfile(sh): shells.append(sh) if not shells: # Will probably work for any shell but csh. self.skipTest("bash or ksh required for this test") sh = '/bin/sh' if os.path.isfile(sh) and not os.path.islink(sh): # Test will fail if /bin/sh is a symlink to csh. shells.append(sh) for sh in shells: p = subprocess.Popen("echo $0", executable=sh, shell=True, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), sh) def _kill_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) return p @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) p.communicate() def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() self.assertIn('KeyboardInterrupt', stderr) self.assertNotEqual(p.wait(), 0) def test_kill(self): p = self._kill_process('kill') _, stderr = p.communicate() self.assertStderrEqual(stderr, '') self.assertEqual(p.wait(), -signal.SIGKILL) def test_terminate(self): p = self._kill_process('terminate') _, stderr = p.communicate() self.assertStderrEqual(stderr, '') self.assertEqual(p.wait(), -signal.SIGTERM) def test_send_signal_dead(self): # Sending a signal to a dead process self._kill_dead_process('send_signal', signal.SIGINT) def test_kill_dead(self): # Killing a dead process self._kill_dead_process('kill') def test_terminate_dead(self): # Terminating a dead process self._kill_dead_process('terminate') def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed stdin = 0 newfds = [] for a in fds: b = os.dup(a) newfds.append(b) if a == 0: stdin = b try: for fd in fds: os.close(fd) out, err = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() err = test_support.strip_python_stderr(err) self.assertEqual((out, err), (b'apple', b'orange')) finally: for b, a in zip(newfds, fds): os.dup2(b, a) for b in newfds: os.close(b) def test_close_fd_0(self): self.check_close_std_fds([0]) def test_close_fd_1(self): self.check_close_std_fds([1]) def test_close_fd_2(self): self.check_close_std_fds([2]) def test_close_fds_0_1(self): self.check_close_std_fds([0, 1]) def test_close_fds_0_2(self): self.check_close_std_fds([0, 2]) def test_close_fds_1_2(self): self.check_close_std_fds([1, 2]) def test_close_fds_0_1_2(self): # Issue #10806: test that subprocess pipes still work properly with # all standard fds closed. self.check_close_std_fds([0, 1, 2]) def check_swap_fds(self, stdin_no, stdout_no, stderr_no): # open up some temporary files temps = [tempfile.mkstemp() for i in range(3)] temp_fds = [fd for fd, fname in temps] try: # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # save a copy of the standard file descriptors saved_fds = [os.dup(fd) for fd in range(3)] try: # duplicate the temp files over the standard fd's 0, 1, 2 for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # write some data to what will become stdin, and rewind os.write(stdin_no, b"STDIN") os.lseek(stdin_no, 0, 0) # now use those files in the given order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=stdin_no, stdout=stdout_no, stderr=stderr_no) p.wait() for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(stdout_no, 1024) err = test_support.strip_python_stderr(os.read(stderr_no, 1024)) finally: for std, saved in enumerate(saved_fds): os.dup2(saved, std) os.close(saved) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) # When duping fds, if there arises a situation where one of the fds is # either 0, 1 or 2, it is possible that it is overwritten (#12607). # This tests all combinations of this. def test_swap_fds(self): self.check_swap_fds(0, 1, 2) self.check_swap_fds(0, 2, 1) self.check_swap_fds(1, 0, 2) self.check_swap_fds(1, 2, 0) self.check_swap_fds(2, 0, 1) self.check_swap_fds(2, 1, 0) def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = test_support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(0, p.returncode, "sigchild_ignore.py exited" " non-zero with this error:\n%s" % stderr) def test_zombie_fast_process_del(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, it wouldn't be added to subprocess._active, and would # remain a zombie. # spawn a Popen, and delete its reference before it exits p = subprocess.Popen([sys.executable, "-c", 'import sys, time;' 'time.sleep(0.2)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) def test_leak_fast_process_del_killed(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, and the process got killed by a signal, it would never # be removed from subprocess._active, which triggered a FD and memory # leak. # spawn a Popen, delete its reference and kill it p = subprocess.Popen([sys.executable, "-c", 'import time;' 'time.sleep(3)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p os.kill(pid, signal.SIGKILL) # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) # let some time for the process to exit, and create a new Popen: this # should trigger the wait() of p time.sleep(0.2) with self.assertRaises(EnvironmentError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass # p should have been wait()ed on, and removed from the _active list self.assertRaises(OSError, os.waitpid, pid, 0) self.assertNotIn(ident, [id(o) for o in subprocess._active]) def test_pipe_cloexec(self): # Issue 12786: check that the communication pipes' FDs are set CLOEXEC, # and are not inherited by another child process. p1 = subprocess.Popen([sys.executable, "-c", 'import os;' 'os.read(0, 1)' ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p2 = subprocess.Popen([sys.executable, "-c", """if True: import os, errno, sys for fd in %r: try: os.close(fd) except OSError as e: if e.errno != errno.EBADF: raise else: sys.exit(1) sys.exit(0) """ % [f.fileno() for f in (p1.stdin, p1.stdout, p1.stderr)] ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) p1.communicate('foo') _, stderr = p2.communicate() self.assertEqual(p2.returncode, 0, "Unexpected error: " + repr(stderr)) @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_MAXIMIZE # Since Python is a console process, it won't be affected # by wShowWindow, but the argument should be silently # ignored subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) def test_creationflags(self): # creationflags argument CREATE_NEW_CONSOLE = 16 sys.stderr.write(" a DOS box should flash briefly ...\n") subprocess.call(sys.executable + ' -c "import time; time.sleep(0.25)"', creationflags=CREATE_NEW_CONSOLE) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], stdout=subprocess.PIPE, close_fds=True) def test_close_fds(self): # close file descriptors rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"], close_fds=True) self.assertEqual(rc, 47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn("physalis", p.stdout.read()) def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn("physalis", p.stdout.read()) def test_call_string(self): # call() function with string argument on Windows rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) def _kill_process(self, method, *args): # Some win32 buildbot raises EOFError if stdin is inherited p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, '') returncode = p.wait() self.assertNotEqual(returncode, 0) def _kill_dead_process(self, method, *args): p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() sys.exit(42) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') rc = p.wait() self.assertEqual(rc, 42) def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) def test_kill(self): self._kill_process('kill') def test_terminate(self): self._kill_process('terminate') def test_send_signal_dead(self): self._kill_dead_process('send_signal', signal.SIGTERM) def test_kill_dead(self): self._kill_dead_process('kill') def test_terminate_dead(self): self._kill_dead_process('terminate') @unittest.skipUnless(getattr(subprocess, '_has_poll', False), "poll system call not supported") class ProcessTestCaseNoPoll(ProcessTestCase): def setUp(self): subprocess._has_poll = False ProcessTestCase.setUp(self) def tearDown(self): subprocess._has_poll = True ProcessTestCase.tearDown(self) class HelperFunctionTests(unittest.TestCase): @unittest.skipIf(mswindows, "errno and EINTR make no sense on windows") def test_eintr_retry_call(self): record_calls = [] def fake_os_func(*args): record_calls.append(args) if len(record_calls) == 2: raise OSError(errno.EINTR, "fake interrupted system call") return tuple(reversed(args)) self.assertEqual((999, 256), subprocess._eintr_retry_call(fake_os_func, 256, 999)) self.assertEqual([(256, 999)], record_calls) # This time there will be an EINTR so it will loop once. self.assertEqual((666,), subprocess._eintr_retry_call(fake_os_func, 666)) self.assertEqual([(256, 999), (666,), (666,)], record_calls) @unittest.skipUnless(mswindows, "mswindows only") class CommandsWithSpaces (BaseTestCase): def setUp(self): super(CommandsWithSpaces, self).setUp() f, fname = tempfile.mkstemp(".py", "te st") self.fname = fname.lower () os.write(f, b"import sys;" b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))" ) os.close(f) def tearDown(self): os.remove(self.fname) super(CommandsWithSpaces, self).tearDown() def with_spaces(self, *args, **kwargs): kwargs['stdout'] = subprocess.PIPE p = subprocess.Popen(*args, **kwargs) self.addCleanup(p.stdout.close) self.assertEqual( p.stdout.read ().decode("mbcs"), "2 [%r, 'ab cd']" % self.fname ) def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd"), shell=1) def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1) def test_noshell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd")) def test_noshell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"]) def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, ProcessTestCaseNoPoll, HelperFunctionTests, CommandsWithSpaces) test_support.run_unittest(*unit_tests) test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_telnetlib.py0000644000076500000000000003730012666555342021443 0ustar jmaddenwheel00000000000000import socket import telnetlib import time import Queue import unittest from unittest import TestCase from test import test_support threading = test_support.import_module('threading') HOST = test_support.HOST EOF_sigil = object() def server(evt, serv, dataq=None): """ Open a tcp server in three steps 1) set evt to true to let the parent know we are ready 2) [optional] if is not False, write the list of data from dataq.get() to the socket. """ serv.listen(5) evt.set() try: conn, addr = serv.accept() if dataq: data = '' new_data = dataq.get(True, 0.5) dataq.task_done() for item in new_data: if item == EOF_sigil: break if type(item) in [int, float]: time.sleep(item) else: data += item written = conn.send(data) data = data[written:] conn.close() except socket.timeout: pass finally: serv.close() class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(60) # Safety net. Look issue 11812 self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock)) self.thread.setDaemon(True) self.thread.start() self.evt.wait() def tearDown(self): self.thread.join() def testBasic(self): # connects telnet = telnetlib.Telnet(HOST, self.port) telnet.sock.close() def testTimeoutDefault(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet(HOST, self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutNone(self): # None, having other default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(telnet.sock.gettimeout() is None) telnet.sock.close() def testTimeoutValue(self): telnet = telnetlib.Telnet(HOST, self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutOpen(self): telnet = telnetlib.Telnet() telnet.open(HOST, self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testGetters(self): # Test telnet getter methods telnet = telnetlib.Telnet(HOST, self.port, timeout=30) t_sock = telnet.sock self.assertEqual(telnet.get_socket(), t_sock) self.assertEqual(telnet.fileno(), t_sock.fileno()) telnet.sock.close() def _read_setUp(self): self.evt = threading.Event() self.dataq = Queue.Queue() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq)) self.thread.start() self.evt.wait() def _read_tearDown(self): self.thread.join() class ReadTests(TestCase): setUp = _read_setUp tearDown = _read_tearDown # use a similar approach to testing timeouts as test_timeout.py # these will never pass 100% but make the fuzz big enough that it is rare block_long = 0.6 block_short = 0.3 def test_read_until_A(self): """ read_until(expected, [timeout]) Read until the expected string has been seen, or a timeout is hit (default is no timeout); may block. """ want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_until_B(self): # test the timeout - it does NOT raise socket.timeout want = ['hello', self.block_long, 'not seen', EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_until('not seen', self.block_short) self.assertEqual(data, want[0]) self.assertEqual(telnet.read_all(), 'not seen') def test_read_until_with_poll(self): """Use select.poll() to implement telnet.read_until().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) if not telnet._has_poll: raise unittest.SkipTest('select.poll() is required') telnet._has_poll = True self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_until_with_select(self): """Use select.select() to implement telnet.read_until().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) telnet._has_poll = False self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_all_A(self): """ read_all() Read all data until EOF; may block. """ want = ['x' * 500, 'y' * 500, 'z' * 500, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_all() self.assertEqual(data, ''.join(want[:-1])) def _test_blocking(self, func): self.dataq.put([self.block_long, EOF_sigil]) self.dataq.join() start = time.time() data = func() self.assertTrue(self.block_short <= time.time() - start) def test_read_all_B(self): self._test_blocking(telnetlib.Telnet(HOST, self.port).read_all) def test_read_all_C(self): self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() telnet.read_all() telnet.read_all() # shouldn't raise def test_read_some_A(self): """ read_some() Read at least one byte or EOF; may block. """ # test 'at least one byte' want = ['x' * 500, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_all() self.assertTrue(len(data) >= 1) def test_read_some_B(self): # test EOF self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() self.assertEqual('', telnet.read_some()) def test_read_some_C(self): self._test_blocking(telnetlib.Telnet(HOST, self.port).read_some) def _test_read_any_eager_A(self, func_name): """ read_very_eager() Read all data available already queued or on the socket, without blocking. """ want = [self.block_long, 'x' * 100, 'y' * 100, EOF_sigil] expects = want[1] + want[2] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() func = getattr(telnet, func_name) data = '' while True: try: data += func() self.assertTrue(expects.startswith(data)) except EOFError: break self.assertEqual(expects, data) def _test_read_any_eager_B(self, func_name): # test EOF self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) func = getattr(telnet, func_name) self.assertRaises(EOFError, func) # read_eager and read_very_eager make the same gaurantees # (they behave differently but we only test the gaurantees) def test_read_very_eager_A(self): self._test_read_any_eager_A('read_very_eager') def test_read_very_eager_B(self): self._test_read_any_eager_B('read_very_eager') def test_read_eager_A(self): self._test_read_any_eager_A('read_eager') def test_read_eager_B(self): self._test_read_any_eager_B('read_eager') # NB -- we need to test the IAC block which is mentioned in the docstring # but not in the module docs def _test_read_any_lazy_B(self, func_name): self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() func = getattr(telnet, func_name) telnet.fill_rawq() self.assertRaises(EOFError, func) def test_read_lazy_A(self): want = ['x' * 100, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) self.assertEqual('', telnet.read_lazy()) data = '' while True: try: read_data = telnet.read_lazy() data += read_data if not read_data: telnet.fill_rawq() except EOFError: break self.assertTrue(want[0].startswith(data)) self.assertEqual(data, want[0]) def test_read_lazy_B(self): self._test_read_any_lazy_B('read_lazy') def test_read_very_lazy_A(self): want = ['x' * 100, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) self.assertEqual('', telnet.read_very_lazy()) data = '' while True: try: read_data = telnet.read_very_lazy() except EOFError: break data += read_data if not read_data: telnet.fill_rawq() self.assertEqual('', telnet.cookedq) telnet.process_rawq() self.assertTrue(want[0].startswith(data)) self.assertEqual(data, want[0]) def test_read_very_lazy_B(self): self._test_read_any_lazy_B('read_very_lazy') class nego_collector(object): def __init__(self, sb_getter=None): self.seen = '' self.sb_getter = sb_getter self.sb_seen = '' def do_nego(self, sock, cmd, opt): self.seen += cmd + opt if cmd == tl.SE and self.sb_getter: sb_data = self.sb_getter() self.sb_seen += sb_data tl = telnetlib class OptionTests(TestCase): setUp = _read_setUp tearDown = _read_tearDown # RFC 854 commands cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP] def _test_command(self, data): """ helper for testing IAC + cmd """ self.setUp() self.dataq.put(data) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() nego = nego_collector() telnet.set_option_negotiation_callback(nego.do_nego) txt = telnet.read_all() cmd = nego.seen self.assertTrue(len(cmd) > 0) # we expect at least one command self.assertIn(cmd[0], self.cmds) self.assertEqual(cmd[1], tl.NOOPT) self.assertEqual(len(''.join(data[:-1])), len(txt + cmd)) nego.sb_getter = None # break the nego => telnet cycle self.tearDown() def test_IAC_commands(self): # reset our setup self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() self.tearDown() for cmd in self.cmds: self._test_command(['x' * 100, tl.IAC + cmd, 'y'*100, EOF_sigil]) self._test_command(['x' * 10, tl.IAC + cmd, 'y'*10, EOF_sigil]) self._test_command([tl.IAC + cmd, EOF_sigil]) # all at once self._test_command([tl.IAC + cmd for (cmd) in self.cmds] + [EOF_sigil]) self.assertEqual('', telnet.read_sb_data()) def test_SB_commands(self): # RFC 855, subnegotiations portion send = [tl.IAC + tl.SB + tl.IAC + tl.SE, tl.IAC + tl.SB + tl.IAC + tl.IAC + tl.IAC + tl.SE, tl.IAC + tl.SB + tl.IAC + tl.IAC + 'aa' + tl.IAC + tl.SE, tl.IAC + tl.SB + 'bb' + tl.IAC + tl.IAC + tl.IAC + tl.SE, tl.IAC + tl.SB + 'cc' + tl.IAC + tl.IAC + 'dd' + tl.IAC + tl.SE, EOF_sigil, ] self.dataq.put(send) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() nego = nego_collector(telnet.read_sb_data) telnet.set_option_negotiation_callback(nego.do_nego) txt = telnet.read_all() self.assertEqual(txt, '') want_sb_data = tl.IAC + tl.IAC + 'aabb' + tl.IAC + 'cc' + tl.IAC + 'dd' self.assertEqual(nego.sb_seen, want_sb_data) self.assertEqual('', telnet.read_sb_data()) nego.sb_getter = None # break the nego => telnet cycle class ExpectTests(TestCase): def setUp(self): self.evt = threading.Event() self.dataq = Queue.Queue() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq)) self.thread.start() self.evt.wait() def tearDown(self): self.thread.join() # use a similar approach to testing timeouts as test_timeout.py # these will never pass 100% but make the fuzz big enough that it is rare block_long = 0.6 block_short = 0.3 def test_expect_A(self): """ expect(expected, [timeout]) Read until the expected string has been seen, or a timeout is hit (default is no timeout); may block. """ want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_expect_B(self): # test the timeout - it does NOT raise socket.timeout want = ['hello', self.block_long, 'not seen', EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() (_,_,data) = telnet.expect(['not seen'], self.block_short) self.assertEqual(data, want[0]) self.assertEqual(telnet.read_all(), 'not seen') def test_expect_with_poll(self): """Use select.poll() to implement telnet.expect().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) if not telnet._has_poll: raise unittest.SkipTest('select.poll() is required') telnet._has_poll = True self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_expect_with_select(self): """Use select.select() to implement telnet.expect().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) telnet._has_poll = False self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_main(verbose=None): test_support.run_unittest(GeneralTests, ReadTests, OptionTests, ExpectTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_thread.py0000644000076500000000000002012212666555342020722 0ustar jmaddenwheel00000000000000import os import unittest import random from test import test_support thread = test_support.import_module('thread') import time import sys import weakref from test import lock_tests NUMTASKS = 10 NUMTRIPS = 3 _print_mutex = thread.allocate_lock() def verbose_print(arg): """Helper function for printing out debugging output.""" if test_support.verbose: with _print_mutex: print arg class BasicThreadTest(unittest.TestCase): def setUp(self): self.done_mutex = thread.allocate_lock() self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() self.created = 0 self.running = 0 self.next_ident = 0 class ThreadRunningTests(BasicThreadTest): def newtask(self): with self.running_mutex: self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) self.created += 1 self.running += 1 def task(self, ident): with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay*1e6))) time.sleep(delay) verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): # Basic test for thread creation. for i in range(NUMTASKS): self.newtask() verbose_print("waiting for tasks to complete...") self.done_mutex.acquire() verbose_print("all tasks done") def test_stack_size(self): # Various stack size tests. self.assertEqual(thread.stack_size(), 0, "initial stack size is not 0") thread.stack_size(0) self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default") @unittest.skipIf(os.name not in ("nt", "os2", "posix"), 'test meant for nt, os2, and posix') def test_nt_and_posix_stack_size(self): try: thread.stack_size(4096) except ValueError: verbose_print("caught expected ValueError setting " "stack_size(4096)") except thread.error: self.skipTest("platform does not support changing thread stack " "size") fail_msg = "stack_size(%d) failed - should succeed" for tss in (262144, 0x100000, 0): thread.stack_size(tss) self.assertEqual(thread.stack_size(), tss, fail_msg % tss) verbose_print("successfully set stack_size(%d)" % tss) for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 self.created = 0 for i in range(NUMTASKS): self.newtask() verbose_print("waiting for all tasks to complete") self.done_mutex.acquire() verbose_print("all tasks done") thread.stack_size(0) def test__count(self): # Test the _count() function. orig = thread._count() mut = thread.allocate_lock() mut.acquire() started = [] def task(): started.append(None) mut.acquire() mut.release() thread.start_new_thread(task, ()) while not started: time.sleep(0.01) self.assertEqual(thread._count(), orig + 1) # Allow the task to finish. mut.release() # The only reliable way to be sure that the thread ended from the # interpreter's point of view is to wait for the function object to be # destroyed. done = [] wr = weakref.ref(task, lambda _: done.append(None)) del task while not done: time.sleep(0.01) self.assertEqual(thread._count(), orig) def test_save_exception_state_on_error(self): # See issue #14474 def task(): started.release() raise SyntaxError def mywrite(self, *args): try: raise ValueError except ValueError: pass real_write(self, *args) c = thread._count() started = thread.allocate_lock() with test_support.captured_output("stderr") as stderr: real_write = stderr.write stderr.write = mywrite started.acquire() thread.start_new_thread(task, ()) started.acquire() while thread._count() > c: time.sleep(0.01) self.assertIn("Traceback", stderr.getvalue()) class Barrier: def __init__(self, num_threads): self.num_threads = num_threads self.waiting = 0 self.checkin_mutex = thread.allocate_lock() self.checkout_mutex = thread.allocate_lock() self.checkout_mutex.acquire() def enter(self): self.checkin_mutex.acquire() self.waiting = self.waiting + 1 if self.waiting == self.num_threads: self.waiting = self.num_threads - 1 self.checkout_mutex.release() return self.checkin_mutex.release() self.checkout_mutex.acquire() self.waiting = self.waiting - 1 if self.waiting == 0: self.checkin_mutex.release() return self.checkout_mutex.release() class BarrierTest(BasicThreadTest): def test_barrier(self): self.bar = Barrier(NUMTASKS) self.running = NUMTASKS for i in range(NUMTASKS): thread.start_new_thread(self.task2, (i,)) verbose_print("waiting for tasks to end") self.done_mutex.acquire() verbose_print("tasks done") def task2(self, ident): for i in range(NUMTRIPS): if ident == 0: # give it a good chance to enter the next # barrier before the others are all out # of the current one delay = 0 else: with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay * 1e6))) time.sleep(delay) verbose_print("task %s entering %s" % (ident, i)) self.bar.enter() verbose_print("task %s leaving barrier" % ident) with self.running_mutex: self.running -= 1 # Must release mutex before releasing done, else the main thread can # exit and set mutex to None as part of global teardown; then # mutex.release() raises AttributeError. finished = self.running == 0 if finished: self.done_mutex.release() class LockTests(lock_tests.LockTests): locktype = thread.allocate_lock class TestForkInThread(unittest.TestCase): def setUp(self): self.read_fd, self.write_fd = os.pipe() @unittest.skipIf(sys.platform.startswith('win'), "This test is only appropriate for POSIX-like systems.") @test_support.reap_threads def test_forkinthread(self): def thread1(): try: pid = os.fork() # fork in a thread except RuntimeError: sys.exit(0) # exit the child if pid == 0: # child os.close(self.read_fd) os.write(self.write_fd, "OK") sys.exit(0) else: # parent os.close(self.write_fd) thread.start_new_thread(thread1, ()) self.assertEqual(os.read(self.read_fd, 2), "OK", "Unable to fork() in thread") def tearDown(self): try: os.close(self.read_fd) except OSError: pass try: os.close(self.write_fd) except OSError: pass def test_main(): test_support.run_unittest(ThreadRunningTests, BarrierTest, LockTests, TestForkInThread) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_threading.py0000644000076500000000000010363612666555342021434 0ustar jmaddenwheel00000000000000# Very rudimentary test of threading module import test.test_support from test.test_support import verbose, cpython_only from test.script_helper import assert_python_ok import random import re import sys thread = test.test_support.import_module('thread') threading = test.test_support.import_module('threading') import time import unittest import weakref import os import subprocess try: import _testcapi except ImportError: _testcapi = None import lock_tests # gevent: use local copy # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print 'task %s will run for %.1f usec' % ( self.name, delay * 1e6) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print self.nrunning.get(), 'tasks are running' self.testcase.assertTrue(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print 'task', self.name, 'done' with self.mutex: self.nrunning.dec() self.testcase.assertTrue(self.nrunning.get() >= 0) if verbose: print '%s is finished. %d tasks are running' % ( self.name, self.nrunning.get()) class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test.test_support.threading_setup() def tearDown(self): test.test_support.threading_cleanup(*self._threads) test.test_support.reap_children() class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) self.assertEqual(t.ident, None) self.assertTrue(re.match('', repr(t))) t.start() if verbose: print 'waiting for all tasks to complete' for t in threads: t.join(NUMTASKS) self.assertTrue(not t.is_alive()) self.assertNotEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assertTrue(re.match('', repr(t))) if verbose: print 'all tasks done' self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertFalse(threading.currentThread().ident is None) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print 'with 256kB thread stack size...' try: threading.stack_size(262144) except thread.error: self.skipTest('platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print 'with 1MB thread stack size...' try: threading.stack_size(0x100000) except thread.error: self.skipTest('platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assertIn(tid, threading._active) self.assertIsInstance(threading._active[tid], threading._DummyThread) del threading._active[tid] # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. def test_PyThreadState_SetAsyncExc(self): try: import ctypes except ImportError: self.skipTest('requires ctypes') set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # First check it works when setting the exception from the same thread. tid = thread.get_ident() try: result = set_async_exc(ctypes.c_long(tid), exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: pass except AsyncExc: pass else: # This code is unreachable but it reflects the intent. If we wanted # to be smarter the above loop wouldn't be infinite. self.fail("AsyncExc not raised") try: self.assertEqual(result, 1) # one thread state modified except UnboundLocalError: # The exception was raised too quickly for us to get the result. pass # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = thread.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print " started worker thread" # Try a thread id that doesn't make sense. if verbose: print " trying nonsensical thread id" result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print " waiting for worker thread to get started" ret = worker_started.wait() self.assertTrue(ret) if verbose: print " verifying worker hasn't exited" self.assertTrue(not t.finished) if verbose: print " attempting to raise asynch exception in worker" result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print " waiting for worker to say it caught the exception" worker_saw_exception.wait(timeout=10) self.assertTrue(t.finished) if verbose: print " all OK -- joining worker" if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise thread.error() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(thread.error, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. try: import ctypes except ImportError: self.skipTest('requires ctypes') rc = subprocess.call([sys.executable, "-c", """if 1: import ctypes, sys, time, thread # This lock is used as a simple event variable. ready = thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """]) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print 'program blocked; aborting' os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) stdout, stderr = p.communicate() rc = p.returncode self.assertFalse(rc == 2, "interpreted was blocked") self.assertTrue(rc == 0, "Unexpected error: " + repr(stderr)) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown p = subprocess.Popen([sys.executable, "-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print "Woke up, sleep function is:", sleep threading.Thread(target=child).start() raise SystemExit """], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) stdout, stderr = p.communicate() self.assertEqual(stdout.strip(), "Woke up, sleep function is: ") stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getcheckinterval() try: for i in xrange(1, 100): # Try a couple times at each thread-switching interval # to get more interleavings. sys.setcheckinterval(i // 5) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertNotIn(t, l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setcheckinterval(old_interval) def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertEqual(None, weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertEqual(None, weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') def test_dummy_thread_after_fork(self): # Issue #14308: a dummy thread in the active list doesn't mess up # the after-fork mechanism. code = """if 1: import thread, threading, os, time def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: os.wait() """ _, out, err = assert_python_ok("-c", code) self.assertEqual(out, '') self.assertEqual(err, '') @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_is_alive_after_fork(self): # Try hard to trigger #18418: is_alive() could sometimes be True on # threads that vanished after a fork. old_interval = sys.getcheckinterval() # Make the bug more likely to manifest. sys.setcheckinterval(10) try: for i in range(20): t = threading.Thread(target=lambda: None) t.start() pid = os.fork() if pid == 0: os._exit(1 if t.is_alive() else 0) else: t.join() pid, status = os.waitpid(pid, 0) self.assertEqual(0, status) finally: sys.setcheckinterval(old_interval) def test_BoundedSemaphore_limit(self): # BoundedSemaphore should raise ValueError if released too often. for limit in range(1, 10): bs = threading.BoundedSemaphore(limit) threads = [threading.Thread(target=bs.acquire) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() threads = [threading.Thread(target=bs.release) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() self.assertRaises(ValueError, bs.release) class ThreadJoinOnShutdown(BaseTestCase): # Between fork() and exec(), only async-safe functions are allowed (issues # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', 'os2emx') def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print 'end of thread' \n""" + script p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().replace('\r', '') p.stdout.close() self.assertEqual(data, "end of main\nend of thread\n") self.assertFalse(rc == 2, "interpreter was blocked") self.assertTrue(rc == 0, "Unexpected error") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print 'end of main' """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print 'end of main' """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print 'end of main' t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) def assertScriptHasOutput(self, script, expected_output): p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().decode().replace('\r', '') self.assertEqual(rc, 0, "Unexpected error") self.assertEqual(data, expected_output) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_4_joining_across_fork_in_worker_thread(self): # There used to be a possible deadlock when forking from a child # thread. See http://bugs.python.org/issue6643. # The script takes the following steps: # - The main thread in the parent process starts a new thread and then # tries to join it. # - The join operation acquires the Lock inside the thread's _block # Condition. (See threading.py:Thread.join().) # - We stub out the acquire method on the condition to force it to wait # until the child thread forks. (See LOCK ACQUIRED HERE) # - The child thread forks. (See LOCK HELD and WORKER THREAD FORKS # HERE) # - The main thread of the parent process enters Condition.wait(), # which releases the lock on the child thread. # - The child process returns. Without the necessary fix, when the # main thread of the child process (which used to be the child thread # in the parent process) attempts to exit, it will try to acquire the # lock in the Thread._block Condition object and hang, because the # lock was held across the fork. script = """if 1: import os, time, threading finish_join = False start_fork = False def worker(): # Wait until this thread's lock is acquired before forking to # create the deadlock. global finish_join while not start_fork: time.sleep(0.01) # LOCK HELD: Main thread holds lock across this call. childpid = os.fork() finish_join = True if childpid != 0: # Parent process just waits for child. os.waitpid(childpid, 0) # Child process should just return. w = threading.Thread(target=worker) # Stub out the private condition variable's lock acquire method. # This acquires the lock and then waits until the child has forked # before returning, which will release the lock soon after. If # someone else tries to fix this test case by acquiring this lock # before forking instead of resetting it, the test case will # deadlock when it shouldn't. condition = w._block orig_acquire = condition.acquire call_count_lock = threading.Lock() call_count = 0 def my_acquire(): global call_count global start_fork orig_acquire() # LOCK ACQUIRED HERE start_fork = True if call_count == 0: while not finish_join: time.sleep(0.01) # WORKER THREAD FORKS HERE with call_count_lock: call_count += 1 condition.acquire = my_acquire w.start() w.join() print('end of main') """ self.assertScriptHasOutput(script, "end of main\n") @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_5_clear_waiter_locks_to_avoid_crash(self): # Check that a spawned thread that forks doesn't segfault on certain # platforms, namely OS X. This used to happen if there was a waiter # lock in the thread's condition variable's waiters list. Even though # we know the lock will be held across the fork, it is not safe to # release locks held across forks on all platforms, so releasing the # waiter lock caused a segfault on OS X. Furthermore, since locks on # OS X are (as of this writing) implemented with a mutex + condition # variable instead of a semaphore, while we know that the Python-level # lock will be acquired, we can't know if the internal mutex will be # acquired at the time of the fork. script = """if True: import os, time, threading start_fork = False def worker(): # Wait until the main thread has attempted to join this thread # before continuing. while not start_fork: time.sleep(0.01) childpid = os.fork() if childpid != 0: # Parent process just waits for child. (cpid, rc) = os.waitpid(childpid, 0) assert cpid == childpid assert rc == 0 print('end of worker thread') else: # Child process should just return. pass w = threading.Thread(target=worker) # Stub out the private condition variable's _release_save method. # This releases the condition's lock and flips the global that # causes the worker to fork. At this point, the problematic waiter # lock has been acquired once by the waiter and has been put onto # the waiters list. condition = w._block orig_release_save = condition._release_save def my_release_save(): global start_fork orig_release_save() # Waiter lock held here, condition lock released. start_fork = True condition._release_save = my_release_save w.start() w.join() print('end of main thread') """ output = "end of worker thread\nend of main thread\n" self.assertScriptHasOutput(script, output) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): # Issue #13817: fork() would deadlock in a multithreaded program with # the ad-hoc TLS implementation. def do_fork_and_wait(): # just fork a child process and wait it pid = os.fork() if pid > 0: os.waitpid(pid, 0) else: os._exit(0) # start a bunch of threads that will fork() child processes threads = [] for i in range(16): t = threading.Thread(target=do_fork_and_wait) threads.append(t) t.start() for t in threads: t.join() @cpython_only @unittest.skipIf(_testcapi is None, "need _testcapi module") def test_frame_tstate_tracing(self): # Issue #14432: Crash when a generator is created in a C thread that is # destroyed while the generator is still used. The issue was that a # generator contains a frame, and the frame kept a reference to the # Python state of the destroyed C thread. The crash occurs when a trace # function is setup. def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "genereator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call _testcapi.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) def test_print_exception(self): script = r"""if 1: import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1.0/0.0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, '') self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_1(self): script = r"""if 1: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1.0/0.0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) sys.stderr = None running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, '') self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_2(self): script = r"""if 1: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1.0/0.0 sys.stderr = None t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, '') self.assertNotIn("Unhandled exception", err) class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class RLockTests(lock_tests.RLockTests): locktype = staticmethod(threading.RLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) @unittest.skipUnless(sys.platform == 'darwin', 'test macosx problem') def test_recursion_limit(self): # Issue 9670 # test that excessive recursion within a non-main thread causes # an exception rather than crashing the interpreter on platforms # like Mac OS X or FreeBSD which have small default stack sizes # for threads script = """if True: import threading def recurse(): return recurse() def outer(): try: recurse() except RuntimeError: pass w = threading.Thread(target=outer) w.start() w.join() print('end of main thread') """ expected_output = "end of main thread\n" p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) stdout, stderr = p.communicate() data = stdout.decode().replace('\r', '') self.assertEqual(p.returncode, 0, "Unexpected error") self.assertEqual(data, expected_output) def test_main(): test.test_support.run_unittest(LockTests, RLockTests, EventTests, ConditionAsRLockTests, ConditionTests, SemaphoreTests, BoundedSemaphoreTests, ThreadTests, ThreadJoinOnShutdown, ThreadingExceptionTests, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_threading_local.py0000644000076500000000000001472312666555342022604 0ustar jmaddenwheel00000000000000import unittest from doctest import DocTestSuite from test import test_support as support import weakref import gc # Modules under test _thread = support.import_module('thread') threading = support.import_module('threading') import _threading_local class Weak(object): pass def target(local, weaklist): weak = Weak() local.weak = weak weaklist.append(weakref.ref(weak)) class BaseLocalTest: def test_local_refs(self): self._local_refs(20) self._local_refs(50) self._local_refs(100) def _local_refs(self, n): local = self._local() weaklist = [] for i in range(n): t = threading.Thread(target=target, args=(local, weaklist)) t.start() t.join() del t gc.collect() self.assertEqual(len(weaklist), n) # XXX _threading_local keeps the local of the last stopped thread alive. deadlist = [weak for weak in weaklist if weak() is None] self.assertIn(len(deadlist), (n-1, n)) # Assignment to the same thread local frees it sometimes (!) local.someothervar = None gc.collect() deadlist = [weak for weak in weaklist if weak() is None] self.assertIn(len(deadlist), (n-1, n), (n, len(deadlist))) def test_derived(self): # Issue 3088: if there is a threads switch inside the __init__ # of a threading.local derived class, the per-thread dictionary # is created but not correctly set on the object. # The first member set may be bogus. import time class Local(self._local): def __init__(self): time.sleep(0.01) local = Local() def f(i): local.x = i # Simply check that the variable is correctly set self.assertEqual(local.x, i) with support.start_threads(threading.Thread(target=f, args=(i,)) for i in range(10)): pass def test_derived_cycle_dealloc(self): # http://bugs.python.org/issue6990 class Local(self._local): pass locals = None passed = [False] e1 = threading.Event() e2 = threading.Event() def f(): # 1) Involve Local in a cycle cycle = [Local()] cycle.append(cycle) cycle[0].foo = 'bar' # 2) GC the cycle (triggers threadmodule.c::local_clear # before local_dealloc) del cycle gc.collect() e1.set() e2.wait() # 4) New Locals should be empty passed[0] = all(not hasattr(local, 'foo') for local in locals) t = threading.Thread(target=f) t.start() e1.wait() # 3) New Locals should recycle the original's address. Creating # them in the thread overwrites the thread state and avoids the # bug locals = [Local() for i in range(10)] e2.set() t.join() self.assertTrue(passed[0]) def test_arguments(self): # Issue 1522237 from thread import _local as local from _threading_local import local as py_local for cls in (local, py_local): class MyLocal(cls): def __init__(self, *args, **kwargs): pass MyLocal(a=1) MyLocal(1) self.assertRaises(TypeError, cls, a=1) self.assertRaises(TypeError, cls, 1) def _test_one_class(self, c): self._failed = "No error message set or cleared." obj = c() e1 = threading.Event() e2 = threading.Event() def f1(): obj.x = 'foo' obj.y = 'bar' del obj.y e1.set() e2.wait() def f2(): try: foo = obj.x except AttributeError: # This is expected -- we haven't set obj.x in this thread yet! self._failed = "" # passed else: self._failed = ('Incorrectly got value %r from class %r\n' % (foo, c)) sys.stderr.write(self._failed) t1 = threading.Thread(target=f1) t1.start() e1.wait() t2 = threading.Thread(target=f2) t2.start() t2.join() # The test is done; just let t1 know it can exit, and wait for it. e2.set() t1.join() self.assertFalse(self._failed, self._failed) def test_threading_local(self): self._test_one_class(self._local) def test_threading_local_subclass(self): class LocalSubclass(self._local): """To test that subclasses behave properly.""" self._test_one_class(LocalSubclass) def _test_dict_attribute(self, cls): obj = cls() obj.x = 5 self.assertEqual(obj.__dict__, {'x': 5}) with self.assertRaises(AttributeError): obj.__dict__ = {} with self.assertRaises(AttributeError): del obj.__dict__ def test_dict_attribute(self): self._test_dict_attribute(self._local) def test_dict_attribute_subclass(self): class LocalSubclass(self._local): """To test that subclasses behave properly.""" self._test_dict_attribute(LocalSubclass) class ThreadLocalTest(unittest.TestCase, BaseLocalTest): _local = _thread._local # Fails for the pure Python implementation def test_cycle_collection(self): class X: pass x = X() x.local = self._local() x.local.x = x wr = weakref.ref(x) del x gc.collect() self.assertIs(wr(), None) class PyThreadingLocalTest(unittest.TestCase, BaseLocalTest): _local = _threading_local.local def test_main(): suite = unittest.TestSuite() suite.addTest(DocTestSuite('_threading_local')) suite.addTest(unittest.makeSuite(ThreadLocalTest)) suite.addTest(unittest.makeSuite(PyThreadingLocalTest)) try: from thread import _local except ImportError: pass else: import _threading_local local_orig = _threading_local.local def setUp(test): _threading_local.local = _local def tearDown(test): _threading_local.local = local_orig suite.addTest(DocTestSuite('_threading_local', setUp=setUp, tearDown=tearDown) ) support.run_unittest(suite) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_timeout.py0000644000076500000000000001566412666555342021160 0ustar jmaddenwheel00000000000000"""Unit tests for socket timeout feature.""" import unittest from test import test_support # This requires the 'network' resource as given on the regrtest command line. skip_expected = not test_support.is_resource_enabled('network') import time import socket class CreationTestCase(unittest.TestCase): """Test case for socket.gettimeout() and socket.settimeout()""" def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): self.sock.close() def testObjectCreation(self): # Test Socket creation self.assertEqual(self.sock.gettimeout(), None, "timeout not disabled by default") def testFloatReturnValue(self): # Test return value of gettimeout() self.sock.settimeout(7.345) self.assertEqual(self.sock.gettimeout(), 7.345) self.sock.settimeout(3) self.assertEqual(self.sock.gettimeout(), 3) self.sock.settimeout(None) self.assertEqual(self.sock.gettimeout(), None) def testReturnType(self): # Test return type of gettimeout() self.sock.settimeout(1) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) self.sock.settimeout(3.9) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) def testTypeCheck(self): # Test type checking by settimeout() self.sock.settimeout(0) self.sock.settimeout(0L) self.sock.settimeout(0.0) self.sock.settimeout(None) self.assertRaises(TypeError, self.sock.settimeout, "") self.assertRaises(TypeError, self.sock.settimeout, u"") self.assertRaises(TypeError, self.sock.settimeout, ()) self.assertRaises(TypeError, self.sock.settimeout, []) self.assertRaises(TypeError, self.sock.settimeout, {}) self.assertRaises(TypeError, self.sock.settimeout, 0j) def testRangeCheck(self): # Test range checking by settimeout() self.assertRaises(ValueError, self.sock.settimeout, -1) self.assertRaises(ValueError, self.sock.settimeout, -1L) self.assertRaises(ValueError, self.sock.settimeout, -1.0) def testTimeoutThenBlocking(self): # Test settimeout() followed by setblocking() self.sock.settimeout(10) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.settimeout(10) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) def testBlockingThenTimeout(self): # Test setblocking() followed by settimeout() self.sock.setblocking(0) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) self.sock.setblocking(1) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) class TimeoutTestCase(unittest.TestCase): """Test case for socket.socket() timeout functions""" # There are a number of tests here trying to make sure that an operation # doesn't take too much longer than expected. But competing machine # activity makes it inevitable that such tests will fail at times. # When fuzz was at 1.0, I (tim) routinely saw bogus failures on Win2K # and Win98SE. Boosting it to 2.0 helped a lot, but isn't a real # solution. fuzz = 2.0 def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() def testConnectTimeout(self): # Choose a private address that is unlikely to exist to prevent # failures due to the connect succeeding before the timeout. # Use a dotted IP address to avoid including the DNS lookup time # with the connect time. This avoids failing the assertion that # the timeout occurred fast enough. addr = ('10.0.0.0', 12345) # Test connect() timeout _timeout = 0.001 self.sock.settimeout(_timeout) _t1 = time.time() self.assertRaises(socket.error, self.sock.connect, addr) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is more than %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvTimeout(self): # Test recv() timeout _timeout = 0.02 with test_support.transient_internet(self.addr_remote[0]): self.sock.connect(self.addr_remote) self.sock.settimeout(_timeout) _t1 = time.time() self.assertRaises(socket.timeout, self.sock.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testAcceptTimeout(self): # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() self.assertRaises(socket.error, self.sock.accept) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvfromTimeout(self): # Test recvfrom() timeout _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) _t1 = time.time() self.assertRaises(socket.error, self.sock.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) @unittest.skip('test not implemented') def testSend(self): # Test send() timeout # couldn't figure out how to test it pass @unittest.skip('test not implemented') def testSendto(self): # Test sendto() timeout # couldn't figure out how to test it pass @unittest.skip('test not implemented') def testSendall(self): # Test sendall() timeout # couldn't figure out how to test it pass def test_main(): test_support.requires('network') test_support.run_unittest(CreationTestCase, TimeoutTestCase) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_urllib.py0000644000076500000000000012043012666555342020747 0ustar jmaddenwheel00000000000000"""Regresssion tests for urllib""" import urllib import httplib import unittest import os import sys import mimetools import tempfile import StringIO from test import test_support from base64 import b64encode def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr class FakeHTTPMixin(object): def fakehttp(self, fakedata): class FakeSocket(StringIO.StringIO): def sendall(self, data): FakeHTTPConnection.buf = data def makefile(self, *args, **kwds): return self def read(self, amt=None): if self.closed: return "" return StringIO.StringIO.read(self, amt) def readline(self, length=None): if self.closed: return "" return StringIO.StringIO.readline(self, length) class FakeHTTPConnection(httplib.HTTPConnection): # buffer to store data for verification in urlopen tests. buf = "" def connect(self): self.sock = FakeSocket(fakedata) assert httplib.HTTP._connection_class == httplib.HTTPConnection httplib.HTTP._connection_class = FakeHTTPConnection def unfakehttp(self): httplib.HTTP._connection_class = httplib.HTTPConnection class urlopen_FileTests(unittest.TestCase): """Test urlopen() opening a temporary file. Try to test as much functionality as possible so as to cut down on reliance on connecting to the Net for testing. """ def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ FILE = file(test_support.TESTFN, 'wb') try: FILE.write(self.text) finally: FILE.close() self.pathname = test_support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) def tearDown(self): """Shut down the open object""" self.returned_obj.close() os.remove(test_support.TESTFN) def test_interface(self): # Make sure object returned by urlopen() has the specified methods for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl", "getcode", "__iter__"): self.assertTrue(hasattr(self.returned_obj, attr), "object returned by urlopen() lacks %s attribute" % attr) def test_read(self): self.assertEqual(self.text, self.returned_obj.read()) def test_readline(self): self.assertEqual(self.text, self.returned_obj.readline()) self.assertEqual('', self.returned_obj.readline(), "calling readline() after exhausting the file did not" " return an empty string") def test_readlines(self): lines_list = self.returned_obj.readlines() self.assertEqual(len(lines_list), 1, "readlines() returned the wrong number of lines") self.assertEqual(lines_list[0], self.text, "readlines() returned improper text") def test_fileno(self): file_num = self.returned_obj.fileno() self.assertIsInstance(file_num, int, "fileno() did not return an int") self.assertEqual(os.read(file_num, len(self.text)), self.text, "Reading on the file descriptor returned by fileno() " "did not return the expected text") def test_close(self): # Test close() by calling it hear and then having it be called again # by the tearDown() method for the test self.returned_obj.close() def test_info(self): self.assertIsInstance(self.returned_obj.info(), mimetools.Message) def test_geturl(self): self.assertEqual(self.returned_obj.geturl(), self.pathname) def test_getcode(self): self.assertEqual(self.returned_obj.getcode(), None) def test_iter(self): # Test iterator # Don't need to count number of iterations since test would fail the # instant it returned anything beyond the first line from the # comparison for line in self.returned_obj.__iter__(): self.assertEqual(line, self.text) def test_relativelocalfile(self): self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname) class ProxyTests(unittest.TestCase): def setUp(self): # Records changes to env vars self.env = test_support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k) def tearDown(self): # Restore all proxy related env vars self.env.__exit__() del self.env def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin): """Test urlopen() opening a fake http connection.""" def test_read(self): self.fakehttp('Hello!') try: fp = urllib.urlopen("http://python.org/") self.assertEqual(fp.readline(), 'Hello!') self.assertEqual(fp.readline(), '') self.assertEqual(fp.geturl(), 'http://python.org/') self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() def test_url_fragment(self): # Issue #11703: geturl() omits fragments in the original URL. url = 'http://docs.python.org/library/urllib.html#OK' self.fakehttp('Hello!') try: fp = urllib.urlopen(url) self.assertEqual(fp.geturl(), url) finally: self.unfakehttp() def test_read_bogus(self): # urlopen() should raise IOError for many error codes. self.fakehttp('''HTTP/1.1 401 Authentication Required Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Type: text/html; charset=iso-8859-1 ''') try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_invalid_redirect(self): # urlopen() should raise IOError for many error codes. self.fakehttp("""HTTP/1.1 302 Found Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Location: file:README Connection: close Content-Type: text/html; charset=iso-8859-1 """) try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_empty_socket(self): # urlopen() raises IOError if the underlying socket does not send any # data. (#1680230) self.fakehttp('') try: self.assertRaises(IOError, urllib.urlopen, 'http://something') finally: self.unfakehttp() def test_missing_localfile(self): self.assertRaises(IOError, urllib.urlopen, 'file://localhost/a/missing/file.py') fd, tmp_file = tempfile.mkstemp() tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/') self.assertTrue(os.path.exists(tmp_file)) try: fp = urllib.urlopen(tmp_fileurl) fp.close() finally: os.close(fd) os.unlink(tmp_file) self.assertFalse(os.path.exists(tmp_file)) self.assertRaises(IOError, urllib.urlopen, tmp_fileurl) def test_ftp_nonexisting(self): self.assertRaises(IOError, urllib.urlopen, 'ftp://localhost/not/existing/file.py') def test_userpass_inurl(self): self.fakehttp('Hello!') try: fakehttp_wrapper = httplib.HTTP._connection_class fp = urllib.urlopen("http://user:pass@python.org/") authorization = ("Authorization: Basic %s\r\n" % b64encode('user:pass')) # The authorization header must be in place self.assertIn(authorization, fakehttp_wrapper.buf) self.assertEqual(fp.readline(), "Hello!") self.assertEqual(fp.readline(), "") self.assertEqual(fp.geturl(), 'http://user:pass@python.org/') self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() def test_userpass_with_spaces_inurl(self): self.fakehttp('Hello!') try: url = "http://a b:c d@python.org/" fakehttp_wrapper = httplib.HTTP._connection_class authorization = ("Authorization: Basic %s\r\n" % b64encode('a b:c d')) fp = urllib.urlopen(url) # The authorization header must be in place self.assertIn(authorization, fakehttp_wrapper.buf) self.assertEqual(fp.readline(), "Hello!") self.assertEqual(fp.readline(), "") # the spaces are quoted in URL so no match self.assertNotEqual(fp.geturl(), url) self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() class urlretrieve_FileTests(unittest.TestCase): """Test urllib.urlretrieve() on local files""" def setUp(self): # Create a list of temporary files. Each item in the list is a file # name (absolute path or relative to the current working directory). # All files in this list will be deleted in the tearDown method. Note, # this only helps to makes sure temporary files get deleted, but it # does nothing about trying to close files that may still be open. It # is the responsibility of the developer to properly close files even # when exceptional conditions occur. self.tempFiles = [] # Create a temporary file. self.registerFileForCleanUp(test_support.TESTFN) self.text = 'testing urllib.urlretrieve' try: FILE = file(test_support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: try: FILE.close() except: pass def tearDown(self): # Delete the temporary files. for each in self.tempFiles: try: os.remove(each) except: pass def constructLocalFileUrl(self, filePath): return "file://%s" % urllib.pathname2url(os.path.abspath(filePath)) def createNewTempFile(self, data=""): """Creates a new temporary file containing the specified data, registers the file for deletion during the test fixture tear down, and returns the absolute path of the file.""" newFd, newFilePath = tempfile.mkstemp() try: self.registerFileForCleanUp(newFilePath) newFile = os.fdopen(newFd, "wb") newFile.write(data) newFile.close() finally: try: newFile.close() except: pass return newFilePath def registerFileForCleanUp(self, fileName): self.tempFiles.append(fileName) def test_basic(self): # Make sure that a local file just gets its own location returned and # a headers value is returned. result = urllib.urlretrieve("file:%s" % test_support.TESTFN) self.assertEqual(result[0], test_support.TESTFN) self.assertIsInstance(result[1], mimetools.Message, "did not get a mimetools.Message instance as " "second returned value") def test_copy(self): # Test that setting the filename argument works. second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) result = urllib.urlretrieve(self.constructLocalFileUrl( test_support.TESTFN), second_temp) self.assertEqual(second_temp, result[0]) self.assertTrue(os.path.exists(second_temp), "copy of the file was not " "made") FILE = file(second_temp, 'rb') try: text = FILE.read() FILE.close() finally: try: FILE.close() except: pass self.assertEqual(self.text, text) def test_reporthook(self): # Make sure that the reporthook works. def hooktester(count, block_size, total_size, count_holder=[0]): self.assertIsInstance(count, int) self.assertIsInstance(block_size, int) self.assertIsInstance(total_size, int) self.assertEqual(count, count_holder[0]) count_holder[0] = count_holder[0] + 1 second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN), second_temp, hooktester) def test_reporthook_0_bytes(self): # Test on zero length file. Should call reporthook only 1 time. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile() urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 1) self.assertEqual(report[0][2], 0) def test_reporthook_5_bytes(self): # Test on 5 byte file. Should call reporthook only 2 times (once when # the "network connection" is established and once when the block is # read). Since the block size is 8192 bytes, only one block read is # required to read the entire file. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 5) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 2) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 5) def test_reporthook_8193_bytes(self): # Test on 8193 byte file. Should call reporthook only 3 times (once # when the "network connection" is established, once for the next 8192 # bytes, and once for the last byte). report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 8193) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) class urlretrieve_HttpTests(unittest.TestCase, FakeHTTPMixin): """Test urllib.urlretrieve() using fake http connections""" def test_short_content_raises_ContentTooShortError(self): self.fakehttp('''HTTP/1.1 200 OK Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Length: 100 Content-Type: text/html; charset=iso-8859-1 FF ''') def _reporthook(par1, par2, par3): pass try: self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com', reporthook=_reporthook) finally: self.unfakehttp() def test_short_content_raises_ContentTooShortError_without_reporthook(self): self.fakehttp('''HTTP/1.1 200 OK Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Length: 100 Content-Type: text/html; charset=iso-8859-1 FF ''') try: self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com/') finally: self.unfakehttp() class QuotingTests(unittest.TestCase): """Tests for urllib.quote() and urllib.quote_plus() According to RFC 2396 ("Uniform Resource Identifiers), to escape a character you write it as '%' + <2 character US-ASCII hex value>. The Python code of ``'%' + hex(ord())[2:]`` escapes a character properly. Case does not matter on the hex letters. The various character sets specified are: Reserved characters : ";/?:@&=+$," Have special meaning in URIs and must be escaped if not being used for their special meaning Data characters : letters, digits, and "-_.!~*'()" Unreserved and do not need to be escaped; can be, though, if desired Control characters : 0x00 - 0x1F, 0x7F Have no use in URIs so must be escaped space : 0x20 Must be escaped Delimiters : '<>#%"' Must be escaped Unwise : "{}|\^[]`" Must be escaped """ def test_never_quote(self): # Make sure quote() does not quote letters, digits, and "_,.-" do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789", "_.-"]) result = urllib.quote(do_not_quote) self.assertEqual(do_not_quote, result, "using quote(): %s != %s" % (do_not_quote, result)) result = urllib.quote_plus(do_not_quote) self.assertEqual(do_not_quote, result, "using quote_plus(): %s != %s" % (do_not_quote, result)) def test_default_safe(self): # Test '/' is default value for 'safe' parameter self.assertEqual(urllib.quote.func_defaults[0], '/') def test_safe(self): # Test setting 'safe' parameter does what it should do quote_by_default = "<>" result = urllib.quote(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote(): %s != %s" % (quote_by_default, result)) result = urllib.quote_plus(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote_plus(): %s != %s" % (quote_by_default, result)) def test_default_quoting(self): # Make sure all characters that should be quoted are by default sans # space (separate test for that). should_quote = [chr(num) for num in range(32)] # For 0x00 - 0x1F should_quote.append('<>#%"{}|\^[]`') should_quote.append(chr(127)) # For 0x7F should_quote = ''.join(should_quote) for char in should_quote: result = urllib.quote(char) self.assertEqual(hexescape(char), result, "using quote(): %s should be escaped to %s, not %s" % (char, hexescape(char), result)) result = urllib.quote_plus(char) self.assertEqual(hexescape(char), result, "using quote_plus(): " "%s should be escapes to %s, not %s" % (char, hexescape(char), result)) del should_quote partial_quote = "ab[]cd" expected = "ab%5B%5Dcd" result = urllib.quote(partial_quote) self.assertEqual(expected, result, "using quote(): %s != %s" % (expected, result)) result = urllib.quote_plus(partial_quote) self.assertEqual(expected, result, "using quote_plus(): %s != %s" % (expected, result)) self.assertRaises(TypeError, urllib.quote, None) def test_quoting_space(self): # Make sure quote() and quote_plus() handle spaces as specified in # their unique way result = urllib.quote(' ') self.assertEqual(result, hexescape(' '), "using quote(): %s != %s" % (result, hexescape(' '))) result = urllib.quote_plus(' ') self.assertEqual(result, '+', "using quote_plus(): %s != +" % result) given = "a b cd e f" expect = given.replace(' ', hexescape(' ')) result = urllib.quote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) expect = given.replace(' ', '+') result = urllib.quote_plus(given) self.assertEqual(expect, result, "using quote_plus(): %s != %s" % (expect, result)) def test_quoting_plus(self): self.assertEqual(urllib.quote_plus('alpha+beta gamma'), 'alpha%2Bbeta+gamma') self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'), 'alpha+beta+gamma') class UnquotingTests(unittest.TestCase): """Tests for unquote() and unquote_plus() See the doc string for quoting_Tests for details on quoting and such. """ def test_unquoting(self): # Make sure unquoting of all ASCII values works escape_list = [] for num in range(128): given = hexescape(chr(num)) expect = chr(num) result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) escape_list.append(given) escape_string = ''.join(escape_list) del escape_list result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using quote(): not all characters escaped; %s" % result) result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using unquote(): not all characters escaped: " "%s" % result) def test_unquoting_badpercent(self): # Test unquoting on bad percent-escapes given = '%xab' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%x' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_mixed_case(self): # Test unquoting on mixed-case hex digits in the percent-escapes given = '%Ab%eA' expect = '\xab\xea' result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_parts(self): # Make sure unquoting works when have non-quoted characters # interspersed given = 'ab%sd' % hexescape('c') expect = "abcd" result = urllib.unquote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquoting_plus(self): # Test difference between unquote() and unquote_plus() given = "are+there+spaces..." expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) expect = given.replace('+', ' ') result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquote_with_unicode(self): r = urllib.unquote(u'br%C3%BCckner_sapporo_20050930.doc') self.assertEqual(r, u'br\xc3\xbcckner_sapporo_20050930.doc') class urlencode_Tests(unittest.TestCase): """Tests for urlencode()""" def help_inputtype(self, given, test_type): """Helper method for testing different input types. 'given' must lead to only the pairs: * 1st, 1 * 2nd, 2 * 3rd, 3 Test cannot assume anything about order. Docs make no guarantee and have possible dictionary input. """ expect_somewhere = ["1st=1", "2nd=2", "3rd=3"] result = urllib.urlencode(given) for expected in expect_somewhere: self.assertIn(expected, result, "testing %s: %s not found in %s" % (test_type, expected, result)) self.assertEqual(result.count('&'), 2, "testing %s: expected 2 '&'s; got %s" % (test_type, result.count('&'))) amp_location = result.index('&') on_amp_left = result[amp_location - 1] on_amp_right = result[amp_location + 1] self.assertTrue(on_amp_left.isdigit() and on_amp_right.isdigit(), "testing %s: '&' not located in proper place in %s" % (test_type, result)) self.assertEqual(len(result), (5 * 3) + 2, #5 chars per thing and amps "testing %s: " "unexpected number of characters: %s != %s" % (test_type, len(result), (5 * 3) + 2)) def test_using_mapping(self): # Test passing in a mapping object as an argument. self.help_inputtype({"1st":'1', "2nd":'2', "3rd":'3'}, "using dict as input type") def test_using_sequence(self): # Test passing in a sequence of two-item sequences as an argument. self.help_inputtype([('1st', '1'), ('2nd', '2'), ('3rd', '3')], "using sequence of two-item tuples as input") def test_quoting(self): # Make sure keys and values are quoted using quote_plus() given = {"&":"="} expect = "%s=%s" % (hexescape('&'), hexescape('=')) result = urllib.urlencode(given) self.assertEqual(expect, result) given = {"key name":"A bunch of pluses"} expect = "key+name=A+bunch+of+pluses" result = urllib.urlencode(given) self.assertEqual(expect, result) def test_doseq(self): # Test that passing True for 'doseq' parameter works correctly given = {'sequence':['1', '2', '3']} expect = "sequence=%s" % urllib.quote_plus(str(['1', '2', '3'])) result = urllib.urlencode(given) self.assertEqual(expect, result) result = urllib.urlencode(given, True) for value in given["sequence"]: expect = "sequence=%s" % value self.assertIn(expect, result) self.assertEqual(result.count('&'), 2, "Expected 2 '&'s, got %s" % result.count('&')) class Pathname_Tests(unittest.TestCase): """Test pathname2url() and url2pathname()""" def test_basic(self): # Make sure simple tests pass expected_path = os.path.join("parts", "of", "a", "path") expected_url = "parts/of/a/path" result = urllib.pathname2url(expected_path) self.assertEqual(expected_url, result, "pathname2url() failed; %s != %s" % (result, expected_url)) result = urllib.url2pathname(expected_url) self.assertEqual(expected_path, result, "url2pathame() failed; %s != %s" % (result, expected_path)) def test_quoting(self): # Test automatic quoting and unquoting works for pathnam2url() and # url2pathname() respectively given = os.path.join("needs", "quot=ing", "here") expect = "needs/%s/here" % urllib.quote("quot=ing") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) expect = given result = urllib.url2pathname(result) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) given = os.path.join("make sure", "using_quote") expect = "%s/using_quote" % urllib.quote("make sure") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) given = "make+sure/using_unquote" expect = os.path.join("make+sure", "using_unquote") result = urllib.url2pathname(given) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) @unittest.skipUnless(sys.platform == 'win32', 'test specific to the nturl2path library') def test_ntpath(self): given = ('/C:/', '///C:/', '/C|//') expect = 'C:\\' for url in given: result = urllib.url2pathname(url) self.assertEqual(expect, result, 'nturl2path.url2pathname() failed; %s != %s' % (expect, result)) given = '///C|/path' expect = 'C:\\path' result = urllib.url2pathname(given) self.assertEqual(expect, result, 'nturl2path.url2pathname() failed; %s != %s' % (expect, result)) class Utility_Tests(unittest.TestCase): """Testcase to test the various utility functions in the urllib.""" # In Python 3 this test class is moved to test_urlparse. def test_splittype(self): splittype = urllib.splittype self.assertEqual(splittype('type:opaquestring'), ('type', 'opaquestring')) self.assertEqual(splittype('opaquestring'), (None, 'opaquestring')) self.assertEqual(splittype(':opaquestring'), (None, ':opaquestring')) self.assertEqual(splittype('type:'), ('type', '')) self.assertEqual(splittype('type:opaque:string'), ('type', 'opaque:string')) def test_splithost(self): splithost = urllib.splithost self.assertEqual(splithost('//www.example.org:80/foo/bar/baz.html'), ('www.example.org:80', '/foo/bar/baz.html')) self.assertEqual(splithost('//www.example.org:80'), ('www.example.org:80', '')) self.assertEqual(splithost('/foo/bar/baz.html'), (None, '/foo/bar/baz.html')) def test_splituser(self): splituser = urllib.splituser self.assertEqual(splituser('User:Pass@www.python.org:080'), ('User:Pass', 'www.python.org:080')) self.assertEqual(splituser('@www.python.org:080'), ('', 'www.python.org:080')) self.assertEqual(splituser('www.python.org:080'), (None, 'www.python.org:080')) self.assertEqual(splituser('User:Pass@'), ('User:Pass', '')) self.assertEqual(splituser('User@example.com:Pass@www.python.org:080'), ('User@example.com:Pass', 'www.python.org:080')) def test_splitpasswd(self): # Some of the password examples are not sensible, but it is added to # confirming to RFC2617 and addressing issue4675. splitpasswd = urllib.splitpasswd self.assertEqual(splitpasswd('user:ab'), ('user', 'ab')) self.assertEqual(splitpasswd('user:a\nb'), ('user', 'a\nb')) self.assertEqual(splitpasswd('user:a\tb'), ('user', 'a\tb')) self.assertEqual(splitpasswd('user:a\rb'), ('user', 'a\rb')) self.assertEqual(splitpasswd('user:a\fb'), ('user', 'a\fb')) self.assertEqual(splitpasswd('user:a\vb'), ('user', 'a\vb')) self.assertEqual(splitpasswd('user:a:b'), ('user', 'a:b')) self.assertEqual(splitpasswd('user:a b'), ('user', 'a b')) self.assertEqual(splitpasswd('user 2:ab'), ('user 2', 'ab')) self.assertEqual(splitpasswd('user+1:a+b'), ('user+1', 'a+b')) self.assertEqual(splitpasswd('user:'), ('user', '')) self.assertEqual(splitpasswd('user'), ('user', None)) self.assertEqual(splitpasswd(':ab'), ('', 'ab')) def test_splitport(self): splitport = urllib.splitport self.assertEqual(splitport('parrot:88'), ('parrot', '88')) self.assertEqual(splitport('parrot'), ('parrot', None)) self.assertEqual(splitport('parrot:'), ('parrot', None)) self.assertEqual(splitport('127.0.0.1'), ('127.0.0.1', None)) self.assertEqual(splitport('parrot:cheese'), ('parrot:cheese', None)) self.assertEqual(splitport('[::1]:88'), ('[::1]', '88')) self.assertEqual(splitport('[::1]'), ('[::1]', None)) self.assertEqual(splitport(':88'), ('', '88')) def test_splitnport(self): splitnport = urllib.splitnport self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) self.assertEqual(splitnport('parrot'), ('parrot', -1)) self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) self.assertEqual(splitnport('parrot:'), ('parrot', -1)) self.assertEqual(splitnport('parrot:', 55), ('parrot', 55)) self.assertEqual(splitnport('127.0.0.1'), ('127.0.0.1', -1)) self.assertEqual(splitnport('127.0.0.1', 55), ('127.0.0.1', 55)) self.assertEqual(splitnport('parrot:cheese'), ('parrot', None)) self.assertEqual(splitnport('parrot:cheese', 55), ('parrot', None)) def test_splitquery(self): # Normal cases are exercised by other tests; ensure that we also # catch cases with no port specified (testcase ensuring coverage) splitquery = urllib.splitquery self.assertEqual(splitquery('http://python.org/fake?foo=bar'), ('http://python.org/fake', 'foo=bar')) self.assertEqual(splitquery('http://python.org/fake?foo=bar?'), ('http://python.org/fake?foo=bar', '')) self.assertEqual(splitquery('http://python.org/fake'), ('http://python.org/fake', None)) self.assertEqual(splitquery('?foo=bar'), ('', 'foo=bar')) def test_splittag(self): splittag = urllib.splittag self.assertEqual(splittag('http://example.com?foo=bar#baz'), ('http://example.com?foo=bar', 'baz')) self.assertEqual(splittag('http://example.com?foo=bar#'), ('http://example.com?foo=bar', '')) self.assertEqual(splittag('#baz'), ('', 'baz')) self.assertEqual(splittag('http://example.com?foo=bar'), ('http://example.com?foo=bar', None)) self.assertEqual(splittag('http://example.com?foo=bar#baz#boo'), ('http://example.com?foo=bar#baz', 'boo')) def test_splitattr(self): splitattr = urllib.splitattr self.assertEqual(splitattr('/path;attr1=value1;attr2=value2'), ('/path', ['attr1=value1', 'attr2=value2'])) self.assertEqual(splitattr('/path;'), ('/path', [''])) self.assertEqual(splitattr(';attr1=value1;attr2=value2'), ('', ['attr1=value1', 'attr2=value2'])) self.assertEqual(splitattr('/path'), ('/path', [])) def test_splitvalue(self): # Normal cases are exercised by other tests; test pathological cases # with no key/value pairs. (testcase ensuring coverage) splitvalue = urllib.splitvalue self.assertEqual(splitvalue('foo=bar'), ('foo', 'bar')) self.assertEqual(splitvalue('foo='), ('foo', '')) self.assertEqual(splitvalue('=bar'), ('', 'bar')) self.assertEqual(splitvalue('foobar'), ('foobar', None)) self.assertEqual(splitvalue('foo=bar=baz'), ('foo', 'bar=baz')) def test_toBytes(self): result = urllib.toBytes(u'http://www.python.org') self.assertEqual(result, 'http://www.python.org') self.assertRaises(UnicodeError, urllib.toBytes, test_support.u(r'http://www.python.org/medi\u00e6val')) def test_unwrap(self): url = urllib.unwrap('') self.assertEqual(url, 'type://host/path') class URLopener_Tests(unittest.TestCase): """Testcase to test the open method of URLopener class.""" def test_quoted_open(self): class DummyURLopener(urllib.URLopener): def open_spam(self, url): return url self.assertEqual(DummyURLopener().open( 'spam://example/ /'),'//example/%20/') # test the safe characters are not quoted by urlopen self.assertEqual(DummyURLopener().open( "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"), "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/") # Just commented them out. # Can't really tell why keep failing in windows and sparc. # Everywhere else they work ok, but on those machines, sometimes # fail in one of the tests, sometimes in other. I have a linux, and # the tests go ok. # If anybody has one of the problematic environments, please help! # . Facundo # # def server(evt): # import socket, time # serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # serv.settimeout(3) # serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # serv.bind(("", 9093)) # serv.listen(5) # try: # conn, addr = serv.accept() # conn.send("1 Hola mundo\n") # cantdata = 0 # while cantdata < 13: # data = conn.recv(13-cantdata) # cantdata += len(data) # time.sleep(.3) # conn.send("2 No more lines\n") # conn.close() # except socket.timeout: # pass # finally: # serv.close() # evt.set() # # class FTPWrapperTests(unittest.TestCase): # # def setUp(self): # import ftplib, time, threading # ftplib.FTP.port = 9093 # self.evt = threading.Event() # threading.Thread(target=server, args=(self.evt,)).start() # time.sleep(.1) # # def tearDown(self): # self.evt.wait() # # def testBasic(self): # # connects # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # ftp.close() # # def testTimeoutNone(self): # # global default timeout is ignored # import socket # self.assertIsNone(socket.getdefaulttimeout()) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutDefault(self): # # global default timeout is used # import socket # self.assertIsNone(socket.getdefaulttimeout()) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutValue(self): # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [], # timeout=30) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() def test_main(): import warnings with warnings.catch_warnings(): warnings.filterwarnings('ignore', ".*urllib\.urlopen.*Python 3.0", DeprecationWarning) test_support.run_unittest( urlopen_FileTests, urlopen_HttpTests, urlretrieve_FileTests, urlretrieve_HttpTests, ProxyTests, QuotingTests, UnquotingTests, urlencode_Tests, Pathname_Tests, Utility_Tests, URLopener_Tests, #FTPWrapperTests, ) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7/test_urllib2.py0000644000076500000000000015253412666555342021043 0ustar jmaddenwheel00000000000000import unittest from test import test_support import os import socket import StringIO import urllib2 from urllib2 import Request, OpenerDirector try: import ssl except ImportError: ssl = None # XXX # Request # CacheFTPHandler (hard to write) # parse_keqv_list, parse_http_list, HTTPDigestAuthHandler class TrivialTests(unittest.TestCase): def test_trivial(self): # A couple trivial tests self.assertRaises(ValueError, urllib2.urlopen, 'bogus url') # XXX Name hacking to get this to work on Windows. fname = os.path.abspath(urllib2.__file__).replace(os.sep, '/') # And more hacking to get it to work on MacOS. This assumes # urllib.pathname2url works, unfortunately... if os.name == 'riscos': import string fname = os.expand(fname) fname = fname.translate(string.maketrans("/.", "./")) if os.name == 'nt': file_url = "file:///%s" % fname else: file_url = "file://%s" % fname f = urllib2.urlopen(file_url) buf = f.read() f.close() def test_parse_http_list(self): tests = [('a,b,c', ['a', 'b', 'c']), ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']), ('a, b, "c", "d", "e,f", g, h', ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']), ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])] for string, list in tests: self.assertEqual(urllib2.parse_http_list(string), list) @unittest.skipUnless(ssl, "ssl module required") def test_cafile_and_context(self): context = ssl.create_default_context() with self.assertRaises(ValueError): urllib2.urlopen( "https://localhost", cafile="/nonexistent/path", context=context ) def test_request_headers_dict(): """ The Request.headers dictionary is not a documented interface. It should stay that way, because the complete set of headers are only accessible through the .get_header(), .has_header(), .header_items() interface. However, .headers pre-dates those methods, and so real code will be using the dictionary. The introduction in 2.4 of those methods was a mistake for the same reason: code that previously saw all (urllib2 user)-provided headers in .headers now sees only a subset (and the function interface is ugly and incomplete). A better change would have been to replace .headers dict with a dict subclass (or UserDict.DictMixin instance?) that preserved the .headers interface and also provided access to the "unredirected" headers. It's probably too late to fix that, though. Check .capitalize() case normalization: >>> url = "http://example.com" >>> Request(url, headers={"Spam-eggs": "blah"}).headers["Spam-eggs"] 'blah' >>> Request(url, headers={"spam-EggS": "blah"}).headers["Spam-eggs"] 'blah' Currently, Request(url, "Spam-eggs").headers["Spam-Eggs"] raises KeyError, but that could be changed in future. """ def test_request_headers_methods(): """ Note the case normalization of header names here, to .capitalize()-case. This should be preserved for backwards-compatibility. (In the HTTP case, normalization to .title()-case is done by urllib2 before sending headers to httplib). >>> url = "http://example.com" >>> r = Request(url, headers={"Spam-eggs": "blah"}) >>> r.has_header("Spam-eggs") True >>> r.header_items() [('Spam-eggs', 'blah')] >>> r.add_header("Foo-Bar", "baz") >>> items = r.header_items() >>> items.sort() >>> items [('Foo-bar', 'baz'), ('Spam-eggs', 'blah')] Note that e.g. r.has_header("spam-EggS") is currently False, and r.get_header("spam-EggS") returns None, but that could be changed in future. >>> r.has_header("Not-there") False >>> print r.get_header("Not-there") None >>> r.get_header("Not-there", "default") 'default' """ def test_password_manager(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password >>> add("Some Realm", "http://example.com/", "joe", "password") >>> add("Some Realm", "http://example.com/ni", "ni", "ni") >>> add("c", "http://example.com/foo", "foo", "ni") >>> add("c", "http://example.com/bar", "bar", "nini") >>> add("b", "http://example.com/", "first", "blah") >>> add("b", "http://example.com/", "second", "spam") >>> add("a", "http://example.com", "1", "a") >>> add("Some Realm", "http://c.example.com:3128", "3", "c") >>> add("Some Realm", "d.example.com", "4", "d") >>> add("Some Realm", "e.example.com:3128", "5", "e") >>> mgr.find_user_password("Some Realm", "example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam/spam") ('joe', 'password') >>> mgr.find_user_password("c", "http://example.com/foo") ('foo', 'ni') >>> mgr.find_user_password("c", "http://example.com/bar") ('bar', 'nini') Actually, this is really undefined ATM ## Currently, we use the highest-level path where more than one match: ## >>> mgr.find_user_password("Some Realm", "http://example.com/ni") ## ('joe', 'password') Use latest add_password() in case of conflict: >>> mgr.find_user_password("b", "http://example.com/") ('second', 'spam') No special relationship between a.example.com and example.com: >>> mgr.find_user_password("a", "http://example.com/") ('1', 'a') >>> mgr.find_user_password("a", "http://a.example.com/") (None, None) Ports: >>> mgr.find_user_password("Some Realm", "c.example.com") (None, None) >>> mgr.find_user_password("Some Realm", "c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "http://c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "d.example.com") ('4', 'd') >>> mgr.find_user_password("Some Realm", "e.example.com:3128") ('5', 'e') """ pass def test_password_manager_default_port(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password The point to note here is that we can't guess the default port if there's no scheme. This applies to both add_password and find_user_password. >>> add("f", "http://g.example.com:80", "10", "j") >>> add("g", "http://h.example.com", "11", "k") >>> add("h", "i.example.com:80", "12", "l") >>> add("i", "j.example.com", "13", "m") >>> mgr.find_user_password("f", "g.example.com:100") (None, None) >>> mgr.find_user_password("f", "g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "g.example.com") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:100") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "http://g.example.com") ('10', 'j') >>> mgr.find_user_password("g", "h.example.com") ('11', 'k') >>> mgr.find_user_password("g", "h.example.com:80") ('11', 'k') >>> mgr.find_user_password("g", "http://h.example.com:80") ('11', 'k') >>> mgr.find_user_password("h", "i.example.com") (None, None) >>> mgr.find_user_password("h", "i.example.com:80") ('12', 'l') >>> mgr.find_user_password("h", "http://i.example.com:80") ('12', 'l') >>> mgr.find_user_password("i", "j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "j.example.com:80") (None, None) >>> mgr.find_user_password("i", "http://j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "http://j.example.com:80") (None, None) """ class MockOpener: addheaders = [] def open(self, req, data=None,timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.req, self.data, self.timeout = req, data, timeout def error(self, proto, *args): self.proto, self.args = proto, args class MockFile: def read(self, count=None): pass def readline(self, count=None): pass def close(self): pass class MockHeaders(dict): def getheaders(self, name): return self.values() class MockResponse(StringIO.StringIO): def __init__(self, code, msg, headers, data, url=None): StringIO.StringIO.__init__(self, data) self.code, self.msg, self.headers, self.url = code, msg, headers, url def info(self): return self.headers def geturl(self): return self.url class MockCookieJar: def add_cookie_header(self, request): self.ach_req = request def extract_cookies(self, response, request): self.ec_req, self.ec_r = request, response class FakeMethod: def __init__(self, meth_name, action, handle): self.meth_name = meth_name self.handle = handle self.action = action def __call__(self, *args): return self.handle(self.meth_name, self.action, *args) class MockHTTPResponse: def __init__(self, fp, msg, status, reason): self.fp = fp self.msg = msg self.status = status self.reason = reason def read(self): return '' class MockHTTPClass: def __init__(self): self.req_headers = [] self.data = None self.raise_on_endheaders = False self._tunnel_headers = {} def __call__(self, host, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.host = host self.timeout = timeout return self def set_debuglevel(self, level): self.level = level def set_tunnel(self, host, port=None, headers=None): self._tunnel_host = host self._tunnel_port = port if headers: self._tunnel_headers = headers else: self._tunnel_headers.clear() def request(self, method, url, body=None, headers=None): self.method = method self.selector = url if headers is not None: self.req_headers += headers.items() self.req_headers.sort() if body: self.data = body if self.raise_on_endheaders: import socket raise socket.error() def getresponse(self): return MockHTTPResponse(MockFile(), {}, 200, "OK") def close(self): pass class MockHandler: # useful for testing handler machinery # see add_ordered_mock_handlers() docstring handler_order = 500 def __init__(self, methods): self._define_methods(methods) def _define_methods(self, methods): for spec in methods: if len(spec) == 2: name, action = spec else: name, action = spec, None meth = FakeMethod(name, action, self.handle) setattr(self.__class__, name, meth) def handle(self, fn_name, action, *args, **kwds): self.parent.calls.append((self, fn_name, args, kwds)) if action is None: return None elif action == "return self": return self elif action == "return response": res = MockResponse(200, "OK", {}, "") return res elif action == "return request": return Request("http://blah/") elif action.startswith("error"): code = action[action.rfind(" ")+1:] try: code = int(code) except ValueError: pass res = MockResponse(200, "OK", {}, "") return self.parent.error("http", args[0], res, code, "", {}) elif action == "raise": raise urllib2.URLError("blah") assert False def close(self): pass def add_parent(self, parent): self.parent = parent self.parent.calls = [] def __lt__(self, other): if not hasattr(other, "handler_order"): # No handler_order, leave in original order. Yuck. return True return self.handler_order < other.handler_order def add_ordered_mock_handlers(opener, meth_spec): """Create MockHandlers and add them to an OpenerDirector. meth_spec: list of lists of tuples and strings defining methods to define on handlers. eg: [["http_error", "ftp_open"], ["http_open"]] defines methods .http_error() and .ftp_open() on one handler, and .http_open() on another. These methods just record their arguments and return None. Using a tuple instead of a string causes the method to perform some action (see MockHandler.handle()), eg: [["http_error"], [("http_open", "return request")]] defines .http_error() on one handler (which simply returns None), and .http_open() on another handler, which returns a Request object. """ handlers = [] count = 0 for meths in meth_spec: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order += count h.add_parent(opener) count = count + 1 handlers.append(h) opener.add_handler(h) return handlers def build_test_opener(*handler_instances): opener = OpenerDirector() for h in handler_instances: opener.add_handler(h) return opener class MockHTTPHandler(urllib2.BaseHandler): # useful for testing redirections and auth # sends supplied headers and code as first response # sends 200 OK as second response def __init__(self, code, headers): self.code = code self.headers = headers self.reset() def reset(self): self._count = 0 self.requests = [] def http_open(self, req): import mimetools, httplib, copy from StringIO import StringIO self.requests.append(copy.deepcopy(req)) if self._count == 0: self._count = self._count + 1 name = httplib.responses[self.code] msg = mimetools.Message(StringIO(self.headers)) return self.parent.error( "http", req, MockFile(), self.code, name, msg) else: self.req = req msg = mimetools.Message(StringIO("\r\n\r\n")) return MockResponse(200, "OK", msg, "", req.get_full_url()) class MockHTTPSHandler(urllib2.AbstractHTTPHandler): # Useful for testing the Proxy-Authorization request by verifying the # properties of httpcon def __init__(self): urllib2.AbstractHTTPHandler.__init__(self) self.httpconn = MockHTTPClass() def https_open(self, req): return self.do_open(self.httpconn, req) class MockPasswordManager: def add_password(self, realm, uri, user, password): self.realm = realm self.url = uri self.user = user self.password = password def find_user_password(self, realm, authuri): self.target_realm = realm self.target_url = authuri return self.user, self.password class OpenerDirectorTests(unittest.TestCase): def test_add_non_handler(self): class NonHandler(object): pass self.assertRaises(TypeError, OpenerDirector().add_handler, NonHandler()) def test_badly_named_methods(self): # test work-around for three methods that accidentally follow the # naming conventions for handler methods # (*_open() / *_request() / *_response()) # These used to call the accidentally-named methods, causing a # TypeError in real code; here, returning self from these mock # methods would either cause no exception, or AttributeError. from urllib2 import URLError o = OpenerDirector() meth_spec = [ [("do_open", "return self"), ("proxy_open", "return self")], [("redirect_request", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) o.add_handler(urllib2.UnknownHandler()) for scheme in "do", "proxy", "redirect": self.assertRaises(URLError, o.open, scheme+"://example.com/") def test_handled(self): # handler returning non-None means no more handlers will be called o = OpenerDirector() meth_spec = [ ["http_open", "ftp_open", "http_error_302"], ["ftp_open"], [("http_open", "return self")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # Second .http_open() gets called, third doesn't, since second returned # non-None. Handlers without .http_open() never get any methods called # on them. # In fact, second mock handler defining .http_open() returns self # (instead of response), which becomes the OpenerDirector's return # value. self.assertEqual(r, handlers[2]) calls = [(handlers[0], "http_open"), (handlers[2], "http_open")] for expected, got in zip(calls, o.calls): handler, name, args, kwds = got self.assertEqual((handler, name), expected) self.assertEqual(args, (req,)) def test_handler_order(self): o = OpenerDirector() handlers = [] for meths, handler_order in [ ([("http_open", "return self")], 500), (["http_open"], 0), ]: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order = handler_order handlers.append(h) o.add_handler(h) r = o.open("http://example.com/") # handlers called in reverse order, thanks to their sort order self.assertEqual(o.calls[0][0], handlers[1]) self.assertEqual(o.calls[1][0], handlers[0]) def test_raise(self): # raising URLError stops processing of request o = OpenerDirector() meth_spec = [ [("http_open", "raise")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") self.assertRaises(urllib2.URLError, o.open, req) self.assertEqual(o.calls, [(handlers[0], "http_open", (req,), {})]) ## def test_error(self): ## # XXX this doesn't actually seem to be used in standard library, ## # but should really be tested anyway... def test_http_error(self): # XXX http_error_default # http errors are a special case o = OpenerDirector() meth_spec = [ [("http_open", "error 302")], [("http_error_400", "raise"), "http_open"], [("http_error_302", "return response"), "http_error_303", "http_error"], [("http_error_302")], ] handlers = add_ordered_mock_handlers(o, meth_spec) class Unknown: def __eq__(self, other): return True req = Request("http://example.com/") r = o.open(req) assert len(o.calls) == 2 calls = [(handlers[0], "http_open", (req,)), (handlers[2], "http_error_302", (req, Unknown(), 302, "", {}))] for expected, got in zip(calls, o.calls): handler, method_name, args = expected self.assertEqual((handler, method_name), got[:2]) self.assertEqual(args, got[2]) def test_processors(self): # *_request / *_response methods get called appropriately o = OpenerDirector() meth_spec = [ [("http_request", "return request"), ("http_response", "return response")], [("http_request", "return request"), ("http_response", "return response")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # processor methods are called on *all* handlers that define them, # not just the first handler that handles the request calls = [ (handlers[0], "http_request"), (handlers[1], "http_request"), (handlers[0], "http_response"), (handlers[1], "http_response")] for i, (handler, name, args, kwds) in enumerate(o.calls): if i < 2: # *_request self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 1) self.assertIsInstance(args[0], Request) else: # *_response self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 2) self.assertIsInstance(args[0], Request) # response from opener.open is None, because there's no # handler that defines http_open to handle it if args[1] is not None: self.assertIsInstance(args[1], MockResponse) def sanepathname2url(path): import urllib urlpath = urllib.pathname2url(path) if os.name == "nt" and urlpath.startswith("///"): urlpath = urlpath[2:] # XXX don't ask me about the mac... return urlpath class HandlerTests(unittest.TestCase): def test_ftp(self): class MockFTPWrapper: def __init__(self, data): self.data = data def retrfile(self, filename, filetype): self.filename, self.filetype = filename, filetype return StringIO.StringIO(self.data), len(self.data) def close(self): pass class NullFTPHandler(urllib2.FTPHandler): def __init__(self, data): self.data = data def connect_ftp(self, user, passwd, host, port, dirs, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.user, self.passwd = user, passwd self.host, self.port = host, port self.dirs = dirs self.ftpwrapper = MockFTPWrapper(self.data) return self.ftpwrapper import ftplib data = "rheum rhaponicum" h = NullFTPHandler(data) o = h.parent = MockOpener() for url, host, port, user, passwd, type_, dirs, filename, mimetype in [ ("ftp://localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://%25parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "%parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://%2542parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "%42parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://localhost:80/foo/bar/", "localhost", 80, "", "", "D", ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", [], "baz.gif", None), # XXX really this should guess image/gif ]: req = Request(url) req.timeout = None r = h.ftp_open(req) # ftp authentication not yet implemented by FTPHandler self.assertEqual(h.user, user) self.assertEqual(h.passwd, passwd) self.assertEqual(h.host, socket.gethostbyname(host)) self.assertEqual(h.port, port) self.assertEqual(h.dirs, dirs) self.assertEqual(h.ftpwrapper.filename, filename) self.assertEqual(h.ftpwrapper.filetype, type_) headers = r.info() self.assertEqual(headers.get("Content-type"), mimetype) self.assertEqual(int(headers["Content-length"]), len(data)) def test_file(self): import rfc822, socket h = urllib2.FileHandler() o = h.parent = MockOpener() TESTFN = test_support.TESTFN urlpath = sanepathname2url(os.path.abspath(TESTFN)) towrite = "hello, world\n" urls = [ "file://localhost%s" % urlpath, "file://%s" % urlpath, "file://%s%s" % (socket.gethostbyname('localhost'), urlpath), ] try: localaddr = socket.gethostbyname(socket.gethostname()) except socket.gaierror: localaddr = '' if localaddr: urls.append("file://%s%s" % (localaddr, urlpath)) for url in urls: f = open(TESTFN, "wb") try: try: f.write(towrite) finally: f.close() r = h.file_open(Request(url)) try: data = r.read() headers = r.info() respurl = r.geturl() finally: r.close() stats = os.stat(TESTFN) modified = rfc822.formatdate(stats.st_mtime) finally: os.remove(TESTFN) self.assertEqual(data, towrite) self.assertEqual(headers["Content-type"], "text/plain") self.assertEqual(headers["Content-length"], "13") self.assertEqual(headers["Last-modified"], modified) self.assertEqual(respurl, url) for url in [ "file://localhost:80%s" % urlpath, "file:///file_does_not_exist.txt", "file://%s:80%s/%s" % (socket.gethostbyname('localhost'), os.getcwd(), TESTFN), "file://somerandomhost.ontheinternet.com%s/%s" % (os.getcwd(), TESTFN), ]: try: f = open(TESTFN, "wb") try: f.write(towrite) finally: f.close() self.assertRaises(urllib2.URLError, h.file_open, Request(url)) finally: os.remove(TESTFN) h = urllib2.FileHandler() o = h.parent = MockOpener() # XXXX why does // mean ftp (and /// mean not ftp!), and where # is file: scheme specified? I think this is really a bug, and # what was intended was to distinguish between URLs like: # file:/blah.txt (a file) # file://localhost/blah.txt (a file) # file:///blah.txt (a file) # file://ftp.example.com/blah.txt (an ftp URL) for url, ftp in [ ("file://ftp.example.com//foo.txt", True), ("file://ftp.example.com///foo.txt", False), # XXXX bug: fails with OSError, should be URLError ("file://ftp.example.com/foo.txt", False), ("file://somehost//foo/something.txt", True), ("file://localhost//foo/something.txt", False), ]: req = Request(url) try: h.file_open(req) # XXXX remove OSError when bug fixed except (urllib2.URLError, OSError): self.assertTrue(not ftp) else: self.assertTrue(o.req is req) self.assertEqual(req.type, "ftp") self.assertEqual(req.type == "ftp", ftp) def test_http(self): h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() url = "http://example.com/" for method, data in [("GET", None), ("POST", "blah")]: req = Request(url, data, {"Foo": "bar"}) req.timeout = None req.add_unredirected_header("Spam", "eggs") http = MockHTTPClass() r = h.do_open(http, req) # result attributes r.read; r.readline # wrapped MockFile methods r.info; r.geturl # addinfourl methods r.code, r.msg == 200, "OK" # added from MockHTTPClass.getreply() hdrs = r.info() hdrs.get; hdrs.has_key # r.info() gives dict from .getreply() self.assertEqual(r.geturl(), url) self.assertEqual(http.host, "example.com") self.assertEqual(http.level, 0) self.assertEqual(http.method, method) self.assertEqual(http.selector, "/") self.assertEqual(http.req_headers, [("Connection", "close"), ("Foo", "bar"), ("Spam", "eggs")]) self.assertEqual(http.data, data) # check socket.error converted to URLError http.raise_on_endheaders = True self.assertRaises(urllib2.URLError, h.do_open, http, req) # check adding of standard headers o.addheaders = [("Spam", "eggs")] for data in "", None: # POST, GET req = Request("http://example.com/", data) r = MockResponse(200, "OK", {}, "") newreq = h.do_request_(req) if data is None: # GET self.assertNotIn("Content-length", req.unredirected_hdrs) self.assertNotIn("Content-type", req.unredirected_hdrs) else: # POST self.assertEqual(req.unredirected_hdrs["Content-length"], "0") self.assertEqual(req.unredirected_hdrs["Content-type"], "application/x-www-form-urlencoded") # XXX the details of Host could be better tested self.assertEqual(req.unredirected_hdrs["Host"], "example.com") self.assertEqual(req.unredirected_hdrs["Spam"], "eggs") # don't clobber existing headers req.add_unredirected_header("Content-length", "foo") req.add_unredirected_header("Content-type", "bar") req.add_unredirected_header("Host", "baz") req.add_unredirected_header("Spam", "foo") newreq = h.do_request_(req) self.assertEqual(req.unredirected_hdrs["Content-length"], "foo") self.assertEqual(req.unredirected_hdrs["Content-type"], "bar") self.assertEqual(req.unredirected_hdrs["Host"], "baz") self.assertEqual(req.unredirected_hdrs["Spam"], "foo") def test_http_doubleslash(self): # Checks that the presence of an unnecessary double slash in a url doesn't break anything # Previously, a double slash directly after the host could cause incorrect parsing of the url h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() data = "" ds_urls = [ "http://example.com/foo/bar/baz.html", "http://example.com//foo/bar/baz.html", "http://example.com/foo//bar/baz.html", "http://example.com/foo/bar//baz.html", ] for ds_url in ds_urls: ds_req = Request(ds_url, data) # Check whether host is determined correctly if there is no proxy np_ds_req = h.do_request_(ds_req) self.assertEqual(np_ds_req.unredirected_hdrs["Host"],"example.com") # Check whether host is determined correctly if there is a proxy ds_req.set_proxy("someproxy:3128",None) p_ds_req = h.do_request_(ds_req) self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com") def test_fixpath_in_weirdurls(self): # Issue4493: urllib2 to supply '/' when to urls where path does not # start with'/' h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() weird_url = 'http://www.python.org?getspam' req = Request(weird_url) newreq = h.do_request_(req) self.assertEqual(newreq.get_host(),'www.python.org') self.assertEqual(newreq.get_selector(),'/?getspam') url_without_path = 'http://www.python.org' req = Request(url_without_path) newreq = h.do_request_(req) self.assertEqual(newreq.get_host(),'www.python.org') self.assertEqual(newreq.get_selector(),'') def test_errors(self): h = urllib2.HTTPErrorProcessor() o = h.parent = MockOpener() url = "http://example.com/" req = Request(url) # all 2xx are passed through r = MockResponse(200, "OK", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called r = MockResponse(202, "Accepted", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called r = MockResponse(206, "Partial content", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called # anything else calls o.error (and MockOpener returns None, here) r = MockResponse(502, "Bad gateway", {}, "", url) self.assertTrue(h.http_response(req, r) is None) self.assertEqual(o.proto, "http") # o.error called self.assertEqual(o.args, (req, r, 502, "Bad gateway", {})) def test_cookies(self): cj = MockCookieJar() h = urllib2.HTTPCookieProcessor(cj) o = h.parent = MockOpener() req = Request("http://example.com/") r = MockResponse(200, "OK", {}, "") newreq = h.http_request(req) self.assertTrue(cj.ach_req is req is newreq) self.assertEqual(req.get_origin_req_host(), "example.com") self.assertTrue(not req.is_unverifiable()) newr = h.http_response(req, r) self.assertTrue(cj.ec_req is req) self.assertTrue(cj.ec_r is r is newr) def test_redirect(self): from_url = "http://example.com/a.html" to_url = "http://example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() # ordinary redirect behaviour for code in 301, 302, 303, 307: for data in None, "blah\nblah\n": method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) req.add_header("Nonsense", "viking=withhold") req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT if data is not None: req.add_header("Content-Length", str(len(data))) req.add_unredirected_header("Spam", "spam") try: method(req, MockFile(), code, "Blah", MockHeaders({"location": to_url})) except urllib2.HTTPError: # 307 in response to POST requires user OK self.assertEqual(code, 307) self.assertIsNotNone(data) self.assertEqual(o.req.get_full_url(), to_url) try: self.assertEqual(o.req.get_method(), "GET") except AttributeError: self.assertTrue(not o.req.has_data()) # now it's a GET, there should not be headers regarding content # (possibly dragged from before being a POST) headers = [x.lower() for x in o.req.headers] self.assertNotIn("content-length", headers) self.assertNotIn("content-type", headers) self.assertEqual(o.req.headers["Nonsense"], "viking=withhold") self.assertNotIn("Spam", o.req.headers) self.assertNotIn("Spam", o.req.unredirected_hdrs) # loop detection req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT def redirect(h, req, url=to_url): h.http_error_302(req, MockFile(), 302, "Blah", MockHeaders({"location": url})) # Note that the *original* request shares the same record of # redirections with the sub-requests caused by the redirections. # detect infinite loop redirect of a URL to itself req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/") count = count + 1 except urllib2.HTTPError: # don't stop until max_repeats, because cookies may introduce state self.assertEqual(count, urllib2.HTTPRedirectHandler.max_repeats) # detect endless non-repeating chain of redirects req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/%d" % count) count = count + 1 except urllib2.HTTPError: self.assertEqual(count, urllib2.HTTPRedirectHandler.max_redirections) def test_invalid_redirect(self): from_url = "http://example.com/a.html" valid_schemes = ['http', 'https', 'ftp'] invalid_schemes = ['file', 'imap', 'ldap'] schemeless_url = "example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT for scheme in invalid_schemes: invalid_url = scheme + '://' + schemeless_url self.assertRaises(urllib2.HTTPError, h.http_error_302, req, MockFile(), 302, "Security Loophole", MockHeaders({"location": invalid_url})) for scheme in valid_schemes: valid_url = scheme + '://' + schemeless_url h.http_error_302(req, MockFile(), 302, "That's fine", MockHeaders({"location": valid_url})) self.assertEqual(o.req.get_full_url(), valid_url) def test_cookie_redirect(self): # cookies shouldn't leak into redirected requests from cookielib import CookieJar from test.test_cookielib import interact_netscape cj = CookieJar() interact_netscape(cj, "http://www.example.com/", "spam=eggs") hh = MockHTTPHandler(302, "Location: http://www.cracker.com/\r\n\r\n") hdeh = urllib2.HTTPDefaultErrorHandler() hrh = urllib2.HTTPRedirectHandler() cp = urllib2.HTTPCookieProcessor(cj) o = build_test_opener(hh, hdeh, hrh, cp) o.open("http://www.example.com/") self.assertTrue(not hh.req.has_header("Cookie")) def test_redirect_fragment(self): redirected_url = 'http://www.example.com/index.html#OK\r\n\r\n' hh = MockHTTPHandler(302, 'Location: ' + redirected_url) hdeh = urllib2.HTTPDefaultErrorHandler() hrh = urllib2.HTTPRedirectHandler() o = build_test_opener(hh, hdeh, hrh) fp = o.open('http://www.example.com') self.assertEqual(fp.geturl(), redirected_url.strip()) def test_proxy(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) o.add_handler(ph) meth_spec = [ [("http_open", "return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://acme.example.com/") self.assertEqual(req.get_host(), "acme.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) def test_proxy_no_proxy(self): os.environ['no_proxy'] = 'python.org' o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com")) o.add_handler(ph) req = Request("http://www.perl.org/") self.assertEqual(req.get_host(), "www.perl.org") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com") req = Request("http://www.python.org") self.assertEqual(req.get_host(), "www.python.org") r = o.open(req) self.assertEqual(req.get_host(), "www.python.org") del os.environ['no_proxy'] def test_proxy_https(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) meth_spec = [ [("https_open","return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("https://www.example.com/") self.assertEqual(req.get_host(), "www.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "https_open")], [tup[0:2] for tup in o.calls]) def test_proxy_https_proxy_authorization(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) https_handler = MockHTTPSHandler() o.add_handler(https_handler) req = Request("https://www.example.com/") req.add_header("Proxy-Authorization","FooBar") req.add_header("User-Agent","Grail") self.assertEqual(req.get_host(), "www.example.com") self.assertIsNone(req._tunnel_host) r = o.open(req) # Verify Proxy-Authorization gets tunneled to request. # httpsconn req_headers do not have the Proxy-Authorization header but # the req will have. self.assertNotIn(("Proxy-Authorization","FooBar"), https_handler.httpconn.req_headers) self.assertIn(("User-Agent","Grail"), https_handler.httpconn.req_headers) self.assertIsNotNone(req._tunnel_host) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual(req.get_header("Proxy-authorization"),"FooBar") def test_basic_auth(self, quote_char='"'): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm=%s%s%s\r\n\r\n' % (quote_char, realm, quote_char) ) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected" ) def test_basic_auth_with_single_quoted_realm(self): self.test_basic_auth(quote_char="'") def test_basic_auth_with_unquoted_realm(self): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm=%s\r\n\r\n' % realm) opener.add_handler(auth_handler) opener.add_handler(http_handler) msg = "Basic Auth Realm was unquoted" with test_support.check_warnings((msg, UserWarning)): self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected" ) def test_proxy_basic_auth(self): opener = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) opener.add_handler(ph) password_manager = MockPasswordManager() auth_handler = urllib2.ProxyBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Proxy-authorization", realm, http_handler, password_manager, "http://acme.example.com:3128/protected", "proxy.example.com:3128", ) def test_basic_and_digest_auth_handlers(self): # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40* # response (http://python.org/sf/1479302), where it should instead # return None to allow another handler (especially # HTTPBasicAuthHandler) to handle the response. # Also (http://python.org/sf/14797027, RFC 2617 section 1.2), we must # try digest first (since it's the strongest auth scheme), so we record # order of calls here to check digest comes first: class RecordingOpenerDirector(OpenerDirector): def __init__(self): OpenerDirector.__init__(self) self.recorded = [] def record(self, info): self.recorded.append(info) class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("digest") urllib2.HTTPDigestAuthHandler.http_error_401(self, *args, **kwds) class TestBasicAuthHandler(urllib2.HTTPBasicAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("basic") urllib2.HTTPBasicAuthHandler.http_error_401(self, *args, **kwds) opener = RecordingOpenerDirector() password_manager = MockPasswordManager() digest_handler = TestDigestAuthHandler(password_manager) basic_handler = TestBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(basic_handler) opener.add_handler(digest_handler) opener.add_handler(http_handler) # check basic auth isn't blocked by digest handler failing self._test_basic_auth(opener, basic_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected", ) # check digest was tried before basic (twice, because # _test_basic_auth called .open() twice) self.assertEqual(opener.recorded, ["digest", "basic"]*2) def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): import base64 user, password = "wile", "coyote" # .add_password() fed through to password manager auth_handler.add_password(realm, request_url, user, password) self.assertEqual(realm, password_manager.realm) self.assertEqual(request_url, password_manager.url) self.assertEqual(user, password_manager.user) self.assertEqual(password, password_manager.password) r = opener.open(request_url) # should have asked the password manager for the username/password self.assertEqual(password_manager.target_realm, realm) self.assertEqual(password_manager.target_url, protected_url) # expect one request without authorization, then one with self.assertEqual(len(http_handler.requests), 2) self.assertFalse(http_handler.requests[0].has_header(auth_header)) userpass = '%s:%s' % (user, password) auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip() self.assertEqual(http_handler.requests[1].get_header(auth_header), auth_hdr_value) self.assertEqual(http_handler.requests[1].unredirected_hdrs[auth_header], auth_hdr_value) # if the password manager can't find a password, the handler won't # handle the HTTP auth error password_manager.user = password_manager.password = None http_handler.reset() r = opener.open(request_url) self.assertEqual(len(http_handler.requests), 1) self.assertFalse(http_handler.requests[0].has_header(auth_header)) class MiscTests(unittest.TestCase): def test_build_opener(self): class MyHTTPHandler(urllib2.HTTPHandler): pass class FooHandler(urllib2.BaseHandler): def foo_open(self): pass class BarHandler(urllib2.BaseHandler): def bar_open(self): pass build_opener = urllib2.build_opener o = build_opener(FooHandler, BarHandler) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # can take a mix of classes and instances o = build_opener(FooHandler, BarHandler()) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # subclasses of default handlers override default handlers o = build_opener(MyHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) # a particular case of overriding: default handlers can be passed # in explicitly o = build_opener() self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler) self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler()) self.opener_has_handler(o, urllib2.HTTPHandler) # Issue2670: multiple handlers sharing the same base class class MyOtherHTTPHandler(urllib2.HTTPHandler): pass o = build_opener(MyHTTPHandler, MyOtherHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) self.opener_has_handler(o, MyOtherHTTPHandler) def opener_has_handler(self, opener, handler_class): for h in opener.handlers: if h.__class__ == handler_class: break else: self.assertTrue(False) class RequestTests(unittest.TestCase): def setUp(self): self.get = urllib2.Request("http://www.python.org/~jeremy/") self.post = urllib2.Request("http://www.python.org/~jeremy/", "data", headers={"X-Test": "test"}) def test_method(self): self.assertEqual("POST", self.post.get_method()) self.assertEqual("GET", self.get.get_method()) def test_add_data(self): self.assertTrue(not self.get.has_data()) self.assertEqual("GET", self.get.get_method()) self.get.add_data("spam") self.assertTrue(self.get.has_data()) self.assertEqual("POST", self.get.get_method()) def test_get_full_url(self): self.assertEqual("http://www.python.org/~jeremy/", self.get.get_full_url()) def test_selector(self): self.assertEqual("/~jeremy/", self.get.get_selector()) req = urllib2.Request("http://www.python.org/") self.assertEqual("/", req.get_selector()) def test_get_type(self): self.assertEqual("http", self.get.get_type()) def test_get_host(self): self.assertEqual("www.python.org", self.get.get_host()) def test_get_host_unquote(self): req = urllib2.Request("http://www.%70ython.org/") self.assertEqual("www.python.org", req.get_host()) def test_proxy(self): self.assertTrue(not self.get.has_proxy()) self.get.set_proxy("www.perl.org", "http") self.assertTrue(self.get.has_proxy()) self.assertEqual("www.python.org", self.get.get_origin_req_host()) self.assertEqual("www.perl.org", self.get.get_host()) def test_wrapped_url(self): req = Request("") self.assertEqual("www.python.org", req.get_host()) def test_url_fragment(self): req = Request("http://www.python.org/?qs=query#fragment=true") self.assertEqual("/?qs=query", req.get_selector()) req = Request("http://www.python.org/#fun=true") self.assertEqual("/", req.get_selector()) # Issue 11703: geturl() omits fragment in the original URL. url = 'http://docs.python.org/library/urllib2.html#OK' req = Request(url) self.assertEqual(req.get_full_url(), url) def test_HTTPError_interface(self): """ Issue 13211 reveals that HTTPError didn't implement the URLError interface even though HTTPError is a subclass of URLError. >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) >>> assert hasattr(err, 'reason') >>> err.reason 'something bad happened' """ def test_HTTPError_interface_call(self): """ Issue 15701= - HTTPError interface has info method available from URLError. """ err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs='Content-Length:42', fp=None) self.assertTrue(hasattr(err, 'reason')) assert hasattr(err, 'reason') assert hasattr(err, 'info') assert callable(err.info) try: err.info() except AttributeError: self.fail("err.info() failed") self.assertEqual(err.info(), "Content-Length:42") def test_main(verbose=None): from test import test_urllib2 test_support.run_doctest(test_urllib2, verbose) test_support.run_doctest(urllib2, verbose) tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, RequestTests) test_support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) gevent-1.1.0/greentest/2.7/test_urllib2_localnet.py0000644000076500000000000006267312666555342022730 0ustar jmaddenwheel00000000000000import os import base64 import urlparse import urllib2 import BaseHTTPServer import unittest import hashlib from test import test_support mimetools = test_support.import_module('mimetools', deprecated=True) threading = test_support.import_module('threading') try: import ssl except ImportError: ssl = None here = os.path.dirname(__file__) # Self-signed cert file for 'localhost' CERT_localhost = os.path.join(here, 'keycert.pem') # Self-signed cert file for 'fakehostname' CERT_fakehostname = os.path.join(here, 'keycert2.pem') # Loopback http server infrastructure class LoopbackHttpServer(BaseHTTPServer.HTTPServer): """HTTP server w/ a few modifications that make it useful for loopback testing purposes. """ def __init__(self, server_address, RequestHandlerClass): BaseHTTPServer.HTTPServer.__init__(self, server_address, RequestHandlerClass) # Set the timeout of our listening socket really low so # that we can stop the server easily. self.socket.settimeout(0.1) def get_request(self): """BaseHTTPServer method, overridden.""" request, client_address = self.socket.accept() # It's a loopback connection, so setting the timeout # really low shouldn't affect anything, but should make # deadlocks less likely to occur. request.settimeout(10.0) return (request, client_address) class LoopbackHttpServerThread(threading.Thread): """Stoppable thread that runs a loopback http server.""" def __init__(self, request_handler): threading.Thread.__init__(self) self._stop = False self.ready = threading.Event() request_handler.protocol_version = "HTTP/1.0" self.httpd = LoopbackHttpServer(('127.0.0.1', 0), request_handler) #print "Serving HTTP on %s port %s" % (self.httpd.server_name, # self.httpd.server_port) self.port = self.httpd.server_port def stop(self): """Stops the webserver if it's currently running.""" # Set the stop flag. self._stop = True self.join() def run(self): self.ready.set() while not self._stop: self.httpd.handle_request() # Authentication infrastructure class BasicAuthHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handler for performing Basic Authentication.""" # Server side values USER = "testUser" PASSWD = "testPass" REALM = "Test" USER_PASSWD = "%s:%s" % (USER, PASSWD) ENCODED_AUTH = base64.b64encode(USER_PASSWD) def __init__(self, *args, **kwargs): BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs) def log_message(self, format, *args): # Supress the HTTP Console log output pass def do_HEAD(self): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() def do_AUTHHEAD(self): self.send_response(401) self.send_header("WWW-Authenticate", "Basic realm=\"%s\"" % self.REALM) self.send_header("Content-type", "text/html") self.end_headers() def do_GET(self): if self.headers.getheader("Authorization") == None: self.do_AUTHHEAD() self.wfile.write("No Auth Header Received") elif self.headers.getheader( "Authorization") == "Basic " + self.ENCODED_AUTH: self.wfile.write("It works!") else: # Unauthorized Request self.do_AUTHHEAD() class DigestAuthHandler: """Handler for performing digest authentication.""" def __init__(self): self._request_num = 0 self._nonces = [] self._users = {} self._realm_name = "Test Realm" self._qop = "auth" def set_qop(self, qop): self._qop = qop def set_users(self, users): assert isinstance(users, dict) self._users = users def set_realm(self, realm): self._realm_name = realm def _generate_nonce(self): self._request_num += 1 nonce = hashlib.md5(str(self._request_num)).hexdigest() self._nonces.append(nonce) return nonce def _create_auth_dict(self, auth_str): first_space_index = auth_str.find(" ") auth_str = auth_str[first_space_index+1:] parts = auth_str.split(",") auth_dict = {} for part in parts: name, value = part.split("=") name = name.strip() if value[0] == '"' and value[-1] == '"': value = value[1:-1] else: value = value.strip() auth_dict[name] = value return auth_dict def _validate_auth(self, auth_dict, password, method, uri): final_dict = {} final_dict.update(auth_dict) final_dict["password"] = password final_dict["method"] = method final_dict["uri"] = uri HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict HA1 = hashlib.md5(HA1_str).hexdigest() HA2_str = "%(method)s:%(uri)s" % final_dict HA2 = hashlib.md5(HA2_str).hexdigest() final_dict["HA1"] = HA1 final_dict["HA2"] = HA2 response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \ "%(cnonce)s:%(qop)s:%(HA2)s" % final_dict response = hashlib.md5(response_str).hexdigest() return response == auth_dict["response"] def _return_auth_challenge(self, request_handler): request_handler.send_response(407, "Proxy Authentication Required") request_handler.send_header("Content-Type", "text/html") request_handler.send_header( 'Proxy-Authenticate', 'Digest realm="%s", ' 'qop="%s",' 'nonce="%s", ' % \ (self._realm_name, self._qop, self._generate_nonce())) # XXX: Not sure if we're supposed to add this next header or # not. #request_handler.send_header('Connection', 'close') request_handler.end_headers() request_handler.wfile.write("Proxy Authentication Required.") return False def handle_request(self, request_handler): """Performs digest authentication on the given HTTP request handler. Returns True if authentication was successful, False otherwise. If no users have been set, then digest auth is effectively disabled and this method will always return True. """ if len(self._users) == 0: return True if 'Proxy-Authorization' not in request_handler.headers: return self._return_auth_challenge(request_handler) else: auth_dict = self._create_auth_dict( request_handler.headers['Proxy-Authorization'] ) if auth_dict["username"] in self._users: password = self._users[ auth_dict["username"] ] else: return self._return_auth_challenge(request_handler) if not auth_dict.get("nonce") in self._nonces: return self._return_auth_challenge(request_handler) else: self._nonces.remove(auth_dict["nonce"]) auth_validated = False # MSIE uses short_path in its validation, but Python's # urllib2 uses the full path, so we're going to see if # either of them works here. for path in [request_handler.path, request_handler.short_path]: if self._validate_auth(auth_dict, password, request_handler.command, path): auth_validated = True if not auth_validated: return self._return_auth_challenge(request_handler) return True # Proxy test infrastructure class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler): """This is a 'fake proxy' that makes it look like the entire internet has gone down due to a sudden zombie invasion. It main utility is in providing us with authentication support for testing. """ def __init__(self, digest_auth_handler, *args, **kwargs): # This has to be set before calling our parent's __init__(), which will # try to call do_GET(). self.digest_auth_handler = digest_auth_handler BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs) def log_message(self, format, *args): # Uncomment the next line for debugging. #sys.stderr.write(format % args) pass def do_GET(self): (scm, netloc, path, params, query, fragment) = urlparse.urlparse( self.path, 'http') self.short_path = path if self.digest_auth_handler.handle_request(self): self.send_response(200, "OK") self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write("You've reached %s!
    " % self.path) self.wfile.write("Our apologies, but our server is down due to " "a sudden zombie invasion.") # Test cases class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() def tearDown(self): test_support.threading_cleanup(*self._threads) class BasicAuthTests(BaseTestCase): USER = "testUser" PASSWD = "testPass" INCORRECT_PASSWD = "Incorrect" REALM = "Test" def setUp(self): super(BasicAuthTests, self).setUp() # With Basic Authentication def http_server_with_basic_auth_handler(*args, **kwargs): return BasicAuthHandler(*args, **kwargs) self.server = LoopbackHttpServerThread(http_server_with_basic_auth_handler) self.server_url = 'http://127.0.0.1:%s' % self.server.port self.server.start() self.server.ready.wait() def tearDown(self): self.server.stop() super(BasicAuthTests, self).tearDown() def test_basic_auth_success(self): ah = urllib2.HTTPBasicAuthHandler() ah.add_password(self.REALM, self.server_url, self.USER, self.PASSWD) urllib2.install_opener(urllib2.build_opener(ah)) try: self.assertTrue(urllib2.urlopen(self.server_url)) except urllib2.HTTPError: self.fail("Basic Auth Failed for url: %s" % self.server_url) except Exception as e: raise e def test_basic_auth_httperror(self): ah = urllib2.HTTPBasicAuthHandler() ah.add_password(self.REALM, self.server_url, self.USER, self.INCORRECT_PASSWD) urllib2.install_opener(urllib2.build_opener(ah)) self.assertRaises(urllib2.HTTPError, urllib2.urlopen, self.server_url) class ProxyAuthTests(BaseTestCase): URL = "http://localhost" USER = "tester" PASSWD = "test123" REALM = "TestRealm" def setUp(self): super(ProxyAuthTests, self).setUp() self.digest_auth_handler = DigestAuthHandler() self.digest_auth_handler.set_users({self.USER: self.PASSWD}) self.digest_auth_handler.set_realm(self.REALM) # With Digest Authentication def create_fake_proxy_handler(*args, **kwargs): return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs) self.server = LoopbackHttpServerThread(create_fake_proxy_handler) self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port handler = urllib2.ProxyHandler({"http" : proxy_url}) self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler() self.opener = urllib2.build_opener(handler, self.proxy_digest_handler) def tearDown(self): self.server.stop() super(ProxyAuthTests, self).tearDown() def test_proxy_with_bad_password_raises_httperror(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD+"bad") self.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_with_no_password_raises_httperror(self): self.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_qop_auth_works(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth") result = self.opener.open(self.URL) while result.read(): pass result.close() def test_proxy_qop_auth_int_works_or_throws_urlerror(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth-int") try: result = self.opener.open(self.URL) except urllib2.URLError: # It's okay if we don't support auth-int, but we certainly # shouldn't receive any kind of exception here other than # a URLError. result = None if result: while result.read(): pass result.close() def GetRequestHandler(responses): class FakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version = "TestHTTP/" requests = [] headers_received = [] port = 80 def do_GET(self): body = self.send_head() if body: self.wfile.write(body) def do_POST(self): content_length = self.headers['Content-Length'] post_data = self.rfile.read(int(content_length)) self.do_GET() self.requests.append(post_data) def send_head(self): FakeHTTPRequestHandler.headers_received = self.headers self.requests.append(self.path) response_code, headers, body = responses.pop(0) self.send_response(response_code) for (header, value) in headers: self.send_header(header, value % self.port) if body: self.send_header('Content-type', 'text/plain') self.end_headers() return body self.end_headers() def log_message(self, *args): pass return FakeHTTPRequestHandler class TestUrlopen(BaseTestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. """ def setUp(self): proxy_handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(proxy_handler) urllib2.install_opener(opener) super(TestUrlopen, self).setUp() def urlopen(self, url, data=None, **kwargs): l = [] f = urllib2.urlopen(url, data, **kwargs) try: # Exercise various methods l.extend(f.readlines(200)) l.append(f.readline()) l.append(f.read(1024)) l.append(f.read()) finally: f.close() return b"".join(l) def start_server(self, responses): handler = GetRequestHandler(responses) self.server = LoopbackHttpServerThread(handler) self.server.start() self.server.ready.wait() port = self.server.port handler.port = port return handler def start_https_server(self, responses=None, **kwargs): if not hasattr(urllib2, 'HTTPSHandler'): self.skipTest('ssl support required') from test.ssl_servers import make_https_server if responses is None: responses = [(200, [], b"we care a bit")] handler = GetRequestHandler(responses) server = make_https_server(self, handler_class=handler, **kwargs) handler.port = server.port return handler def test_redirection(self): expected_response = 'We got here...' responses = [ (302, [('Location', 'http://localhost:%s/somewhere_else')], ''), (200, [], expected_response) ] handler = self.start_server(responses) try: f = urllib2.urlopen('http://localhost:%s/' % handler.port) data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/', '/somewhere_else']) finally: self.server.stop() def test_404(self): expected_response = 'Bad bad bad...' handler = self.start_server([(404, [], expected_response)]) try: try: urllib2.urlopen('http://localhost:%s/weeble' % handler.port) except urllib2.URLError, f: pass else: self.fail('404 should raise URLError') data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/weeble']) finally: self.server.stop() def test_200(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port) data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/bizarre']) finally: self.server.stop() def test_200_with_parameters(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port, 'get=with_feeling') data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/bizarre', 'get=with_feeling']) finally: self.server.stop() def test_https(self): handler = self.start_https_server() context = ssl.create_default_context(cafile=CERT_localhost) data = self.urlopen("https://localhost:%s/bizarre" % handler.port, context=context) self.assertEqual(data, b"we care a bit") def test_https_with_cafile(self): handler = self.start_https_server(certfile=CERT_localhost) # Good cert data = self.urlopen("https://localhost:%s/bizarre" % handler.port, cafile=CERT_localhost) self.assertEqual(data, b"we care a bit") # Bad cert with self.assertRaises(urllib2.URLError): self.urlopen("https://localhost:%s/bizarre" % handler.port, cafile=CERT_fakehostname) # Good cert, but mismatching hostname handler = self.start_https_server(certfile=CERT_fakehostname) with self.assertRaises(ssl.CertificateError): self.urlopen("https://localhost:%s/bizarre" % handler.port, cafile=CERT_fakehostname) def test_https_with_cadefault(self): handler = self.start_https_server(certfile=CERT_localhost) # Self-signed cert should fail verification with system certificate store with self.assertRaises(urllib2.URLError): self.urlopen("https://localhost:%s/bizarre" % handler.port, cadefault=True) def test_https_sni(self): if ssl is None: self.skipTest("ssl module required") if not ssl.HAS_SNI: self.skipTest("SNI support required in OpenSSL") sni_name = [None] def cb_sni(ssl_sock, server_name, initial_context): sni_name[0] = server_name context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.set_servername_callback(cb_sni) handler = self.start_https_server(context=context, certfile=CERT_localhost) context = ssl.create_default_context(cafile=CERT_localhost) self.urlopen("https://localhost:%s" % handler.port, context=context) self.assertEqual(sni_name[0], "localhost") def test_sending_headers(self): handler = self.start_server([(200, [], "we don't care")]) try: req = urllib2.Request("http://localhost:%s/" % handler.port, headers={'Range': 'bytes=20-39'}) urllib2.urlopen(req) self.assertEqual(handler.headers_received['Range'], 'bytes=20-39') finally: self.server.stop() def test_basic(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) for attr in ("read", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " "urlopen lacks the %s attribute" % attr) try: self.assertTrue(open_url.read(), "calling 'read' failed") finally: open_url.close() finally: self.server.stop() def test_info(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) info_obj = open_url.info() self.assertIsInstance(info_obj, mimetools.Message, "object returned by 'info' is not an " "instance of mimetools.Message") self.assertEqual(info_obj.getsubtype(), "plain") finally: self.server.stop() def test_geturl(self): # Make sure same URL as opened is returned by geturl. handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) url = open_url.geturl() self.assertEqual(url, "http://localhost:%s" % handler.port) finally: self.server.stop() def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. # as indicated by the comment below, this might fail with some ISP, # so we run the test only when -unetwork/-uall is specified to # mitigate the problem a bit (see #17564) test_support.requires('network') self.assertRaises(IOError, # Given that both VeriSign and various ISPs have in # the past or are presently hijacking various invalid # domain name requests in an attempt to boost traffic # to their own sites, finding a domain name to use # for this test is difficult. RFC2606 leads one to # believe that '.invalid' should work, but experience # seemed to indicate otherwise. Single character # TLDs are likely to remain invalid, so this seems to # be the best choice. The trailing '.' prevents a # related problem: The normal DNS resolver appends # the domain names from the search path if there is # no '.' the end and, and if one of those domains # implements a '*' rule a result is returned. # However, none of this will prevent the test from # failing if the ISP hijacks all invalid domain # requests. The real solution would be to be able to # parameterize the framework with a mock resolver. urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./") def test_iteration(self): expected_response = "pycon 2008..." handler = self.start_server([(200, [], expected_response)]) try: data = urllib2.urlopen("http://localhost:%s" % handler.port) for line in data: self.assertEqual(line, expected_response) finally: self.server.stop() def ztest_line_iteration(self): lines = ["We\n", "got\n", "here\n", "verylong " * 8192 + "\n"] expected_response = "".join(lines) handler = self.start_server([(200, [], expected_response)]) try: data = urllib2.urlopen("http://localhost:%s" % handler.port) for index, line in enumerate(data): self.assertEqual(line, lines[index], "Fetched line number %s doesn't match expected:\n" " Expected length was %s, got %s" % (index, len(lines[index]), len(line))) finally: self.server.stop() self.assertEqual(index + 1, len(lines)) def test_main(): # We will NOT depend on the network resource flag # (Lib/test/regrtest.py -u network) since all tests here are only # localhost. However, if this is a bad rationale, then uncomment # the next line. #test_support.requires("network") test_support.run_unittest(BasicAuthTests, ProxyAuthTests, TestUrlopen) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_urllib2net.py0000644000076500000000000002742312666555342021550 0ustar jmaddenwheel00000000000000import unittest from test import test_support from test.test_urllib2 import sanepathname2url import socket import urllib2 import os import sys TIMEOUT = 60 # seconds def _retry_thrice(func, exc, *args, **kwargs): for i in range(3): try: return func(*args, **kwargs) except exc, last_exc: continue except: raise raise last_exc def _wrap_with_retry_thrice(func, exc): def wrapped(*args, **kwargs): return _retry_thrice(func, exc, *args, **kwargs) return wrapped # Connecting to remote hosts is flaky. Make it more robust by retrying # the connection several times. _urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError) class AuthTests(unittest.TestCase): """Tests urllib2 authentication features.""" ## Disabled at the moment since there is no page under python.org which ## could be used to HTTP authentication. # # def test_basic_auth(self): # import httplib # # test_url = "http://www.python.org/test/test_urllib2/basic_auth" # test_hostport = "www.python.org" # test_realm = 'Test Realm' # test_user = 'test.test_urllib2net' # test_password = 'blah' # # # failure # try: # _urlopen_with_retry(test_url) # except urllib2.HTTPError, exc: # self.assertEqual(exc.code, 401) # else: # self.fail("urlopen() should have failed with 401") # # # success # auth_handler = urllib2.HTTPBasicAuthHandler() # auth_handler.add_password(test_realm, test_hostport, # test_user, test_password) # opener = urllib2.build_opener(auth_handler) # f = opener.open('http://localhost/') # response = _urlopen_with_retry("http://www.python.org/") # # # The 'userinfo' URL component is deprecated by RFC 3986 for security # # reasons, let's not implement it! (it's already implemented for proxy # # specification strings (that is, URLs or authorities specifying a # # proxy), so we must keep that) # self.assertRaises(httplib.InvalidURL, # urllib2.urlopen, "http://evil:thing@example.com") class CloseSocketTest(unittest.TestCase): def test_close(self): import httplib # calling .close() on urllib2's response objects should close the # underlying socket # delve deep into response to fetch socket._socketobject response = _urlopen_with_retry("http://www.example.com/") abused_fileobject = response.fp #self.assertIs(abused_fileobject.__class__, socket._fileobject) # JAM: gevent: disable httpresponse = abused_fileobject._sock self.assertIs(httpresponse.__class__, httplib.HTTPResponse) fileobject = httpresponse.fp #self.assertIs(fileobject.__class__, socket._fileobject) # JAM: gevent: disable self.assertTrue(not fileobject.closed) response.close() self.assertTrue(fileobject.closed) class OtherNetworkTests(unittest.TestCase): def setUp(self): if 0: # for debugging import logging logger = logging.getLogger("test_urllib2net") logger.addHandler(logging.StreamHandler()) # XXX The rest of these tests aren't very good -- they don't check much. # They do sometimes catch some major disasters, though. def test_ftp(self): urls = [ 'ftp://ftp.debian.org/debian/README', ('ftp://ftp.debian.org/debian/non-existent-file', None, urllib2.URLError), ] self._test_urls(urls, self._extra_handlers()) def test_file(self): TESTFN = test_support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') f.close() urls = [ 'file:'+sanepathname2url(os.path.abspath(TESTFN)), ('file:///nonsensename/etc/passwd', None, urllib2.URLError), ] self._test_urls(urls, self._extra_handlers(), retry=True) finally: os.remove(TESTFN) self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file') # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes. ## def test_cnri(self): ## if socket.gethostname() == 'bitdiddle': ## localhost = 'bitdiddle.cnri.reston.va.us' ## elif socket.gethostname() == 'bitdiddle.concentric.net': ## localhost = 'localhost' ## else: ## localhost = None ## if localhost is not None: ## urls = [ ## 'file://%s/etc/passwd' % localhost, ## 'http://%s/simple/' % localhost, ## 'http://%s/digest/' % localhost, ## 'http://%s/not/found.h' % localhost, ## ] ## bauth = HTTPBasicAuthHandler() ## bauth.add_password('basic_test_realm', localhost, 'jhylton', ## 'password') ## dauth = HTTPDigestAuthHandler() ## dauth.add_password('digest_test_realm', localhost, 'jhylton', ## 'password') ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def test_urlwithfrag(self): urlwith_frag = "http://www.pythontest.net/index.html#frag" with test_support.transient_internet(urlwith_frag): req = urllib2.Request(urlwith_frag) res = urllib2.urlopen(req) self.assertEqual(res.geturl(), "http://www.pythontest.net/index.html#frag") def test_fileno(self): req = urllib2.Request("http://www.example.com") opener = urllib2.build_opener() res = opener.open(req) try: res.fileno() except AttributeError: self.fail("HTTPResponse object should return a valid fileno") finally: res.close() def test_custom_headers(self): url = "http://www.example.com" with test_support.transient_internet(url): opener = urllib2.build_opener() request = urllib2.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent') def test_sites_no_connection_close(self): # Some sites do not send Connection: close header. # Verify that those work properly. (#issue12576) URL = 'http://www.imdb.com' # No Connection:close with test_support.transient_internet(URL): req = urllib2.urlopen(URL) res = req.read() self.assertTrue(res) def _test_urls(self, urls, handlers, retry=True): import time import logging debug = logging.getLogger("test_urllib2").debug urlopen = urllib2.build_opener(*handlers).open if retry: urlopen = _wrap_with_retry_thrice(urlopen, urllib2.URLError) for url in urls: if isinstance(url, tuple): url, req, expected_err = url else: req = expected_err = None with test_support.transient_internet(url): debug(url) try: f = urlopen(url, req, TIMEOUT) except EnvironmentError as err: debug(err) if expected_err: msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" % (expected_err, url, req, type(err), err)) self.assertIsInstance(err, expected_err, msg) except urllib2.URLError as err: if isinstance(err[0], socket.timeout): print >>sys.stderr, "" % url continue else: raise else: try: with test_support.transient_internet(url): buf = f.read() debug("read %d bytes" % len(buf)) except socket.timeout: print >>sys.stderr, "" % url f.close() debug("******** next url coming up...") time.sleep(0.1) def _extra_handlers(self): handlers = [] cfh = urllib2.CacheFTPHandler() self.addCleanup(cfh.clear_cache) cfh.setTimeout(1) handlers.append(cfh) return handlers class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) def test_http_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url) finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) def test_http_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) def test_http_timeout(self): url = "http://www.example.com" with test_support.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) FTP_HOST = 'ftp://ftp.debian.org/debian/' def test_ftp_basic(self): self.assertIsNone(socket.getdefaulttimeout()) with test_support.transient_internet(self.FTP_HOST, timeout=None): u = _urlopen_with_retry(self.FTP_HOST) self.assertIsNone(u.fp.fp._sock.gettimeout()) def test_ftp_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_ftp_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout(),) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(u.fp.fp._sock.gettimeout()) def test_ftp_timeout(self): with test_support.transient_internet(self.FTP_HOST): u = _urlopen_with_retry(self.FTP_HOST, timeout=60) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_main(): test_support.requires("network") test_support.run_unittest(AuthTests, OtherNetworkTests, CloseSocketTest, TimeoutTest, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/test_wsgiref.py0000644000076500000000000004633312666555342021135 0ustar jmaddenwheel00000000000000from unittest import TestCase from wsgiref.util import setup_testing_defaults from wsgiref.headers import Headers from wsgiref.handlers import BaseHandler, BaseCGIHandler from wsgiref import util from wsgiref.validate import validator from wsgiref.simple_server import WSGIServer, WSGIRequestHandler from wsgiref.simple_server import make_server from StringIO import StringIO from SocketServer import BaseServer import os import re import sys from test import test_support class MockServer(WSGIServer): """Non-socket HTTP server""" def __init__(self, server_address, RequestHandlerClass): BaseServer.__init__(self, server_address, RequestHandlerClass) self.server_bind() def server_bind(self): host, port = self.server_address self.server_name = host self.server_port = port self.setup_environ() class MockHandler(WSGIRequestHandler): """Non-socket HTTP handler""" def setup(self): self.connection = self.request self.rfile, self.wfile = self.connection def finish(self): pass def hello_app(environ,start_response): start_response("200 OK", [ ('Content-Type','text/plain'), ('Date','Mon, 05 Jun 2006 18:49:54 GMT') ]) return ["Hello, world!"] def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"): server = make_server("", 80, app, MockServer, MockHandler) inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr sys.stderr = err try: server.finish_request((inp,out), ("127.0.0.1",8888)) finally: sys.stderr = olderr return out.getvalue(), err.getvalue() def compare_generic_iter(make_it,match): """Utility to compare a generic 2.1/2.2+ iterator with an iterable If running under Python 2.2+, this tests the iterator using iter()/next(), as well as __getitem__. 'make_it' must be a function returning a fresh iterator to be tested (since this may test the iterator twice).""" it = make_it() n = 0 for item in match: if not it[n]==item: raise AssertionError n+=1 try: it[n] except IndexError: pass else: raise AssertionError("Too many items from __getitem__",it) try: iter, StopIteration except NameError: pass else: # Only test iter mode under 2.2+ it = make_it() if not iter(it) is it: raise AssertionError for item in match: if not it.next()==item: raise AssertionError try: it.next() except StopIteration: pass else: raise AssertionError("Too many items from .next()",it) class IntegrationTests(TestCase): def check_hello(self, out, has_length=True): self.assertEqual(out, "HTTP/1.0 200 OK\r\n" "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n" "Content-Type: text/plain\r\n" "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" + (has_length and "Content-Length: 13\r\n" or "") + "\r\n" "Hello, world!" ) def test_plain_hello(self): out, err = run_amock() self.check_hello(out) def test_request_length(self): out, err = run_amock(data="GET " + ("x" * 65537) + " HTTP/1.0\n\n") self.assertEqual(out.splitlines()[0], "HTTP/1.0 414 Request-URI Too Long") def test_validated_hello(self): out, err = run_amock(validator(hello_app)) # the middleware doesn't support len(), so content-length isn't there self.check_hello(out, has_length=False) def test_simple_validation_error(self): def bad_app(environ,start_response): start_response("200 OK", ('Content-Type','text/plain')) return ["Hello, world!"] out, err = run_amock(validator(bad_app)) self.assertTrue(out.endswith( "A server error occurred. Please contact the administrator." )) self.assertEqual( err.splitlines()[-2], "AssertionError: Headers (('Content-Type', 'text/plain')) must" " be of type list: " ) class UtilityTests(TestCase): def checkShift(self,sn_in,pi_in,part,sn_out,pi_out): env = {'SCRIPT_NAME':sn_in,'PATH_INFO':pi_in} util.setup_testing_defaults(env) self.assertEqual(util.shift_path_info(env),part) self.assertEqual(env['PATH_INFO'],pi_out) self.assertEqual(env['SCRIPT_NAME'],sn_out) return env def checkDefault(self, key, value, alt=None): # Check defaulting when empty env = {} util.setup_testing_defaults(env) if isinstance(value, StringIO): self.assertIsInstance(env[key], StringIO) else: self.assertEqual(env[key], value) # Check existing value env = {key:alt} util.setup_testing_defaults(env) self.assertIs(env[key], alt) def checkCrossDefault(self,key,value,**kw): util.setup_testing_defaults(kw) self.assertEqual(kw[key],value) def checkAppURI(self,uri,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.application_uri(kw),uri) def checkReqURI(self,uri,query=1,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.request_uri(kw,query),uri) def checkFW(self,text,size,match): def make_it(text=text,size=size): return util.FileWrapper(StringIO(text),size) compare_generic_iter(make_it,match) it = make_it() self.assertFalse(it.filelike.closed) for item in it: pass self.assertFalse(it.filelike.closed) it.close() self.assertTrue(it.filelike.closed) def testSimpleShifts(self): self.checkShift('','/', '', '/', '') self.checkShift('','/x', 'x', '/x', '') self.checkShift('/','', None, '/', '') self.checkShift('/a','/x/y', 'x', '/a/x', '/y') self.checkShift('/a','/x/', 'x', '/a/x', '/') def testNormalizedShifts(self): self.checkShift('/a/b', '/../y', '..', '/a', '/y') self.checkShift('', '/../y', '..', '', '/y') self.checkShift('/a/b', '//y', 'y', '/a/b/y', '') self.checkShift('/a/b', '//y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '/./y', 'y', '/a/b/y', '') self.checkShift('/a/b', '/./y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '///./..//y/.//', '..', '/a', '/y/') self.checkShift('/a/b', '///', '', '/a/b/', '') self.checkShift('/a/b', '/.//', '', '/a/b/', '') self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/') self.checkShift('/a/b', '/.', None, '/a/b', '') def testDefaults(self): for key, value in [ ('SERVER_NAME','127.0.0.1'), ('SERVER_PORT', '80'), ('SERVER_PROTOCOL','HTTP/1.0'), ('HTTP_HOST','127.0.0.1'), ('REQUEST_METHOD','GET'), ('SCRIPT_NAME',''), ('PATH_INFO','/'), ('wsgi.version', (1,0)), ('wsgi.run_once', 0), ('wsgi.multithread', 0), ('wsgi.multiprocess', 0), ('wsgi.input', StringIO("")), ('wsgi.errors', StringIO()), ('wsgi.url_scheme','http'), ]: self.checkDefault(key,value) def testCrossDefaults(self): self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="1") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="yes") self.checkCrossDefault('wsgi.url_scheme',"http",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on") def testGuessScheme(self): self.assertEqual(util.guess_scheme({}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"on"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https") def testAppURIs(self): self.checkAppURI("http://127.0.0.1/") self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkAppURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkAppURI("http://spam.example.com:2071/", HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071") self.checkAppURI("http://spam.example.com/", SERVER_NAME="spam.example.com") self.checkAppURI("http://127.0.0.1/", HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com") self.checkAppURI("https://127.0.0.1/", HTTPS="on") self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000", HTTP_HOST=None) def testReqURIs(self): self.checkReqURI("http://127.0.0.1/") self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkReqURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam", SCRIPT_NAME="/spammity", PATH_INFO="/spam") self.checkReqURI("http://127.0.0.1/spammity/sp%E4m", SCRIPT_NAME="/spammity", PATH_INFO="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam;ham", SCRIPT_NAME="/spammity", PATH_INFO="/spam;ham") self.checkReqURI("http://127.0.0.1/spammity/spam;cookie=1234,5678", SCRIPT_NAME="/spammity", PATH_INFO="/spam;cookie=1234,5678") self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") self.checkReqURI("http://127.0.0.1/spammity/spam?s%E4y=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="s%E4y=ni") self.checkReqURI("http://127.0.0.1/spammity/spam", 0, SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") def testFileWrapper(self): self.checkFW("xyz"*50, 120, ["xyz"*40,"xyz"*10]) def testHopByHop(self): for hop in ( "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization " "TE Trailers Transfer-Encoding Upgrade" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.assertTrue(util.is_hop_by_hop(alt)) # Not comprehensive, just a few random header names for hop in ( "Accept Cache-Control Date Pragma Trailer Via Warning" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.assertFalse(util.is_hop_by_hop(alt)) class HeaderTests(TestCase): def testMappingInterface(self): test = [('x','y')] self.assertEqual(len(Headers([])),0) self.assertEqual(len(Headers(test[:])),1) self.assertEqual(Headers(test[:]).keys(), ['x']) self.assertEqual(Headers(test[:]).values(), ['y']) self.assertEqual(Headers(test[:]).items(), test) self.assertIsNot(Headers(test).items(), test) # must be copy! h=Headers([]) del h['foo'] # should not raise an error h['Foo'] = 'bar' for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__: self.assertTrue(m('foo')) self.assertTrue(m('Foo')) self.assertTrue(m('FOO')) self.assertFalse(m('bar')) self.assertEqual(h['foo'],'bar') h['foo'] = 'baz' self.assertEqual(h['FOO'],'baz') self.assertEqual(h.get_all('foo'),['baz']) self.assertEqual(h.get("foo","whee"), "baz") self.assertEqual(h.get("zoo","whee"), "whee") self.assertEqual(h.setdefault("foo","whee"), "baz") self.assertEqual(h.setdefault("zoo","whee"), "whee") self.assertEqual(h["foo"],"baz") self.assertEqual(h["zoo"],"whee") def testRequireList(self): self.assertRaises(TypeError, Headers, "foo") def testExtras(self): h = Headers([]) self.assertEqual(str(h),'\r\n') h.add_header('foo','bar',baz="spam") self.assertEqual(h['foo'], 'bar; baz="spam"') self.assertEqual(str(h),'foo: bar; baz="spam"\r\n\r\n') h.add_header('Foo','bar',cheese=None) self.assertEqual(h.get_all('foo'), ['bar; baz="spam"', 'bar; cheese']) self.assertEqual(str(h), 'foo: bar; baz="spam"\r\n' 'Foo: bar; cheese\r\n' '\r\n' ) class ErrorHandler(BaseCGIHandler): """Simple handler subclass for testing BaseHandler""" # BaseHandler records the OS environment at import time, but envvars # might have been changed later by other tests, which trips up # HandlerTests.testEnviron(). os_environ = dict(os.environ.items()) def __init__(self,**kw): setup_testing_defaults(kw) BaseCGIHandler.__init__( self, StringIO(''), StringIO(), StringIO(), kw, multithread=True, multiprocess=True ) class TestHandler(ErrorHandler): """Simple handler subclass for testing BaseHandler, w/error passthru""" def handle_error(self): raise # for testing, we want to see what's happening class HandlerTests(TestCase): def checkEnvironAttrs(self, handler): env = handler.environ for attr in [ 'version','multithread','multiprocess','run_once','file_wrapper' ]: if attr=='file_wrapper' and handler.wsgi_file_wrapper is None: continue self.assertEqual(getattr(handler,'wsgi_'+attr),env['wsgi.'+attr]) def checkOSEnviron(self,handler): empty = {}; setup_testing_defaults(empty) env = handler.environ from os import environ for k,v in environ.items(): if k not in empty: self.assertEqual(env[k],v) for k,v in empty.items(): self.assertIn(k, env) def testEnviron(self): h = TestHandler(X="Y") h.setup_environ() self.checkEnvironAttrs(h) self.checkOSEnviron(h) self.assertEqual(h.environ["X"],"Y") def testCGIEnviron(self): h = BaseCGIHandler(None,None,None,{}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': self.assertIn(key, h.environ) def testScheme(self): h=TestHandler(HTTPS="on"); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'https') h=TestHandler(); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'http') def testAbstractMethods(self): h = BaseHandler() for name in [ '_flush','get_stdin','get_stderr','add_cgi_vars' ]: self.assertRaises(NotImplementedError, getattr(h,name)) self.assertRaises(NotImplementedError, h._write, "test") def testContentLength(self): # Demo one reason iteration is better than write()... ;) def trivial_app1(e,s): s('200 OK',[]) return [e['wsgi.url_scheme']] def trivial_app2(e,s): s('200 OK',[])(e['wsgi.url_scheme']) return [] def trivial_app4(e,s): # Simulate a response to a HEAD request s('200 OK',[('Content-Length', '12345')]) return [] h = TestHandler() h.run(trivial_app1) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 4\r\n" "\r\n" "http") h = TestHandler() h.run(trivial_app2) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n" "http") h = TestHandler() h.run(trivial_app4) self.assertEqual(h.stdout.getvalue(), b'Status: 200 OK\r\n' b'Content-Length: 12345\r\n' b'\r\n') def testBasicErrorOutput(self): def non_error_app(e,s): s('200 OK',[]) return [] def error_app(e,s): raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(non_error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n") self.assertEqual(h.stderr.getvalue(),"") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: %s\r\n" "Content-Type: text/plain\r\n" "Content-Length: %d\r\n" "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)) self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1) def testErrorAfterOutput(self): MSG = "Some output has been sent" def error_app(e,s): s("200 OK",[])(MSG) raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n"+MSG) self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1) def testHeaderFormats(self): def non_error_app(e,s): s('200 OK',[]) return [] stdpat = ( r"HTTP/%s 200 OK\r\n" r"Date: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n" r"%s" r"Content-Length: 0\r\n" r"\r\n" ) shortpat = ( "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n" ) for ssw in "FooBar/1.0", None: sw = ssw and "Server: %s\r\n" % ssw or "" for version in "1.0", "1.1": for proto in "HTTP/0.9", "HTTP/1.0", "HTTP/1.1": h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = False h.http_version = version h.server_software = ssw h.run(non_error_app) self.assertEqual(shortpat,h.stdout.getvalue()) h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = True h.http_version = version h.server_software = ssw h.run(non_error_app) if proto=="HTTP/0.9": self.assertEqual(h.stdout.getvalue(),"") else: self.assertTrue( re.match(stdpat%(version,sw), h.stdout.getvalue()), (stdpat%(version,sw), h.stdout.getvalue()) ) def testCloseOnError(self): side_effects = {'close_called': False} MSG = b"Some output has been sent" def error_app(e,s): s("200 OK",[])(MSG) class CrashyIterable(object): def __iter__(self): while True: yield b'blah' raise AssertionError("This should be caught by handler") def close(self): side_effects['close_called'] = True return CrashyIterable() h = ErrorHandler() h.run(error_app) self.assertEqual(side_effects['close_called'], True) def test_main(): test_support.run_unittest(__name__) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7/version0000644000076500000000000000000712666555342017452 0ustar jmaddenwheel000000000000002.7.11 gevent-1.1.0/greentest/2.7/wrongcert.pem0000644000076500000000000000353012666555342020563 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw eSHj5jpC8iZKjCHBn+mAi4cQ514= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/0000755000076500000000000000000012666555433016770 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7pypy/badcert.pem0000644000076500000000000000361012666555342021076 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/badkey.pem0000644000076500000000000000416212666555342020734 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/https_svn_python_org_root.pem0000644000076500000000000000501112666555342025032 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/keycert.pem0000644000076500000000000000336712666555342021151 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/lock_tests.py0000644000076500000000000003542612666555342021525 0ustar jmaddenwheel00000000000000""" Various tests for synchronization primitives. """ import sys import time from thread import start_new_thread, get_ident import threading import unittest from test import test_support as support def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() for i in range(n): start_new_thread(task, ()) def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children() class BaseLockTests(BaseTestCase): """ Tests for both recursive and non-recursive locks. """ def test_constructor(self): lock = self.locktype() del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) def test_with(self): lock = self.locktype() def f(): lock.acquire() lock.release() def _with(err=None): with lock: if err is not None: raise err _with() # Check the lock is unacquired Bunch(f, 1).wait_for_finished() self.assertRaises(TypeError, _with, TypeError) # Check the lock is unacquired Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. Bunch(f, 15).wait_for_finished() self.assertEqual(n, len(threading.enumerate())) class LockTests(BaseLockTests): """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def test_reacquire(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def test_different_thread(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() class RLockTests(BaseLockTests): """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_different_thread(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) class EventTests(BaseTestCase): """ Tests for Event objects. """ def test_is_set(self): evt = self.eventtype() self.assertFalse(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) def _check_notify(self, evt): # All threads get notified N = 5 results1 = [] results2 = [] def f(): results1.append(evt.wait()) results2.append(evt.wait()) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(results1), 0) evt.set() b.wait_for_finished() self.assertEqual(results1, [True] * N) self.assertEqual(results2, [True] * N) def test_notify(self): evt = self.eventtype() self._check_notify(evt) # Another time, after an explicit clear() evt.set() evt.clear() self._check_notify(evt) def test_timeout(self): evt = self.eventtype() results1 = [] results2 = [] N = 5 def f(): results1.append(evt.wait(0.0)) t1 = time.time() r = evt.wait(0.2) t2 = time.time() results2.append((r, t2 - t1)) Bunch(f, N).wait_for_finished() self.assertEqual(results1, [False] * N) for r, dt in results2: self.assertFalse(r) self.assertTrue(dt >= 0.2, dt) # The event is set results1 = [] results2 = [] evt.set() Bunch(f, N).wait_for_finished() self.assertEqual(results1, [True] * N) for r, dt in results2: self.assertTrue(r) class ConditionTests(BaseTestCase): """ Tests for condition variables. """ def test_acquire(self): cond = self.condtype() # Be default we have an RLock: the condition can be acquired multiple # times. cond.acquire() cond.acquire() cond.release() cond.release() lock = threading.Lock() cond = self.condtype(lock) cond.acquire() self.assertFalse(lock.acquire(False)) cond.release() self.assertTrue(lock.acquire(False)) self.assertFalse(cond.acquire(False)) lock.release() with cond: self.assertFalse(lock.acquire(False)) def test_unacquired_wait(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.wait) def test_unacquired_notify(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.notify) def _check_notify(self, cond): N = 5 results1 = [] results2 = [] phase_num = 0 def f(): cond.acquire() cond.wait() cond.release() results1.append(phase_num) cond.acquire() cond.wait() cond.release() results2.append(phase_num) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(results1, []) # Notify 3 threads at first cond.acquire() cond.notify(3) _wait() phase_num = 1 cond.release() while len(results1) < 3: _wait() self.assertEqual(results1, [1] * 3) self.assertEqual(results2, []) # Notify 5 threads: they might be in their first or second wait cond.acquire() cond.notify(5) _wait() phase_num = 2 cond.release() while len(results1) + len(results2) < 8: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3) # Notify all threads: they are all in their second wait cond.acquire() cond.notify_all() _wait() phase_num = 3 cond.release() while len(results2) < 5: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3 + [3] * 2) b.wait_for_finished() def test_notify(self): cond = self.condtype() self._check_notify(cond) # A second time, to check internal state is still ok. self._check_notify(cond) def test_timeout(self): cond = self.condtype() results = [] N = 5 def f(): cond.acquire() t1 = time.time() cond.wait(0.2) t2 = time.time() cond.release() results.append(t2 - t1) Bunch(f, N).wait_for_finished() self.assertEqual(len(results), 5) for dt in results: self.assertTrue(dt >= 0.2, dt) class BaseSemaphoreTests(BaseTestCase): """ Common tests for {bounded, unbounded} semaphore objects. """ def test_constructor(self): self.assertRaises(ValueError, self.semtype, value = -1) self.assertRaises(ValueError, self.semtype, value = -sys.maxint) def test_acquire(self): sem = self.semtype(1) sem.acquire() sem.release() sem = self.semtype(2) sem.acquire() sem.acquire() sem.release() sem.release() def test_acquire_destroy(self): sem = self.semtype() sem.acquire() del sem def test_acquire_contended(self): sem = self.semtype(7) sem.acquire() N = 10 results1 = [] results2 = [] phase_num = 0 def f(): sem.acquire() results1.append(phase_num) sem.acquire() results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() while len(results1) + len(results2) < 6: _wait() self.assertEqual(results1 + results2, [0] * 6) phase_num = 1 for i in range(7): sem.release() while len(results1) + len(results2) < 13: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7) phase_num = 2 for i in range(6): sem.release() while len(results1) + len(results2) < 19: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7 + [2] * 6) # The semaphore is still locked self.assertFalse(sem.acquire(False)) # Final release, to let the last thread finish sem.release() b.wait_for_finished() def test_try_acquire(self): sem = self.semtype(2) self.assertTrue(sem.acquire(False)) self.assertTrue(sem.acquire(False)) self.assertFalse(sem.acquire(False)) sem.release() self.assertTrue(sem.acquire(False)) def test_try_acquire_contended(self): sem = self.semtype(4) sem.acquire() results = [] def f(): results.append(sem.acquire(False)) results.append(sem.acquire(False)) Bunch(f, 5).wait_for_finished() # There can be a thread switch between acquiring the semaphore and # appending the result, therefore results will not necessarily be # ordered. self.assertEqual(sorted(results), [False] * 7 + [True] * 3 ) def test_default_value(self): # The default initial value is 1. sem = self.semtype() sem.acquire() def f(): sem.acquire() sem.release() b = Bunch(f, 1) b.wait_for_started() _wait() self.assertFalse(b.finished) sem.release() b.wait_for_finished() def test_with(self): sem = self.semtype(2) def _with(err=None): with sem: self.assertTrue(sem.acquire(False)) sem.release() with sem: self.assertFalse(sem.acquire(False)) if err: raise err _with() self.assertTrue(sem.acquire(False)) sem.release() self.assertRaises(TypeError, _with, TypeError) self.assertTrue(sem.acquire(False)) sem.release() class SemaphoreTests(BaseSemaphoreTests): """ Tests for unbounded semaphores. """ def test_release_unacquired(self): # Unbounded releases are allowed and increment the semaphore's value sem = self.semtype(1) sem.release() sem.acquire() sem.acquire() sem.release() class BoundedSemaphoreTests(BaseSemaphoreTests): """ Tests for bounded semaphores. """ def test_release_unacquired(self): # Cannot go past the initial value sem = self.semtype() self.assertRaises(ValueError, sem.release) sem.acquire() sem.release() self.assertRaises(ValueError, sem.release) gevent-1.1.0/greentest/2.7pypy/nokia.pem0000644000076500000000000000360312666555342020575 0ustar jmaddenwheel00000000000000# Certificate for projects.developer.nokia.com:443 (see issue 13034) -----BEGIN CERTIFICATE----- MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/nullcert.pem0000644000076500000000000000000012666555342021310 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7pypy/sha256.pem0000644000076500000000000002017212666555342020504 0ustar jmaddenwheel00000000000000# Certificate chain for https://sha256.tbs-internet.com 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=Certificats TBS X509/CN=ecom.tbs-x509.com i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA business -----BEGIN CERTIFICATE----- MIIGTjCCBTagAwIBAgIQOh3d9dNDPq1cSdJmEiMpqDANBgkqhkiG9w0BAQUFADCB yTELMAkGA1UEBhMCRlIxETAPBgNVBAgTCENhbHZhZG9zMQ0wCwYDVQQHEwRDYWVu MRUwEwYDVQQKEwxUQlMgSU5URVJORVQxSDBGBgNVBAsTP1Rlcm1zIGFuZCBDb25k aXRpb25zOiBodHRwOi8vd3d3LnRicy1pbnRlcm5ldC5jb20vQ0EvcmVwb3NpdG9y eTEYMBYGA1UECxMPVEJTIElOVEVSTkVUIENBMR0wGwYDVQQDExRUQlMgWDUwOSBD QSBidXNpbmVzczAeFw0xMTAxMjUwMDAwMDBaFw0xMzAyMDUyMzU5NTlaMIHHMQsw CQYDVQQGEwJGUjEOMAwGA1UEERMFMTQwMDAxETAPBgNVBAgTCENhbHZhZG9zMQ0w CwYDVQQHEwRDQUVOMRswGQYDVQQJExIyMiBydWUgZGUgQnJldGFnbmUxFTATBgNV BAoTDFRCUyBJTlRFUk5FVDEXMBUGA1UECxMOMDAwMiA0NDA0NDM4MTAxHTAbBgNV BAsTFENlcnRpZmljYXRzIFRCUyBYNTA5MRowGAYDVQQDExFlY29tLnRicy14NTA5 LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKRrlHUnJ++1lpcg jtYco7cdmRe+EEfTmwPfCdfV3G1QfsTSvY6FfMpm/83pqHfT+4ANwr18wD9ZrAEN G16mf9VdCGK12+TP7DmqeZyGIqlFFoahQnmb8EarvE43/1UeQ2CV9XmzwZvpqeli LfXsFonawrY3H6ZnMwS64St61Z+9gdyuZ/RbsoZBbT5KUjDEG844QRU4OT1IGeEI eY5NM5RNIh6ZNhVtqeeCxMS7afONkHQrOco73RdSTRck/Hj96Ofl3MHNHryr+AMK DGFk1kLCZGpPdXtkxXvaDeQoiYDlil26CWc+YK6xyDPMdsWvoG14ZLyCpzMXA7/7 4YAQRH0CAwEAAaOCAjAwggIsMB8GA1UdIwQYMBaAFBoJBMz5CY+7HqDO1KQUf0vV I1jNMB0GA1UdDgQWBBQgOU8HsWzbmD4WZP5Wtdw7jca2WDAOBgNVHQ8BAf8EBAMC BaAwDAYDVR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw TAYDVR0gBEUwQzBBBgsrBgEEAYDlNwIBATAyMDAGCCsGAQUFBwIBFiRodHRwczov L3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL0NQUzEwdwYDVR0fBHAwbjA3oDWgM4Yx aHR0cDovL2NybC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQWJ1c2luZXNzLmNy bDAzoDGgL4YtaHR0cDovL2NybC50YnMteDUwOS5jb20vVEJTWDUwOUNBYnVzaW5l c3MuY3JsMIGwBggrBgEFBQcBAQSBozCBoDA9BggrBgEFBQcwAoYxaHR0cDovL2Ny dC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQWJ1c2luZXNzLmNydDA5BggrBgEF BQcwAoYtaHR0cDovL2NydC50YnMteDUwOS5jb20vVEJTWDUwOUNBYnVzaW5lc3Mu Y3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC50YnMteDUwOS5jb20wMwYDVR0R BCwwKoIRZWNvbS50YnMteDUwOS5jb22CFXd3dy5lY29tLnRicy14NTA5LmNvbTAN BgkqhkiG9w0BAQUFAAOCAQEArT4NHfbY87bGAw8lPV4DmHlmuDuVp/y7ltO3Ynse 3Rz8RxW2AzuO0Oy2F0Cu4yWKtMyEyMXyHqWtae7ElRbdTu5w5GwVBLJHClCzC8S9 SpgMMQTx3Rgn8vjkHuU9VZQlulZyiPK7yunjc7c310S9FRZ7XxOwf8Nnx4WnB+No WrfApzhhQl31w+RyrNxZe58hCfDDHmevRvwLjQ785ZoQXJDj2j3qAD4aI2yB8lB5 oaE1jlCJzC7Kmz/Y9jzfmv/zAs1LQTm9ktevv4BTUFaGjv9jxnQ1xnS862ZiouLW zZYIlYPf4F6JjXGiIQgQRglILUfq3ftJd9/ok9W9ZF8h8w== -----END CERTIFICATE----- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA business i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root -----BEGIN CERTIFICATE----- MIIFPzCCBCegAwIBAgIQDlBz/++iRSmLDeVRHT/hADANBgkqhkiG9w0BAQUFADBv MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDcwOTE4MTkyMlow gckxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEdMBsGA1UEAxMUVEJTIFg1MDkg Q0EgYnVzaW5lc3MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDB1PAU qudCcz3tmyGcf+u6EkZqonKKHrV4gZYbvVkIRojmmlhfi/jwvpHvo8bqSt/9Rj5S jhCDW0pcbI+IPPtD1Jy+CHNSfnMqVDy6CKQ3p5maTzCMG6ZT+XjnvcND5v+FtaiB xk1iCX6uvt0jeUtdZvYbyytsSDE6c3Y5//wRxOF8tM1JxibwO3pyER26jbbN2gQz m/EkdGjLdJ4svPk23WDAvQ6G0/z2LcAaJB+XLfqRwfQpHQvfKa1uTi8PivC8qtip rmNQMMPMjxSK2azX8cKjjTDJiUKaCb4VHlJDWKEsCFRpgJAoAuX8f7Yfs1M4esGo sWb3PGspK3O22uIlAgMBAAGjggF6MIIBdjAdBgNVHQ4EFgQUGgkEzPkJj7seoM7U pBR/S9UjWM0wDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwGAYD VR0gBBEwDzANBgsrBgEEAYDlNwIBATB7BgNVHR8EdDByMDigNqA0hjJodHRwOi8v Y3JsLmNvbW9kb2NhLmNvbS9BZGRUcnVzdEV4dGVybmFsQ0FSb290LmNybDA2oDSg MoYwaHR0cDovL2NybC5jb21vZG8ubmV0L0FkZFRydXN0RXh0ZXJuYWxDQVJvb3Qu Y3JsMIGGBggrBgEFBQcBAQR6MHgwOwYIKwYBBQUHMAKGL2h0dHA6Ly9jcnQuY29t b2RvY2EuY29tL0FkZFRydXN0VVROU2VydmVyQ0EuY3J0MDkGCCsGAQUFBzAChi1o dHRwOi8vY3J0LmNvbW9kby5uZXQvQWRkVHJ1c3RVVE5TZXJ2ZXJDQS5jcnQwEQYJ YIZIAYb4QgEBBAQDAgIEMA0GCSqGSIb3DQEBBQUAA4IBAQA7mqrMgk/MrE6QnbNA h4nRCn2ti4bg4w2C3lB6bSvRPnYwuNw9Jb8vuKkNFzRDxNJXqVDZdfFW5CVQJuyd nfAx83+wk+spzvFaE1KhFYfN9G9pQfXUfvDRoIcJgPEKUXL1wRiOG+IjU3VVI8pg IgqHkr7ylln5i5zCiFAPuIJmYUSFg/gxH5xkCNcjJqqrHrHatJr6Qrrke93joupw oU1njfAcZtYp6fbiK6u2b1pJqwkVBE8RsfLnPhRj+SFbpvjv8Od7o/ieJhFIYQNU k2jX2u8qZnAiNw93LZW9lpYjtuvMXq8QQppENNja5b53q7UwI+lU7ZGjZ7quuESp J6/5 -----END CERTIFICATE----- 2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware -----BEGIN CERTIFICATE----- MIIETzCCAzegAwIBAgIQHM5EYpUZep1jUvnyI6m2mDANBgkqhkiG9w0BAQUFADCB lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt SGFyZHdhcmUwHhcNMDUwNjA3MDgwOTEwWhcNMTkwNzA5MTgxOTIyWjBvMQswCQYD VQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0 IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5h bCBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt/caM+by AAQtOeBOW+0fvGwPzbX6I7bO3psRM5ekKUx9k5+9SryT7QMa44/P5W1QWtaXKZRa gLBJetsulf24yr83OC0ePpFBrXBWx/BPP+gynnTKyJBU6cZfD3idmkA8Dqxhql4U j56HoWpQ3NeaTq8Fs6ZxlJxxs1BgCscTnTgHhgKo6ahpJhiQq0ywTyOrOk+E2N/O n+Fpb7vXQtdrROTHre5tQV9yWnEIN7N5ZaRZoJQ39wAvDcKSctrQOHLbFKhFxF0q fbe01sTurM0TRLfJK91DACX6YblpalgjEbenM49WdVn1zSnXRrcKK2W200JvFbK4 e/vv6V1T1TRaJwIDAQABo4G9MIG6MB8GA1UdIwQYMBaAFKFyXyYbKJhDlV0HN9WF lp1L0sNFMB0GA1UdDgQWBBStvZh6NLQm9/rEJlTvA73gJMtUGjAOBgNVHQ8BAf8E BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zARBglghkgBhvhCAQEEBAMCAQIwRAYDVR0f BD0wOzA5oDegNYYzaHR0cDovL2NybC51c2VydHJ1c3QuY29tL1VUTi1VU0VSRmly c3QtSGFyZHdhcmUuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQByQhANOs4kClrwF8BW onvUOGCSjRK52zYZgDXYNjDtmr5rJ6NyPFDNn+JxkLpjYetIFMTbSRe679Bt8m7a gIAoQYFQtxMuyLnJegB2aEbQiIxh/tC21UcFF7ktdnDoTlA6w3pLuvunaI84Of3o 2YBrhzkTbCfaYk5JRlTpudW9DkUkHBsyx3nknPKnplkIGaK0jgn8E0n+SFabYaHk I9LroYT/+JtLefh9lgBdAgVv0UPbzoGfuDsrk/Zh+UrgbLFpHoVnElhzbkh64Z0X OGaJunQc68cCZu5HTn/aK7fBGMcVflRCXLVEQpU9PIAdGA8Ynvg684t8GMaKsRl1 jIGZ -----END CERTIFICATE----- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware -----BEGIN CERTIFICATE----- MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn 0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0 dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM //bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t 3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA== -----END CERTIFICATE----- gevent-1.1.0/greentest/2.7pypy/subprocessdata/0000755000076500000000000000000012666555433022012 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/2.7pypy/subprocessdata/sigchild_ignore.py0000644000076500000000000000136512666555342025521 0ustar jmaddenwheel00000000000000import signal, subprocess, sys, time # On Linux this causes os.waitpid to fail with OSError as the OS has already # reaped our child process. The wait() passing the OSError on to the caller # and causing us to exit with an error is what we are testing against. signal.signal(signal.SIGCHLD, signal.SIG_IGN) subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait() # Also ensure poll() handles an errno.ECHILD appropriately. p = subprocess.Popen([sys.executable, '-c', 'print("albatross")']) num_polls = 0 while p.poll() is None: # Waiting for the process to finish. time.sleep(0.01) # Avoid being a CPU busy loop. num_polls += 1 if num_polls > 3000: raise RuntimeError('poll should have returned 0 within 30 seconds') gevent-1.1.0/greentest/2.7pypy/test_asyncore.py0000644000076500000000000005466212666555342022240 0ustar jmaddenwheel00000000000000import asyncore import unittest import select import os import socket import sys import time import warnings import errno import struct from test import test_support from test.test_support import TESTFN, run_unittest, unlink, HOST from StringIO import StringIO try: import threading except ImportError: threading = None class dummysocket: def __init__(self): self.closed = False def close(self): self.closed = True def fileno(self): return 42 class dummychannel: def __init__(self): self.socket = dummysocket() def close(self): self.socket.close() class exitingdummy: def __init__(self): pass def handle_read_event(self): raise asyncore.ExitNow() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event class crashingdummy: def __init__(self): self.error_handled = False def handle_read_event(self): raise Exception() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event def handle_error(self): self.error_handled = True # used when testing senders; just collects what it gets until newline is sent def capture_server(evt, buf, serv): try: serv.listen(5) conn, addr = serv.accept() except socket.timeout: pass else: n = 200 while n > 0: r, w, e = select.select([conn], [], []) if r: data = conn.recv(10) # keep everything except for the newline terminator buf.write(data.replace('\n', '')) if '\n' in data: break n -= 1 time.sleep(0.01) conn.close() finally: serv.close() evt.set() class HelperFunctionTests(unittest.TestCase): def test_readwriteexc(self): # Check exception handling behavior of read, write and _exception # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore read/write/_exception calls tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.read, tr1) self.assertRaises(asyncore.ExitNow, asyncore.write, tr1) self.assertRaises(asyncore.ExitNow, asyncore._exception, tr1) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() asyncore.read(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore.write(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore._exception(tr2) self.assertEqual(tr2.error_handled, True) # asyncore.readwrite uses constants in the select module that # are not present in Windows systems (see this thread: # http://mail.python.org/pipermail/python-list/2001-October/109973.html) # These constants should be present as long as poll is available @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') def test_readwrite(self): # Check that correct methods are called by readwrite() attributes = ('read', 'expt', 'write', 'closed', 'error_handled') expected = ( (select.POLLIN, 'read'), (select.POLLPRI, 'expt'), (select.POLLOUT, 'write'), (select.POLLERR, 'closed'), (select.POLLHUP, 'closed'), (select.POLLNVAL, 'closed'), ) class testobj: def __init__(self): self.read = False self.write = False self.closed = False self.expt = False self.error_handled = False def handle_read_event(self): self.read = True def handle_write_event(self): self.write = True def handle_close(self): self.closed = True def handle_expt_event(self): self.expt = True def handle_error(self): self.error_handled = True for flag, expectedattr in expected: tobj = testobj() self.assertEqual(getattr(tobj, expectedattr), False) asyncore.readwrite(tobj, flag) # Only the attribute modified by the routine we expect to be # called should be True. for attr in attributes: self.assertEqual(getattr(tobj, attr), attr==expectedattr) # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore readwrite call tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() self.assertEqual(tr2.error_handled, False) asyncore.readwrite(tr2, flag) self.assertEqual(tr2.error_handled, True) def test_closeall(self): self.closeall_check(False) def test_closeall_default(self): self.closeall_check(True) def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True) def test_compact_traceback(self): try: raise Exception("I don't like spam!") except: real_t, real_v, real_tb = sys.exc_info() r = asyncore.compact_traceback() else: self.fail("Expected exception") (f, function, line), t, v, info = r self.assertEqual(os.path.split(f)[-1], 'test_asyncore.py') self.assertEqual(function, 'test_compact_traceback') self.assertEqual(t, real_t) self.assertEqual(v, real_v) self.assertEqual(info, '[%s|%s|%s]' % (f, function, line)) class DispatcherTests(unittest.TestCase): def setUp(self): pass def tearDown(self): asyncore.close_all() def test_basic(self): d = asyncore.dispatcher() self.assertEqual(d.readable(), True) self.assertEqual(d.writable(), True) def test_repr(self): d = asyncore.dispatcher() self.assertEqual(repr(d), '' % id(d)) def test_log(self): d = asyncore.dispatcher() # capture output of dispatcher.log() (to stderr) fp = StringIO() stderr = sys.stderr l1 = "Lovely spam! Wonderful spam!" l2 = "I don't like spam!" try: sys.stderr = fp d.log(l1) d.log(l2) finally: sys.stderr = stderr lines = fp.getvalue().splitlines() self.assertEqual(lines, ['log: %s' % l1, 'log: %s' % l2]) def test_log_info(self): d = asyncore.dispatcher() # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout l1 = "Have you got anything without spam?" l2 = "Why can't she have egg bacon spam and sausage?" l3 = "THAT'S got spam in it!" try: sys.stdout = fp d.log_info(l1, 'EGGS') d.log_info(l2) d.log_info(l3, 'SPAM') finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3] self.assertEqual(lines, expected) def test_unhandled(self): d = asyncore.dispatcher() d.ignore_log_types = () # capture output of dispatcher.log_info() (to stdout via print) fp = StringIO() stdout = sys.stdout try: sys.stdout = fp d.handle_expt() d.handle_read() d.handle_write() d.handle_connect() d.handle_accept() finally: sys.stdout = stdout lines = fp.getvalue().splitlines() expected = ['warning: unhandled incoming priority event', 'warning: unhandled read event', 'warning: unhandled write event', 'warning: unhandled connect event', 'warning: unhandled accept event'] self.assertEqual(lines, expected) def test_issue_8594(self): # XXX - this test is supposed to be removed in next major Python # version d = asyncore.dispatcher(socket.socket()) # make sure the error message no longer refers to the socket # object but the dispatcher instance instead self.assertRaisesRegexp(AttributeError, 'dispatcher instance', getattr, d, 'foo') # cheap inheritance with the underlying socket is supposed # to still work but a DeprecationWarning is expected with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") family = d.family self.assertEqual(family, socket.AF_INET) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) if hasattr(os, 'strerror'): self.assertEqual(err, os.strerror(errno.EPERM)) err = asyncore._strerror(-1) self.assertTrue(err != "") class dispatcherwithsend_noread(asyncore.dispatcher_with_send): def readable(self): return False def handle_connect(self): pass class DispatcherWithSendTests(unittest.TestCase): usepoll = False def setUp(self): pass def tearDown(self): asyncore.close_all() @unittest.skipUnless(threading, 'Threading required for this test.') @test_support.reap_threads def test_send(self): evt = threading.Event() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(3) port = test_support.bind_port(sock) cap = StringIO() args = (evt, cap, sock) t = threading.Thread(target=capture_server, args=args) t.start() try: # wait a little longer for the server to initialize (it sometimes # refuses connections on slow machines without this wait) time.sleep(0.2) data = "Suppose there isn't a 16-ton weight?" d = dispatcherwithsend_noread() d.create_socket(socket.AF_INET, socket.SOCK_STREAM) d.connect((HOST, port)) # give time for socket to connect time.sleep(0.1) d.send(data) d.send(data) d.send('\n') n = 1000 while d.out_buffer and n > 0: asyncore.poll() n -= 1 evt.wait() self.assertEqual(cap.getvalue(), data*2) finally: t.join() class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): usepoll = True @unittest.skipUnless(hasattr(asyncore, 'file_wrapper'), 'asyncore.file_wrapper required') class FileWrapperTest(unittest.TestCase): def setUp(self): self.d = "It's not dead, it's sleeping!" with file(TESTFN, 'w') as h: h.write(self.d) def tearDown(self): unlink(TESTFN) def test_recv(self): fd = os.open(TESTFN, os.O_RDONLY) w = asyncore.file_wrapper(fd) os.close(fd) self.assertNotEqual(w.fd, fd) self.assertNotEqual(w.fileno(), fd) self.assertEqual(w.recv(13), "It's not dead") self.assertEqual(w.read(6), ", it's") w.close() self.assertRaises(OSError, w.read, 1) def test_send(self): d1 = "Come again?" d2 = "I want to buy some cheese." fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND) w = asyncore.file_wrapper(fd) os.close(fd) w.write(d1) w.send(d2) w.close() self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'), 'asyncore.file_dispatcher required') def test_dispatcher(self): fd = os.open(TESTFN, os.O_RDONLY) data = [] class FileDispatcher(asyncore.file_dispatcher): def handle_read(self): data.append(self.recv(29)) s = FileDispatcher(fd) os.close(fd) asyncore.loop(timeout=0.01, use_poll=True, count=2) self.assertEqual(b"".join(data), self.d) class BaseTestHandler(asyncore.dispatcher): def __init__(self, sock=None): asyncore.dispatcher.__init__(self, sock) self.flag = False def handle_accept(self): raise Exception("handle_accept not supposed to be called") def handle_connect(self): raise Exception("handle_connect not supposed to be called") def handle_expt(self): raise Exception("handle_expt not supposed to be called") def handle_close(self): raise Exception("handle_close not supposed to be called") def handle_error(self): raise class TCPServer(asyncore.dispatcher): """A server which listens on an address and dispatches the connection to a handler. """ def __init__(self, handler=BaseTestHandler, host=HOST, port=0): asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.set_reuse_addr() self.bind((host, port)) self.listen(5) self.handler = handler @property def address(self): return self.socket.getsockname()[:2] def handle_accept(self): pair = self.accept() if pair is not None: self.handler(pair[0]) def handle_error(self): raise class BaseClient(BaseTestHandler): def __init__(self, address): BaseTestHandler.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.connect(address) def handle_connect(self): pass class BaseTestAPI(unittest.TestCase): def tearDown(self): asyncore.close_all() def loop_waiting_for_flag(self, instance, timeout=5): timeout = float(timeout) / 100 count = 100 while asyncore.socket_map and count > 0: asyncore.loop(timeout=0.01, count=1, use_poll=self.use_poll) if instance.flag: return count -= 1 time.sleep(timeout) self.fail("flag not set") def test_handle_connect(self): # make sure handle_connect is called on connect() class TestClient(BaseClient): def handle_connect(self): self.flag = True server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_accept(self): # make sure handle_accept() is called when a client connects class TestListener(BaseTestHandler): def __init__(self): BaseTestHandler.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.bind((HOST, 0)) self.listen(5) self.address = self.socket.getsockname()[:2] def handle_accept(self): self.flag = True server = TestListener() client = BaseClient(server.address) self.loop_waiting_for_flag(server) def test_handle_read(self): # make sure handle_read is called on data received class TestClient(BaseClient): def handle_read(self): self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.send('x' * 1024) server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_write(self): # make sure handle_write is called class TestClient(BaseClient): def handle_write(self): self.flag = True server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_close(self): # make sure handle_close is called when the other end closes # the connection class TestClient(BaseClient): def handle_read(self): # in order to make handle_close be called we are supposed # to make at least one recv() call self.recv(1024) def handle_close(self): self.flag = True self.close() class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.close() server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) @unittest.skipIf(sys.platform.startswith("sunos"), "OOB support is broken on Solaris") def test_handle_expt(self): # Make sure handle_expt is called on OOB data received. # Note: this might fail on some platforms as OOB data is # tenuously supported and rarely used. class TestClient(BaseClient): def handle_expt(self): self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.socket.send(chr(244), socket.MSG_OOB) server = TCPServer(TestHandler) client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_handle_error(self): class TestClient(BaseClient): def handle_write(self): 1.0 / 0 def handle_error(self): self.flag = True try: raise except ZeroDivisionError: pass else: raise Exception("exception not raised") server = TCPServer() client = TestClient(server.address) self.loop_waiting_for_flag(client) def test_connection_attributes(self): server = TCPServer() client = BaseClient(server.address) # we start disconnected self.assertFalse(server.connected) self.assertTrue(server.accepting) # this can't be taken for granted across all platforms #self.assertFalse(client.connected) self.assertFalse(client.accepting) # execute some loops so that client connects to server asyncore.loop(timeout=0.01, use_poll=self.use_poll, count=100) self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertTrue(client.connected) self.assertFalse(client.accepting) # disconnect the client client.close() self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertFalse(client.connected) self.assertFalse(client.accepting) # stop serving server.close() self.assertFalse(server.connected) self.assertFalse(server.accepting) def test_create_socket(self): s = asyncore.dispatcher() s.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.assertEqual(s.socket.family, socket.AF_INET) self.assertEqual(s.socket.type, socket.SOCK_STREAM) def test_bind(self): s1 = asyncore.dispatcher() s1.create_socket(socket.AF_INET, socket.SOCK_STREAM) s1.bind((HOST, 0)) s1.listen(5) port = s1.socket.getsockname()[1] s2 = asyncore.dispatcher() s2.create_socket(socket.AF_INET, socket.SOCK_STREAM) # EADDRINUSE indicates the socket was correctly bound self.assertRaises(socket.error, s2.bind, (HOST, port)) def test_set_reuse_addr(self): sock = socket.socket() try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) except socket.error: unittest.skip("SO_REUSEADDR not supported on this platform") else: # if SO_REUSEADDR succeeded for sock we expect asyncore # to do the same s = asyncore.dispatcher(socket.socket()) self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) s.create_socket(socket.AF_INET, socket.SOCK_STREAM) s.set_reuse_addr() self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) finally: sock.close() @unittest.skipUnless(threading, 'Threading required for this test.') @test_support.reap_threads def test_quick_connect(self): # see: http://bugs.python.org/issue10340 server = TCPServer() t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() self.addCleanup(t.join) for x in xrange(20): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(.2) s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0)) try: s.connect(server.address) except socket.error: pass finally: s.close() class TestAPI_UseSelect(BaseTestAPI): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') class TestAPI_UsePoll(BaseTestAPI): use_poll = True def test_main(): tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, DispatcherWithSendTests_UsePoll, TestAPI_UseSelect, TestAPI_UsePoll, FileWrapperTest] run_unittest(*tests) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_ftplib.py0000644000076500000000000006306212666555342021667 0ustar jmaddenwheel00000000000000"""Test script for ftplib module.""" # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS # environment import ftplib import asyncore import asynchat import socket import StringIO import errno import os try: import ssl except ImportError: ssl = None from unittest import TestCase, SkipTest, skipUnless from test import test_support from test.test_support import HOST, HOSTv6 threading = test_support.import_module('threading') # the dummy data returned by server over the data channel when # RETR, LIST and NLST commands are issued RETR_DATA = 'abcde12345\r\n' * 1000 LIST_DATA = 'foo\r\nbar\r\n' NLST_DATA = 'foo\r\nbar\r\n' class DummyDTPHandler(asynchat.async_chat): dtp_conn_closed = False def __init__(self, conn, baseclass): asynchat.async_chat.__init__(self, conn) self.baseclass = baseclass self.baseclass.last_received_data = '' def handle_read(self): self.baseclass.last_received_data += self.recv(1024) def handle_close(self): # XXX: this method can be called many times in a row for a single # connection, including in clear-text (non-TLS) mode. # (behaviour witnessed with test_data_connection) if not self.dtp_conn_closed: self.baseclass.push('226 transfer complete') self.close() self.dtp_conn_closed = True def handle_error(self): raise class DummyFTPHandler(asynchat.async_chat): dtp_handler = DummyDTPHandler def __init__(self, conn): asynchat.async_chat.__init__(self, conn) self.set_terminator("\r\n") self.in_buffer = [] self.dtp = None self.last_received_cmd = None self.last_received_data = '' self.next_response = '' self.rest = None self.next_retr_data = RETR_DATA self.push('220 welcome') def collect_incoming_data(self, data): self.in_buffer.append(data) def found_terminator(self): line = ''.join(self.in_buffer) self.in_buffer = [] if self.next_response: self.push(self.next_response) self.next_response = '' cmd = line.split(' ')[0].lower() self.last_received_cmd = cmd space = line.find(' ') if space != -1: arg = line[space + 1:] else: arg = "" if hasattr(self, 'cmd_' + cmd): method = getattr(self, 'cmd_' + cmd) method(arg) else: self.push('550 command "%s" not understood.' %cmd) def handle_error(self): raise def push(self, data): asynchat.async_chat.push(self, data + '\r\n') def cmd_port(self, arg): addr = map(int, arg.split(',')) ip = '%d.%d.%d.%d' %tuple(addr[:4]) port = (addr[4] * 256) + addr[5] s = socket.create_connection((ip, port), timeout=10) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_pasv(self, arg): sock = socket.socket() sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(10) ip, port = sock.getsockname()[:2] ip = ip.replace('.', ',') p1, p2 = divmod(port, 256) self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_eprt(self, arg): af, ip, port = arg.split(arg[0])[1:-1] port = int(port) s = socket.create_connection((ip, port), timeout=10) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_epsv(self, arg): sock = socket.socket(socket.AF_INET6) sock.bind((self.socket.getsockname()[0], 0)) sock.listen(5) sock.settimeout(10) port = sock.getsockname()[1] self.push('229 entering extended passive mode (|||%d|)' %port) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_echo(self, arg): # sends back the received string (used by the test suite) self.push(arg) def cmd_user(self, arg): self.push('331 username ok') def cmd_pass(self, arg): self.push('230 password ok') def cmd_acct(self, arg): self.push('230 acct ok') def cmd_rnfr(self, arg): self.push('350 rnfr ok') def cmd_rnto(self, arg): self.push('250 rnto ok') def cmd_dele(self, arg): self.push('250 dele ok') def cmd_cwd(self, arg): self.push('250 cwd ok') def cmd_size(self, arg): self.push('250 1000') def cmd_mkd(self, arg): self.push('257 "%s"' %arg) def cmd_rmd(self, arg): self.push('250 rmd ok') def cmd_pwd(self, arg): self.push('257 "pwd ok"') def cmd_type(self, arg): self.push('200 type ok') def cmd_quit(self, arg): self.push('221 quit ok') self.close() def cmd_stor(self, arg): self.push('125 stor ok') def cmd_rest(self, arg): self.rest = arg self.push('350 rest ok') def cmd_retr(self, arg): self.push('125 retr ok') if self.rest is not None: offset = int(self.rest) else: offset = 0 self.dtp.push(self.next_retr_data[offset:]) self.dtp.close_when_done() self.rest = None def cmd_list(self, arg): self.push('125 list ok') self.dtp.push(LIST_DATA) self.dtp.close_when_done() def cmd_nlst(self, arg): self.push('125 nlst ok') self.dtp.push(NLST_DATA) self.dtp.close_when_done() def cmd_setlongretr(self, arg): # For testing. Next RETR will return long line. self.next_retr_data = 'x' * int(arg) self.push('125 setlongretr ok') class DummyFTPServer(asyncore.dispatcher, threading.Thread): handler = DummyFTPHandler def __init__(self, address, af=socket.AF_INET): threading.Thread.__init__(self) asyncore.dispatcher.__init__(self) self.create_socket(af, socket.SOCK_STREAM) self.bind(address) self.listen(5) self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] def start(self): assert not self.active self.__flag = threading.Event() threading.Thread.start(self) self.__flag.wait() def run(self): self.active = True self.__flag.set() while self.active and asyncore.socket_map: self.active_lock.acquire() asyncore.loop(timeout=0.1, count=1) self.active_lock.release() asyncore.close_all(ignore_all=True) def stop(self): assert self.active self.active = False self.join() def handle_accept(self): conn, addr = self.accept() self.handler = self.handler(conn) self.close() def handle_connect(self): self.close() handle_read = handle_connect def writable(self): return 0 def handle_error(self): raise if ssl is not None: CERTFILE = os.path.join(os.path.dirname(__file__), "keycert.pem") class SSLConnection(object, asyncore.dispatcher): """An asyncore.dispatcher subclass supporting TLS/SSL.""" _ssl_accepting = False _ssl_closing = False def secure_connection(self): self.socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False, certfile=CERTFILE, server_side=True, do_handshake_on_connect=False, ssl_version=ssl.PROTOCOL_SSLv23) self._ssl_accepting = True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except socket.error, err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def _do_ssl_shutdown(self): self._ssl_closing = True try: self.socket = self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return except socket.error, err: # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return # from OpenSSL's SSL_shutdown(), corresponding to a # closed socket condition. See also: # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html pass self._ssl_closing = False super(SSLConnection, self).close() def handle_read_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_read_event() def handle_write_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_write_event() def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return 0 raise def recv(self, buffer_size): try: return super(SSLConnection, self).recv(buffer_size) except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return '' if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): self.handle_close() return '' raise def handle_error(self): raise def close(self): if (isinstance(self.socket, ssl.SSLSocket) and self.socket._sslobj is not None): self._do_ssl_shutdown() class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler): """A DummyDTPHandler subclass supporting TLS/SSL.""" def __init__(self, conn, baseclass): DummyDTPHandler.__init__(self, conn, baseclass) if self.baseclass.secure_data_channel: self.secure_connection() class DummyTLS_FTPHandler(SSLConnection, DummyFTPHandler): """A DummyFTPHandler subclass supporting TLS/SSL.""" dtp_handler = DummyTLS_DTPHandler def __init__(self, conn): DummyFTPHandler.__init__(self, conn) self.secure_data_channel = False def cmd_auth(self, line): """Set up secure control channel.""" self.push('234 AUTH TLS successful') self.secure_connection() def cmd_pbsz(self, line): """Negotiate size of buffer for secure data transfer. For TLS/SSL the only valid value for the parameter is '0'. Any other value is accepted but ignored. """ self.push('200 PBSZ=0 successful.') def cmd_prot(self, line): """Setup un/secure data channel.""" arg = line.upper() if arg == 'C': self.push('200 Protection set to Clear') self.secure_data_channel = False elif arg == 'P': self.push('200 Protection set to Private') self.secure_data_channel = True else: self.push("502 Unrecognized PROT type (use C or P).") class DummyTLS_FTPServer(DummyFTPServer): handler = DummyTLS_FTPHandler class TestFTPClass(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP(timeout=10) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_getwelcome(self): self.assertEqual(self.client.getwelcome(), '220 welcome') def test_sanitize(self): self.assertEqual(self.client.sanitize('foo'), repr('foo')) self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****')) self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****')) def test_exceptions(self): self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599') self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999') def test_all_errors(self): exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm, ftplib.error_proto, ftplib.Error, IOError, EOFError) for x in exceptions: try: raise x('exception not included in all_errors set') except ftplib.all_errors: pass def test_set_pasv(self): # passive mode is supposed to be enabled by default self.assertTrue(self.client.passiveserver) self.client.set_pasv(True) self.assertTrue(self.client.passiveserver) self.client.set_pasv(False) self.assertFalse(self.client.passiveserver) def test_voidcmd(self): self.client.voidcmd('echo 200') self.client.voidcmd('echo 299') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300') def test_login(self): self.client.login() def test_acct(self): self.client.acct('passwd') def test_rename(self): self.client.rename('a', 'b') self.server.handler.next_response = '200' self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b') def test_delete(self): self.client.delete('foo') self.server.handler.next_response = '199' self.assertRaises(ftplib.error_reply, self.client.delete, 'foo') def test_size(self): self.client.size('foo') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_rmd(self): self.client.rmd('foo') def test_cwd(self): dir = self.client.cwd('/foo') self.assertEqual(dir, '250 cwd ok') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_pwd(self): dir = self.client.pwd() self.assertEqual(dir, 'pwd ok') def test_quit(self): self.assertEqual(self.client.quit(), '221 quit ok') # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) def test_retrbinary(self): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) def test_retrbinary_rest(self): for rest in (0, 10, 20): received = [] self.client.retrbinary('retr', received.append, rest=rest) self.assertEqual(''.join(received), RETR_DATA[rest:], msg='rest test case %d %d %d' % (rest, len(''.join(received)), len(RETR_DATA[rest:]))) def test_retrlines(self): received = [] self.client.retrlines('retr', received.append) self.assertEqual(''.join(received), RETR_DATA.replace('\r\n', '')) def test_storbinary(self): f = StringIO.StringIO(RETR_DATA) self.client.storbinary('stor', f) self.assertEqual(self.server.handler.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storbinary('stor', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_storbinary_rest(self): f = StringIO.StringIO(RETR_DATA) for r in (30, '30'): f.seek(0) self.client.storbinary('stor', f, rest=r) self.assertEqual(self.server.handler.rest, str(r)) def test_storlines(self): f = StringIO.StringIO(RETR_DATA.replace('\r\n', '\n')) self.client.storlines('stor', f) self.assertEqual(self.server.handler.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1]) def test_dir(self): l = [] self.client.dir(lambda x: l.append(x)) self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', '')) def test_makeport(self): self.client.makeport() # IPv4 is in use, just make sure send_eprt has not been used self.assertEqual(self.server.handler.last_received_cmd, 'port') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 10) conn.close() # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler.last_received_cmd, 'pasv') def test_line_too_long(self): self.assertRaises(ftplib.Error, self.client.sendcmd, 'x' * self.client.maxline * 2) def test_retrlines_too_long(self): self.client.sendcmd('SETLONGRETR %d' % (self.client.maxline * 2)) received = [] self.assertRaises(ftplib.Error, self.client.retrlines, 'retr', received.append) def test_storlines_too_long(self): f = StringIO.StringIO('x' * self.client.maxline * 2) self.assertRaises(ftplib.Error, self.client.storlines, 'stor', f) @skipUnless(socket.has_ipv6, "IPv6 not enabled") class TestIPv6Environment(TestCase): @classmethod def setUpClass(cls): try: DummyFTPServer((HOST, 0), af=socket.AF_INET6) except socket.error: raise SkipTest("IPv6 not enabled") def setUp(self): self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6) self.server.start() self.client = ftplib.FTP() self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_af(self): self.assertEqual(self.client.af, socket.AF_INET6) def test_makeport(self): self.client.makeport() self.assertEqual(self.server.handler.last_received_cmd, 'eprt') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), 10) conn.close() self.assertEqual(self.server.handler.last_received_cmd, 'epsv') def test_transfer(self): def retr(): received = [] self.client.retrbinary('retr', received.append) self.assertEqual(''.join(received), RETR_DATA) self.client.set_pasv(True) retr() self.client.set_pasv(False) retr() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClassMixin(TestFTPClass): """Repeat TestFTPClass tests starting the TLS layer for both control and data connections first. """ def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=10) self.client.connect(self.server.host, self.server.port) # enable TLS self.client.auth() self.client.prot_p() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClass(TestCase): """Specific TLS_FTP class tests.""" def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=10) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() def test_control_connection(self): self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIsInstance(self.client.sock, ssl.SSLSocket) def test_data_connection(self): # clear text sock = self.client.transfercmd('list') self.assertNotIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") # secured, after PROT P self.client.prot_p() sock = self.client.transfercmd('list') self.assertIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") # PROT C is issued, the connection must be in cleartext again self.client.prot_c() sock = self.client.transfercmd('list') self.assertNotIsInstance(sock, ssl.SSLSocket) sock.close() self.assertEqual(self.client.voidresp(), "226 transfer complete") def test_login(self): # login() is supposed to implicitly secure the control connection self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.login() self.assertIsInstance(self.client.sock, ssl.SSLSocket) # make sure that AUTH TLS doesn't get issued again self.client.login() def test_auth_issued_twice(self): self.client.auth() self.assertRaises(ValueError, self.client.auth) def test_auth_ssl(self): try: self.client.ssl_version = ssl.PROTOCOL_SSLv3 self.client.auth() self.assertRaises(ValueError, self.client.auth) finally: self.client.ssl_version = ssl.PROTOCOL_TLSv1 class TestTimeouts(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) threading.Thread(target=self.server, args=(self.evt,self.sock)).start() # Wait for the server to be ready. self.evt.wait() self.evt.clear() ftplib.FTP.port = self.port def tearDown(self): self.evt.wait() def server(self, evt, serv): # This method sets the evt 3 times: # 1) when the connection is ready to be accepted. # 2) when it is safe for the caller to close the connection # 3) when we have closed the socket serv.listen(5) # (1) Signal the caller that we are ready to accept the connection. evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: conn.send("1 Hola mundo\n") # (2) Signal the caller that it is safe to close the socket. evt.set() conn.close() finally: serv.close() # (3) Signal the caller that we are done. evt.set() def testTimeoutDefault(self): # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutNone(self): # no timeout -- do not use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(ftp.sock.gettimeout()) self.evt.wait() ftp.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDirectAccess(self): ftp = ftplib.FTP() ftp.timeout = 30 ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def test_main(): tests = [TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass] thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_httplib.py0000644000076500000000000005152312666555342022054 0ustar jmaddenwheel00000000000000import httplib import array import httplib import StringIO import socket import errno import unittest TestCase = unittest.TestCase from test import test_support HOST = test_support.HOST class FakeSocket: def __init__(self, text, fileclass=StringIO.StringIO, host=None, port=None): self.text = text self.fileclass = fileclass self.data = '' self.host = host self.port = port def sendall(self, data): self.data += ''.join(data) def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return self.fileclass(self.text) def close(self): pass class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): # When sendall() is called with pipe_trigger, raise EPIPE. FakeSocket.__init__(self, text) self.pipe_trigger = pipe_trigger def sendall(self, data): if self.pipe_trigger in data: raise socket.error(errno.EPIPE, "gotcha") self.data += data def close(self): pass class NoEOFStringIO(StringIO.StringIO): """Like StringIO, but raises AssertionError on EOF. This is used below to test that httplib doesn't try to read more from the underlying file than it should. """ def read(self, n=-1): data = StringIO.StringIO.read(self, n) if data == '': raise AssertionError('caller tried to read past EOF') return data def readline(self, length=None): data = StringIO.StringIO.readline(self, length) if data == '': raise AssertionError('caller tried to read past EOF') return data class HeaderTests(TestCase): def test_auto_headers(self): # Some headers are added automatically, but should not be added by # .request() if they are explicitly set. class HeaderCountingBuffer(list): def __init__(self): self.count = {} def append(self, item): kv = item.split(':') if len(kv) > 1: # item is a 'Key: Value' header string lcKey = kv[0].lower() self.count.setdefault(lcKey, 0) self.count[lcKey] += 1 list.append(self, item) for explicit_header in True, False: for header in 'Content-length', 'Host', 'Accept-encoding': conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket('blahblahblah') conn._buffer = HeaderCountingBuffer() body = 'spamspamspam' headers = {} if explicit_header: headers[header] = str(len(body)) conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) def test_content_length_0(self): class ContentLengthChecker(list): def __init__(self): list.__init__(self) self.content_length = None def append(self, item): kv = item.split(':', 1) if len(kv) > 1 and kv[0].lower() == 'content-length': self.content_length = kv[1].strip() list.append(self, item) # POST with empty body conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request('POST', '/', '') self.assertEqual(conn._buffer.content_length, '0', 'Header Content-Length not set') # PUT request with empty body conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request('PUT', '/', '') self.assertEqual(conn._buffer.content_length, '0', 'Header Content-Length not set') def test_putheader(self): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length',42) self.assertIn('Content-length: 42', conn._buffer) def test_ipv6host_header(self): # Default host header on IPv6 transaction should wrapped by [] if # its actual IPv6 address expected = 'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \ 'Accept-Encoding: identity\r\n\r\n' conn = httplib.HTTPConnection('[2001::]:81') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) expected = 'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \ 'Accept-Encoding: identity\r\n\r\n' conn = httplib.HTTPConnection('[2001:102A::]') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) class BasicTest(TestCase): def test_status_lines(self): # Test HTTP status lines body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(0), '') # Issue #20007 self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(), 'Text') self.assertTrue(resp.isclosed()) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertRaises(httplib.BadStatusLine, resp.begin) def test_bad_status_repr(self): exc = httplib.BadStatusLine('') self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''') def test_partial_reads(self): # if we have a length, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertTrue(resp.isclosed()) def test_partial_reads_no_content_length(self): # when no length is present, the socket should be gracefully closed when # all data was read body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertEqual(resp.read(1), '') self.assertTrue(resp.isclosed()) def test_partial_reads_incomplete_body(self): # if the server shuts down the connection before the whole # content-length is delivered, the socket is gracefully closed body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), 'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), 'xt') self.assertEqual(resp.read(1), '') self.assertTrue(resp.isclosed()) def test_host_port(self): # Check invalid host_port # Note that httplib does not accept user:password@ in the host-port. for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), ("www.python.org", "www.python.org", 80), ("www.python.org:", "www.python.org", 80), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): http = httplib.HTTP(hp) c = http._conn if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) def test_response_headers(self): # test response with multiple message headers with the same field name. text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE";' ' Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = httplib.HTTPResponse(s) r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: self.fail("multiple headers not combined properly") def test_read_head(self): # Test that the library doesn't attempt to read any data # from a HEAD request. (Tickles SF bug #622042.) sock = FakeSocket( 'HTTP/1.1 200 OK\r\n' 'Content-Length: 14432\r\n' '\r\n', NoEOFStringIO) resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() if resp.read() != "": self.fail("Did not expect response from HEAD request") def test_send_file(self): expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 'Accept-Encoding: identity\r\nContent-Length:' body = open(__file__, 'rb') conn = httplib.HTTPConnection('example.com') sock = FakeSocket(body) conn.sock = sock conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected)) def test_send(self): expected = 'this is a test this is only a test' conn = httplib.HTTPConnection('example.com') sock = FakeSocket(None) conn.sock = sock conn.send(expected) self.assertEqual(expected, sock.data) sock.data = '' conn.send(array.array('c', expected)) self.assertEqual(expected, sock.data) sock.data = '' conn.send(StringIO.StringIO(expected)) self.assertEqual(expected, sock.data) def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello worl\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), 'hello world') resp.close() for x in ('', 'foo\r\n'): sock = FakeSocket(chunked_start + x) resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead, i: self.assertEqual(i.partial, 'hello world') self.assertEqual(repr(i),'IncompleteRead(11 bytes read)') self.assertEqual(str(i),'IncompleteRead(11 bytes read)') else: self.fail('IncompleteRead expected') finally: resp.close() def test_chunked_head(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello world\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = httplib.HTTPResponse(sock, method="HEAD") resp.begin() self.assertEqual(resp.read(), '') self.assertEqual(resp.status, 200) self.assertEqual(resp.reason, 'OK') self.assertTrue(resp.isclosed()) def test_negative_content_length(self): sock = FakeSocket('HTTP/1.1 200 OK\r\n' 'Content-Length: -1\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), 'Hello\r\n') self.assertTrue(resp.isclosed()) def test_incomplete_read(self): sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n') resp = httplib.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except httplib.IncompleteRead as i: self.assertEqual(i.partial, 'Hello\r\n') self.assertEqual(repr(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertEqual(str(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertTrue(resp.isclosed()) else: self.fail('IncompleteRead expected') def test_epipe(self): sock = EPipeSocket( "HTTP/1.0 401 Authorization Required\r\n" "Content-type: text/html\r\n" "WWW-Authenticate: Basic realm=\"example\"\r\n", b"Content-Length") conn = httplib.HTTPConnection("example.com") conn.sock = sock self.assertRaises(socket.error, lambda: conn.request("PUT", "/url", "body")) resp = conn.getresponse() self.assertEqual(401, resp.status) self.assertEqual("Basic realm=\"example\"", resp.getheader("www-authenticate")) def test_filenoattr(self): # Just test the fileno attribute in the HTTPResponse Object. body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) self.assertTrue(hasattr(resp,'fileno'), 'HTTPResponse should expose a fileno attribute') # Test lines overflowing the max line size (_MAXLINE in http.client) def test_overflowing_status_line(self): self.skipTest("disabled for HTTP 0.9 support") body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n" resp = httplib.HTTPResponse(FakeSocket(body)) self.assertRaises((httplib.LineTooLong, httplib.BadStatusLine), resp.begin) def test_overflowing_header_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n' ) resp = httplib.HTTPResponse(FakeSocket(body)) self.assertRaises(httplib.LineTooLong, resp.begin) def test_overflowing_chunked_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' + '0' * 65536 + 'a\r\n' 'hello world\r\n' '0\r\n' ) resp = httplib.HTTPResponse(FakeSocket(body)) resp.begin() self.assertRaises(httplib.LineTooLong, resp.read) def test_early_eof(self): # Test httpresponse with no \r\n termination, body = "HTTP/1.1 200 Ok" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(), '') self.assertTrue(resp.isclosed()) class OfflineTest(TestCase): def test_responses(self): self.assertEqual(httplib.responses[httplib.NOT_FOUND], "Not Found") class SourceAddressTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.source_port = test_support.find_unused_port() self.serv.listen(5) self.conn = None def tearDown(self): if self.conn: self.conn.close() self.conn = None self.serv.close() self.serv = None def testHTTPConnectionSourceAddress(self): self.conn = httplib.HTTPConnection(HOST, self.port, source_address=('', self.source_port)) self.conn.connect() self.assertEqual(self.conn.sock.getsockname()[1], self.source_port) @unittest.skipIf(not hasattr(httplib, 'HTTPSConnection'), 'httplib.HTTPSConnection not defined') def testHTTPSConnectionSourceAddress(self): self.conn = httplib.HTTPSConnection(HOST, self.port, source_address=('', self.source_port)) # We don't test anything here other the constructor not barfing as # this code doesn't deal with setting up an active running SSL server # for an ssl_wrapped connect() to actually return from. class TimeoutTest(TestCase): PORT = None def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) TimeoutTest.PORT = test_support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): self.serv.close() self.serv = None def testTimeoutAttribute(self): '''This will prove that the timeout gets through HTTPConnection and into the socket. ''' # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() # no timeout -- do not use global socket default self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=None) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), None) httpConn.close() # a value httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30) httpConn.connect() self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() class HTTPSTimeoutTest(TestCase): # XXX Here should be tests for HTTPS, there isn't any right now! def test_attributes(self): # simple test to check it's storing it if hasattr(httplib, 'HTTPSConnection'): h = httplib.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30) self.assertEqual(h.timeout, 30) @unittest.skipIf(not hasattr(httplib, 'HTTPS'), 'httplib.HTTPS not available') def test_host_port(self): # Check invalid host_port # Note that httplib does not accept user:password@ in the host-port. for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("pypi.python.org:443", "pypi.python.org", 443), ("pypi.python.org", "pypi.python.org", 443), ("pypi.python.org:", "pypi.python.org", 443), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)): http = httplib.HTTPS(hp) c = http._conn if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) class TunnelTests(TestCase): def test_connect(self): response_text = ( 'HTTP/1.0 200 OK\r\n\r\n' # Reply to CONNECT 'HTTP/1.1 200 OK\r\n' # Reply to HEAD 'Content-Length: 42\r\n\r\n' ) def create_connection(address, timeout=None, source_address=None): return FakeSocket(response_text, host=address[0], port=address[1]) conn = httplib.HTTPConnection('proxy.com') conn._create_connection = create_connection # Once connected, we should not be able to tunnel anymore conn.connect() self.assertRaises(RuntimeError, conn.set_tunnel, 'destination.com') # But if close the connection, we are good. conn.close() conn.set_tunnel('destination.com') conn.request('HEAD', '/', '') self.assertEqual(conn.sock.host, 'proxy.com') self.assertEqual(conn.sock.port, 80) self.assertTrue('CONNECT destination.com' in conn.sock.data) self.assertTrue('Host: destination.com' in conn.sock.data) self.assertTrue('Host: proxy.com' not in conn.sock.data) conn.close() conn.request('PUT', '/', '') self.assertEqual(conn.sock.host, 'proxy.com') self.assertEqual(conn.sock.port, 80) self.assertTrue('CONNECT destination.com' in conn.sock.data) self.assertTrue('Host: destination.com' in conn.sock.data) def test_main(verbose=None): test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTimeoutTest, SourceAddressTest, TunnelTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_httpservers.py0000644000076500000000000004665712666555342023013 0ustar jmaddenwheel00000000000000"""Unittests for the various HTTPServer modules. Written by Cody A.W. Somerville , Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest. """ import os import sys import re import base64 import shutil import urllib import httplib import tempfile import unittest import CGIHTTPServer from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler from CGIHTTPServer import CGIHTTPRequestHandler from StringIO import StringIO from test import test_support threading = test_support.import_module('threading') class NoLogRequestHandler: def log_message(self, *args): # don't write log messages to stderr pass class SocketlessRequestHandler(SimpleHTTPRequestHandler): def __init__(self): self.get_called = False self.protocol_version = "HTTP/1.1" def do_GET(self): self.get_called = True self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(b'Data\r\n') def log_message(self, fmt, *args): pass class TestServerThread(threading.Thread): def __init__(self, test_object, request_handler): threading.Thread.__init__(self) self.request_handler = request_handler self.test_object = test_object def run(self): self.server = HTTPServer(('', 0), self.request_handler) self.test_object.PORT = self.server.socket.getsockname()[1] self.test_object.server_started.set() self.test_object = None try: self.server.serve_forever(0.05) finally: self.server.server_close() def stop(self): self.server.shutdown() class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() os.environ = test_support.EnvironmentVarGuard() self.server_started = threading.Event() self.thread = TestServerThread(self, self.request_handler) self.thread.start() self.server_started.wait() def tearDown(self): self.thread.stop() os.environ.__exit__() test_support.threading_cleanup(*self._threads) def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) self.connection.request(method, uri, body, headers) return self.connection.getresponse() class BaseHTTPRequestHandlerTestCase(unittest.TestCase): """Test the functionality of the BaseHTTPServer focussing on BaseHTTPRequestHandler. """ HTTPResponseMatch = re.compile('HTTP/1.[0-9]+ 200 OK') def setUp (self): self.handler = SocketlessRequestHandler() def send_typical_request(self, message): input_msg = StringIO(message) output = StringIO() self.handler.rfile = input_msg self.handler.wfile = output self.handler.handle_one_request() output.seek(0) return output.readlines() def verify_get_called(self): self.assertTrue(self.handler.get_called) def verify_expected_headers(self, headers): for fieldName in 'Server: ', 'Date: ', 'Content-Type: ': self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1) def verify_http_server_response(self, response): match = self.HTTPResponseMatch.search(response) self.assertIsNotNone(match) def test_http_1_1(self): result = self.send_typical_request('GET / HTTP/1.1\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_http_1_0(self): result = self.send_typical_request('GET / HTTP/1.0\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_http_0_9(self): result = self.send_typical_request('GET / HTTP/0.9\r\n\r\n') self.assertEqual(len(result), 1) self.assertEqual(result[0], 'Data\r\n') self.verify_get_called() def test_with_continue_1_0(self): result = self.send_typical_request('GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n') self.verify_http_server_response(result[0]) self.verify_expected_headers(result[1:-1]) self.verify_get_called() self.assertEqual(result[-1], 'Data\r\n') def test_request_length(self): # Issue #10714: huge request lines are discarded, to avoid Denial # of Service attacks. result = self.send_typical_request(b'GET ' + b'x' * 65537) self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n') self.assertFalse(self.handler.get_called) class BaseHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' default_request_version = 'HTTP/1.1' def do_TEST(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def do_KEEP(self): self.send_response(204) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'keep-alive') self.end_headers() def do_KEYERROR(self): self.send_error(999) def do_CUSTOM(self): self.send_response(999) self.send_header('Content-Type', 'text/html') self.send_header('Connection', 'close') self.end_headers() def setUp(self): BaseTestCase.setUp(self) self.con = httplib.HTTPConnection('localhost', self.PORT) self.con.connect() def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() self.assertEqual(res.status, 501) def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_version_bogus(self): self.con._http_vsn_str = 'FUBAR' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_digits(self): self.con._http_vsn_str = 'HTTP/9.9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_version_none(self): # Test that a valid method is rejected when not HTTP/1.x self.con._http_vsn_str = '' self.con.putrequest('CUSTOM', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_version_invalid(self): self.con._http_vsn = 99 self.con._http_vsn_str = 'HTTP/9.9' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 505) def test_send_blank(self): self.con._http_vsn_str = '' self.con.putrequest('', '') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) def test_header_close(self): self.con.putrequest('GET', '/') self.con.putheader('Connection', 'close') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' self.con.putrequest('GET', '/') self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) def test_handler(self): self.con.request('TEST', '/') res = self.con.getresponse() self.assertEqual(res.status, 204) def test_return_header_keep_alive(self): self.con.request('KEEP', '/') res = self.con.getresponse() self.assertEqual(res.getheader('Connection'), 'keep-alive') self.con.request('TEST', '/') self.addCleanup(self.con.close) def test_internal_key_error(self): self.con.request('KEYERROR', '/') res = self.con.getresponse() self.assertEqual(res.status, 999) def test_return_custom_status(self): self.con.request('CUSTOM', '/') res = self.con.getresponse() self.assertEqual(res.status, 999) class SimpleHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.cwd = os.getcwd() basetempdir = tempfile.gettempdir() os.chdir(basetempdir) self.data = 'We are the knights who say Ni!' self.tempdir = tempfile.mkdtemp(dir=basetempdir) self.tempdir_name = os.path.basename(self.tempdir) temp = open(os.path.join(self.tempdir, 'test'), 'wb') temp.write(self.data) temp.close() def tearDown(self): try: os.chdir(self.cwd) try: shutil.rmtree(self.tempdir) except OSError: pass finally: BaseTestCase.tearDown(self) def check_status_and_reason(self, response, status, data=None): body = response.read() self.assertTrue(response) self.assertEqual(response.status, status) self.assertIsNotNone(response.reason) if data: self.assertEqual(data, body) def test_get(self): #constructs the path relative to the root directory of the HTTPServer response = self.request(self.tempdir_name + '/test') self.check_status_and_reason(response, 200, data=self.data) # check for trailing "/" which should return 404. See Issue17324 response = self.request(self.tempdir_name + '/test/') self.check_status_and_reason(response, 404) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name) self.check_status_and_reason(response, 301) response = self.request('/ThisDoesNotExist') self.check_status_and_reason(response, 404) response = self.request('/' + 'ThisDoesNotExist' + '/') self.check_status_and_reason(response, 404) with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as fp: response = self.request('/' + self.tempdir_name + '/') self.check_status_and_reason(response, 200) # chmod() doesn't work as expected on Windows, and filesystem # permissions are ignored by root on Unix. if os.name == 'posix' and os.geteuid() != 0: os.chmod(self.tempdir, 0) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 404) os.chmod(self.tempdir, 0755) def test_head(self): response = self.request( self.tempdir_name + '/test', method='HEAD') self.check_status_and_reason(response, 200) self.assertEqual(response.getheader('content-length'), str(len(self.data))) self.assertEqual(response.getheader('content-type'), 'application/octet-stream') def test_invalid_requests(self): response = self.request('/', method='FOO') self.check_status_and_reason(response, 501) # requests must be case sensitive,so this should fail too response = self.request('/', method='get') self.check_status_and_reason(response, 501) response = self.request('/', method='GETs') self.check_status_and_reason(response, 501) cgi_file1 = """\ #!%s print "Content-type: text/html" print print "Hello World" """ cgi_file2 = """\ #!%s import cgi print "Content-type: text/html" print form = cgi.FieldStorage() print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"), form.getfirst("bacon")) """ @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, "This test can't be run reliably as root (issue #13308).") class CGIHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler): pass def setUp(self): BaseTestCase.setUp(self) self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') os.mkdir(self.cgi_dir) # The shebang line should be pure ASCII: use symlink if possible. # See issue #7668. if hasattr(os, 'symlink'): self.pythonexe = os.path.join(self.parent_dir, 'python') os.symlink(sys.executable, self.pythonexe) else: self.pythonexe = sys.executable self.nocgi_path = os.path.join(self.parent_dir, 'nocgi.py') with open(self.nocgi_path, 'w') as fp: fp.write(cgi_file1 % self.pythonexe) os.chmod(self.nocgi_path, 0777) self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: file1.write(cgi_file1 % self.pythonexe) os.chmod(self.file1_path, 0777) self.file2_path = os.path.join(self.cgi_dir, 'file2.py') with open(self.file2_path, 'w') as file2: file2.write(cgi_file2 % self.pythonexe) os.chmod(self.file2_path, 0777) self.cwd = os.getcwd() os.chdir(self.parent_dir) def tearDown(self): try: os.chdir(self.cwd) if self.pythonexe != sys.executable: os.remove(self.pythonexe) os.remove(self.nocgi_path) os.remove(self.file1_path) os.remove(self.file2_path) os.rmdir(self.cgi_dir) os.rmdir(self.parent_dir) finally: BaseTestCase.tearDown(self) def test_url_collapse_path(self): # verify tail is the last portion and head is the rest on proper urls test_vectors = { '': '//', '..': IndexError, '/.//..': IndexError, '/': '//', '//': '//', '/\\': '//\\', '/.//': '//', 'cgi-bin/file1.py': '/cgi-bin/file1.py', '/cgi-bin/file1.py': '/cgi-bin/file1.py', 'a': '//a', '/a': '//a', '//a': '//a', './a': '//a', './C:/': '/C:/', '/a/b': '/a/b', '/a/b/': '/a/b/', '/a/b/.': '/a/b/', '/a/b/c/..': '/a/b/', '/a/b/c/../d': '/a/b/d', '/a/b/c/../d/e/../f': '/a/b/d/f', '/a/b/c/../d/e/../../f': '/a/b/f', '/a/b/c/../d/e/.././././..//f': '/a/b/f', '../a/b/c/../d/e/.././././..//f': IndexError, '/a/b/c/../d/e/../../../f': '/a/f', '/a/b/c/../d/e/../../../../f': '//f', '/a/b/c/../d/e/../../../../../f': IndexError, '/a/b/c/../d/e/../../../../f/..': '//', '/a/b/c/../d/e/../../../../f/../.': '//', } for path, expected in test_vectors.iteritems(): if isinstance(expected, type) and issubclass(expected, Exception): self.assertRaises(expected, CGIHTTPServer._url_collapse_path, path) else: actual = CGIHTTPServer._url_collapse_path(path) self.assertEqual(expected, actual, msg='path = %r\nGot: %r\nWanted: %r' % (path, actual, expected)) def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_issue19435(self): res = self.request('///////////nocgi.py/../cgi-bin/nothere.sh') self.assertEqual(res.status, 404) def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} res = self.request('/cgi-bin/file2.py', 'POST', params, headers) self.assertEqual(res.read(), '1, python, 123456\n') def test_invaliduri(self): res = self.request('/cgi-bin/invalid') res.read() self.assertEqual(res.status, 404) def test_authorization(self): headers = {'Authorization' : 'Basic %s' % base64.b64encode('username:pass')} res = self.request('/cgi-bin/file1.py', 'GET', headers=headers) self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) def test_os_environ_is_not_altered(self): signature = "Test CGI Server" os.environ['SERVER_SOFTWARE'] = signature res = self.request('/cgi-bin/file1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) self.assertEqual(os.environ['SERVER_SOFTWARE'], signature) def test_urlquote_decoding_in_cgi_check(self): res = self.request('/cgi-bin%2ffile1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): """ Test url parsing """ def setUp(self): self.translated = os.getcwd() self.translated = os.path.join(self.translated, 'filename') self.handler = SocketlessRequestHandler() def test_query_arguments(self): path = self.handler.translate_path('/filename') self.assertEqual(path, self.translated) path = self.handler.translate_path('/filename?foo=bar') self.assertEqual(path, self.translated) path = self.handler.translate_path('/filename?a=b&spam=eggs#zot') self.assertEqual(path, self.translated) def test_start_with_double_slash(self): path = self.handler.translate_path('//filename') self.assertEqual(path, self.translated) path = self.handler.translate_path('//filename?foo=bar') self.assertEqual(path, self.translated) def test_main(verbose=None): try: cwd = os.getcwd() test_support.run_unittest(BaseHTTPRequestHandlerTestCase, SimpleHTTPRequestHandlerTestCase, BaseHTTPServerTestCase, SimpleHTTPServerTestCase, CGIHTTPServerTestCase ) finally: os.chdir(cwd) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_queue.py0000644000076500000000000002730712666555342021535 0ustar jmaddenwheel00000000000000# Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. import Queue import time import unittest from test import test_support threading = test_support.import_module('threading') QUEUE_SIZE = 5 # A thread to run a function that unclogs a blocked Queue. class _TriggerThread(threading.Thread): def __init__(self, fn, args): self.fn = fn self.args = args self.startedEvent = threading.Event() threading.Thread.__init__(self) def run(self): # The sleep isn't necessary, but is intended to give the blocking # function in the main thread a chance at actually blocking before # we unclog it. But if the sleep is longer than the timeout-based # tests wait in their blocking functions, those tests will fail. # So we give them much longer timeout values compared to the # sleep here (I aimed at 10 seconds for blocking functions -- # they should never actually wait that long - they should make # progress as soon as we call self.fn()). time.sleep(0.1) self.startedEvent.set() self.fn(*self.args) # Execute a function that blocks, and in a separate thread, a function that # triggers the release. Returns the result of the blocking function. Caution: # block_func must guarantee to block until trigger_func is called, and # trigger_func must guarantee to change queue state so that block_func can make # enough progress to return. In particular, a block_func that just raises an # exception regardless of whether trigger_func is called will lead to # timing-dependent sporadic failures, and one of those went rarely seen but # undiagnosed for years. Now block_func must be unexceptional. If block_func # is supposed to raise an exception, call do_exceptional_blocking_test() # instead. class BlockingTestMixin: def tearDown(self): self.t = None def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() self.result = block_func(*block_args) # If block_func returned before our thread made the call, we failed! if not self.t.startedEvent.is_set(): self.fail("blocking function '%r' appeared not to block" % block_func) self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) return self.result # Call this instead if block_func is supposed to raise an exception. def do_exceptional_blocking_test(self,block_func, block_args, trigger_func, trigger_args, expected_exception_class): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() try: try: block_func(*block_args) except expected_exception_class: raise else: self.fail("expected exception of kind %r" % expected_exception_class) finally: self.t.join(10) # make sure the thread terminates if self.t.is_alive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) if not self.t.startedEvent.is_set(): self.fail("trigger thread ended but event never set") class BaseQueueTest(BlockingTestMixin): def setUp(self): self.cum = 0 self.cumlock = threading.Lock() def simple_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" # I guess we better check things actually queue correctly a little :) q.put(111) q.put(333) q.put(222) target_order = dict(Queue = [111, 333, 222], LifoQueue = [222, 333, 111], PriorityQueue = [111, 222, 333]) actual_order = [q.get(), q.get(), q.get()] self.assertEqual(actual_order, target_order[q.__class__.__name__], "Didn't seem to queue the correct data!") for i in range(QUEUE_SIZE-1): q.put(i) self.assertTrue(not q.empty(), "Queue should not be empty") self.assertTrue(not q.full(), "Queue should not be full") last = 2 * QUEUE_SIZE full = 3 * 2 * QUEUE_SIZE q.put(last) self.assertTrue(q.full(), "Queue should be full") try: q.put(full, block=0) self.fail("Didn't appear to block with a full queue") except Queue.Full: pass try: q.put(full, timeout=0.01) self.fail("Didn't appear to time-out with a full queue") except Queue.Full: pass # Test a blocking put self.do_blocking_test(q.put, (full,), q.get, ()) self.do_blocking_test(q.put, (full, True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assertTrue(q.empty(), "Queue should be empty") try: q.get(block=0) self.fail("Didn't appear to block with an empty queue") except Queue.Empty: pass try: q.get(timeout=0.01) self.fail("Didn't appear to time-out with an empty queue") except Queue.Empty: pass # Test a blocking get self.do_blocking_test(q.get, (), q.put, ('empty',)) self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) def worker(self, q): while True: x = q.get() if x is None: q.task_done() return with self.cumlock: self.cum += x q.task_done() def queue_join_test(self, q): self.cum = 0 for i in (0,1): threading.Thread(target=self.worker, args=(q,)).start() for i in xrange(100): q.put(i) q.join() self.assertEqual(self.cum, sum(range(100)), "q.join() did not block until all tasks were done") for i in (0,1): q.put(None) # instruct the threads to close q.join() # verify that you can join twice def test_queue_task_done(self): # Test to make sure a queue task completed successfully. q = self.type2test() try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_queue_join(self): # Test that a queue join()s successfully, and before anything else # (done twice for insurance). q = self.type2test() self.queue_join_test(q) self.queue_join_test(q) try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_simple_queue(self): # Do it a couple of times on the same queue. # Done twice to make sure works with same instance reused. q = self.type2test(QUEUE_SIZE) self.simple_queue_test(q) self.simple_queue_test(q) class QueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.Queue class LifoQueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.LifoQueue class PriorityQueueTest(BaseQueueTest, unittest.TestCase): type2test = Queue.PriorityQueue # A Queue subclass that can provoke failure at a moment's notice :) class FailingQueueException(Exception): pass class FailingQueue(Queue.Queue): def __init__(self, *args): self.fail_next_put = False self.fail_next_get = False Queue.Queue.__init__(self, *args) def _put(self, item): if self.fail_next_put: self.fail_next_put = False raise FailingQueueException, "You Lose" return Queue.Queue._put(self, item) def _get(self): if self.fail_next_get: self.fail_next_get = False raise FailingQueueException, "You Lose" return Queue.Queue._get(self) class FailingQueueTest(BlockingTestMixin, unittest.TestCase): def failing_queue_test(self, q): if not q.empty(): raise RuntimeError, "Call this function with an empty queue" for i in range(QUEUE_SIZE-1): q.put(i) # Test a failing non-blocking put. q.fail_next_put = True try: q.put("oops", block=0) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.fail_next_put = True try: q.put("oops", timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.put("last") self.assertTrue(q.full(), "Queue should be full") # Test a failing blocking put q.fail_next_put = True try: self.do_blocking_test(q.put, ("full",), q.get, ()) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") # Test a failing timeout put q.fail_next_put = True try: self.do_exceptional_blocking_test(q.put, ("full", True, 10), q.get, (), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put("last") self.assertTrue(q.full(), "Queue should be full") q.get() self.assertTrue(not q.full(), "Queue should not be full") q.put("last") self.assertTrue(q.full(), "Queue should be full") # Test a blocking put self.do_blocking_test(q.put, ("full",), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assertTrue(q.empty(), "Queue should be empty") q.put("first") q.fail_next_get = True try: q.get() self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assertTrue(not q.empty(), "Queue should not be empty") q.fail_next_get = True try: q.get(timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assertTrue(not q.empty(), "Queue should not be empty") q.get() self.assertTrue(q.empty(), "Queue should be empty") q.fail_next_get = True try: self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # put succeeded, but get failed. self.assertTrue(not q.empty(), "Queue should not be empty") q.get() self.assertTrue(q.empty(), "Queue should be empty") def test_failing_queue(self): # Test to make sure a queue is functioning correctly. # Done twice to the same instance. q = FailingQueue(QUEUE_SIZE) self.failing_queue_test(q) self.failing_queue_test(q) def test_main(): test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_select.py0000644000076500000000000000417612666555342021667 0ustar jmaddenwheel00000000000000from test import test_support import unittest import select import os import sys @unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'), "can't easily test on this system") class SelectTestCase(unittest.TestCase): class Nope: pass class Almost: def fileno(self): return 'fileno' def test_error_conditions(self): self.assertRaises(TypeError, select.select, 1, 2, 3) self.assertRaises(TypeError, select.select, [self.Nope()], [], []) self.assertRaises(TypeError, select.select, [self.Almost()], [], []) self.assertRaises(TypeError, select.select, [], [], [], "not a number") def test_returned_list_identity(self): # See issue #8329 r, w, x = select.select([], [], [], 1) self.assertIsNot(r, w) self.assertIsNot(r, x) self.assertIsNot(w, x) def test_select(self): cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 0.1; done' p = os.popen(cmd, 'r') for tout in (0, 0.1, 0.2, 0.4, 0.8, 1.6) + (None,)*10: if test_support.verbose: print 'timeout =', tout rfd, wfd, xfd = select.select([p], [], [], tout) if (rfd, wfd, xfd) == ([], [], []): continue if (rfd, wfd, xfd) == ([p], [], []): line = p.readline() if test_support.verbose: print repr(line) if not line: if test_support.verbose: print 'EOF' break continue self.fail('Unexpected return values from select():', rfd, wfd, xfd) p.close() # Issue 16230: Crash on select resized list def test_select_mutated(self): a = [] class F: def fileno(self): del a[-1] return sys.__stdout__.fileno() a[:] = [F()] * 10 self.assertEqual(select.select([], a, []), ([], a[:5], [])) def test_main(): test_support.run_unittest(SelectTestCase) test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_signal.py0000644000076500000000000004473112666555342021666 0ustar jmaddenwheel00000000000000import unittest from test import test_support from contextlib import closing import gc import pickle import select import signal import subprocess import traceback import sys, os, time, errno if sys.platform in ('os2', 'riscos'): raise unittest.SkipTest("Can't test signal on %s" % sys.platform) class HandlerBCalled(Exception): pass def exit_subprocess(): """Use os._exit(0) to exit the current subprocess. Otherwise, the test catches the SystemExit and continues executing in parallel with the original test, so you wind up with an exponential number of tests running concurrently. """ os._exit(0) def ignoring_eintr(__func, *args, **kwargs): try: return __func(*args, **kwargs) except EnvironmentError as e: if e.errno != errno.EINTR: raise return None @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. def setUp(self): self.using_gc = gc.isenabled() gc.disable() def tearDown(self): if self.using_gc: gc.enable() def format_frame(self, frame, limit=None): return ''.join(traceback.format_stack(frame, limit=limit)) def handlerA(self, signum, frame): self.a_called = True if test_support.verbose: print "handlerA invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) def handlerB(self, signum, frame): self.b_called = True if test_support.verbose: print "handlerB invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1)) raise HandlerBCalled(signum, self.format_frame(frame)) def wait(self, child): """Wait for child to finish, ignoring EINTR.""" while True: try: child.wait() return except OSError as e: if e.errno != errno.EINTR: raise def run_test(self): # Install handlers. This function runs in a sub-process, so we # don't worry about re-setting the default handlers. signal.signal(signal.SIGHUP, self.handlerA) signal.signal(signal.SIGUSR1, self.handlerB) signal.signal(signal.SIGUSR2, signal.SIG_IGN) signal.signal(signal.SIGALRM, signal.default_int_handler) # Variables the signals will modify: self.a_called = False self.b_called = False # Let the sub-processes know who to send signals to. pid = os.getpid() if test_support.verbose: print "test runner's pid is", pid child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)]) if child: self.wait(child) if not self.a_called: time.sleep(1) # Give the signal time to be delivered. self.assertTrue(self.a_called) self.assertFalse(self.b_called) self.a_called = False # Make sure the signal isn't delivered while the previous # Popen object is being destroyed, because __del__ swallows # exceptions. del child try: child = subprocess.Popen(['kill', '-USR1', str(pid)]) # This wait should be interrupted by the signal's exception. self.wait(child) time.sleep(1) # Give the signal time to be delivered. self.fail('HandlerBCalled exception not raised') except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) if test_support.verbose: print "HandlerBCalled exception caught" child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)]) if child: self.wait(child) # Nothing should happen. try: signal.alarm(1) # The race condition in pause doesn't matter in this case, # since alarm is going to raise a KeyboardException, which # will skip the call. signal.pause() # But if another signal arrives before the alarm, pause # may return early. time.sleep(1) except KeyboardInterrupt: if test_support.verbose: print "KeyboardInterrupt (the alarm() went off)" except: self.fail("Some other exception woke us from pause: %s" % traceback.format_exc()) else: self.fail("pause returned of its own accord, and the signal" " didn't arrive after another second.") # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform=='freebsd6', 'inter process signals not reliable (do not mix well with threading) ' 'on freebsd6') def test_main(self): # This function spawns a child process to insulate the main # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child # raises. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with closing(os.fdopen(os_done_r)) as done_r, \ closing(os.fdopen(os_done_w, 'w')) as done_w: child = os.fork() if child == 0: # In the child process; run the test and report results # through the pipe. try: done_r.close() # Have to close done_w again here because # exit_subprocess() will skip the enclosing with block. with closing(done_w): try: self.run_test() except: pickle.dump(traceback.format_exc(), done_w) else: pickle.dump(None, done_w) except: print 'Uh oh, raised from pickle.' traceback.print_exc() finally: exit_subprocess() done_w.close() # Block for up to MAX_DURATION seconds for the test to finish. r, w, x = select.select([done_r], [], [], self.MAX_DURATION) if done_r in r: tb = pickle.load(done_r) if tb: self.fail(tb) else: os.kill(child, signal.SIGKILL) self.fail('Test deadlocked after %d seconds.' % self.MAX_DURATION) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class BasicSignalTests(unittest.TestCase): def trivial_signal_handler(self, *args): pass def test_out_of_range_signal_number_raises_error(self): self.assertRaises(ValueError, signal.getsignal, 4242) self.assertRaises(ValueError, signal.signal, 4242, self.trivial_signal_handler) def test_setting_signal_handler_to_none_raises_error(self): self.assertRaises(TypeError, signal.signal, signal.SIGUSR1, None) def test_getsignal(self): hup = signal.signal(signal.SIGHUP, self.trivial_signal_handler) self.assertEqual(signal.getsignal(signal.SIGHUP), self.trivial_signal_handler) signal.signal(signal.SIGHUP, hup) self.assertEqual(signal.getsignal(signal.SIGHUP), hup) @unittest.skipUnless(sys.platform == "win32", "Windows specific") class WindowsSignalTests(unittest.TestCase): def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows signal.signal(sig, signal.signal(sig, handler)) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler) class WakeupFDTests(unittest.TestCase): def test_invalid_fd(self): fd = test_support.make_bad_fd() self.assertRaises(ValueError, signal.set_wakeup_fd, fd) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): TIMEOUT_FULL = 10 TIMEOUT_HALF = 5 def test_wakeup_fd_early(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the sleep, # before select is called time.sleep(self.TIMEOUT_FULL) mid_time = time.time() self.assertTrue(mid_time - before_time < self.TIMEOUT_HALF) select.select([self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF) def test_wakeup_fd_during(self): import select signal.alarm(1) before_time = time.time() # We attempt to get a signal during the select call self.assertRaises(select.error, select.select, [self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - before_time < self.TIMEOUT_HALF) def setUp(self): import fcntl self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None) self.read, self.write = os.pipe() flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(self.write, fcntl.F_SETFL, flags) self.old_wakeup = signal.set_wakeup_fd(self.write) def tearDown(self): signal.set_wakeup_fd(self.old_wakeup) os.close(self.read) os.close(self.write) signal.signal(signal.SIGALRM, self.alrm) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class SiginterruptTest(unittest.TestCase): def setUp(self): """Install a no-op signal handler that can be set to allow interrupts or not, and arrange for the original signal handler to be re-installed when the test is finished. """ self.signum = signal.SIGUSR1 oldhandler = signal.signal(self.signum, lambda x,y: None) self.addCleanup(signal.signal, self.signum, oldhandler) def readpipe_interrupted(self): """Perform a read during which a signal will arrive. Return True if the read is interrupted by the signal and raises an exception. Return False if it returns normally. """ # Create a pipe that can be used for the read. Also clean it up # when the test is over, since nothing else will (but see below for # the write end). r, w = os.pipe() self.addCleanup(os.close, r) # Create another process which can send a signal to this one to try # to interrupt the read. ppid = os.getpid() pid = os.fork() if pid == 0: # Child code: sleep to give the parent enough time to enter the # read() call (there's a race here, but it's really tricky to # eliminate it); then signal the parent process. Also, sleep # again to make it likely that the signal is delivered to the # parent process before the child exits. If the child exits # first, the write end of the pipe will be closed and the test # is invalid. try: time.sleep(0.2) os.kill(ppid, self.signum) time.sleep(0.2) finally: # No matter what, just exit as fast as possible now. exit_subprocess() else: # Parent code. # Make sure the child is eventually reaped, else it'll be a # zombie for the rest of the test suite run. self.addCleanup(os.waitpid, pid, 0) # Close the write end of the pipe. The child has a copy, so # it's not really closed until the child exits. We need it to # close when the child exits so that in the non-interrupt case # the read eventually completes, otherwise we could just close # it *after* the test. os.close(w) # Try the read and report whether it is interrupted or not to # the caller. try: d = os.read(r, 1) return False except OSError, err: if err.errno != errno.EINTR: raise return True def test_without_siginterrupt(self): """If a signal handler is installed and siginterrupt is not called at all, when that signal arrives, it interrupts a syscall that's in progress. """ i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_on(self): """If a signal handler is installed and siginterrupt is called with a true value for the second argument, when that signal arrives, it interrupts a syscall that's in progress. """ signal.siginterrupt(self.signum, 1) i = self.readpipe_interrupted() self.assertTrue(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertTrue(i) def test_siginterrupt_off(self): """If a signal handler is installed and siginterrupt is called with a false value for the second argument, when that signal arrives, it does not interrupt a syscall that's in progress. """ signal.siginterrupt(self.signum, 0) i = self.readpipe_interrupted() self.assertFalse(i) # Arrival of the signal shouldn't have changed anything. i = self.readpipe_interrupted() self.assertFalse(i) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class ItimerTest(unittest.TestCase): def setUp(self): self.hndl_called = False self.hndl_count = 0 self.itimer = None self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) def sig_alrm(self, *args): self.hndl_called = True if test_support.verbose: print("SIGALRM handler invoked", args) def sig_vtalrm(self, *args): self.hndl_called = True if self.hndl_count > 3: # it shouldn't be here, because it should have been disabled. raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL " "timer.") elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) if test_support.verbose: print("last SIGVTALRM handler call") self.hndl_count += 1 if test_support.verbose: print("SIGVTALRM handler invoked", args) def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args) def test_itimer_exc(self): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) # Negative times are treated as zero on some platforms. if 0: self.assertRaises(signal.ItimerError, signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1.0) if test_support.verbose: print("\ncall pause()...") signal.pause() self.assertEqual(self.hndl_called, True) # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'), 'itimer not reliable (does not mix well with threading) on some BSDs.') def test_itimer_virtual(self): self.itimer = signal.ITIMER_VIRTUAL signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # virtual itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) # Issue 3864. Unknown if this affects earlier versions of freebsd also. @unittest.skipIf(sys.platform=='freebsd6', 'itimer not reliable (does not mix well with threading) on freebsd6') def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) def test_main(): test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupFDTests, WakeupSignalTests, SiginterruptTest, ItimerTest, WindowsSignalTests) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_smtplib.py0000644000076500000000000004362412666555342022063 0ustar jmaddenwheel00000000000000import asyncore import email.utils import socket import smtpd import smtplib import StringIO import sys import time import select import unittest from test import test_support try: import threading except ImportError: threading = None HOST = test_support.HOST def server(evt, buf, serv): serv.listen(5) evt.set() try: conn, addr = serv.accept() except socket.timeout: pass else: n = 500 while buf and n > 0: r, w, e = select.select([], [conn], []) if w: sent = conn.send(buf) buf = buf[sent:] n -= 1 conn.close() finally: serv.close() evt.set() @unittest.skipUnless(threading, 'Threading required for this test.') class GeneralTests(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "220 Hola mundo\n", self.sock) self.thread = threading.Thread(target=server, args=servargs) self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) def testBasic1(self): # connects smtp = smtplib.SMTP(HOST, self.port) smtp.close() def testBasic2(self): # connects, include port in host name smtp = smtplib.SMTP("%s:%s" % (HOST, self.port)) smtp.close() def testLocalHostName(self): # check that supplied local_hostname is used smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost") self.assertEqual(smtp.local_hostname, "testhost") smtp.close() def testTimeoutDefault(self): self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() def testTimeoutNone(self): self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(smtp.sock.gettimeout()) smtp.close() def testTimeoutValue(self): smtp = smtplib.SMTP(HOST, self.port, timeout=30) self.assertEqual(smtp.sock.gettimeout(), 30) smtp.close() # Test server thread using the specified SMTP server class def debugging_server(serv, serv_evt, client_evt): serv_evt.set() try: if hasattr(select, 'poll'): poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll n = 1000 while asyncore.socket_map and n > 0: poll_fun(0.01, asyncore.socket_map) # when the client conversation is finished, it will # set client_evt, and it's then ok to kill the server if client_evt.is_set(): serv.close() break n -= 1 except socket.timeout: pass finally: if not client_evt.is_set(): # allow some time for the client to read the result time.sleep(0.5) serv.close() asyncore.close_all() serv_evt.set() MSG_BEGIN = '---------- MESSAGE FOLLOWS ----------\n' MSG_END = '------------ END MESSAGE ------------\n' # NOTE: Some SMTP objects in the tests below are created with a non-default # local_hostname argument to the constructor, since (on some systems) the FQDN # lookup caused by the default local_hostname sometimes takes so long that the # test server times out, causing the test to fail. # Test behavior of smtpd.DebuggingServer @unittest.skipUnless(threading, 'Threading required for this test.') class DebuggingServerTests(unittest.TestCase): def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout def testBasic(self): # connect smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.quit() def testNOOP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.noop(), expected) smtp.quit() def testRSET(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, 'Ok') self.assertEqual(smtp.rset(), expected) smtp.quit() def testNotImplemented(self): # EHLO isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "EHLO" not implemented') self.assertEqual(smtp.ehlo(), expected) smtp.quit() def testVRFY(self): # VRFY isn't implemented in DebuggingServer smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (502, 'Error: command "VRFY" not implemented') self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected) self.assertEqual(smtp.verify('nobody@nowhere.com'), expected) smtp.quit() def testSecondHELO(self): # check that a second HELO returns a message that it's a duplicate # (this behavior is specific to smtpd.SMTPChannel) smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.helo() expected = (503, 'Duplicate HELO/EHLO') self.assertEqual(smtp.helo(), expected) smtp.quit() def testHELP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) self.assertEqual(smtp.help(), 'Error: command "HELP" not implemented') smtp.quit() def testSend(self): # connect and send mail m = 'A test message' smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.sendmail('John', 'Sally', m) # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor # in asyncore. This sleep might help, but should really be fixed # properly by using an Event variable. time.sleep(0.01) smtp.quit() self.client_evt.set() self.serv_evt.wait() self.output.flush() mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END) self.assertEqual(self.output.getvalue(), mexpect) class NonConnectingTests(unittest.TestCase): def testNotConnected(self): # Test various operations on an unconnected SMTP object that # should raise exceptions (at present the attempt in SMTP.send # to reference the nonexistent 'sock' attribute of the SMTP object # causes an AttributeError) smtp = smtplib.SMTP() self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo) self.assertRaises(smtplib.SMTPServerDisconnected, smtp.send, 'test msg') def testNonnumericPort(self): # check that non-numeric port raises socket.error self.assertRaises(socket.error, smtplib.SMTP, "localhost", "bogus") self.assertRaises(socket.error, smtplib.SMTP, "localhost:bogus") # test response of client to a non-successful HELO message @unittest.skipUnless(threading, 'Threading required for this test.') class BadHELOServerTests(unittest.TestCase): def setUp(self): self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "199 no hello for you!\n", self.sock) self.thread = threading.Thread(target=server, args=servargs) self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) sys.stdout = self.old_stdout def testFailingHELO(self): self.assertRaises(smtplib.SMTPConnectError, smtplib.SMTP, HOST, self.port, 'localhost', 3) sim_users = {'Mr.A@somewhere.com':'John A', 'Ms.B@somewhere.com':'Sally B', 'Mrs.C@somewhereesle.com':'Ruth C', } sim_auth = ('Mr.A@somewhere.com', 'somepassword') sim_cram_md5_challenge = ('PENCeUxFREJoU0NnbmhNWitOMjNGNn' 'dAZWx3b29kLmlubm9zb2Z0LmNvbT4=') sim_auth_credentials = { 'login': 'TXIuQUBzb21ld2hlcmUuY29t', 'plain': 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ=', 'cram-md5': ('TXIUQUBZB21LD2HLCMUUY29TIDG4OWQ0MJ' 'KWZGQ4ODNMNDA4NTGXMDRLZWMYZJDMODG1'), } sim_auth_login_password = 'C29TZXBHC3N3B3JK' sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'], 'list-2':['Ms.B@somewhere.com',], } # Simulated SMTP channel & server class SimSMTPChannel(smtpd.SMTPChannel): def __init__(self, extra_features, *args, **kw): self._extrafeatures = ''.join( [ "250-{0}\r\n".format(x) for x in extra_features ]) smtpd.SMTPChannel.__init__(self, *args, **kw) def smtp_EHLO(self, arg): resp = ('250-testhost\r\n' '250-EXPN\r\n' '250-SIZE 20000000\r\n' '250-STARTTLS\r\n' '250-DELIVERBY\r\n') resp = resp + self._extrafeatures + '250 HELP' self.push(resp) def smtp_VRFY(self, arg): # For max compatibility smtplib should be sending the raw address. if arg in sim_users: self.push('250 %s %s' % (sim_users[arg], smtplib.quoteaddr(arg))) else: self.push('550 No such user: %s' % arg) def smtp_EXPN(self, arg): list_name = arg.lower() if list_name in sim_lists: user_list = sim_lists[list_name] for n, user_email in enumerate(user_list): quoted_addr = smtplib.quoteaddr(user_email) if n < len(user_list) - 1: self.push('250-%s %s' % (sim_users[user_email], quoted_addr)) else: self.push('250 %s %s' % (sim_users[user_email], quoted_addr)) else: self.push('550 No access for you!') def smtp_AUTH(self, arg): if arg.strip().lower()=='cram-md5': self.push('334 {0}'.format(sim_cram_md5_challenge)) return mech, auth = arg.split() mech = mech.lower() if mech not in sim_auth_credentials: self.push('504 auth type unimplemented') return if mech == 'plain' and auth==sim_auth_credentials['plain']: self.push('235 plain auth ok') elif mech=='login' and auth==sim_auth_credentials['login']: self.push('334 Password:') else: self.push('550 No access for you!') def handle_error(self): raise class SimSMTPServer(smtpd.SMTPServer): def __init__(self, *args, **kw): self._extra_features = [] smtpd.SMTPServer.__init__(self, *args, **kw) def handle_accept(self): conn, addr = self.accept() self._SMTPchannel = SimSMTPChannel(self._extra_features, self, conn, addr) def process_message(self, peer, mailfrom, rcpttos, data): pass def add_feature(self, feature): self._extra_features.append(feature) def handle_error(self): raise # Test various SMTP & ESMTP commands/behaviors that require a simulated server # (i.e., something with more features than DebuggingServer) @unittest.skipUnless(threading, 'Threading required for this test.') class SMTPSimTests(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear() def tearDown(self): # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() test_support.threading_cleanup(*self._threads) def testBasic(self): # smoke test smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) smtp.quit() def testEHLO(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) # no features should be present before the EHLO self.assertEqual(smtp.esmtp_features, {}) # features expected from the test server expected_features = {'expn':'', 'size': '20000000', 'starttls': '', 'deliverby': '', 'help': '', } smtp.ehlo() self.assertEqual(smtp.esmtp_features, expected_features) for k in expected_features: self.assertTrue(smtp.has_extn(k)) self.assertFalse(smtp.has_extn('unsupported-feature')) smtp.quit() def testVRFY(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for email, name in sim_users.items(): expected_known = (250, '%s %s' % (name, smtplib.quoteaddr(email))) self.assertEqual(smtp.vrfy(email), expected_known) u = 'nobody@nowhere.com' expected_unknown = (550, 'No such user: %s' % u) self.assertEqual(smtp.vrfy(u), expected_unknown) smtp.quit() def testEXPN(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) for listname, members in sim_lists.items(): users = [] for m in members: users.append('%s %s' % (sim_users[m], smtplib.quoteaddr(m))) expected_known = (250, '\n'.join(users)) self.assertEqual(smtp.expn(listname), expected_known) u = 'PSU-Members-List' expected_unknown = (550, 'No access for you!') self.assertEqual(smtp.expn(u), expected_unknown) smtp.quit() def testAUTH_PLAIN(self): self.serv.add_feature("AUTH PLAIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) expected_auth_ok = (235, b'plain auth ok') self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok) # SimSMTPChannel doesn't fully support LOGIN or CRAM-MD5 auth because they # require a synchronous read to obtain the credentials...so instead smtpd # sees the credential sent by smtplib's login method as an unknown command, # which results in smtplib raising an auth error. Fortunately the error # message contains the encoded credential, so we can partially check that it # was generated correctly (partially, because the 'word' is uppercased in # the error message). def testAUTH_LOGIN(self): self.serv.add_feature("AUTH LOGIN") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_login_password not in str(err): raise "expected encoded password not found in error message" def testAUTH_CRAM_MD5(self): self.serv.add_feature("AUTH CRAM-MD5") smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: if sim_auth_credentials['cram-md5'] not in str(err): raise "expected encoded credentials not found in error message" #TODO: add tests for correct AUTH method fallback now that the #test infrastructure can support it. def test_main(verbose=None): test_support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests, BadHELOServerTests, SMTPSimTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_socket.py0000644000076500000000000017265412666555342021707 0ustar jmaddenwheel00000000000000import unittest from test import test_support import errno import socket import select import time import traceback import Queue import sys import os import array import contextlib from weakref import proxy import signal import math def try_address(host, port=0, family=socket.AF_INET): """Try to bind a socket on the given host:port and return True if that has been possible.""" try: sock = socket.socket(family, socket.SOCK_STREAM) sock.bind((host, port)) except (socket.error, socket.gaierror): return False else: sock.close() return True HOST = test_support.HOST MSG = b'Michael Gilfix was here\n' SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6) try: import thread import threading except ImportError: thread = None threading = None HOST = test_support.HOST MSG = 'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = test_support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceeded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) self.__setUp() if not self.server_ready.is_set(): self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() if not self.queue.empty(): msg = self.queue.get() self.fail(msg) def clientRun(self, test_func): self.server_ready.wait() self.clientSetUp() self.client_ready.set() if not callable(test_func): raise TypeError("test_func must be a callable function.") try: test_func() except Exception, strerror: self.queue.put(strerror) self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class SocketConnectedTest(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None test_support.gc_collect() try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def testSocketError(self): # Testing socket module exceptions def raise_error(*args, **kwargs): raise socket.error def raise_herror(*args, **kwargs): raise socket.herror def raise_gaierror(*args, **kwargs): raise socket.gaierror self.assertRaises(socket.error, raise_error, "Error raising socket exception.") self.assertRaises(socket.error, raise_herror, "Error raising socket exception.") self.assertRaises(socket.error, raise_gaierror, "Error raising socket exception.") def testSendtoErrors(self): # Testing that sendto doens't masks failures. See #10169. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) s.bind(('', 0)) sockname = s.getsockname() # 2 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, sockname) self.assertIn('complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None) self.assertIn('NoneType', str(cm.exception)) # 3 args with self.assertRaises(UnicodeEncodeError): s.sendto(u'\u2620', 0, sockname) with self.assertRaises(TypeError) as cm: s.sendto(5j, 0, sockname) self.assertIn('complex', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, None) if test_support.check_impl_detail(): self.assertIn('not NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 'bar', sockname) self.assertIn('integer', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', None, None) if test_support.check_impl_detail(): self.assertIn('an integer is required', str(cm.exception)) # wrong number of args with self.assertRaises(TypeError) as cm: s.sendto('foo') self.assertIn(' given)', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto('foo', 0, sockname, 4) self.assertIn(' given)', str(cm.exception)) def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except socket.error: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except socket.error: # Probably a similar problem as above; skip this test self.skipTest('address lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: self.assertEqual(sys.getrefcount(__name__), orig, "socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except socket.error: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1L<= _testcapi.ULONG_MAX: self.skipTest('needs UINT_MAX < ULONG_MAX') self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) self.serv.setblocking(_testcapi.UINT_MAX + 1) self.assertIsNone(self.serv.gettimeout()) _testSetBlocking_overflow = test_support.cpython_only(_testSetBlocking) def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) try: conn, addr = self.serv.accept() except socket.error: pass else: self.fail("Error trying to do non-blocking accept.") read, write, err = select.select([self.serv], [], []) if self.serv in read: conn, addr = self.serv.accept() conn.close() else: self.fail("Error trying to do accept after select.") def _testAccept(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) def testConnect(self): # Testing non-blocking connect conn, addr = self.serv.accept() conn.close() def _testConnect(self): self.cli.settimeout(10) self.cli.connect((HOST, self.port)) def testRecv(self): # Testing non-blocking recv conn, addr = self.serv.accept() conn.setblocking(0) try: msg = conn.recv(len(MSG)) except socket.error: pass else: self.fail("Error trying to do non-blocking recv.") read, write, err = select.select([conn], [], []) if conn in read: msg = conn.recv(len(MSG)) conn.close() self.assertEqual(msg, MSG) else: self.fail("Error during select call to non-blocking socket.") def _testRecv(self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class FileObjectClassTestCase(SocketConnectedTest): bufsize = -1 # Use default buffer size def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def setUp(self): SocketConnectedTest.setUp(self) self.serv_file = self.cli_conn.makefile('rb', self.bufsize) def tearDown(self): self.serv_file.close() self.assertTrue(self.serv_file.closed) SocketConnectedTest.tearDown(self) self.serv_file = None def clientSetUp(self): SocketConnectedTest.clientSetUp(self) self.cli_file = self.serv_conn.makefile('wb') def clientTearDown(self): self.cli_file.close() self.assertTrue(self.cli_file.closed) self.cli_file = None SocketConnectedTest.clientTearDown(self) def testSmallRead(self): # Performing small file read test first_seg = self.serv_file.read(len(MSG)-3) second_seg = self.serv_file.read(3) msg = first_seg + second_seg self.assertEqual(msg, MSG) def _testSmallRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testFullRead(self): # read until EOF msg = self.serv_file.read() self.assertEqual(msg, MSG) def _testFullRead(self): self.cli_file.write(MSG) self.cli_file.close() def testUnbufferedRead(self): # Performing unbuffered file read test buf = '' while 1: char = self.serv_file.read(1) if not char: break buf += char self.assertEqual(buf, MSG) def _testUnbufferedRead(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadline(self): # Performing file readline test line = self.serv_file.readline() self.assertEqual(line, MSG) def _testReadline(self): self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterRead(self): a_baloo_is = self.serv_file.read(len("A baloo is")) self.assertEqual("A baloo is", a_baloo_is) _a_bear = self.serv_file.read(len(" a bear")) self.assertEqual(" a bear", _a_bear) line = self.serv_file.readline() self.assertEqual("\n", line) line = self.serv_file.readline() self.assertEqual("A BALOO IS A BEAR.\n", line) line = self.serv_file.readline() self.assertEqual(MSG, line) def _testReadlineAfterRead(self): self.cli_file.write("A baloo is a bear\n") self.cli_file.write("A BALOO IS A BEAR.\n") self.cli_file.write(MSG) self.cli_file.flush() def testReadlineAfterReadNoNewline(self): end_of_ = self.serv_file.read(len("End Of ")) self.assertEqual("End Of ", end_of_) line = self.serv_file.readline() self.assertEqual("Line", line) def _testReadlineAfterReadNoNewline(self): self.cli_file.write("End Of Line") def testClosedAttr(self): self.assertTrue(not self.serv_file.closed) def _testClosedAttr(self): self.assertTrue(not self.cli_file.closed) class FileObjectInterruptedTestCase(unittest.TestCase): """Test that the file object correctly handles EINTR internally.""" class MockSocket(object): def __init__(self, recv_funcs=()): # A generator that returns callables that we'll call for each # call to recv(). self._recv_step = iter(recv_funcs) def recv(self, size): return self._recv_step.next()() def _reuse(self): pass def _drop(self): pass @staticmethod def _raise_eintr(): raise socket.error(errno.EINTR) def _test_readline(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.readline(size), "This is the first line\n") self.assertEqual(fo.readline(size), "And the second line is here\n") def _test_read(self, size=-1, **kwargs): mock_sock = self.MockSocket(recv_funcs=[ lambda : "This is the first line\nAnd the sec", self._raise_eintr, lambda : "ond line is here\n", lambda : "", ]) fo = socket._fileobject(mock_sock, **kwargs) self.assertEqual(fo.read(size), "This is the first line\n" "And the second line is here\n") def test_default(self): self._test_readline() self._test_readline(size=100) self._test_read() self._test_read(size=100) def test_with_1k_buffer(self): self._test_readline(bufsize=1024) self._test_readline(size=100, bufsize=1024) self._test_read(bufsize=1024) self._test_read(size=100, bufsize=1024) def _test_readline_no_buffer(self, size=-1): mock_sock = self.MockSocket(recv_funcs=[ lambda : "aa", lambda : "\n", lambda : "BB", self._raise_eintr, lambda : "bb", lambda : "", ]) fo = socket._fileobject(mock_sock, bufsize=0) self.assertEqual(fo.readline(size), "aa\n") self.assertEqual(fo.readline(size), "BBbb") def test_no_buffer(self): self._test_readline_no_buffer() self._test_readline_no_buffer(size=4) self._test_read(bufsize=0) self._test_read(size=100, bufsize=0) class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): """Repeat the tests from FileObjectClassTestCase with bufsize==0. In this case (and in this case only), it should be possible to create a file object, read a line from it, create another file object, read another line from it, without loss of data in the first file object's buffer. Note that httplib relies on this when reading multiple requests from the same socket.""" bufsize = 0 # Use unbuffered mode def testUnbufferedReadline(self): # Read a line, create a new file object, read another line with it line = self.serv_file.readline() # first line self.assertEqual(line, "A. " + MSG) # first line self.serv_file = self.cli_conn.makefile('rb', 0) line = self.serv_file.readline() # second line self.assertEqual(line, "B. " + MSG) # second line def _testUnbufferedReadline(self): self.cli_file.write("A. " + MSG) self.cli_file.write("B. " + MSG) self.cli_file.flush() class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 1 # Default-buffered for reading; line-buffered for writing class SocketMemo(object): """A wrapper to keep track of sent data, needed to examine write behaviour""" def __init__(self, sock): self._sock = sock self.sent = [] def send(self, data, flags=0): n = self._sock.send(data, flags) self.sent.append(data[:n]) return n def sendall(self, data, flags=0): self._sock.sendall(data, flags) self.sent.append(data) def __getattr__(self, attr): return getattr(self._sock, attr) def getsent(self): return [e.tobytes() if isinstance(e, memoryview) else e for e in self.sent] def setUp(self): FileObjectClassTestCase.setUp(self) self.serv_file._sock = self.SocketMemo(self.serv_file._sock) def testLinebufferedWrite(self): # Write two lines, in small chunks msg = MSG.strip() print >> self.serv_file, msg, print >> self.serv_file, msg # second line: print >> self.serv_file, msg, print >> self.serv_file, msg, print >> self.serv_file, msg # third line print >> self.serv_file, '' self.serv_file.flush() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3]) def _testLinebufferedWrite(self): msg = MSG.strip() msg1 = "%s %s\n"%(msg, msg) msg2 = "%s %s %s\n"%(msg, msg, msg) msg3 = "\n" l1 = self.cli_file.readline() self.assertEqual(l1, msg1) l2 = self.cli_file.readline() self.assertEqual(l2, msg2) l3 = self.cli_file.readline() self.assertEqual(l3, msg3) class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code class NetworkConnectionTest(object): """Prove network connection.""" def clientSetUp(self): # We're inherited below by BasicTCPTest2, which also inherits # BasicTCPTest, which defines self.port referenced below. self.cli = socket.create_connection((HOST, self.port)) self.serv_conn = self.cli class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): """Tests that NetworkConnection does not break existing TCP functionality. """ class NetworkConnectionNoServer(unittest.TestCase): class MockSocket(socket.socket): def connect(self, *args): raise socket.timeout('timed out') @contextlib.contextmanager def mocked_socket_module(self): """Return a socket which times out on connect""" old_socket = socket.socket import gevent.socket old_g_socket = gevent.socket.socket socket.socket = self.MockSocket gevent.socket.socket = self.MockSocket try: yield finally: socket.socket = old_socket gevent.socket.socket = old_g_socket def test_connect(self): port = test_support.find_unused_port() cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(cli.close) with self.assertRaises(socket.error) as cm: cli.connect((HOST, port)) self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection(self): # Issue #9792: errors raised by create_connection() should have # a proper errno attribute. port = test_support.find_unused_port() with self.assertRaises(socket.error) as cm: socket.create_connection((HOST, port)) # Issue #16257: create_connection() calls getaddrinfo() against # 'localhost'. This may result in an IPV6 addr being returned # as well as an IPV4 one: # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), # (26, 2, 0, '', ('::1', 41230, 0, 0))] # # create_connection() enumerates through all the addresses returned # and if it doesn't successfully bind to any of them, it propagates # the last exception it encountered. # # On Solaris, ENETUNREACH is returned in this circumstance instead # of ECONNREFUSED. So, if that errno exists, add it to our list of # expected errnos. expected_errnos = [ errno.ECONNREFUSED, ] if hasattr(errno, 'ENETUNREACH'): expected_errnos.append(errno.ENETUNREACH) self.assertIn(cm.exception.errno, expected_errnos) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors # as generic socket errors. with self.mocked_socket_module(): with self.assertRaises(socket.timeout): socket.create_connection((HOST, 1234)) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.source_port = test_support.find_unused_port() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def _justAccept(self): conn, addr = self.serv.accept() conn.close() testFamily = _justAccept def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.family, 2) testSourceAddress = _justAccept def _testSourceAddress(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.addCleanup(self.cli.close) self.assertEqual(self.cli.getsockname()[1], self.source_port) # The port number being used is sufficient to show that the bind() # call happened. testTimeoutDefault = _justAccept def _testTimeoutDefault(self): # passing no explicit timeout uses socket's global default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(42) try: self.cli = socket.create_connection((HOST, self.port)) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), 42) testTimeoutNone = _justAccept def _testTimeoutNone(self): # None timeout means the same as sock.settimeout(None) self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: self.cli = socket.create_connection((HOST, self.port), timeout=None) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), None) testTimeoutValueNamed = _justAccept def _testTimeoutValueNamed(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.gettimeout(), 30) testTimeoutValueNonamed = _justAccept def _testTimeoutValueNonamed(self): self.cli = socket.create_connection((HOST, self.port), 30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.gettimeout(), 30) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send("done!") testOutsideTimeout = testInsideTimeout def _testInsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port)) data = sock.recv(5) self.assertEqual(data, "done!") def _testOutsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port), timeout=1) self.assertRaises(socket.timeout, lambda: sock.recv(5)) class Urllib2FileobjectTest(unittest.TestCase): # urllib2.HTTPHandler has "borrowed" socket._fileobject, and requires that # it close the socket if the close c'tor argument is true def testClose(self): class MockSocket: closed = False def flush(self): pass def close(self): self.closed = True def _reuse(self): pass def _drop(self): pass # must not close unless we request it: the original use of _fileobject # by module socket requires that the underlying socket not be closed until # the _socketobject that created the _fileobject is closed s = MockSocket() f = socket._fileobject(s) f.close() self.assertTrue(not s.closed) s = MockSocket() f = socket._fileobject(s, close=True) f.close() self.assertTrue(s.closed) class TCPTimeoutTest(SocketTCPTest): def testTCPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (TCP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of error (TCP)") except socket.error: ok = True except: self.fail("caught unexpected exception (TCP)") if not ok: self.fail("accept() returned success when we did not expect it") @unittest.skipUnless(hasattr(signal, 'alarm'), 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass def alarm_handler(signal, frame): raise Alarm old_alarm = signal.signal(signal.SIGALRM, alarm_handler) try: signal.alarm(2) # POSIX allows alarm to be up to 1 second early try: foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of Alarm") except Alarm: pass except: self.fail("caught other exception instead of Alarm:" " %s(%s):\n%s" % (sys.exc_info()[:2] + (traceback.format_exc(),))) else: self.fail("nothing caught") finally: signal.alarm(0) # shut off alarm except Alarm: self.fail("got Alarm in wrong place") finally: # no alarm can be pending. Safe to restore old handler. signal.signal(signal.SIGALRM, old_alarm) class UDPTimeoutTest(SocketUDPTest): def testUDPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.recv(1024) self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (UDP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.recv(1024) except socket.timeout: self.fail("caught timeout instead of error (UDP)") except socket.error: ok = True except: self.fail("caught unexpected exception (UDP)") if not ok: self.fail("recv() returned success when we did not expect it") class TestExceptions(unittest.TestCase): def testExceptionTree(self): self.assertTrue(issubclass(socket.error, Exception)) self.assertTrue(issubclass(socket.herror, socket.error)) self.assertTrue(issubclass(socket.gaierror, socket.error)) self.assertTrue(issubclass(socket.timeout, socket.error)) @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 def testLinuxAbstractNamespace(self): address = "\x00python-test-hello\x00\xff" s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s1.bind(address) s1.listen(1) s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s2.connect(s1.getsockname()) s1.accept() self.assertEqual(s1.getsockname(), address) self.assertEqual(s2.getpeername(), address) def testMaxName(self): address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.bind(address) self.assertEqual(s.getsockname(), address) def testNameOverflow(self): address = "\x00" + "h" * self.UNIX_PATH_MAX s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.assertRaises(socket.error, s.bind, address) @unittest.skipUnless(thread, 'Threading required for this test.') class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). """ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecvIntoArray(self): buf = array.array('c', ' '*1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvIntoBytearray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoBytearray = _testRecvIntoArray def testRecvIntoMemoryview(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoMemoryview = _testRecvIntoArray def testRecvFromIntoArray(self): buf = array.array('c', ' '*1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFromIntoArray(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoBytearray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoBytearray = _testRecvFromIntoArray def testRecvFromIntoMemoryview(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoMemoryview = _testRecvFromIntoArray def testRecvFromIntoSmallBuffer(self): # See issue #20246. buf = bytearray(8) self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) def _testRecvFromIntoSmallBuffer(self): with test_support.check_py3k_warnings(): buf = buffer(MSG) self.serv_conn.send(buf) def testRecvFromIntoEmptyBuffer(self): buf = bytearray() self.cli_conn.recvfrom_into(buf) self.cli_conn.recvfrom_into(buf, 0) _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray TIPC_STYPE = 2000 TIPC_LOWER = 200 TIPC_UPPER = 210 def isTipcAvailable(): """Check if the TIPC module is loaded The TIPC module is not loaded automatically on Ubuntu and probably other Linux distros. """ if not hasattr(socket, "AF_TIPC"): return False if not os.path.isfile("/proc/modules"): return False with open("/proc/modules") as f: for line in f: if line.startswith("tipc "): return True return False @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCTest(unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) srv.bind(srvaddr) sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) cli.sendto(MSG, sendaddr) msg, recvaddr = srv.recvfrom(1024) self.assertEqual(cli.getsockname(), recvaddr) self.assertEqual(msg, MSG) @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCThreadableTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) def setUp(self): self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) self.srv.bind(srvaddr) self.srv.listen(5) self.serverExplicitReady() self.conn, self.connaddr = self.srv.accept() def clientSetUp(self): # The is a hittable race between serverExplicitReady() and the # accept() call; sleep a little while to avoid it, otherwise # we could get an exception time.sleep(0.1) self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0) self.cli.connect(addr) self.cliaddr = self.cli.getsockname() def testStream(self): msg = self.conn.recv(1024) self.assertEqual(msg, MSG) self.assertEqual(self.cliaddr, self.connaddr) def _testStream(self): self.cli.send(MSG) self.cli.close() def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_socketserver.py0000644000076500000000000002533312666555342023125 0ustar jmaddenwheel00000000000000""" Test suite for SocketServer.py. """ import contextlib import imp import os import select import signal import socket import select import errno import tempfile import unittest import SocketServer import test.test_support from test.test_support import reap_children, reap_threads, verbose try: import threading except ImportError: threading = None test.test_support.requires("network") TEST_STR = "hello world\n" HOST = test.test_support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") requires_unix_sockets = unittest.skipUnless(HAVE_UNIX_SOCKETS, 'requires Unix sockets') HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" requires_forking = unittest.skipUnless(HAVE_FORKING, 'requires forking') def signal_alarm(n): """Call signal.alarm when it exists (i.e. not on Windows).""" if hasattr(signal, 'alarm'): signal.alarm(n) # Remember real select() to avoid interferences with mocking _real_select = select.select def receive(sock, n, timeout=20): r, w, x = _real_select([sock], [], [], timeout) if sock in r: return sock.recv(n) else: raise RuntimeError, "timed out on %r" % (sock,) if HAVE_UNIX_SOCKETS: class ForkingUnixStreamServer(SocketServer.ForkingMixIn, SocketServer.UnixStreamServer): pass class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, SocketServer.UnixDatagramServer): pass @contextlib.contextmanager def simple_subprocess(testcase): pid = os.fork() if pid == 0: # Don't raise an exception; it would be caught by the test harness. os._exit(72) yield None pid2, status = os.waitpid(pid, 0) testcase.assertEqual(pid2, pid) testcase.assertEqual(72 << 8, status) @unittest.skipUnless(threading, 'Threading required for this test.') class SocketServerTest(unittest.TestCase): """Test all socket servers.""" def setUp(self): signal_alarm(60) # Kill deadlocks after 60 seconds. self.port_seed = 0 self.test_files = [] def tearDown(self): signal_alarm(0) # Didn't deadlock. reap_children() for fn in self.test_files: try: os.remove(fn) except os.error: pass self.test_files[:] = [] def pickaddr(self, proto): if proto == socket.AF_INET: return (HOST, 0) else: # XXX: We need a way to tell AF_UNIX to pick its own name # like AF_INET provides port==0. dir = None if os.name == 'os2': dir = '\socket' fn = tempfile.mktemp(prefix='unix_socket.', dir=dir) if os.name == 'os2': # AF_UNIX socket names on OS/2 require a specific prefix # which can't include a drive letter and must also use # backslashes as directory separators if fn[1] == ':': fn = fn[2:] if fn[0] in (os.sep, os.altsep): fn = fn[1:] if os.sep == '/': fn = fn.replace(os.sep, os.altsep) else: fn = fn.replace(os.altsep, os.sep) self.test_files.append(fn) return fn def make_server(self, addr, svrcls, hdlrbase): class MyServer(svrcls): def handle_error(self, request, client_address): self.close_request(request) self.server_close() raise class MyHandler(hdlrbase): def handle(self): line = self.rfile.readline() self.wfile.write(line) if verbose: print "creating server" server = MyServer(addr, MyHandler) self.assertEqual(server.server_address, server.socket.getsockname()) return server @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) # We had the OS pick a port, so pull the real address out of # the server. addr = server.server_address if verbose: print "server created" print "ADDR =", addr print "CLASS =", svrcls t = threading.Thread( name='%s serving' % svrcls, target=server.serve_forever, # Short poll interval to make the test finish quickly. # Time between requests is short enough that we won't wake # up spuriously too many times. kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. t.start() if verbose: print "server running" for i in range(3): if verbose: print "test client", i testfunc(svrcls.address_family, addr) if verbose: print "waiting for server" server.shutdown() t.join() if verbose: print "done" def stream_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_STREAM) s.connect(addr) s.sendall(TEST_STR) buf = data = receive(s, 100) while data and '\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and '\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def test_TCPServer(self): self.run_server(SocketServer.TCPServer, SocketServer.StreamRequestHandler, self.stream_examine) def test_ThreadingTCPServer(self): self.run_server(SocketServer.ThreadingTCPServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_forking def test_ForkingTCPServer(self): with simple_subprocess(self): self.run_server(SocketServer.ForkingTCPServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_UnixStreamServer(self): self.run_server(SocketServer.UnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_ThreadingUnixStreamServer(self): self.run_server(SocketServer.ThreadingUnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) @requires_unix_sockets @requires_forking def test_ForkingUnixStreamServer(self): with simple_subprocess(self): self.run_server(ForkingUnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) def test_UDPServer(self): self.run_server(SocketServer.UDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) def test_ThreadingUDPServer(self): self.run_server(SocketServer.ThreadingUDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) @requires_forking def test_ForkingUDPServer(self): with simple_subprocess(self): self.run_server(SocketServer.ForkingUDPServer, SocketServer.DatagramRequestHandler, self.dgram_examine) @contextlib.contextmanager def mocked_select_module(self): """Mocks the select.select() call to raise EINTR for first call""" old_select = select.select class MockSelect: def __init__(self): self.called = 0 def __call__(self, *args): self.called += 1 if self.called == 1: # raise the exception on first call raise select.error(errno.EINTR, os.strerror(errno.EINTR)) else: # Return real select value for consecutive calls return old_select(*args) select.select = MockSelect() try: yield select.select finally: select.select = old_select def test_InterruptServerSelectCall(self): with self.mocked_select_module() as mock_select: pid = self.run_server(SocketServer.TCPServer, SocketServer.StreamRequestHandler, self.stream_examine) # Make sure select was called again: self.assertGreater(mock_select.called, 1) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: # @requires_unix_sockets # def test_UnixDatagramServer(self): # self.run_server(SocketServer.UnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # @requires_unix_sockets # def test_ThreadingUnixDatagramServer(self): # self.run_server(SocketServer.ThreadingUnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # @requires_unix_sockets # @requires_forking # def test_ForkingUnixDatagramServer(self): # self.run_server(SocketServer.ForkingUnixDatagramServer, # SocketServer.DatagramRequestHandler, # self.dgram_examine) @reap_threads def test_shutdown(self): # Issue #2302: shutdown() should always succeed in making an # other thread leave serve_forever(). class MyServer(SocketServer.TCPServer): pass class MyHandler(SocketServer.StreamRequestHandler): pass threads = [] for i in range(20): s = MyServer((HOST, 0), MyHandler) t = threading.Thread( name='MyServer serving', target=s.serve_forever, kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. threads.append((t, s)) for t, s in threads: t.start() s.shutdown() for t, s in threads: t.join() def test_main(): if imp.lock_held(): # If the import lock is held, the threads will hang raise unittest.SkipTest("can't run when import lock is held") test.test_support.run_unittest(SocketServerTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_ssl.py0000644000076500000000000021404512666555342021207 0ustar jmaddenwheel00000000000000# Test the support for SSL and sockets import sys import unittest from test import test_support support = test_support import asyncore import socket import select import time import gc import os import errno import pprint import urllib, urlparse import traceback import weakref import functools import platform from contextlib import closing from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler ssl = test_support.import_module("ssl") try: PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) except AttributeError: PROTOCOLS = () HOST = test_support.HOST CERTFILE = None SVN_PYTHON_ORG_ROOT_CERT = None def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) if test_support.verbose: sys.stdout.write(prefix + exc_format) class BasicTests(unittest.TestCase): def test_sslwrap_simple(self): # A crude test for the legacy API try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise # Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2 def skip_if_broken_ubuntu_ssl(func): if hasattr(ssl, 'PROTOCOL_SSLv2'): if hasattr(ssl, 'SSLContext'): # >= 2.7.9 def f(*args, **kwargs): try: ssl.SSLContext(ssl.PROTOCOL_SSLv2) except ssl.SSLError: if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and platform.linux_distribution() == ('debian', 'squeeze/sid', '')): raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour") return func(*args, **kwargs) return f # We need to access the lower-level wrapper in order to create an # implicit SSL context without trying to connect or listen. try: import _ssl except ImportError: # The returned function won't get executed, just ignore the error pass @functools.wraps(func) def f(*args, **kwargs): try: s = socket.socket(socket.AF_INET) _ssl.sslwrap(s._sock, 0, None, None, ssl.CERT_NONE, ssl.PROTOCOL_SSLv2, None, None) except ssl.SSLError as e: if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and platform.linux_distribution() == ('debian', 'squeeze/sid', '') and 'Invalid SSL protocol variant specified' in str(e)): raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour") return func(*args, **kwargs) return f else: return func class BasicSocketTests(unittest.TestCase): def test_constants(self): #ssl.PROTOCOL_SSLv2 ssl.PROTOCOL_SSLv23 ssl.PROTOCOL_SSLv3 ssl.PROTOCOL_TLSv1 ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED def test_random(self): v = ssl.RAND_status() if test_support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) try: ssl.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" ssl.RAND_add("this is a random string", 75.0) def test_parse_cert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code try: p = ssl._ssl._test_decode_cert(CERTFILE, False) except TypeError: # >= 2.7.9 p = ssl._ssl._test_decode_cert(CERTFILE) if test_support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subject'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) # Issue #13034: the subjectAltName in some certificates # (notably projects.developer.nokia.com:443) wasn't parsed p = ssl._ssl._test_decode_cert(NOKIACERT) if test_support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subjectAltName'], (('DNS', 'projects.developer.nokia.com'), ('DNS', 'projects.forum.nokia.com')) ) def test_DER_to_PEM(self): with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f: pem = f.read() d1 = ssl.PEM_cert_to_DER_cert(pem) p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) self.assertEqual(d1, d2) if not p2.startswith(ssl.PEM_HEADER + '\n'): self.fail("DER-to-PEM didn't include correct header:\n%r\n" % p2) if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'): self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2) def test_openssl_version(self): n = ssl.OPENSSL_VERSION_NUMBER t = ssl.OPENSSL_VERSION_INFO s = ssl.OPENSSL_VERSION self.assertIsInstance(n, (int, long)) self.assertIsInstance(t, tuple) self.assertIsInstance(s, str) # Some sanity checks follow # >= 0.9 self.assertGreaterEqual(n, 0x900000) # < 2.0 self.assertLess(n, 0x20000000) major, minor, fix, patch, status = t self.assertGreaterEqual(major, 0) self.assertLess(major, 2) self.assertGreaterEqual(minor, 0) self.assertLess(minor, 256) self.assertGreaterEqual(fix, 0) self.assertLess(fix, 256) self.assertGreaterEqual(patch, 0) if sys.pypy_version_info[:3] < (2, 7, 0): # gevent: compat with 2.7.0+; actually, this might depend on the local build environment self.assertLessEqual(patch, 26) else: self.assertLessEqual(patch, 29) self.assertGreaterEqual(status, 0) self.assertLessEqual(status, 15) # Version string as returned by OpenSSL, the format might change self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), (s, t)) def test_ciphers(self): if not test_support.is_resource_enabled('network'): return remote = ("svn.python.org", 443) with test_support.transient_internet(remote[0]): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") s.connect(remote) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") s.connect(remote) # Error checking can happen at instantiation (>=2.7.9) or when connecting with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx") s.connect(remote) @test_support.cpython_only def test_refcycle(self): # Issue #7943: an SSL object doesn't create reference cycles with # itself. s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) del ss self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # The _delegate_methods in socket.py are correctly delegated to by an # unconnected SSLSocket, so they will raise a socket.error rather than # something unexpected like TypeError. s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) self.assertRaises(socket.error, ss.recv, 1) self.assertRaises(socket.error, ss.recv_into, bytearray(b'x')) self.assertRaises(socket.error, ss.recvfrom, 1) self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1) self.assertRaises(socket.error, ss.send, b'x') self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0)) class NetworkedTests(unittest.TestCase): @unittest.skipIf(True, "svn.python.org cert changed; see https://bugs.python.org/issue25940") def test_connect(self): with test_support.transient_internet("svn.python.org"): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: self.fail("Peer cert %s shouldn't be here!") s.close() # this should fail because we have no verification certs s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED) try: s.connect(("svn.python.org", 443)) except ssl.SSLError: pass finally: s.close() # this should succeed because we specify the root cert s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=SVN_PYTHON_ORG_ROOT_CERT) try: s.connect(("svn.python.org", 443)) finally: s.close() @unittest.skipIf(True, "svn.python.org cert changed; see https://bugs.python.org/issue25940") def test_connect_ex(self): # Issue #11326: check connect_ex() implementation with test_support.transient_internet("svn.python.org"): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=SVN_PYTHON_ORG_ROOT_CERT) try: self.assertEqual(0, s.connect_ex(("svn.python.org", 443))) self.assertTrue(s.getpeercert()) finally: s.close() def test_non_blocking_connect_ex(self): # Issue #11326: non-blocking connect_ex() should allow handshake # to proceed after the socket gets ready. with test_support.transient_internet("svn.python.org"): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=SVN_PYTHON_ORG_ROOT_CERT, do_handshake_on_connect=False) try: s.setblocking(False) rc = s.connect_ex(('svn.python.org', 443)) # EWOULDBLOCK under Windows, EINPROGRESS elsewhere self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK)) # Wait for connect to finish select.select([], [s], [], 5.0) # Non-blocking handshake while True: try: s.do_handshake() break except ssl.SSLError as err: if err.args[0] == ssl.SSL_ERROR_WANT_READ: select.select([s], [], [], 5.0) elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: select.select([], [s], [], 5.0) else: raise # SSL established self.assertTrue(s.getpeercert()) finally: s.close() @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't # delay closing the underlying "real socket" (here tested with its # file descriptor, hence skipping the test under Windows). with test_support.transient_internet("svn.python.org"): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) ss.connect(("svn.python.org", 443)) fd = ss.fileno() f = ss.makefile() f.close() # The fd is still open os.read(fd, 0) # Closing the SSL socket should close the fd too ss.close() gc.collect() with self.assertRaises(OSError) as e: os.read(fd, 0) self.assertEqual(e.exception.errno, errno.EBADF) def test_non_blocking_handshake(self): with test_support.transient_internet("svn.python.org"): s = socket.socket(socket.AF_INET) s.connect(("svn.python.org", 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLError, err: if err.args[0] == ssl.SSL_ERROR_WANT_READ: select.select([s], [], []) elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: select.select([], [s], []) else: raise s.close() if test_support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) @unittest.skipIf(True, "svn.python.org cert changed; see https://bugs.python.org/issue25940") def test_get_server_certificate(self): with test_support.transient_internet("svn.python.org"): pem = ssl.get_server_certificate(("svn.python.org", 443)) if not pem: self.fail("No server certificate on svn.python.org:443!") try: pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) except ssl.SSLError: #should fail pass else: self.fail("Got server certificate %s for svn.python.org!" % pem) pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) if not pem: self.fail("No server certificate on svn.python.org:443!") if test_support.verbose: sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem) def test_algorithms(self): # Issue #8484: all algorithms should be available when verifying a # certificate. # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) if not hasattr(ssl, 'SSLContext') or not getattr(ssl, 'HAS_SNI', True): # The Python 2.7.8 test lib doesn't run this self.skipTest('remote host needs SNI, only available on Python 3.2+') # NOTE: https://sha256.tbs-internet.com is another possible test host remote = ("sha256.tbs-internet.com", 443) sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") with test_support.transient_internet("sha256.tbs-internet.com"): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(sha256_cert) s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname="sha256.tbs-internet.com") try: s.connect(remote) if test_support.verbose: sys.stdout.write("\nCipher with %r is %r\n" % (remote, s.cipher())) sys.stdout.write("Certificate is:\n%s\n" % pprint.pformat(s.getpeercert())) finally: s.close() try: import threading except ImportError: _have_threads = False else: _have_threads = True class ThreadedEchoServer(threading.Thread): class ConnectionHandler(threading.Thread): """A mildly complicated class, because we want it to work both with and without the SSL wrapper around the socket connection, so that we can test the STARTTLS functionality.""" def __init__(self, server, connsock): self.server = server self.running = False self.sock = connsock self.sock.setblocking(1) self.sslconn = None threading.Thread.__init__(self) self.daemon = True def show_conn_details(self): if self.server.certreqs == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() if test_support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) if test_support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() if test_support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") if hasattr(ssl, 'SSLContext'): # >= 2.7.9 def wrap_conn(self): try: self.sslconn = self.server.context.wrap_socket( self.sock, server_side=True) self.server.selected_protocols.append(self.sslconn.selected_npn_protocol()) except socket.error as e: # We treat ConnectionResetError as though it were an # SSLError - OpenSSL on Ubuntu abruptly closes the # connection when asked to use an unsupported protocol. # # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. if not isinstance(e, ssl.SSLError) and e.errno != errno.ECONNRESET: raise self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n") self.running = False self.server.stop() self.close() return False else: if self.server.context.verify_mode == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") sys.stdout.write(" server: selected protocol is now " + str(self.sslconn.selected_npn_protocol()) + "\n") return True else: def wrap_conn(self): try: self.sslconn = ssl.wrap_socket(self.sock, server_side=True, certfile=self.server.certificate, ssl_version=self.server.protocol, ca_certs=self.server.cacerts, cert_reqs=self.server.certreqs, ciphers=self.server.ciphers) except ssl.SSLError as e: # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + str(self.sock.getpeername()) + ":\n") self.close() self.running = False self.server.stop() return False else: return True def read(self): if self.sslconn: return self.sslconn.read() else: return self.sock.recv(1024) def write(self, bytes): if self.sslconn: return self.sslconn.write(bytes) else: return self.sock.send(bytes) def close(self): if self.sslconn: self.sslconn.close() else: self.sock._sock.close() def run(self): self.running = True if not self.server.starttls_server: if isinstance(self.sock, ssl.SSLSocket): self.sslconn = self.sock elif not self.wrap_conn(): return while self.running: try: msg = self.read() if not msg: # eof, so quit this handler self.running = False self.close() elif msg.strip() == 'over': if test_support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif self.server.starttls_server and msg.strip() == 'STARTTLS': if test_support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write("OK\n") if not self.wrap_conn(): return elif self.server.starttls_server and self.sslconn and msg.strip() == 'ENDTLS': if test_support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read ENDTLS from client, sending OK...\n") self.write("OK\n") self.sslconn.unwrap() self.sslconn = None if test_support.verbose and self.server.connectionchatty: sys.stdout.write(" server: connection is now unencrypted...\n") else: if (test_support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %s (%s), sending back %s (%s)...\n" % (repr(msg), ctype, repr(msg.lower()), ctype)) self.write(msg.lower()) except ssl.SSLError: if self.server.chatty: handle_error("Test server failure:\n") self.close() self.running = False # normally, we'd just stop here, but for the test # harness, we want to stop the server self.server.stop() if hasattr(ssl, 'SSLContext'): # >= 2.7.9 def __init__(self, certificate=None, ssl_version=None, certreqs=None, cacerts=None, chatty=True, connectionchatty=False, starttls_server=False, npn_protocols=None, ciphers=None, context=None): if context: self.context = context else: self.context = ssl.SSLContext(ssl_version if ssl_version is not None else ssl.PROTOCOL_TLSv1) self.context.verify_mode = (certreqs if certreqs is not None else ssl.CERT_NONE) if cacerts: self.context.load_verify_locations(cacerts) if certificate: self.context.load_cert_chain(certificate) if npn_protocols: self.context.set_npn_protocols(npn_protocols) if ciphers: self.context.set_ciphers(ciphers) self.chatty = chatty self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() self.port = support.bind_port(self.sock) self.flag = None self.active = False self.selected_protocols = [] self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True else: def __init__(self, certificate, ssl_version=None, certreqs=None, cacerts=None, chatty=True, connectionchatty=False, starttls_server=False, wrap_accepting_socket=False, ciphers=None): if ssl_version is None: ssl_version = ssl.PROTOCOL_TLSv1 if certreqs is None: certreqs = ssl.CERT_NONE self.certificate = certificate self.protocol = ssl_version self.certreqs = certreqs self.cacerts = cacerts self.ciphers = ciphers self.chatty = chatty self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() self.flag = None if wrap_accepting_socket: self.sock = ssl.wrap_socket(self.sock, server_side=True, certfile=self.certificate, cert_reqs = self.certreqs, ca_certs = self.cacerts, ssl_version = self.protocol, ciphers = self.ciphers) if test_support.verbose and self.chatty: sys.stdout.write(' server: wrapped server socket as %s\n' % str(self.sock)) self.port = test_support.bind_port(self.sock) self.active = False self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): self.stop() self.join() def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.sock.settimeout(0.05) self.sock.listen(5) self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if test_support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + str(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn) handler.start() handler.join() except socket.timeout: pass except KeyboardInterrupt: self.stop() self.sock.close() def stop(self): self.active = False class AsyncoreEchoServer(threading.Thread): class EchoServer(asyncore.dispatcher): class ConnectionHandler(asyncore.dispatcher_with_send): def __init__(self, conn, certfile): asyncore.dispatcher_with_send.__init__(self, conn) self.socket = ssl.wrap_socket(conn, server_side=True, certfile=certfile, do_handshake_on_connect=False) self._ssl_accepting = True def readable(self): if isinstance(self.socket, ssl.SSLSocket): while self.socket.pending() > 0: self.handle_read_event() return True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except socket.error, err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() else: data = self.recv(1024) if data and data.strip() != 'over': self.send(data.lower()) def handle_close(self): self.close() if test_support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): raise def __init__(self, certfile): self.certfile = certfile asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.port = test_support.bind_port(self.socket) self.listen(5) def handle_accept(self): sock_obj, addr = self.accept() if test_support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) def handle_error(self): raise def __init__(self, certfile): self.flag = None self.active = False self.server = self.EchoServer(certfile) self.port = self.server.port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): if test_support.verbose: sys.stdout.write(" cleanup: stopping server.\n") self.stop() if test_support.verbose: sys.stdout.write(" cleanup: joining server thread.\n") self.join() if test_support.verbose: sys.stdout.write(" cleanup: successfully joined.\n") def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.active = True if self.flag: self.flag.set() while self.active: asyncore.loop(0.05) def stop(self): self.active = False self.server.close() class SocketServerHTTPSServer(threading.Thread): class HTTPSServer(HTTPServer): def __init__(self, server_address, RequestHandlerClass, certfile): HTTPServer.__init__(self, server_address, RequestHandlerClass) # we assume the certfile contains both private key and certificate self.certfile = certfile self.allow_reuse_address = True def __str__(self): return ('<%s %s:%s>' % (self.__class__.__name__, self.server_name, self.server_port)) def get_request(self): # override this to wrap socket with SSL sock, addr = self.socket.accept() sslconn = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile) return sslconn, addr class RootedHTTPRequestHandler(SimpleHTTPRequestHandler): # need to override translate_path to get a known root, # instead of using os.curdir, since the test could be # run from anywhere server_version = "TestHTTPS/1.0" root = None def translate_path(self, path): """Translate a /-separated PATH to the local filename syntax. Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.) """ # abandon query parameters path = urlparse.urlparse(path)[2] path = os.path.normpath(urllib.unquote(path)) words = path.split('/') words = filter(None, words) path = self.root for word in words: drive, word = os.path.splitdrive(word) head, word = os.path.split(word) if word in self.root: continue path = os.path.join(path, word) return path def log_message(self, format, *args): # we override this to suppress logging unless "verbose" if test_support.verbose: sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" % (self.server.server_address, self.server.server_port, self.request.cipher(), self.log_date_time_string(), format%args)) def __init__(self, certfile): self.flag = None self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] self.server = self.HTTPSServer( (HOST, 0), self.RootedHTTPRequestHandler, certfile) self.port = self.server.server_port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): if self.flag: self.flag.set() self.server.serve_forever(0.05) def stop(self): self.server.shutdown() def bad_cert_test(certfile): """ Launch a server with CERT_REQUIRED, and check that trying to connect to it with the given client certificate fails. """ server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False) with server: try: s = ssl.wrap_socket(socket.socket(), certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError, x: if test_support.verbose: sys.stdout.write("\nSSLError is %s\n" % x[1]) except socket.error, x: if test_support.verbose: sys.stdout.write("\nsocket.error is %s\n" % x[1]) else: raise AssertionError("Use of invalid cert should have failed!") if hasattr(ssl, 'SSLContext'): # >= 2.7.9 def server_params_test(client_context, server_context, indata=b"FOO\n", chatty=True, connectionchatty=False, sni_name=None): """ Launch a server, connect a client to it and try various reads and writes. """ stats = {} server = ThreadedEchoServer(context=server_context, chatty=chatty, connectionchatty=False) with server: with closing(client_context.wrap_socket(socket.socket(), server_hostname=sni_name)) as s: s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(arg) outdata = s.read() if connectionchatty: if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): raise AssertionError( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if connectionchatty: if support.verbose: sys.stdout.write(" client: closing connection.\n") stats.update({ 'compression': s.compression(), 'cipher': s.cipher(), 'peercert': s.getpeercert(), 'client_npn_protocol': s.selected_npn_protocol(), 'version': s.version(), }) s.close() stats['server_npn_protocols'] = server.selected_protocols return stats def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None, server_options=0, client_options=0): """ Try to SSL-connect using *client_protocol* to *server_protocol*. If *expect_success* is true, assert that the connection succeeds, if it's false, assert that the connection fails. Also, if *expect_success* is a string, assert that it is the protocol version actually used by the connection. """ if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) client_context = ssl.SSLContext(client_protocol) client_context.options |= client_options server_context = ssl.SSLContext(server_protocol) server_context.options |= server_options # NOTE: we must enable "ALL" ciphers on the client, otherwise an # SSLv23 client will send an SSLv3 hello (rather than SSLv2) # starting from OpenSSL 1.0.0 (see issue #8322). if client_context.protocol == ssl.PROTOCOL_SSLv23: client_context.set_ciphers("ALL") for ctx in (client_context, server_context): ctx.verify_mode = certsreqs ctx.load_cert_chain(CERTFILE) ctx.load_verify_locations(CERTFILE) try: stats = server_params_test(client_context, server_context, chatty=False, connectionchatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except socket.error as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) elif (expect_success is not True and expect_success != stats['version']): raise AssertionError("version mismatch: expected %r, got %r" % (expect_success, stats['version'])) else: def server_params_test(certfile, protocol, certreqs, cacertsfile, client_certfile, client_protocol=None, indata="FOO\n", ciphers=None, chatty=True, connectionchatty=False, wrap_accepting_socket=False): """ Launch a server, connect a client to it and try various reads and writes. """ server = ThreadedEchoServer(certfile, certreqs=certreqs, ssl_version=protocol, cacerts=cacertsfile, ciphers=ciphers, chatty=chatty, connectionchatty=connectionchatty, wrap_accepting_socket=wrap_accepting_socket) with server: # try to connect if client_protocol is None: client_protocol = protocol s = ssl.wrap_socket(socket.socket(), certfile=client_certfile, ca_certs=cacertsfile, ciphers=ciphers, cert_reqs=certreqs, ssl_version=client_protocol) s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(arg))) s.write(arg) outdata = s.read() if connectionchatty: if test_support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) if outdata != indata.lower(): raise AssertionError( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (outdata[:min(len(outdata),20)], len(outdata), indata[:min(len(indata),20)].lower(), len(indata))) s.write("over\n") if connectionchatty: if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None): if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if test_support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) try: # NOTE: we must enable "ALL" ciphers, otherwise an SSLv23 client # will send an SSLv3 hello (rather than SSLv2) starting from # OpenSSL 1.0.0 (see issue #8322). server_params_test(CERTFILE, server_protocol, certsreqs, CERTFILE, CERTFILE, client_protocol, ciphers="ALL", chatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except socket.error as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) class ThreadedTests(unittest.TestCase): def test_rude_shutdown(self): """A brutal shutdown of an SSL server should raise an IOError in the client when attempting handshake. """ listener_ready = threading.Event() listener_gone = threading.Event() s = socket.socket() port = test_support.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, # and sets Event `listener_gone` to let the main thread know # the socket is gone. def listener(): s.listen(5) listener_ready.set() s.accept() s.close() listener_gone.set() def connector(): listener_ready.wait() c = socket.socket() c.connect((HOST, port)) listener_gone.wait() # XXX why is it necessary? test_support.gc_collect() try: ssl_sock = ssl.wrap_socket(c) except IOError: pass else: self.fail('connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) t.start() try: connector() finally: t.join() @skip_if_broken_ubuntu_ssl def test_echo(self): """Basic test of an SSL client connecting to a server""" if test_support.verbose: sys.stdout.write("\n") if hasattr(ssl, 'SSLContext'): # >= 2.7.9 for protocol in PROTOCOLS: context = ssl.SSLContext(protocol) context.load_cert_chain(CERTFILE) server_params_test(context, context, chatty=True, connectionchatty=True) else: server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE, CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1, chatty=True, connectionchatty=True) def test_getpeercert(self): if test_support.verbose: sys.stdout.write("\n") s2 = socket.socket() server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_SSLv23, cacerts=CERTFILE, chatty=False) with server: s = ssl.wrap_socket(socket.socket(), certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_SSLv23) s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() if test_support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: self.fail("No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): self.fail( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") s.close() def test_empty_cert(self): """Connecting with an empty cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "nullcert.pem")) def test_malformed_cert(self): """Connecting with a badly formatted certificate (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badcert.pem")) def test_nonexisting_cert(self): """Connecting with a non-existing cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "wrongcert.pem")) def test_malformed_key(self): """Connecting with a badly formatted key (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badkey.pem")) @skip_if_broken_ubuntu_ssl def test_protocol_sslv2(self): """Connecting to an SSLv2 server with various client options""" if test_support.verbose: sys.stdout.write("\n") if not hasattr(ssl, 'PROTOCOL_SSLv2'): self.skipTest("PROTOCOL_SSLv2 needed") try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) @skip_if_broken_ubuntu_ssl def test_protocol_sslv23(self): """Connecting to an SSLv23 server with various client options""" if test_support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) @skip_if_broken_ubuntu_ssl def test_protocol_sslv3(self): """Connecting to an SSLv3 server with various client options""" if test_support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) @skip_if_broken_ubuntu_ssl def test_protocol_tlsv1(self): """Connecting to a TLSv1 server with various client options""" if test_support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False) def test_starttls(self): """Switching from clear text to encrypted and back again.""" msgs = ("msg 1", "MSG 2", "STARTTLS", "MSG 3", "msg 4", "ENDTLS", "msg 5", "msg 6") server = ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, starttls_server=True, chatty=True, connectionchatty=True) wrapped = False with server: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) if test_support.verbose: sys.stdout.write("\n") for indata in msgs: if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % repr(indata)) if wrapped: conn.write(indata) outdata = conn.read() else: s.send(indata) outdata = s.recv(1024) if (indata == "STARTTLS" and outdata.strip().lower().startswith("ok")): # STARTTLS ok, switch to secure mode if test_support.verbose: sys.stdout.write( " client: read %s from server, starting TLS...\n" % repr(outdata)) conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) wrapped = True elif (indata == "ENDTLS" and outdata.strip().lower().startswith("ok")): # ENDTLS ok, switch back to clear text if test_support.verbose: sys.stdout.write( " client: read %s from server, ending TLS...\n" % repr(outdata)) s = conn.unwrap() wrapped = False else: if test_support.verbose: sys.stdout.write( " client: read %s from server\n" % repr(outdata)) if test_support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write("over\n") else: s.send("over\n") s.close() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" server = SocketServerHTTPSServer(CERTFILE) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: if test_support.verbose: sys.stdout.write('\n') with open(CERTFILE, 'rb') as f: d1 = f.read() d2 = '' # now fetch the same data from the HTTPS server url = 'https://127.0.0.1:%d/%s' % ( server.port, os.path.split(CERTFILE)[1]) with test_support.check_py3k_warnings(): import ssl if hasattr(ssl, '_create_unverified_context'): # Disable verification for our self-signed cert # on Python >= 2.7.9 and 3.4 ssl_ctx = ssl._create_unverified_context() f = urllib.urlopen(url, context=ssl_ctx) else: f = urllib.urlopen(url) dlen = f.info().getheader("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) if test_support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) f.close() self.assertEqual(d1, d2) finally: server.stop() server.join() @unittest.skipIf(hasattr(ssl, 'SSLContext'), "<= 2.7.9 only") def test_wrapped_accept(self): """Check the accept() method on SSL sockets.""" if test_support.verbose: sys.stdout.write("\n") server_params_test(CERTFILE, ssl.PROTOCOL_SSLv23, ssl.CERT_REQUIRED, CERTFILE, CERTFILE, ssl.PROTOCOL_SSLv23, chatty=True, connectionchatty=True, wrap_accepting_socket=True) def test_asyncore_server(self): """Check the example asyncore integration.""" indata = "TEST MESSAGE of mixed case\n" if test_support.verbose: sys.stdout.write("\n") server = AsyncoreEchoServer(CERTFILE) with server: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if test_support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.write(indata) outdata = s.read() if test_support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) if outdata != indata.lower(): self.fail( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (outdata[:min(len(outdata),20)], len(outdata), indata[:min(len(indata),20)].lower(), len(indata))) s.write("over\n") if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() def test_recv_send(self): """Test recv(), send() and friends.""" if test_support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray("\0"*100) count = s.recv_into(b) return b[:count] def _recvfrom_into(): b = bytearray("\0"*100) count, addr = s.recvfrom_into(b) return b[:count] # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]), ('sendall', s.sendall, True, []), ] recv_methods = [ ('recv', s.recv, True, []), ('recvfrom', s.recvfrom, False, ["some.address"]), ('recv_into', _recv_into, True, []), ('recvfrom_into', _recvfrom_into, False, []), ] data_prefix = u"PREFIX_" for meth_name, send_meth, expect_success, args in send_methods: indata = data_prefix + meth_name try: send_meth(indata.encode('ASCII', 'strict'), *args) outdata = s.read() outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): self.fail( "While sending with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( meth_name, outdata[:20], len(outdata), indata[:20], len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to send with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): self.fail( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e ) ) for meth_name, recv_meth, expect_success, args in recv_methods: indata = data_prefix + meth_name try: s.send(indata.encode('ASCII', 'strict')) outdata = recv_meth(*args) outdata = outdata.decode('ASCII', 'strict') if outdata != indata.lower(): self.fail( "While receiving with <<%s>> bad data " "<<%r>> (%d) received; " "expected <<%r>> (%d)\n" % ( meth_name, outdata[:20], len(outdata), indata[:20], len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to receive with method <<%s>>; " "expected to succeed.\n" % (meth_name,) ) if not str(e).startswith(meth_name): self.fail( "Method <<%s>> failed with unexpected " "exception message: %s\n" % ( meth_name, e ) ) # consume data s.read() s.write("over\n".encode("ASCII", "strict")) s.close() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = test_support.bind_port(server) started = threading.Event() finish = False def serve(): server.listen(5) started.set() conns = [] while not finish: r, w, e = select.select([server], [], [], 0.1) if server in r: # Let the socket hang around rather than having # it closed by garbage collection. conns.append(server.accept()[0]) t = threading.Thread(target=serve) t.start() started.wait() try: try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c.connect((host, port)) # Will attempt handshake and time out self.assertRaisesRegexp(ssl.SSLError, "timed out", ssl.wrap_socket, c) finally: c.close() try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c = ssl.wrap_socket(c) # Will attempt handshake and time out self.assertRaisesRegexp(ssl.SSLError, "timed out", c.connect, (host, port)) finally: c.close() finally: finish = True t.join() server.close() def test_default_ciphers(self): with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: sock = socket.socket() try: # Force a set of weak ciphers on our client socket try: s = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_SSLv23, ciphers="DES") except ssl.SSLError: self.skipTest("no DES cipher available") with self.assertRaises((OSError, ssl.SSLError)): s.connect((HOST, server.port)) finally: sock.close() self.assertIn("no shared cipher", str(server.conn_errors[0])) def test_main(verbose=False): global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.pem") NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nokia.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or not os.path.exists(NOKIACERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests, BasicSocketTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) try: test_support.run_unittest(*tests) finally: if _have_threads: test_support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_subprocess.py0000644000076500000000000016320412666555342022576 0ustar jmaddenwheel00000000000000import unittest from test import test_support import subprocess import sys import signal import os import errno import tempfile import time import re import sysconfig try: import resource except ImportError: resource = None try: import threading except ImportError: threading = None mswindows = (sys.platform == "win32") PYPY = hasattr(sys, 'pypy_version_info') # # Depends on the following external programs: Python # #if mswindows: # SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), ' # 'os.O_BINARY);') #else: # SETBINARY = '' try: mkstemp = tempfile.mkstemp except AttributeError: # tempfile.mkstemp is not available def mkstemp(): """Replacement for mkstemp, calling mktemp.""" fname = tempfile.mktemp() return os.open(fname, os.O_RDWR|os.O_CREAT), fname class BaseTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). test_support.reap_children() def tearDown(self): for inst in subprocess._active: inst.wait() subprocess._cleanup() self.assertFalse(subprocess._active, "subprocess._active not empty") def assertStderrEqual(self, stderr, expected, msg=None): # In a debug build, stuff like "[6580 refs]" is printed to stderr at # shutdown time. That frustrates tests trying to check stderr produced # from a spawned Python process. actual = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr) self.assertEqual(actual, expected, msg) class PopenTestException(Exception): pass class PopenExecuteChildRaises(subprocess.Popen): """Popen subclass for testing cleanup of subprocess.PIPE filehandles when _execute_child fails. """ def _execute_child(self, *args, **kwargs): raise PopenTestException("Forced Exception for Test") class ProcessTestCase(BaseTestCase): def test_call_seq(self): # call() function with sequence argument rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) def test_check_call_zero(self): # check_call() function with zero return code rc = subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(0)"]) self.assertEqual(rc, 0) def test_check_call_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(c.exception.returncode, 47) def test_check_output(self): # check_output() function with zero return code output = subprocess.check_output( [sys.executable, "-c", "print 'BDFL'"]) self.assertIn('BDFL', output) def test_check_output_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_output( [sys.executable, "-c", "import sys; sys.exit(5)"]) self.assertEqual(c.exception.returncode, 5) def test_check_output_stderr(self): # check_output() function stderr redirected to stdout output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"], stderr=subprocess.STDOUT) self.assertIn('BDFL', output) def test_check_output_stdout_arg(self): # check_output() function stderr redirected to stdout with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print 'will not be run'"], stdout=sys.stdout) self.fail("Expected ValueError when stdout arg supplied.") self.assertIn('stdout', c.exception.args[0]) def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() newenv["FRUIT"] = "banana" rc = subprocess.call([sys.executable, "-c", 'import sys, os;' 'sys.exit(os.getenv("FRUIT")=="banana")'], env=newenv) self.assertEqual(rc, 1) def test_invalid_args(self): # Popen() called with invalid arguments should raise TypeError # but Popen.__del__ should not complain (issue #12085) with test_support.captured_stderr() as s: self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1) argcount = subprocess.Popen.__init__.__code__.co_argcount too_many_args = [0] * (argcount + 1) self.assertRaises(TypeError, subprocess.Popen, *too_many_args) self.assertEqual(s.getvalue(), '') def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) p.wait() self.assertEqual(p.stdin, None) def test_stdout_none(self): # .stdout is None when not redirected, and the child's stdout will # be inherited from the parent. In order to test this we run a # subprocess in a subprocess: # this_test # \-- subprocess created by this test (parent) # \-- subprocess created by the parent subprocess (child) # The parent doesn't specify stdout, so the child will use the # parent's stdout. This test checks that the message printed by the # child goes to the parent stdout. The parent also checks that the # child's stdout is None. See #11963. code = ('import sys; from subprocess import Popen, PIPE;' 'p = Popen([sys.executable, "-c", "print \'test_stdout_none\'"],' ' stdin=PIPE, stderr=PIPE);' 'p.wait(); assert p.stdout is None;') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), 'test_stdout_none') def test_stderr_none(self): # .stderr is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print "banana"'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stdin.close) p.wait() self.assertEqual(p.stderr, None) def test_executable_with_cwd(self): python_dir = os.path.dirname(os.path.realpath(sys.executable)) p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"], executable=sys.executable, cwd=python_dir) p.wait() self.assertEqual(p.returncode, 47) @unittest.skipIf(sysconfig.is_python_build() or PYPY, "need an installed Python. See #7774. Also fails to get sys.prefix on stock PyPy") def test_executable_without_cwd(self): # For a normal installation, it should work without 'cwd' # argument. For test runs in the build directory, see #7774. p = subprocess.Popen(["somethingyoudonthave", "-c", "import sys; sys.exit(47)"], executable=sys.executable) p.wait() self.assertEqual(p.returncode, 47) def test_stdin_pipe(self): # stdin redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.stdin.write("pear") p.stdin.close() p.wait() self.assertEqual(p.returncode, 1) def test_stdin_filedes(self): # stdin is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() os.write(d, "pear") os.lseek(d, 0, 0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=d) p.wait() self.assertEqual(p.returncode, 1) def test_stdin_fileobj(self): # stdin is set to open file object tf = tempfile.TemporaryFile() tf.write("pear") tf.seek(0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=tf) p.wait() self.assertEqual(p.returncode, 1) def test_stdout_pipe(self): # stdout redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "orange") def test_stdout_filedes(self): # stdout is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), "orange") def test_stdout_fileobj(self): # stdout is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), "orange") def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.addCleanup(p.stderr.close) self.assertStderrEqual(p.stderr.read(), "strawberry") def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertStderrEqual(os.read(d, 1024), "strawberry") def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), "strawberry") def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.addCleanup(p.stdout.close) self.assertStderrEqual(p.stdout.read(), "appleorange") def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), "appleorange") def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). # To avoid printing the text on stdout, we do something similar to # test_stdout_none (see above). The parent subprocess calls the child # subprocess passing stdout=1, and this test uses stdout=PIPE in # order to capture and check the output of the parent. See #11963. code = ('import sys, subprocess; ' 'rc = subprocess.call([sys.executable, "-c", ' ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), ' '\'test with stdout=1\'))"], stdout=1); ' 'assert rc == 18') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), 'test with stdout=1') def test_cwd(self): tmpdir = tempfile.gettempdir() # We cannot use os.path.realpath to canonicalize the path, # since it doesn't expand Tru64 {memb} strings. See bug 1063571. cwd = os.getcwd() os.chdir(tmpdir) tmpdir = os.getcwd() os.chdir(cwd) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) self.addCleanup(p.stdout.close) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir)) def test_env(self): newenv = os.environ.copy() newenv["FRUIT"] = "orange" p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "orange") def test_communicate_stdin(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.communicate("pear") self.assertEqual(p.returncode, 1) def test_communicate_stdout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("pineapple")'], stdout=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, "pineapple") self.assertEqual(stderr, None) def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertStderrEqual(stderr, "pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) (stdout, stderr) = p.communicate("banana") self.assertEqual(stdout, "banana") self.assertStderrEqual(stderr, "pineapple") # This test is Linux specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") # Test for the fd leak reported in http://bugs.python.org/issue2791. def test_communicate_pipe_fd_leak(self): fd_directory = '/proc/%d/fd' % os.getpid() num_fds_before_popen = len(os.listdir(fd_directory)) p = subprocess.Popen([sys.executable, "-c", "print()"], stdout=subprocess.PIPE) p.communicate() num_fds_after_communicate = len(os.listdir(fd_directory)) del p num_fds_after_destruction = len(os.listdir(fd_directory)) self.assertEqual(num_fds_before_popen, num_fds_after_destruction) self.assertEqual(num_fds_before_popen, num_fds_after_communicate) def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"]) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, None) def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. x, y = os.pipe() if mswindows: pipe_buf = 512 else: pipe_buf = os.fpathconf(x, "PC_PIPE_BUF") os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' 'sys.stderr.write("xyz"*%d);' 'sys.stdout.write(sys.stdin.read())' % pipe_buf], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) string_to_write = "abc"*pipe_buf (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.stdin.write("banana") (stdout, stderr) = p.communicate("split") self.assertEqual(stdout, "bananasplit") self.assertStderrEqual(stderr, "") def test_universal_newlines(self): # NB. replaced SETBINARY with the -u flag p = subprocess.Popen([sys.executable, "-u", "-c", 'import sys,os;' + #SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) stdout = p.stdout.read() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_universal_newlines_communicate(self): # universal newlines through communicate() # NB. replaced SETBINARY with the -u flag p = subprocess.Popen([sys.executable, "-u", "-c", 'import sys,os;' + #SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate() if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") def test_no_leaking(self): # Make sure we leak no resources if not mswindows: max_handles = 1026 # too much for most UNIX systems else: max_handles = 2050 # too much for (at least some) Windows setups handles = [] try: for i in range(max_handles): try: handles.append(os.open(test_support.TESTFN, os.O_WRONLY | os.O_CREAT)) except OSError as e: if e.errno != errno.EMFILE: raise break else: self.skipTest("failed to reach the file descriptor limit " "(tried %d)" % max_handles) # Close a couple of them (should be enough for a subprocess) for i in range(10): os.close(handles.pop()) # Loop creating some subprocesses. If one of them leaks some fds, # the next loop iteration will fail by reaching the max fd limit. for i in range(15): p = subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate(b"lime")[0] self.assertEqual(data, b"lime") finally: for h in handles: os.close(h) test_support.unlink(test_support.TESTFN) def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), '"a b c" d e') self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']), 'ab\\"c \\ d') self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']), 'ab\\"c " \\\\" d') self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']), 'a\\\\\\b "de fg" h') self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']), 'a\\\\\\"b c d') self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']), '"a\\\\b c" d e') self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']), '"a\\\\b\\ c" d e') self.assertEqual(subprocess.list2cmdline(['ab', '']), 'ab ""') def test_poll(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(1)"]) count = 0 while p.poll() is None: time.sleep(0.1) count += 1 # We expect that the poll loop probably went around about 10 times, # but, based on system scheduling we can't control, it's possible # poll() never returned None. It "should be" very rare that it # didn't go around at least twice. self.assertGreaterEqual(count, 2) # Subsequent invocations should just return the returncode self.assertEqual(p.poll(), 0) def test_wait(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(2)"]) self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) def test_invalid_bufsize(self): # an invalid type of the bufsize argument should raise # TypeError. with self.assertRaises(TypeError): subprocess.Popen([sys.executable, "-c", "pass"], "orange") def test_leaking_fds_on_error(self): # see bug #5179: Popen leaks file descriptors to PIPEs if # the child fails to execute; this will eventually exhaust # the maximum number of open fds. 1024 seems a very common # value for that limit, but Windows has 2048, so we loop # 1024 times (each call leaked two fds). for i in range(1024): # Windows raises IOError. Others raise OSError. with self.assertRaises(EnvironmentError) as c: subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # ignore errors that indicate the command was not found if c.exception.errno not in (errno.ENOENT, errno.EACCES): raise c.exception @unittest.skipIf(threading is None, "threading required") def test_double_close_on_error(self): # Issue #18851 fds = [] def open_fds(): for i in range(20): fds.extend(os.pipe()) time.sleep(0.001) t = threading.Thread(target=open_fds) t.start() try: with self.assertRaises(EnvironmentError): subprocess.Popen(['nonexisting_i_hope'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: t.join() exc = None for fd in fds: # If a double close occurred, some of those fds will # already have been closed by mistake, and os.close() # here will raise. try: os.close(fd) except OSError as e: exc = e if exc is not None: raise exc def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released ifhandle, ifname = mkstemp() ofhandle, ofname = mkstemp() efhandle, efname = mkstemp() try: subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle, stderr=efhandle) except OSError: os.close(ifhandle) os.remove(ifname) os.close(ofhandle) os.remove(ofname) os.close(efhandle) os.remove(efname) self.assertFalse(os.path.exists(ifname)) self.assertFalse(os.path.exists(ofname)) self.assertFalse(os.path.exists(efname)) def test_communicate_epipe(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.communicate("x" * 2**20) def test_communicate_epipe_only_stdin(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) time.sleep(2) p.communicate("x" * 2**20) # This test is Linux-ish specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") def test_failed_child_execute_fd_leak(self): """Test for the fork() failure fd leak reported in issue16327.""" fd_directory = '/proc/%d/fd' % os.getpid() fds_before_popen = os.listdir(fd_directory) with self.assertRaises(PopenTestException): PopenExecuteChildRaises( [sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # NOTE: This test doesn't verify that the real _execute_child # does not close the file descriptors itself on the way out # during an exception. Code inspection has confirmed that. fds_after_exception = os.listdir(fd_directory) self.assertEqual(fds_before_popen, fds_after_exception) # context manager class _SuppressCoreFiles(object): """Try to prevent core files from being created.""" old_limit = None def __enter__(self): """Try to save previous ulimit, then set it to (0, 0).""" if resource is not None: try: self.old_limit = resource.getrlimit(resource.RLIMIT_CORE) resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) except (ValueError, resource.error): pass if sys.platform == 'darwin': # Check if the 'Crash Reporter' on OSX was configured # in 'Developer' mode and warn that it will get triggered # when it is. # # This assumes that this context manager is used in tests # that might trigger the next manager. value = subprocess.Popen(['/usr/bin/defaults', 'read', 'com.apple.CrashReporter', 'DialogType'], stdout=subprocess.PIPE).communicate()[0] if value.strip() == b'developer': print "this tests triggers the Crash Reporter, that is intentional" sys.stdout.flush() def __exit__(self, *args): """Return core file behavior to default.""" if self.old_limit is None: return if resource is not None: try: resource.setrlimit(resource.RLIMIT_CORE, self.old_limit) except (ValueError, resource.error): pass @unittest.skipUnless(hasattr(signal, 'SIGALRM'), "Requires signal.SIGALRM") def test_communicate_eintr(self): # Issue #12493: communicate() should handle EINTR def handler(signum, frame): pass old_handler = signal.signal(signal.SIGALRM, handler) self.addCleanup(signal.signal, signal.SIGALRM, old_handler) # the process is running for 2 seconds args = [sys.executable, "-c", 'import time; time.sleep(2)'] for stream in ('stdout', 'stderr'): kw = {stream: subprocess.PIPE} with subprocess.Popen(args, **kw) as process: signal.alarm(1) # communicate() will be interrupted by SIGALRM process.communicate() @unittest.skipIf(mswindows, "POSIX specific tests") class POSIXProcessTestCase(BaseTestCase): def test_exceptions(self): # caught & re-raised exceptions with self.assertRaises(OSError) as c: p = subprocess.Popen([sys.executable, "-c", ""], cwd="/this/path/does/not/exist") # The attribute child_traceback should contain "os.chdir" somewhere. self.assertIn("os.chdir", c.exception.child_traceback) def test_run_abort(self): # returncode handles signal termination with _SuppressCoreFiles(): p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT) def test_preexec(self): # preexec function p = subprocess.Popen([sys.executable, "-c", "import sys, os;" "sys.stdout.write(os.getenv('FRUIT'))"], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "apple") class _TestExecuteChildPopen(subprocess.Popen): """Used to test behavior at the end of _execute_child.""" def __init__(self, testcase, *args, **kwargs): self._testcase = testcase subprocess.Popen.__init__(self, *args, **kwargs) def _execute_child( self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): try: subprocess.Popen._execute_child( self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) finally: # Open a bunch of file descriptors and verify that # none of them are the same as the ones the Popen # instance is using for stdin/stdout/stderr. devzero_fds = [os.open("/dev/zero", os.O_RDONLY) for _ in range(8)] try: for fd in devzero_fds: self._testcase.assertNotIn( fd, (p2cwrite, c2pread, errread)) finally: for fd in devzero_fds: os.close(fd) @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") def test_preexec_errpipe_does_not_double_close_pipes(self): """Issue16140: Don't double close pipes on preexec error.""" def raise_it(): raise RuntimeError("force the _execute_child() errpipe_data path.") with self.assertRaises(RuntimeError): self._TestExecuteChildPopen( self, [sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=raise_it) def test_args_string(self): # args is a string f, fname = mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) self.assertEqual(p.returncode, 47) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], startupinfo=47) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], creationflags=47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen(["echo $FRUIT"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), "apple") def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen("echo $FRUIT", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), "apple") def test_call_string(self): # call() function with string argument on UNIX f, fname = mkstemp() os.write(f, "#!/bin/sh\n") os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.close(f) os.chmod(fname, 0700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) def test_specific_shell(self): # Issue #9265: Incorrect name passed as arg[0]. shells = [] for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']: for name in ['bash', 'ksh']: sh = os.path.join(prefix, name) if os.path.isfile(sh): shells.append(sh) if not shells: # Will probably work for any shell but csh. self.skipTest("bash or ksh required for this test") sh = '/bin/sh' if os.path.isfile(sh) and not os.path.islink(sh): # Test will fail if /bin/sh is a symlink to csh. shells.append(sh) for sh in shells: p = subprocess.Popen("echo $0", executable=sh, shell=True, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), sh) def _kill_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) return p @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) p.communicate() def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() self.assertIn('KeyboardInterrupt', stderr) self.assertNotEqual(p.wait(), 0) def test_kill(self): p = self._kill_process('kill') _, stderr = p.communicate() self.assertStderrEqual(stderr, '') self.assertEqual(p.wait(), -signal.SIGKILL) def test_terminate(self): p = self._kill_process('terminate') _, stderr = p.communicate() self.assertStderrEqual(stderr, '') self.assertEqual(p.wait(), -signal.SIGTERM) def test_send_signal_dead(self): # Sending a signal to a dead process self._kill_dead_process('send_signal', signal.SIGINT) def test_kill_dead(self): # Killing a dead process self._kill_dead_process('kill') def test_terminate_dead(self): # Terminating a dead process self._kill_dead_process('terminate') def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed stdin = 0 newfds = [] for a in fds: b = os.dup(a) newfds.append(b) if a == 0: stdin = b try: for fd in fds: os.close(fd) out, err = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() err = test_support.strip_python_stderr(err) self.assertEqual((out, err), (b'apple', b'orange')) finally: for b, a in zip(newfds, fds): os.dup2(b, a) for b in newfds: os.close(b) def test_close_fd_0(self): self.check_close_std_fds([0]) def test_close_fd_1(self): self.check_close_std_fds([1]) def test_close_fd_2(self): self.check_close_std_fds([2]) def test_close_fds_0_1(self): self.check_close_std_fds([0, 1]) def test_close_fds_0_2(self): self.check_close_std_fds([0, 2]) def test_close_fds_1_2(self): self.check_close_std_fds([1, 2]) def test_close_fds_0_1_2(self): # Issue #10806: test that subprocess pipes still work properly with # all standard fds closed. self.check_close_std_fds([0, 1, 2]) def check_swap_fds(self, stdin_no, stdout_no, stderr_no): # open up some temporary files temps = [mkstemp() for i in range(3)] temp_fds = [fd for fd, fname in temps] try: # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # save a copy of the standard file descriptors saved_fds = [os.dup(fd) for fd in range(3)] try: # duplicate the temp files over the standard fd's 0, 1, 2 for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # write some data to what will become stdin, and rewind os.write(stdin_no, b"STDIN") os.lseek(stdin_no, 0, 0) # now use those files in the given order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=stdin_no, stdout=stdout_no, stderr=stderr_no) p.wait() for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(stdout_no, 1024) err = test_support.strip_python_stderr(os.read(stderr_no, 1024)) finally: for std, saved in enumerate(saved_fds): os.dup2(saved, std) os.close(saved) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) # When duping fds, if there arises a situation where one of the fds is # either 0, 1 or 2, it is possible that it is overwritten (#12607). # This tests all combinations of this. def test_swap_fds(self): self.check_swap_fds(0, 1, 2) self.check_swap_fds(0, 2, 1) self.check_swap_fds(1, 0, 2) self.check_swap_fds(1, 2, 0) self.check_swap_fds(2, 0, 1) self.check_swap_fds(2, 1, 0) def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = test_support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(0, p.returncode, "sigchild_ignore.py exited" " non-zero with this error:\n%s" % stderr) def test_zombie_fast_process_del(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, it wouldn't be added to subprocess._active, and would # remain a zombie. # spawn a Popen, and delete its reference before it exits p = subprocess.Popen([sys.executable, "-c", 'import sys, time;' 'time.sleep(0.2)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p test_support.gc_collect() # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) def test_leak_fast_process_del_killed(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, and the process got killed by a signal, it would never # be removed from subprocess._active, which triggered a FD and memory # leak. # spawn a Popen, delete its reference and kill it p = subprocess.Popen([sys.executable, "-c", 'import time;' 'time.sleep(3)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p test_support.gc_collect() os.kill(pid, signal.SIGKILL) # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) # let some time for the process to exit, and create a new Popen: this # should trigger the wait() of p time.sleep(0.2) with self.assertRaises(EnvironmentError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass # p should have been wait()ed on, and removed from the _active list self.assertRaises(OSError, os.waitpid, pid, 0) self.assertNotIn(ident, [id(o) for o in subprocess._active]) def test_pipe_cloexec(self): # Issue 12786: check that the communication pipes' FDs are set CLOEXEC, # and are not inherited by another child process. p1 = subprocess.Popen([sys.executable, "-c", 'import os;' 'os.read(0, 1)' ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p2 = subprocess.Popen([sys.executable, "-c", """if True: import os, errno, sys for fd in %r: try: os.close(fd) except OSError as e: if e.errno != errno.EBADF: raise else: sys.exit(1) sys.exit(0) """ % [f.fileno() for f in (p1.stdin, p1.stdout, p1.stderr)] ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) p1.communicate('foo') _, stderr = p2.communicate() self.assertEqual(p2.returncode, 0, "Unexpected error: " + repr(stderr)) @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_MAXIMIZE # Since Python is a console process, it won't be affected # by wShowWindow, but the argument should be silently # ignored subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) def test_creationflags(self): # creationflags argument CREATE_NEW_CONSOLE = 16 sys.stderr.write(" a DOS box should flash briefly ...\n") subprocess.call(sys.executable + ' -c "import time; time.sleep(0.25)"', creationflags=CREATE_NEW_CONSOLE) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], stdout=subprocess.PIPE, close_fds=True) def test_close_fds(self): # close file descriptors rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"], close_fds=True) self.assertEqual(rc, 47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn("physalis", p.stdout.read()) def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn("physalis", p.stdout.read()) def test_call_string(self): # call() function with string argument on Windows rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) def _kill_process(self, method, *args): # Some win32 buildbot raises EOFError if stdin is inherited p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, '') returncode = p.wait() self.assertNotEqual(returncode, 0) def _kill_dead_process(self, method, *args): p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() sys.exit(42) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') rc = p.wait() self.assertEqual(rc, 42) def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) def test_kill(self): self._kill_process('kill') def test_terminate(self): self._kill_process('terminate') def test_send_signal_dead(self): self._kill_dead_process('send_signal', signal.SIGTERM) def test_kill_dead(self): self._kill_dead_process('kill') def test_terminate_dead(self): self._kill_dead_process('terminate') @unittest.skipUnless(getattr(subprocess, '_has_poll', False), "poll system call not supported") class ProcessTestCaseNoPoll(ProcessTestCase): def setUp(self): subprocess._has_poll = False ProcessTestCase.setUp(self) def tearDown(self): subprocess._has_poll = True ProcessTestCase.tearDown(self) class HelperFunctionTests(unittest.TestCase): @unittest.skipIf(mswindows, "errno and EINTR make no sense on windows") def test_eintr_retry_call(self): record_calls = [] def fake_os_func(*args): record_calls.append(args) if len(record_calls) == 2: raise OSError(errno.EINTR, "fake interrupted system call") return tuple(reversed(args)) self.assertEqual((999, 256), subprocess._eintr_retry_call(fake_os_func, 256, 999)) self.assertEqual([(256, 999)], record_calls) # This time there will be an EINTR so it will loop once. self.assertEqual((666,), subprocess._eintr_retry_call(fake_os_func, 666)) self.assertEqual([(256, 999), (666,), (666,)], record_calls) @unittest.skipUnless(mswindows, "mswindows only") class CommandsWithSpaces (BaseTestCase): def setUp(self): super(CommandsWithSpaces, self).setUp() f, fname = mkstemp(".py", "te st") self.fname = fname.lower () os.write(f, b"import sys;" b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))" ) os.close(f) def tearDown(self): os.remove(self.fname) super(CommandsWithSpaces, self).tearDown() def with_spaces(self, *args, **kwargs): kwargs['stdout'] = subprocess.PIPE p = subprocess.Popen(*args, **kwargs) self.addCleanup(p.stdout.close) self.assertEqual( p.stdout.read ().decode("mbcs"), "2 [%r, 'ab cd']" % self.fname ) def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd"), shell=1) def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1) def test_noshell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd")) def test_noshell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"]) def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, ProcessTestCaseNoPoll, HelperFunctionTests, CommandsWithSpaces) test_support.run_unittest(*unit_tests) test_support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_telnetlib.py0000644000076500000000000003730012666555342022365 0ustar jmaddenwheel00000000000000import socket import telnetlib import time import Queue import unittest from unittest import TestCase from test import test_support threading = test_support.import_module('threading') HOST = test_support.HOST EOF_sigil = object() def server(evt, serv, dataq=None): """ Open a tcp server in three steps 1) set evt to true to let the parent know we are ready 2) [optional] if is not False, write the list of data from dataq.get() to the socket. """ serv.listen(5) evt.set() try: conn, addr = serv.accept() if dataq: data = '' new_data = dataq.get(True, 0.5) dataq.task_done() for item in new_data: if item == EOF_sigil: break if type(item) in [int, float]: time.sleep(item) else: data += item written = conn.send(data) data = data[written:] conn.close() except socket.timeout: pass finally: serv.close() class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(60) # Safety net. Look issue 11812 self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock)) self.thread.setDaemon(True) self.thread.start() self.evt.wait() def tearDown(self): self.thread.join() def testBasic(self): # connects telnet = telnetlib.Telnet(HOST, self.port) telnet.sock.close() def testTimeoutDefault(self): self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet(HOST, self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutNone(self): # None, having other default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: telnet = telnetlib.Telnet(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) self.assertTrue(telnet.sock.gettimeout() is None) telnet.sock.close() def testTimeoutValue(self): telnet = telnetlib.Telnet(HOST, self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testTimeoutOpen(self): telnet = telnetlib.Telnet() telnet.open(HOST, self.port, timeout=30) self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() def testGetters(self): # Test telnet getter methods telnet = telnetlib.Telnet(HOST, self.port, timeout=30) t_sock = telnet.sock self.assertEqual(telnet.get_socket(), t_sock) self.assertEqual(telnet.fileno(), t_sock.fileno()) telnet.sock.close() def _read_setUp(self): self.evt = threading.Event() self.dataq = Queue.Queue() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq)) self.thread.start() self.evt.wait() def _read_tearDown(self): self.thread.join() class ReadTests(TestCase): setUp = _read_setUp tearDown = _read_tearDown # use a similar approach to testing timeouts as test_timeout.py # these will never pass 100% but make the fuzz big enough that it is rare block_long = 0.6 block_short = 0.3 def test_read_until_A(self): """ read_until(expected, [timeout]) Read until the expected string has been seen, or a timeout is hit (default is no timeout); may block. """ want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_until_B(self): # test the timeout - it does NOT raise socket.timeout want = ['hello', self.block_long, 'not seen', EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_until('not seen', self.block_short) self.assertEqual(data, want[0]) self.assertEqual(telnet.read_all(), 'not seen') def test_read_until_with_poll(self): """Use select.poll() to implement telnet.read_until().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) if not telnet._has_poll: raise unittest.SkipTest('select.poll() is required') telnet._has_poll = True self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_until_with_select(self): """Use select.select() to implement telnet.read_until().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) telnet._has_poll = False self.dataq.join() data = telnet.read_until('match') self.assertEqual(data, ''.join(want[:-2])) def test_read_all_A(self): """ read_all() Read all data until EOF; may block. """ want = ['x' * 500, 'y' * 500, 'z' * 500, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_all() self.assertEqual(data, ''.join(want[:-1])) def _test_blocking(self, func): self.dataq.put([self.block_long, EOF_sigil]) self.dataq.join() start = time.time() data = func() self.assertTrue(self.block_short <= time.time() - start) def test_read_all_B(self): self._test_blocking(telnetlib.Telnet(HOST, self.port).read_all) def test_read_all_C(self): self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() telnet.read_all() telnet.read_all() # shouldn't raise def test_read_some_A(self): """ read_some() Read at least one byte or EOF; may block. """ # test 'at least one byte' want = ['x' * 500, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() data = telnet.read_all() self.assertTrue(len(data) >= 1) def test_read_some_B(self): # test EOF self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() self.assertEqual('', telnet.read_some()) def test_read_some_C(self): self._test_blocking(telnetlib.Telnet(HOST, self.port).read_some) def _test_read_any_eager_A(self, func_name): """ read_very_eager() Read all data available already queued or on the socket, without blocking. """ want = [self.block_long, 'x' * 100, 'y' * 100, EOF_sigil] expects = want[1] + want[2] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() func = getattr(telnet, func_name) data = '' while True: try: data += func() self.assertTrue(expects.startswith(data)) except EOFError: break self.assertEqual(expects, data) def _test_read_any_eager_B(self, func_name): # test EOF self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) func = getattr(telnet, func_name) self.assertRaises(EOFError, func) # read_eager and read_very_eager make the same gaurantees # (they behave differently but we only test the gaurantees) def test_read_very_eager_A(self): self._test_read_any_eager_A('read_very_eager') def test_read_very_eager_B(self): self._test_read_any_eager_B('read_very_eager') def test_read_eager_A(self): self._test_read_any_eager_A('read_eager') def test_read_eager_B(self): self._test_read_any_eager_B('read_eager') # NB -- we need to test the IAC block which is mentioned in the docstring # but not in the module docs def _test_read_any_lazy_B(self, func_name): self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() func = getattr(telnet, func_name) telnet.fill_rawq() self.assertRaises(EOFError, func) def test_read_lazy_A(self): want = ['x' * 100, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) self.assertEqual('', telnet.read_lazy()) data = '' while True: try: read_data = telnet.read_lazy() data += read_data if not read_data: telnet.fill_rawq() except EOFError: break self.assertTrue(want[0].startswith(data)) self.assertEqual(data, want[0]) def test_read_lazy_B(self): self._test_read_any_lazy_B('read_lazy') def test_read_very_lazy_A(self): want = ['x' * 100, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() time.sleep(self.block_short) self.assertEqual('', telnet.read_very_lazy()) data = '' while True: try: read_data = telnet.read_very_lazy() except EOFError: break data += read_data if not read_data: telnet.fill_rawq() self.assertEqual('', telnet.cookedq) telnet.process_rawq() self.assertTrue(want[0].startswith(data)) self.assertEqual(data, want[0]) def test_read_very_lazy_B(self): self._test_read_any_lazy_B('read_very_lazy') class nego_collector(object): def __init__(self, sb_getter=None): self.seen = '' self.sb_getter = sb_getter self.sb_seen = '' def do_nego(self, sock, cmd, opt): self.seen += cmd + opt if cmd == tl.SE and self.sb_getter: sb_data = self.sb_getter() self.sb_seen += sb_data tl = telnetlib class OptionTests(TestCase): setUp = _read_setUp tearDown = _read_tearDown # RFC 854 commands cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP] def _test_command(self, data): """ helper for testing IAC + cmd """ self.setUp() self.dataq.put(data) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() nego = nego_collector() telnet.set_option_negotiation_callback(nego.do_nego) txt = telnet.read_all() cmd = nego.seen self.assertTrue(len(cmd) > 0) # we expect at least one command self.assertIn(cmd[0], self.cmds) self.assertEqual(cmd[1], tl.NOOPT) self.assertEqual(len(''.join(data[:-1])), len(txt + cmd)) nego.sb_getter = None # break the nego => telnet cycle self.tearDown() def test_IAC_commands(self): # reset our setup self.dataq.put([EOF_sigil]) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() self.tearDown() for cmd in self.cmds: self._test_command(['x' * 100, tl.IAC + cmd, 'y'*100, EOF_sigil]) self._test_command(['x' * 10, tl.IAC + cmd, 'y'*10, EOF_sigil]) self._test_command([tl.IAC + cmd, EOF_sigil]) # all at once self._test_command([tl.IAC + cmd for (cmd) in self.cmds] + [EOF_sigil]) self.assertEqual('', telnet.read_sb_data()) def test_SB_commands(self): # RFC 855, subnegotiations portion send = [tl.IAC + tl.SB + tl.IAC + tl.SE, tl.IAC + tl.SB + tl.IAC + tl.IAC + tl.IAC + tl.SE, tl.IAC + tl.SB + tl.IAC + tl.IAC + 'aa' + tl.IAC + tl.SE, tl.IAC + tl.SB + 'bb' + tl.IAC + tl.IAC + tl.IAC + tl.SE, tl.IAC + tl.SB + 'cc' + tl.IAC + tl.IAC + 'dd' + tl.IAC + tl.SE, EOF_sigil, ] self.dataq.put(send) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() nego = nego_collector(telnet.read_sb_data) telnet.set_option_negotiation_callback(nego.do_nego) txt = telnet.read_all() self.assertEqual(txt, '') want_sb_data = tl.IAC + tl.IAC + 'aabb' + tl.IAC + 'cc' + tl.IAC + 'dd' self.assertEqual(nego.sb_seen, want_sb_data) self.assertEqual('', telnet.read_sb_data()) nego.sb_getter = None # break the nego => telnet cycle class ExpectTests(TestCase): def setUp(self): self.evt = threading.Event() self.dataq = Queue.Queue() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq)) self.thread.start() self.evt.wait() def tearDown(self): self.thread.join() # use a similar approach to testing timeouts as test_timeout.py # these will never pass 100% but make the fuzz big enough that it is rare block_long = 0.6 block_short = 0.3 def test_expect_A(self): """ expect(expected, [timeout]) Read until the expected string has been seen, or a timeout is hit (default is no timeout); may block. """ want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_expect_B(self): # test the timeout - it does NOT raise socket.timeout want = ['hello', self.block_long, 'not seen', EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) self.dataq.join() (_,_,data) = telnet.expect(['not seen'], self.block_short) self.assertEqual(data, want[0]) self.assertEqual(telnet.read_all(), 'not seen') def test_expect_with_poll(self): """Use select.poll() to implement telnet.expect().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) if not telnet._has_poll: raise unittest.SkipTest('select.poll() is required') telnet._has_poll = True self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_expect_with_select(self): """Use select.select() to implement telnet.expect().""" want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] self.dataq.put(want) telnet = telnetlib.Telnet(HOST, self.port) telnet._has_poll = False self.dataq.join() (_,_,data) = telnet.expect(['match']) self.assertEqual(data, ''.join(want[:-2])) def test_main(verbose=None): test_support.run_unittest(GeneralTests, ReadTests, OptionTests, ExpectTests) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_thread.py0000644000076500000000000002017012666555342021647 0ustar jmaddenwheel00000000000000import os import unittest import random from test import test_support thread = test_support.import_module('thread') import time import sys import weakref from test import lock_tests NUMTASKS = 10 NUMTRIPS = 3 _print_mutex = thread.allocate_lock() def verbose_print(arg): """Helper function for printing out debugging output.""" if test_support.verbose: with _print_mutex: print arg class BasicThreadTest(unittest.TestCase): def setUp(self): self.done_mutex = thread.allocate_lock() self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() self.created = 0 self.running = 0 self.next_ident = 0 class ThreadRunningTests(BasicThreadTest): def newtask(self): with self.running_mutex: self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) self.created += 1 self.running += 1 def task(self, ident): with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay*1e6))) time.sleep(delay) verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): # Basic test for thread creation. for i in range(NUMTASKS): self.newtask() verbose_print("waiting for tasks to complete...") self.done_mutex.acquire() verbose_print("all tasks done") def test_stack_size(self): # Various stack size tests. self.assertEqual(thread.stack_size(), 0, "initial stack size is not 0") thread.stack_size(0) self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default") @unittest.skipIf(os.name not in ("nt", "os2", "posix"), 'test meant for nt, os2, and posix') def test_nt_and_posix_stack_size(self): try: thread.stack_size(4096) except ValueError: verbose_print("caught expected ValueError setting " "stack_size(4096)") except thread.error: self.skipTest("platform does not support changing thread stack " "size") fail_msg = "stack_size(%d) failed - should succeed" for tss in (262144, 0x100000, 0): thread.stack_size(tss) self.assertEqual(thread.stack_size(), tss, fail_msg % tss) verbose_print("successfully set stack_size(%d)" % tss) for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 self.created = 0 for i in range(NUMTASKS): self.newtask() verbose_print("waiting for all tasks to complete") self.done_mutex.acquire() verbose_print("all tasks done") thread.stack_size(0) def test__count(self): # Test the _count() function. orig = thread._count() mut = thread.allocate_lock() mut.acquire() started = [] def task(): started.append(None) mut.acquire() mut.release() thread.start_new_thread(task, ()) while not started: time.sleep(0.01) self.assertEqual(thread._count(), orig + 1) # Allow the task to finish. mut.release() # The only reliable way to be sure that the thread ended from the # interpreter's point of view is to wait for the function object to be # destroyed. done = [] wr = weakref.ref(task, lambda _: done.append(None)) del task while not done: time.sleep(0.01) test_support.gc_collect() self.assertEqual(thread._count(), orig) def test_save_exception_state_on_error(self): # See issue #14474 def task(): started.release() raise SyntaxError def mywrite(self, *args): try: raise ValueError except ValueError: pass real_write(self, *args) c = thread._count() started = thread.allocate_lock() with test_support.captured_output("stderr") as stderr: real_write = stderr.write stderr.write = mywrite started.acquire() thread.start_new_thread(task, ()) started.acquire() while thread._count() > c: time.sleep(0.01) self.assertIn("Traceback", stderr.getvalue()) class Barrier: def __init__(self, num_threads): self.num_threads = num_threads self.waiting = 0 self.checkin_mutex = thread.allocate_lock() self.checkout_mutex = thread.allocate_lock() self.checkout_mutex.acquire() def enter(self): self.checkin_mutex.acquire() self.waiting = self.waiting + 1 if self.waiting == self.num_threads: self.waiting = self.num_threads - 1 self.checkout_mutex.release() return self.checkin_mutex.release() self.checkout_mutex.acquire() self.waiting = self.waiting - 1 if self.waiting == 0: self.checkin_mutex.release() return self.checkout_mutex.release() class BarrierTest(BasicThreadTest): def test_barrier(self): self.bar = Barrier(NUMTASKS) self.running = NUMTASKS for i in range(NUMTASKS): thread.start_new_thread(self.task2, (i,)) verbose_print("waiting for tasks to end") self.done_mutex.acquire() verbose_print("tasks done") def task2(self, ident): for i in range(NUMTRIPS): if ident == 0: # give it a good chance to enter the next # barrier before the others are all out # of the current one delay = 0 else: with self.random_mutex: delay = random.random() / 10000.0 verbose_print("task %s will run for %sus" % (ident, round(delay * 1e6))) time.sleep(delay) verbose_print("task %s entering %s" % (ident, i)) self.bar.enter() verbose_print("task %s leaving barrier" % ident) with self.running_mutex: self.running -= 1 # Must release mutex before releasing done, else the main thread can # exit and set mutex to None as part of global teardown; then # mutex.release() raises AttributeError. finished = self.running == 0 if finished: self.done_mutex.release() class LockTests(lock_tests.LockTests): locktype = thread.allocate_lock class TestForkInThread(unittest.TestCase): def setUp(self): self.read_fd, self.write_fd = os.pipe() @unittest.skipIf(sys.platform.startswith('win'), "This test is only appropriate for POSIX-like systems.") @test_support.reap_threads def test_forkinthread(self): def thread1(): try: pid = os.fork() # fork in a thread except RuntimeError: sys.exit(0) # exit the child if pid == 0: # child os.close(self.read_fd) os.write(self.write_fd, "OK") sys.exit(0) else: # parent os.close(self.write_fd) thread.start_new_thread(thread1, ()) self.assertEqual(os.read(self.read_fd, 2), "OK", "Unable to fork() in thread") def tearDown(self): try: os.close(self.read_fd) except OSError: pass try: os.close(self.write_fd) except OSError: pass def test_main(): test_support.run_unittest(ThreadRunningTests, BarrierTest, LockTests, TestForkInThread) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_threading.py0000644000076500000000000010277112666555342022355 0ustar jmaddenwheel00000000000000# Very rudimentary test of threading module import test.test_support from test.test_support import verbose, cpython_only from test.script_helper import assert_python_ok import random import re import sys thread = test.test_support.import_module('thread') threading = test.test_support.import_module('threading') import time import unittest import weakref import os import subprocess try: import _testcapi except ImportError: _testcapi = None from test import lock_tests # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print 'task %s will run for %.1f usec' % ( self.name, delay * 1e6) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print self.nrunning.get(), 'tasks are running' self.testcase.assertTrue(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print 'task', self.name, 'done' with self.mutex: self.nrunning.dec() self.testcase.assertTrue(self.nrunning.get() >= 0) if verbose: print '%s is finished. %d tasks are running' % ( self.name, self.nrunning.get()) class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test.test_support.threading_setup() def tearDown(self): test.test_support.threading_cleanup(*self._threads) test.test_support.reap_children() class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) self.assertEqual(t.ident, None) self.assertTrue(re.match('', repr(t))) t.start() if verbose: print 'waiting for all tasks to complete' for t in threads: t.join(NUMTASKS) self.assertTrue(not t.is_alive()) self.assertNotEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assertTrue(re.match('', repr(t))) if verbose: print 'all tasks done' self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertFalse(threading.currentThread().ident is None) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print 'with 256kB thread stack size...' try: threading.stack_size(262144) except thread.error: self.skipTest('platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print 'with 1MB thread stack size...' try: threading.stack_size(0x100000) except thread.error: self.skipTest('platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assertIn(tid, threading._active) self.assertIsInstance(threading._active[tid], threading._DummyThread) del threading._active[tid] # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. @test.test_support.cpython_only def test_PyThreadState_SetAsyncExc(self): try: import ctypes except ImportError: self.skipTest('requires ctypes') set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # First check it works when setting the exception from the same thread. tid = thread.get_ident() try: result = set_async_exc(ctypes.c_long(tid), exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: pass except AsyncExc: pass else: # This code is unreachable but it reflects the intent. If we wanted # to be smarter the above loop wouldn't be infinite. self.fail("AsyncExc not raised") try: self.assertEqual(result, 1) # one thread state modified except UnboundLocalError: # The exception was raised too quickly for us to get the result. pass # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = thread.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print " started worker thread" # Try a thread id that doesn't make sense. if verbose: print " trying nonsensical thread id" result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print " waiting for worker thread to get started" ret = worker_started.wait() self.assertTrue(ret) if verbose: print " verifying worker hasn't exited" self.assertTrue(not t.finished) if verbose: print " attempting to raise asynch exception in worker" result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print " waiting for worker to say it caught the exception" worker_saw_exception.wait(timeout=10) self.assertTrue(t.finished) if verbose: print " all OK -- joining worker" if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise thread.error() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(thread.error, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread @test.test_support.cpython_only def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. try: import ctypes except ImportError: self.skipTest('requires ctypes') rc = subprocess.call([sys.executable, "-c", """if 1: import ctypes, sys, time, thread # This lock is used as a simple event variable. ready = thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """]) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print 'program blocked; aborting' os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) stdout, stderr = p.communicate() rc = p.returncode self.assertFalse(rc == 2, "interpreted was blocked") self.assertTrue(rc == 0, "Unexpected error: " + repr(stderr)) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown p = subprocess.Popen([sys.executable, "-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print "Woke up, sleep function is:", sleep threading.Thread(target=child).start() raise SystemExit """], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) stdout, stderr = p.communicate() self.assertEqual(stdout.strip(), "Woke up, sleep function is: ") stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getcheckinterval() try: for i in xrange(1, 100): # Try a couple times at each thread-switching interval # to get more interleavings. sys.setcheckinterval(i // 5) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertNotIn(t, l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setcheckinterval(old_interval) @test.test_support.cpython_only def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertEqual(None, weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertEqual(None, weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') def test_dummy_thread_after_fork(self): # Issue #14308: a dummy thread in the active list doesn't mess up # the after-fork mechanism. code = """if 1: import thread, threading, os, time def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: os.wait() """ _, out, err = assert_python_ok("-c", code) self.assertEqual(out, '') self.assertEqual(err, '') @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_is_alive_after_fork(self): # Try hard to trigger #18418: is_alive() could sometimes be True on # threads that vanished after a fork. old_interval = sys.getcheckinterval() # Make the bug more likely to manifest. sys.setcheckinterval(10) try: for i in range(20): t = threading.Thread(target=lambda: None) t.start() pid = os.fork() if pid == 0: os._exit(1 if t.is_alive() else 0) else: t.join() pid, status = os.waitpid(pid, 0) self.assertEqual(0, status) finally: sys.setcheckinterval(old_interval) def test_BoundedSemaphore_limit(self): # BoundedSemaphore should raise ValueError if released too often. for limit in range(1, 10): bs = threading.BoundedSemaphore(limit) threads = [threading.Thread(target=bs.acquire) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() threads = [threading.Thread(target=bs.release) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() self.assertRaises(ValueError, bs.release) class ThreadJoinOnShutdown(BaseTestCase): # Between fork() and exec(), only async-safe functions are allowed (issues # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', 'os2emx') def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print 'end of thread' # stdout is fully buffered because not a tty, we have to flush # before exit. sys.stdout.flush() \n""" + script p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().replace('\r', '') p.stdout.close() self.assertEqual(data, "end of main\nend of thread\n") self.assertFalse(rc == 2, "interpreter was blocked") self.assertTrue(rc == 0, "Unexpected error") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print 'end of main' """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print 'end of main' """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print 'end of main' t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) def assertScriptHasOutput(self, script, expected_output): p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().decode().replace('\r', '') self.assertEqual(rc, 0, "Unexpected error") self.assertEqual(data, expected_output) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_4_joining_across_fork_in_worker_thread(self): # There used to be a possible deadlock when forking from a child # thread. See http://bugs.python.org/issue6643. # The script takes the following steps: # - The main thread in the parent process starts a new thread and then # tries to join it. # - The join operation acquires the Lock inside the thread's _block # Condition. (See threading.py:Thread.join().) # - We stub out the acquire method on the condition to force it to wait # until the child thread forks. (See LOCK ACQUIRED HERE) # - The child thread forks. (See LOCK HELD and WORKER THREAD FORKS # HERE) # - The main thread of the parent process enters Condition.wait(), # which releases the lock on the child thread. # - The child process returns. Without the necessary fix, when the # main thread of the child process (which used to be the child thread # in the parent process) attempts to exit, it will try to acquire the # lock in the Thread._block Condition object and hang, because the # lock was held across the fork. script = """if 1: import os, time, threading finish_join = False start_fork = False def worker(): # Wait until this thread's lock is acquired before forking to # create the deadlock. global finish_join while not start_fork: time.sleep(0.01) # LOCK HELD: Main thread holds lock across this call. childpid = os.fork() finish_join = True if childpid != 0: # Parent process just waits for child. os.waitpid(childpid, 0) # Child process should just return. w = threading.Thread(target=worker) # Stub out the private condition variable's lock acquire method. # This acquires the lock and then waits until the child has forked # before returning, which will release the lock soon after. If # someone else tries to fix this test case by acquiring this lock # before forking instead of resetting it, the test case will # deadlock when it shouldn't. condition = w._block orig_acquire = condition.acquire call_count_lock = threading.Lock() call_count = 0 def my_acquire(): global call_count global start_fork orig_acquire() # LOCK ACQUIRED HERE start_fork = True if call_count == 0: while not finish_join: time.sleep(0.01) # WORKER THREAD FORKS HERE with call_count_lock: call_count += 1 condition.acquire = my_acquire w.start() w.join() print('end of main') """ self.assertScriptHasOutput(script, "end of main\n") @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_5_clear_waiter_locks_to_avoid_crash(self): # Check that a spawned thread that forks doesn't segfault on certain # platforms, namely OS X. This used to happen if there was a waiter # lock in the thread's condition variable's waiters list. Even though # we know the lock will be held across the fork, it is not safe to # release locks held across forks on all platforms, so releasing the # waiter lock caused a segfault on OS X. Furthermore, since locks on # OS X are (as of this writing) implemented with a mutex + condition # variable instead of a semaphore, while we know that the Python-level # lock will be acquired, we can't know if the internal mutex will be # acquired at the time of the fork. script = """if True: import os, time, threading start_fork = False def worker(): # Wait until the main thread has attempted to join this thread # before continuing. while not start_fork: time.sleep(0.01) childpid = os.fork() if childpid != 0: # Parent process just waits for child. (cpid, rc) = os.waitpid(childpid, 0) assert cpid == childpid assert rc == 0 print('end of worker thread') else: # Child process should just return. pass w = threading.Thread(target=worker) # Stub out the private condition variable's _release_save method. # This releases the condition's lock and flips the global that # causes the worker to fork. At this point, the problematic waiter # lock has been acquired once by the waiter and has been put onto # the waiters list. condition = w._block orig_release_save = condition._release_save def my_release_save(): global start_fork orig_release_save() # Waiter lock held here, condition lock released. start_fork = True condition._release_save = my_release_save w.start() w.join() print('end of main thread') """ output = "end of worker thread\nend of main thread\n" self.assertScriptHasOutput(script, output) @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") @unittest.skipIf(sys.pypy_version_info[:2] >= (2,6), "This test was removed in CPython 2.7.9, and fails under PyPy 2.6 " "with 'RuntimeError: stream lock is not held' in random_io") def test_6_daemon_threads(self): # Check that a daemon thread cannot crash the interpreter on shutdown # by manipulating internal structures that are being disposed of in # the main thread. script = """if True: import os import random import sys import time import threading thread_has_run = set() def random_io(): '''Loop for a while sleeping random tiny amounts and doing some I/O.''' while True: in_f = open(os.__file__, 'rb') stuff = in_f.read(200) null_f = open(os.devnull, 'wb') null_f.write(stuff) time.sleep(random.random() / 1995) null_f.close() in_f.close() thread_has_run.add(threading.current_thread()) def main(): count = 0 for _ in range(40): new_thread = threading.Thread(target=random_io) new_thread.daemon = True new_thread.start() count += 1 while len(thread_has_run) < count: time.sleep(0.001) # Trigger process shutdown sys.exit(0) main() """ rc, out, err = assert_python_ok('-c', script) self.assertFalse(err) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): # Issue #13817: fork() would deadlock in a multithreaded program with # the ad-hoc TLS implementation. def do_fork_and_wait(): # just fork a child process and wait it pid = os.fork() if pid > 0: os.waitpid(pid, 0) else: os._exit(0) # start a bunch of threads that will fork() child processes threads = [] for i in range(16): t = threading.Thread(target=do_fork_and_wait) threads.append(t) t.start() for t in threads: t.join() @cpython_only @unittest.skipIf(_testcapi is None, "need _testcapi module") def test_frame_tstate_tracing(self): # Issue #14432: Crash when a generator is created in a C thread that is # destroyed while the generator is still used. The issue was that a # generator contains a frame, and the frame kept a reference to the # Python state of the destroyed C thread. The crash occurs when a trace # function is setup. def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "genereator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call _testcapi.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class RLockTests(lock_tests.RLockTests): locktype = staticmethod(threading.RLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) @unittest.skipUnless(sys.platform == 'darwin', 'test macosx problem') def test_recursion_limit(self): # Issue 9670 # test that excessive recursion within a non-main thread causes # an exception rather than crashing the interpreter on platforms # like Mac OS X or FreeBSD which have small default stack sizes # for threads script = """if True: import threading def recurse(): return recurse() def outer(): try: recurse() except RuntimeError: pass w = threading.Thread(target=outer) w.start() w.join() print('end of main thread') """ expected_output = "end of main thread\n" p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) stdout, stderr = p.communicate() data = stdout.decode().replace('\r', '') self.assertEqual(p.returncode, 0, "Unexpected error") self.assertEqual(data, expected_output) def test_main(): test.test_support.run_unittest(LockTests, RLockTests, EventTests, ConditionAsRLockTests, ConditionTests, SemaphoreTests, BoundedSemaphoreTests, ThreadTests, ThreadJoinOnShutdown, ThreadingExceptionTests, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_threading_local.py0000644000076500000000000001520112666555342023516 0ustar jmaddenwheel00000000000000import unittest from doctest import DocTestSuite from test import test_support import weakref import gc # Modules under test _thread = test_support.import_module('thread') threading = test_support.import_module('threading') import _threading_local class Weak(object): pass def target(local, weaklist): weak = Weak() local.weak = weak weaklist.append(weakref.ref(weak)) class BaseLocalTest: def test_local_refs(self): self._local_refs(20) self._local_refs(50) self._local_refs(100) def _local_refs(self, n): local = self._local() weaklist = [] for i in range(n): t = threading.Thread(target=target, args=(local, weaklist)) t.start() t.join() del t gc.collect() gc.collect() # needed when run through gevent; why? self.assertEqual(len(weaklist), n) # XXX _threading_local keeps the local of the last stopped thread alive. deadlist = [weak for weak in weaklist if weak() is None] self.assertIn(len(deadlist), (n-1, n)) # Assignment to the same thread local frees it sometimes (!) local.someothervar = None gc.collect() deadlist = [weak for weak in weaklist if weak() is None] self.assertIn(len(deadlist), (n-1, n), (n, len(deadlist))) def test_derived(self): # Issue 3088: if there is a threads switch inside the __init__ # of a threading.local derived class, the per-thread dictionary # is created but not correctly set on the object. # The first member set may be bogus. import time class Local(self._local): def __init__(self): time.sleep(0.01) local = Local() def f(i): local.x = i # Simply check that the variable is correctly set self.assertEqual(local.x, i) threads= [] for i in range(10): t = threading.Thread(target=f, args=(i,)) t.start() threads.append(t) for t in threads: t.join() def test_derived_cycle_dealloc(self): # http://bugs.python.org/issue6990 class Local(self._local): pass locals = None passed = [False] e1 = threading.Event() e2 = threading.Event() def f(): # 1) Involve Local in a cycle cycle = [Local()] cycle.append(cycle) cycle[0].foo = 'bar' # 2) GC the cycle (triggers threadmodule.c::local_clear # before local_dealloc) del cycle gc.collect() e1.set() e2.wait() # 4) New Locals should be empty passed[0] = all(not hasattr(local, 'foo') for local in locals) t = threading.Thread(target=f) t.start() e1.wait() # 3) New Locals should recycle the original's address. Creating # them in the thread overwrites the thread state and avoids the # bug locals = [Local() for i in range(10)] e2.set() t.join() self.assertTrue(passed[0]) def test_arguments(self): # Issue 1522237 from thread import _local as local from _threading_local import local as py_local for cls in (local, py_local): class MyLocal(cls): def __init__(self, *args, **kwargs): pass MyLocal(a=1) MyLocal(1) self.assertRaises(TypeError, cls, a=1) self.assertRaises(TypeError, cls, 1) def _test_one_class(self, c): self._failed = "No error message set or cleared." obj = c() e1 = threading.Event() e2 = threading.Event() def f1(): obj.x = 'foo' obj.y = 'bar' del obj.y e1.set() e2.wait() def f2(): try: foo = obj.x except AttributeError: # This is expected -- we haven't set obj.x in this thread yet! self._failed = "" # passed else: self._failed = ('Incorrectly got value %r from class %r\n' % (foo, c)) sys.stderr.write(self._failed) t1 = threading.Thread(target=f1) t1.start() e1.wait() t2 = threading.Thread(target=f2) t2.start() t2.join() # The test is done; just let t1 know it can exit, and wait for it. e2.set() t1.join() self.assertFalse(self._failed, self._failed) def test_threading_local(self): self._test_one_class(self._local) def test_threading_local_subclass(self): class LocalSubclass(self._local): """To test that subclasses behave properly.""" self._test_one_class(LocalSubclass) def _test_dict_attribute(self, cls): obj = cls() obj.x = 5 self.assertEqual(obj.__dict__, {'x': 5}) if test_support.check_impl_detail(): with self.assertRaises(AttributeError): obj.__dict__ = {} with self.assertRaises(AttributeError): del obj.__dict__ def test_dict_attribute(self): self._test_dict_attribute(self._local) def test_dict_attribute_subclass(self): class LocalSubclass(self._local): """To test that subclasses behave properly.""" self._test_dict_attribute(LocalSubclass) class ThreadLocalTest(unittest.TestCase, BaseLocalTest): _local = _thread._local # Fails for the pure Python implementation def test_cycle_collection(self): class X: pass x = X() x.local = self._local() x.local.x = x wr = weakref.ref(x) del x gc.collect() self.assertIs(wr(), None) class PyThreadingLocalTest(unittest.TestCase, BaseLocalTest): _local = _threading_local.local def test_main(): suite = unittest.TestSuite() suite.addTest(DocTestSuite('_threading_local')) suite.addTest(unittest.makeSuite(ThreadLocalTest)) suite.addTest(unittest.makeSuite(PyThreadingLocalTest)) try: from thread import _local except ImportError: pass else: import _threading_local local_orig = _threading_local.local def setUp(test): _threading_local.local = _local def tearDown(test): _threading_local.local = local_orig suite.addTest(DocTestSuite('_threading_local', setUp=setUp, tearDown=tearDown) ) test_support.run_unittest(suite) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_timeout.py0000644000076500000000000001566412666555342022102 0ustar jmaddenwheel00000000000000"""Unit tests for socket timeout feature.""" import unittest from test import test_support # This requires the 'network' resource as given on the regrtest command line. skip_expected = not test_support.is_resource_enabled('network') import time import socket class CreationTestCase(unittest.TestCase): """Test case for socket.gettimeout() and socket.settimeout()""" def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): self.sock.close() def testObjectCreation(self): # Test Socket creation self.assertEqual(self.sock.gettimeout(), None, "timeout not disabled by default") def testFloatReturnValue(self): # Test return value of gettimeout() self.sock.settimeout(7.345) self.assertEqual(self.sock.gettimeout(), 7.345) self.sock.settimeout(3) self.assertEqual(self.sock.gettimeout(), 3) self.sock.settimeout(None) self.assertEqual(self.sock.gettimeout(), None) def testReturnType(self): # Test return type of gettimeout() self.sock.settimeout(1) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) self.sock.settimeout(3.9) self.assertEqual(type(self.sock.gettimeout()), type(1.0)) def testTypeCheck(self): # Test type checking by settimeout() self.sock.settimeout(0) self.sock.settimeout(0L) self.sock.settimeout(0.0) self.sock.settimeout(None) self.assertRaises(TypeError, self.sock.settimeout, "") self.assertRaises(TypeError, self.sock.settimeout, u"") self.assertRaises(TypeError, self.sock.settimeout, ()) self.assertRaises(TypeError, self.sock.settimeout, []) self.assertRaises(TypeError, self.sock.settimeout, {}) self.assertRaises(TypeError, self.sock.settimeout, 0j) def testRangeCheck(self): # Test range checking by settimeout() self.assertRaises(ValueError, self.sock.settimeout, -1) self.assertRaises(ValueError, self.sock.settimeout, -1L) self.assertRaises(ValueError, self.sock.settimeout, -1.0) def testTimeoutThenBlocking(self): # Test settimeout() followed by setblocking() self.sock.settimeout(10) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.settimeout(10) self.sock.setblocking(0) self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) def testBlockingThenTimeout(self): # Test setblocking() followed by settimeout() self.sock.setblocking(0) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) self.sock.setblocking(1) self.sock.settimeout(1) self.assertEqual(self.sock.gettimeout(), 1) class TimeoutTestCase(unittest.TestCase): """Test case for socket.socket() timeout functions""" # There are a number of tests here trying to make sure that an operation # doesn't take too much longer than expected. But competing machine # activity makes it inevitable that such tests will fail at times. # When fuzz was at 1.0, I (tim) routinely saw bogus failures on Win2K # and Win98SE. Boosting it to 2.0 helped a lot, but isn't a real # solution. fuzz = 2.0 def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addr_remote = ('www.python.org.', 80) self.localhost = '127.0.0.1' def tearDown(self): self.sock.close() def testConnectTimeout(self): # Choose a private address that is unlikely to exist to prevent # failures due to the connect succeeding before the timeout. # Use a dotted IP address to avoid including the DNS lookup time # with the connect time. This avoids failing the assertion that # the timeout occurred fast enough. addr = ('10.0.0.0', 12345) # Test connect() timeout _timeout = 0.001 self.sock.settimeout(_timeout) _t1 = time.time() self.assertRaises(socket.error, self.sock.connect, addr) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is more than %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvTimeout(self): # Test recv() timeout _timeout = 0.02 with test_support.transient_internet(self.addr_remote[0]): self.sock.connect(self.addr_remote) self.sock.settimeout(_timeout) _t1 = time.time() self.assertRaises(socket.timeout, self.sock.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testAcceptTimeout(self): # Test accept() timeout _timeout = 2 self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) self.sock.listen(5) _t1 = time.time() self.assertRaises(socket.error, self.sock.accept) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) def testRecvfromTimeout(self): # Test recvfrom() timeout _timeout = 2 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(_timeout) # Prevent "Address already in use" socket exceptions test_support.bind_port(self.sock, self.localhost) _t1 = time.time() self.assertRaises(socket.error, self.sock.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) self.assertTrue(_delta < _timeout + self.fuzz, "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) @unittest.skip('test not implemented') def testSend(self): # Test send() timeout # couldn't figure out how to test it pass @unittest.skip('test not implemented') def testSendto(self): # Test sendto() timeout # couldn't figure out how to test it pass @unittest.skip('test not implemented') def testSendall(self): # Test sendall() timeout # couldn't figure out how to test it pass def test_main(): test_support.requires('network') test_support.run_unittest(CreationTestCase, TimeoutTestCase) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_urllib.py0000644000076500000000000010731112666555342021674 0ustar jmaddenwheel00000000000000"""Regresssion tests for urllib""" import urllib import httplib import unittest import os import sys import mimetools import tempfile import StringIO from test import test_support from base64 import b64encode def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr class FakeHTTPMixin(object): def fakehttp(self, fakedata): class FakeSocket(StringIO.StringIO): def sendall(self, data): FakeHTTPConnection.buf = data def makefile(self, *args, **kwds): return self def read(self, amt=None): if self.closed: return "" return StringIO.StringIO.read(self, amt) def readline(self, length=None): if self.closed: return "" return StringIO.StringIO.readline(self, length) class FakeHTTPConnection(httplib.HTTPConnection): # buffer to store data for verification in urlopen tests. buf = "" def connect(self): self.sock = FakeSocket(fakedata) assert httplib.HTTP._connection_class == httplib.HTTPConnection httplib.HTTP._connection_class = FakeHTTPConnection def unfakehttp(self): httplib.HTTP._connection_class = httplib.HTTPConnection class urlopen_FileTests(unittest.TestCase): """Test urlopen() opening a temporary file. Try to test as much functionality as possible so as to cut down on reliance on connecting to the Net for testing. """ def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ FILE = file(test_support.TESTFN, 'wb') try: FILE.write(self.text) finally: FILE.close() self.pathname = test_support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) def tearDown(self): """Shut down the open object""" self.returned_obj.close() os.remove(test_support.TESTFN) def test_interface(self): # Make sure object returned by urlopen() has the specified methods for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl", "getcode", "__iter__"): self.assertTrue(hasattr(self.returned_obj, attr), "object returned by urlopen() lacks %s attribute" % attr) def test_read(self): self.assertEqual(self.text, self.returned_obj.read()) def test_readline(self): self.assertEqual(self.text, self.returned_obj.readline()) self.assertEqual('', self.returned_obj.readline(), "calling readline() after exhausting the file did not" " return an empty string") def test_readlines(self): lines_list = self.returned_obj.readlines() self.assertEqual(len(lines_list), 1, "readlines() returned the wrong number of lines") self.assertEqual(lines_list[0], self.text, "readlines() returned improper text") def test_fileno(self): file_num = self.returned_obj.fileno() self.assertIsInstance(file_num, int, "fileno() did not return an int") self.assertEqual(os.read(file_num, len(self.text)), self.text, "Reading on the file descriptor returned by fileno() " "did not return the expected text") def test_close(self): # Test close() by calling it hear and then having it be called again # by the tearDown() method for the test self.returned_obj.close() def test_info(self): self.assertIsInstance(self.returned_obj.info(), mimetools.Message) def test_geturl(self): self.assertEqual(self.returned_obj.geturl(), self.pathname) def test_getcode(self): self.assertEqual(self.returned_obj.getcode(), None) def test_iter(self): # Test iterator # Don't need to count number of iterations since test would fail the # instant it returned anything beyond the first line from the # comparison for line in self.returned_obj.__iter__(): self.assertEqual(line, self.text) def test_relativelocalfile(self): self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname) class ProxyTests(unittest.TestCase): def setUp(self): # Records changes to env vars self.env = test_support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k) def tearDown(self): # Restore all proxy related env vars self.env.__exit__() del self.env def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin): """Test urlopen() opening a fake http connection.""" def test_read(self): self.fakehttp('Hello!') try: fp = urllib.urlopen("http://python.org/") self.assertEqual(fp.readline(), 'Hello!') self.assertEqual(fp.readline(), '') self.assertEqual(fp.geturl(), 'http://python.org/') self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() def test_url_fragment(self): # Issue #11703: geturl() omits fragments in the original URL. url = 'http://docs.python.org/library/urllib.html#OK' self.fakehttp('Hello!') try: fp = urllib.urlopen(url) self.assertEqual(fp.geturl(), url) finally: self.unfakehttp() def test_read_bogus(self): # urlopen() should raise IOError for many error codes. self.fakehttp('''HTTP/1.1 401 Authentication Required Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Type: text/html; charset=iso-8859-1 ''') try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_invalid_redirect(self): # urlopen() should raise IOError for many error codes. self.fakehttp("""HTTP/1.1 302 Found Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Location: file:README Connection: close Content-Type: text/html; charset=iso-8859-1 """) try: self.assertRaises(IOError, urllib.urlopen, "http://python.org/") finally: self.unfakehttp() def test_empty_socket(self): # urlopen() raises IOError if the underlying socket does not send any # data. (#1680230) self.fakehttp('') try: self.assertRaises(IOError, urllib.urlopen, 'http://something') finally: self.unfakehttp() def test_missing_localfile(self): self.assertRaises(IOError, urllib.urlopen, 'file://localhost/a/missing/file.py') fd, tmp_file = tempfile.mkstemp() tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/') self.assertTrue(os.path.exists(tmp_file)) try: fp = urllib.urlopen(tmp_fileurl) fp.close() finally: os.close(fd) os.unlink(tmp_file) self.assertFalse(os.path.exists(tmp_file)) self.assertRaises(IOError, urllib.urlopen, tmp_fileurl) def test_ftp_nonexisting(self): self.assertRaises(IOError, urllib.urlopen, 'ftp://localhost/not/existing/file.py') def test_userpass_inurl(self): self.fakehttp('Hello!') try: fakehttp_wrapper = httplib.HTTP._connection_class fp = urllib.urlopen("http://user:pass@python.org/") authorization = ("Authorization: Basic %s\r\n" % b64encode('user:pass')) # The authorization header must be in place self.assertIn(authorization, fakehttp_wrapper.buf) self.assertEqual(fp.readline(), "Hello!") self.assertEqual(fp.readline(), "") self.assertEqual(fp.geturl(), 'http://user:pass@python.org/') self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() def test_userpass_with_spaces_inurl(self): self.fakehttp('Hello!') try: url = "http://a b:c d@python.org/" fakehttp_wrapper = httplib.HTTP._connection_class authorization = ("Authorization: Basic %s\r\n" % b64encode('a b:c d')) fp = urllib.urlopen(url) # The authorization header must be in place self.assertIn(authorization, fakehttp_wrapper.buf) self.assertEqual(fp.readline(), "Hello!") self.assertEqual(fp.readline(), "") # the spaces are quoted in URL so no match self.assertNotEqual(fp.geturl(), url) self.assertEqual(fp.getcode(), 200) finally: self.unfakehttp() class urlretrieve_FileTests(unittest.TestCase): """Test urllib.urlretrieve() on local files""" def setUp(self): # Create a list of temporary files. Each item in the list is a file # name (absolute path or relative to the current working directory). # All files in this list will be deleted in the tearDown method. Note, # this only helps to makes sure temporary files get deleted, but it # does nothing about trying to close files that may still be open. It # is the responsibility of the developer to properly close files even # when exceptional conditions occur. self.tempFiles = [] # Create a temporary file. self.registerFileForCleanUp(test_support.TESTFN) self.text = 'testing urllib.urlretrieve' try: FILE = file(test_support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: try: FILE.close() except: pass def tearDown(self): # Delete the temporary files. for each in self.tempFiles: try: os.remove(each) except: pass def constructLocalFileUrl(self, filePath): return "file://%s" % urllib.pathname2url(os.path.abspath(filePath)) def createNewTempFile(self, data=""): """Creates a new temporary file containing the specified data, registers the file for deletion during the test fixture tear down, and returns the absolute path of the file.""" newFd, newFilePath = tempfile.mkstemp() try: self.registerFileForCleanUp(newFilePath) newFile = os.fdopen(newFd, "wb") newFile.write(data) newFile.close() finally: try: newFile.close() except: pass return newFilePath def registerFileForCleanUp(self, fileName): self.tempFiles.append(fileName) def test_basic(self): # Make sure that a local file just gets its own location returned and # a headers value is returned. result = urllib.urlretrieve("file:%s" % test_support.TESTFN) self.assertEqual(result[0], test_support.TESTFN) self.assertIsInstance(result[1], mimetools.Message, "did not get a mimetools.Message instance as " "second returned value") def test_copy(self): # Test that setting the filename argument works. second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) result = urllib.urlretrieve(self.constructLocalFileUrl( test_support.TESTFN), second_temp) self.assertEqual(second_temp, result[0]) self.assertTrue(os.path.exists(second_temp), "copy of the file was not " "made") FILE = file(second_temp, 'rb') try: text = FILE.read() FILE.close() finally: try: FILE.close() except: pass self.assertEqual(self.text, text) def test_reporthook(self): # Make sure that the reporthook works. def hooktester(count, block_size, total_size, count_holder=[0]): self.assertIsInstance(count, int) self.assertIsInstance(block_size, int) self.assertIsInstance(total_size, int) self.assertEqual(count, count_holder[0]) count_holder[0] = count_holder[0] + 1 second_temp = "%s.2" % test_support.TESTFN self.registerFileForCleanUp(second_temp) urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN), second_temp, hooktester) def test_reporthook_0_bytes(self): # Test on zero length file. Should call reporthook only 1 time. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile() urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 1) self.assertEqual(report[0][2], 0) def test_reporthook_5_bytes(self): # Test on 5 byte file. Should call reporthook only 2 times (once when # the "network connection" is established and once when the block is # read). Since the block size is 8192 bytes, only one block read is # required to read the entire file. report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 5) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 2) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 5) def test_reporthook_8193_bytes(self): # Test on 8193 byte file. Should call reporthook only 3 times (once # when the "network connection" is established, once for the next 8192 # bytes, and once for the last byte). report = [] def hooktester(count, block_size, total_size, _report=report): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile("x" * 8193) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), test_support.TESTFN, hooktester) self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) class urlretrieve_HttpTests(unittest.TestCase, FakeHTTPMixin): """Test urllib.urlretrieve() using fake http connections""" def test_short_content_raises_ContentTooShortError(self): self.fakehttp('''HTTP/1.1 200 OK Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Length: 100 Content-Type: text/html; charset=iso-8859-1 FF ''') def _reporthook(par1, par2, par3): pass try: self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com', reporthook=_reporthook) finally: self.unfakehttp() def test_short_content_raises_ContentTooShortError_without_reporthook(self): self.fakehttp('''HTTP/1.1 200 OK Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Length: 100 Content-Type: text/html; charset=iso-8859-1 FF ''') try: self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com/') finally: self.unfakehttp() class QuotingTests(unittest.TestCase): """Tests for urllib.quote() and urllib.quote_plus() According to RFC 2396 ("Uniform Resource Identifiers), to escape a character you write it as '%' + <2 character US-ASCII hex value>. The Python code of ``'%' + hex(ord())[2:]`` escapes a character properly. Case does not matter on the hex letters. The various character sets specified are: Reserved characters : ";/?:@&=+$," Have special meaning in URIs and must be escaped if not being used for their special meaning Data characters : letters, digits, and "-_.!~*'()" Unreserved and do not need to be escaped; can be, though, if desired Control characters : 0x00 - 0x1F, 0x7F Have no use in URIs so must be escaped space : 0x20 Must be escaped Delimiters : '<>#%"' Must be escaped Unwise : "{}|\^[]`" Must be escaped """ def test_never_quote(self): # Make sure quote() does not quote letters, digits, and "_,.-" do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789", "_.-"]) result = urllib.quote(do_not_quote) self.assertEqual(do_not_quote, result, "using quote(): %s != %s" % (do_not_quote, result)) result = urllib.quote_plus(do_not_quote) self.assertEqual(do_not_quote, result, "using quote_plus(): %s != %s" % (do_not_quote, result)) def test_default_safe(self): # Test '/' is default value for 'safe' parameter self.assertEqual(urllib.quote.func_defaults[0], '/') def test_safe(self): # Test setting 'safe' parameter does what it should do quote_by_default = "<>" result = urllib.quote(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote(): %s != %s" % (quote_by_default, result)) result = urllib.quote_plus(quote_by_default, safe=quote_by_default) self.assertEqual(quote_by_default, result, "using quote_plus(): %s != %s" % (quote_by_default, result)) def test_default_quoting(self): # Make sure all characters that should be quoted are by default sans # space (separate test for that). should_quote = [chr(num) for num in range(32)] # For 0x00 - 0x1F should_quote.append('<>#%"{}|\^[]`') should_quote.append(chr(127)) # For 0x7F should_quote = ''.join(should_quote) for char in should_quote: result = urllib.quote(char) self.assertEqual(hexescape(char), result, "using quote(): %s should be escaped to %s, not %s" % (char, hexescape(char), result)) result = urllib.quote_plus(char) self.assertEqual(hexescape(char), result, "using quote_plus(): " "%s should be escapes to %s, not %s" % (char, hexescape(char), result)) del should_quote partial_quote = "ab[]cd" expected = "ab%5B%5Dcd" result = urllib.quote(partial_quote) self.assertEqual(expected, result, "using quote(): %s != %s" % (expected, result)) result = urllib.quote_plus(partial_quote) self.assertEqual(expected, result, "using quote_plus(): %s != %s" % (expected, result)) self.assertRaises(TypeError, urllib.quote, None) def test_quoting_space(self): # Make sure quote() and quote_plus() handle spaces as specified in # their unique way result = urllib.quote(' ') self.assertEqual(result, hexescape(' '), "using quote(): %s != %s" % (result, hexescape(' '))) result = urllib.quote_plus(' ') self.assertEqual(result, '+', "using quote_plus(): %s != +" % result) given = "a b cd e f" expect = given.replace(' ', hexescape(' ')) result = urllib.quote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) expect = given.replace(' ', '+') result = urllib.quote_plus(given) self.assertEqual(expect, result, "using quote_plus(): %s != %s" % (expect, result)) def test_quoting_plus(self): self.assertEqual(urllib.quote_plus('alpha+beta gamma'), 'alpha%2Bbeta+gamma') self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'), 'alpha+beta+gamma') class UnquotingTests(unittest.TestCase): """Tests for unquote() and unquote_plus() See the doc string for quoting_Tests for details on quoting and such. """ def test_unquoting(self): # Make sure unquoting of all ASCII values works escape_list = [] for num in range(128): given = hexescape(chr(num)) expect = chr(num) result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) escape_list.append(given) escape_string = ''.join(escape_list) del escape_list result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using quote(): not all characters escaped; %s" % result) result = urllib.unquote(escape_string) self.assertEqual(result.count('%'), 1, "using unquote(): not all characters escaped: " "%s" % result) def test_unquoting_badpercent(self): # Test unquoting on bad percent-escapes given = '%xab' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%x' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) given = '%' expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_mixed_case(self): # Test unquoting on mixed-case hex digits in the percent-escapes given = '%Ab%eA' expect = '\xab\xea' result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) def test_unquoting_parts(self): # Make sure unquoting works when have non-quoted characters # interspersed given = 'ab%sd' % hexescape('c') expect = "abcd" result = urllib.unquote(given) self.assertEqual(expect, result, "using quote(): %s != %s" % (expect, result)) result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquoting_plus(self): # Test difference between unquote() and unquote_plus() given = "are+there+spaces..." expect = given result = urllib.unquote(given) self.assertEqual(expect, result, "using unquote(): %s != %s" % (expect, result)) expect = given.replace('+', ' ') result = urllib.unquote_plus(given) self.assertEqual(expect, result, "using unquote_plus(): %s != %s" % (expect, result)) def test_unquote_with_unicode(self): r = urllib.unquote(u'br%C3%BCckner_sapporo_20050930.doc') self.assertEqual(r, u'br\xc3\xbcckner_sapporo_20050930.doc') class urlencode_Tests(unittest.TestCase): """Tests for urlencode()""" def help_inputtype(self, given, test_type): """Helper method for testing different input types. 'given' must lead to only the pairs: * 1st, 1 * 2nd, 2 * 3rd, 3 Test cannot assume anything about order. Docs make no guarantee and have possible dictionary input. """ expect_somewhere = ["1st=1", "2nd=2", "3rd=3"] result = urllib.urlencode(given) for expected in expect_somewhere: self.assertIn(expected, result, "testing %s: %s not found in %s" % (test_type, expected, result)) self.assertEqual(result.count('&'), 2, "testing %s: expected 2 '&'s; got %s" % (test_type, result.count('&'))) amp_location = result.index('&') on_amp_left = result[amp_location - 1] on_amp_right = result[amp_location + 1] self.assertTrue(on_amp_left.isdigit() and on_amp_right.isdigit(), "testing %s: '&' not located in proper place in %s" % (test_type, result)) self.assertEqual(len(result), (5 * 3) + 2, #5 chars per thing and amps "testing %s: " "unexpected number of characters: %s != %s" % (test_type, len(result), (5 * 3) + 2)) def test_using_mapping(self): # Test passing in a mapping object as an argument. self.help_inputtype({"1st":'1', "2nd":'2', "3rd":'3'}, "using dict as input type") def test_using_sequence(self): # Test passing in a sequence of two-item sequences as an argument. self.help_inputtype([('1st', '1'), ('2nd', '2'), ('3rd', '3')], "using sequence of two-item tuples as input") def test_quoting(self): # Make sure keys and values are quoted using quote_plus() given = {"&":"="} expect = "%s=%s" % (hexescape('&'), hexescape('=')) result = urllib.urlencode(given) self.assertEqual(expect, result) given = {"key name":"A bunch of pluses"} expect = "key+name=A+bunch+of+pluses" result = urllib.urlencode(given) self.assertEqual(expect, result) def test_doseq(self): # Test that passing True for 'doseq' parameter works correctly given = {'sequence':['1', '2', '3']} expect = "sequence=%s" % urllib.quote_plus(str(['1', '2', '3'])) result = urllib.urlencode(given) self.assertEqual(expect, result) result = urllib.urlencode(given, True) for value in given["sequence"]: expect = "sequence=%s" % value self.assertIn(expect, result) self.assertEqual(result.count('&'), 2, "Expected 2 '&'s, got %s" % result.count('&')) class Pathname_Tests(unittest.TestCase): """Test pathname2url() and url2pathname()""" def test_basic(self): # Make sure simple tests pass expected_path = os.path.join("parts", "of", "a", "path") expected_url = "parts/of/a/path" result = urllib.pathname2url(expected_path) self.assertEqual(expected_url, result, "pathname2url() failed; %s != %s" % (result, expected_url)) result = urllib.url2pathname(expected_url) self.assertEqual(expected_path, result, "url2pathame() failed; %s != %s" % (result, expected_path)) def test_quoting(self): # Test automatic quoting and unquoting works for pathnam2url() and # url2pathname() respectively given = os.path.join("needs", "quot=ing", "here") expect = "needs/%s/here" % urllib.quote("quot=ing") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) expect = given result = urllib.url2pathname(result) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) given = os.path.join("make sure", "using_quote") expect = "%s/using_quote" % urllib.quote("make sure") result = urllib.pathname2url(given) self.assertEqual(expect, result, "pathname2url() failed; %s != %s" % (expect, result)) given = "make+sure/using_unquote" expect = os.path.join("make+sure", "using_unquote") result = urllib.url2pathname(given) self.assertEqual(expect, result, "url2pathname() failed; %s != %s" % (expect, result)) @unittest.skipUnless(sys.platform == 'win32', 'test specific to the nturl2path library') def test_ntpath(self): given = ('/C:/', '///C:/', '/C|//') expect = 'C:\\' for url in given: result = urllib.url2pathname(url) self.assertEqual(expect, result, 'nturl2path.url2pathname() failed; %s != %s' % (expect, result)) given = '///C|/path' expect = 'C:\\path' result = urllib.url2pathname(given) self.assertEqual(expect, result, 'nturl2path.url2pathname() failed; %s != %s' % (expect, result)) class Utility_Tests(unittest.TestCase): """Testcase to test the various utility functions in the urllib.""" def test_splitpasswd(self): """Some of the password examples are not sensible, but it is added to confirming to RFC2617 and addressing issue4675. """ self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab')) self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb')) self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb')) self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb')) self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb')) self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb')) self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b')) self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b')) self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab')) self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b')) def test_splitport(self): splitport = urllib.splitport self.assertEqual(splitport('parrot:88'), ('parrot', '88')) self.assertEqual(splitport('parrot'), ('parrot', None)) self.assertEqual(splitport('parrot:'), ('parrot', None)) self.assertEqual(splitport('127.0.0.1'), ('127.0.0.1', None)) self.assertEqual(splitport('parrot:cheese'), ('parrot:cheese', None)) def test_splitnport(self): splitnport = urllib.splitnport self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) self.assertEqual(splitnport('parrot'), ('parrot', -1)) self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) self.assertEqual(splitnport('parrot:'), ('parrot', -1)) self.assertEqual(splitnport('parrot:', 55), ('parrot', 55)) self.assertEqual(splitnport('127.0.0.1'), ('127.0.0.1', -1)) self.assertEqual(splitnport('127.0.0.1', 55), ('127.0.0.1', 55)) self.assertEqual(splitnport('parrot:cheese'), ('parrot', None)) self.assertEqual(splitnport('parrot:cheese', 55), ('parrot', None)) class URLopener_Tests(unittest.TestCase): """Testcase to test the open method of URLopener class.""" def test_quoted_open(self): class DummyURLopener(urllib.URLopener): def open_spam(self, url): return url self.assertEqual(DummyURLopener().open( 'spam://example/ /'),'//example/%20/') # test the safe characters are not quoted by urlopen self.assertEqual(DummyURLopener().open( "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"), "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/") # Just commented them out. # Can't really tell why keep failing in windows and sparc. # Everywhere else they work ok, but on those machines, sometimes # fail in one of the tests, sometimes in other. I have a linux, and # the tests go ok. # If anybody has one of the problematic environments, please help! # . Facundo # # def server(evt): # import socket, time # serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # serv.settimeout(3) # serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # serv.bind(("", 9093)) # serv.listen(5) # try: # conn, addr = serv.accept() # conn.send("1 Hola mundo\n") # cantdata = 0 # while cantdata < 13: # data = conn.recv(13-cantdata) # cantdata += len(data) # time.sleep(.3) # conn.send("2 No more lines\n") # conn.close() # except socket.timeout: # pass # finally: # serv.close() # evt.set() # # class FTPWrapperTests(unittest.TestCase): # # def setUp(self): # import ftplib, time, threading # ftplib.FTP.port = 9093 # self.evt = threading.Event() # threading.Thread(target=server, args=(self.evt,)).start() # time.sleep(.1) # # def tearDown(self): # self.evt.wait() # # def testBasic(self): # # connects # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # ftp.close() # # def testTimeoutNone(self): # # global default timeout is ignored # import socket # self.assertIsNone(socket.getdefaulttimeout()) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutDefault(self): # # global default timeout is used # import socket # self.assertIsNone(socket.getdefaulttimeout()) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) # finally: # socket.setdefaulttimeout(None) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() # # def testTimeoutValue(self): # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [], # timeout=30) # self.assertEqual(ftp.ftp.sock.gettimeout(), 30) # ftp.close() def test_main(): import warnings with warnings.catch_warnings(): warnings.filterwarnings('ignore', ".*urllib\.urlopen.*Python 3.0", DeprecationWarning) test_support.run_unittest( urlopen_FileTests, urlopen_HttpTests, urlretrieve_FileTests, urlretrieve_HttpTests, ProxyTests, QuotingTests, UnquotingTests, urlencode_Tests, Pathname_Tests, Utility_Tests, URLopener_Tests, #FTPWrapperTests, ) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/2.7pypy/test_urllib2.py0000644000076500000000000015213112666555342021756 0ustar jmaddenwheel00000000000000import unittest from test import test_support import os import socket import StringIO import urllib2 from urllib2 import Request, OpenerDirector # XXX # Request # CacheFTPHandler (hard to write) # parse_keqv_list, parse_http_list, HTTPDigestAuthHandler class TrivialTests(unittest.TestCase): def test_trivial(self): # A couple trivial tests self.assertRaises(ValueError, urllib2.urlopen, 'bogus url') # XXX Name hacking to get this to work on Windows. fname = os.path.abspath(urllib2.__file__).replace('\\', '/') # And more hacking to get it to work on MacOS. This assumes # urllib.pathname2url works, unfortunately... if os.name == 'riscos': import string fname = os.expand(fname) fname = fname.translate(string.maketrans("/.", "./")) if os.name == 'nt': file_url = "file:///%s" % fname else: file_url = "file://%s" % fname f = urllib2.urlopen(file_url) buf = f.read() f.close() def test_parse_http_list(self): tests = [('a,b,c', ['a', 'b', 'c']), ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']), ('a, b, "c", "d", "e,f", g, h', ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']), ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])] for string, list in tests: self.assertEqual(urllib2.parse_http_list(string), list) def test_request_headers_dict(): """ The Request.headers dictionary is not a documented interface. It should stay that way, because the complete set of headers are only accessible through the .get_header(), .has_header(), .header_items() interface. However, .headers pre-dates those methods, and so real code will be using the dictionary. The introduction in 2.4 of those methods was a mistake for the same reason: code that previously saw all (urllib2 user)-provided headers in .headers now sees only a subset (and the function interface is ugly and incomplete). A better change would have been to replace .headers dict with a dict subclass (or UserDict.DictMixin instance?) that preserved the .headers interface and also provided access to the "unredirected" headers. It's probably too late to fix that, though. Check .capitalize() case normalization: >>> url = "http://example.com" >>> Request(url, headers={"Spam-eggs": "blah"}).headers["Spam-eggs"] 'blah' >>> Request(url, headers={"spam-EggS": "blah"}).headers["Spam-eggs"] 'blah' Currently, Request(url, "Spam-eggs").headers["Spam-Eggs"] raises KeyError, but that could be changed in future. """ def test_request_headers_methods(): """ Note the case normalization of header names here, to .capitalize()-case. This should be preserved for backwards-compatibility. (In the HTTP case, normalization to .title()-case is done by urllib2 before sending headers to httplib). >>> url = "http://example.com" >>> r = Request(url, headers={"Spam-eggs": "blah"}) >>> r.has_header("Spam-eggs") True >>> r.header_items() [('Spam-eggs', 'blah')] >>> r.add_header("Foo-Bar", "baz") >>> items = r.header_items() >>> items.sort() >>> items [('Foo-bar', 'baz'), ('Spam-eggs', 'blah')] Note that e.g. r.has_header("spam-EggS") is currently False, and r.get_header("spam-EggS") returns None, but that could be changed in future. >>> r.has_header("Not-there") False >>> print r.get_header("Not-there") None >>> r.get_header("Not-there", "default") 'default' """ def test_password_manager(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password >>> add("Some Realm", "http://example.com/", "joe", "password") >>> add("Some Realm", "http://example.com/ni", "ni", "ni") >>> add("c", "http://example.com/foo", "foo", "ni") >>> add("c", "http://example.com/bar", "bar", "nini") >>> add("b", "http://example.com/", "first", "blah") >>> add("b", "http://example.com/", "second", "spam") >>> add("a", "http://example.com", "1", "a") >>> add("Some Realm", "http://c.example.com:3128", "3", "c") >>> add("Some Realm", "d.example.com", "4", "d") >>> add("Some Realm", "e.example.com:3128", "5", "e") >>> mgr.find_user_password("Some Realm", "example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam") ('joe', 'password') >>> mgr.find_user_password("Some Realm", "http://example.com/spam/spam") ('joe', 'password') >>> mgr.find_user_password("c", "http://example.com/foo") ('foo', 'ni') >>> mgr.find_user_password("c", "http://example.com/bar") ('bar', 'nini') Actually, this is really undefined ATM ## Currently, we use the highest-level path where more than one match: ## >>> mgr.find_user_password("Some Realm", "http://example.com/ni") ## ('joe', 'password') Use latest add_password() in case of conflict: >>> mgr.find_user_password("b", "http://example.com/") ('second', 'spam') No special relationship between a.example.com and example.com: >>> mgr.find_user_password("a", "http://example.com/") ('1', 'a') >>> mgr.find_user_password("a", "http://a.example.com/") (None, None) Ports: >>> mgr.find_user_password("Some Realm", "c.example.com") (None, None) >>> mgr.find_user_password("Some Realm", "c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "http://c.example.com:3128") ('3', 'c') >>> mgr.find_user_password("Some Realm", "d.example.com") ('4', 'd') >>> mgr.find_user_password("Some Realm", "e.example.com:3128") ('5', 'e') """ pass def test_password_manager_default_port(self): """ >>> mgr = urllib2.HTTPPasswordMgr() >>> add = mgr.add_password The point to note here is that we can't guess the default port if there's no scheme. This applies to both add_password and find_user_password. >>> add("f", "http://g.example.com:80", "10", "j") >>> add("g", "http://h.example.com", "11", "k") >>> add("h", "i.example.com:80", "12", "l") >>> add("i", "j.example.com", "13", "m") >>> mgr.find_user_password("f", "g.example.com:100") (None, None) >>> mgr.find_user_password("f", "g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "g.example.com") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:100") (None, None) >>> mgr.find_user_password("f", "http://g.example.com:80") ('10', 'j') >>> mgr.find_user_password("f", "http://g.example.com") ('10', 'j') >>> mgr.find_user_password("g", "h.example.com") ('11', 'k') >>> mgr.find_user_password("g", "h.example.com:80") ('11', 'k') >>> mgr.find_user_password("g", "http://h.example.com:80") ('11', 'k') >>> mgr.find_user_password("h", "i.example.com") (None, None) >>> mgr.find_user_password("h", "i.example.com:80") ('12', 'l') >>> mgr.find_user_password("h", "http://i.example.com:80") ('12', 'l') >>> mgr.find_user_password("i", "j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "j.example.com:80") (None, None) >>> mgr.find_user_password("i", "http://j.example.com") ('13', 'm') >>> mgr.find_user_password("i", "http://j.example.com:80") (None, None) """ class MockOpener: addheaders = [] def open(self, req, data=None,timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.req, self.data, self.timeout = req, data, timeout def error(self, proto, *args): self.proto, self.args = proto, args class MockFile: def read(self, count=None): pass def readline(self, count=None): pass def close(self): pass class MockHeaders(dict): def getheaders(self, name): return self.values() class MockResponse(StringIO.StringIO): def __init__(self, code, msg, headers, data, url=None): StringIO.StringIO.__init__(self, data) self.code, self.msg, self.headers, self.url = code, msg, headers, url def info(self): return self.headers def geturl(self): return self.url class MockCookieJar: def add_cookie_header(self, request): self.ach_req = request def extract_cookies(self, response, request): self.ec_req, self.ec_r = request, response class FakeMethod: def __init__(self, meth_name, action, handle): self.meth_name = meth_name self.handle = handle self.action = action def __call__(self, *args): return self.handle(self.meth_name, self.action, *args) class MockHTTPResponse: def __init__(self, fp, msg, status, reason): self.fp = fp self.msg = msg self.status = status self.reason = reason def read(self): return '' def _reuse(self): pass def _drop(self): pass class MockHTTPClass: def __init__(self): self.req_headers = [] self.data = None self.raise_on_endheaders = False self._tunnel_headers = {} self.sock = None # gevent: compat with 2.7.0+ def __call__(self, host, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.host = host self.timeout = timeout return self def set_debuglevel(self, level): self.level = level def set_tunnel(self, host, port=None, headers=None): self._tunnel_host = host self._tunnel_port = port if headers: self._tunnel_headers = headers else: self._tunnel_headers.clear() def request(self, method, url, body=None, headers=None): self.method = method self.selector = url if headers is not None: self.req_headers += headers.items() self.req_headers.sort() if body: self.data = body if self.raise_on_endheaders: import socket raise socket.error() def getresponse(self): return MockHTTPResponse(MockFile(), {}, 200, "OK") def close(self): pass class MockHandler: # useful for testing handler machinery # see add_ordered_mock_handlers() docstring handler_order = 500 def __init__(self, methods): self._define_methods(methods) def _define_methods(self, methods): for spec in methods: if len(spec) == 2: name, action = spec else: name, action = spec, None meth = FakeMethod(name, action, self.handle) setattr(self.__class__, name, meth) def handle(self, fn_name, action, *args, **kwds): self.parent.calls.append((self, fn_name, args, kwds)) if action is None: return None elif action == "return self": return self elif action == "return response": res = MockResponse(200, "OK", {}, "") return res elif action == "return request": return Request("http://blah/") elif action.startswith("error"): code = action[action.rfind(" ")+1:] try: code = int(code) except ValueError: pass res = MockResponse(200, "OK", {}, "") return self.parent.error("http", args[0], res, code, "", {}) elif action == "raise": raise urllib2.URLError("blah") assert False def close(self): pass def add_parent(self, parent): self.parent = parent self.parent.calls = [] def __lt__(self, other): if not hasattr(other, "handler_order"): # No handler_order, leave in original order. Yuck. return True return self.handler_order < other.handler_order def add_ordered_mock_handlers(opener, meth_spec): """Create MockHandlers and add them to an OpenerDirector. meth_spec: list of lists of tuples and strings defining methods to define on handlers. eg: [["http_error", "ftp_open"], ["http_open"]] defines methods .http_error() and .ftp_open() on one handler, and .http_open() on another. These methods just record their arguments and return None. Using a tuple instead of a string causes the method to perform some action (see MockHandler.handle()), eg: [["http_error"], [("http_open", "return request")]] defines .http_error() on one handler (which simply returns None), and .http_open() on another handler, which returns a Request object. """ handlers = [] count = 0 for meths in meth_spec: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order += count h.add_parent(opener) count = count + 1 handlers.append(h) opener.add_handler(h) return handlers def build_test_opener(*handler_instances): opener = OpenerDirector() for h in handler_instances: opener.add_handler(h) return opener class MockHTTPHandler(urllib2.BaseHandler): # useful for testing redirections and auth # sends supplied headers and code as first response # sends 200 OK as second response def __init__(self, code, headers): self.code = code self.headers = headers self.reset() def reset(self): self._count = 0 self.requests = [] def http_open(self, req): import mimetools, httplib, copy from StringIO import StringIO self.requests.append(copy.deepcopy(req)) if self._count == 0: self._count = self._count + 1 name = httplib.responses[self.code] msg = mimetools.Message(StringIO(self.headers)) return self.parent.error( "http", req, MockFile(), self.code, name, msg) else: self.req = req msg = mimetools.Message(StringIO("\r\n\r\n")) return MockResponse(200, "OK", msg, "", req.get_full_url()) class MockHTTPSHandler(urllib2.AbstractHTTPHandler): # Useful for testing the Proxy-Authorization request by verifying the # properties of httpcon def __init__(self): urllib2.AbstractHTTPHandler.__init__(self) self.httpconn = MockHTTPClass() def https_open(self, req): return self.do_open(self.httpconn, req) class MockPasswordManager: def add_password(self, realm, uri, user, password): self.realm = realm self.url = uri self.user = user self.password = password def find_user_password(self, realm, authuri): self.target_realm = realm self.target_url = authuri return self.user, self.password class OpenerDirectorTests(unittest.TestCase): def test_add_non_handler(self): class NonHandler(object): pass self.assertRaises(TypeError, OpenerDirector().add_handler, NonHandler()) def test_badly_named_methods(self): # test work-around for three methods that accidentally follow the # naming conventions for handler methods # (*_open() / *_request() / *_response()) # These used to call the accidentally-named methods, causing a # TypeError in real code; here, returning self from these mock # methods would either cause no exception, or AttributeError. from urllib2 import URLError o = OpenerDirector() meth_spec = [ [("do_open", "return self"), ("proxy_open", "return self")], [("redirect_request", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) o.add_handler(urllib2.UnknownHandler()) for scheme in "do", "proxy", "redirect": self.assertRaises(URLError, o.open, scheme+"://example.com/") def test_handled(self): # handler returning non-None means no more handlers will be called o = OpenerDirector() meth_spec = [ ["http_open", "ftp_open", "http_error_302"], ["ftp_open"], [("http_open", "return self")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # Second .http_open() gets called, third doesn't, since second returned # non-None. Handlers without .http_open() never get any methods called # on them. # In fact, second mock handler defining .http_open() returns self # (instead of response), which becomes the OpenerDirector's return # value. self.assertEqual(r, handlers[2]) calls = [(handlers[0], "http_open"), (handlers[2], "http_open")] for expected, got in zip(calls, o.calls): handler, name, args, kwds = got self.assertEqual((handler, name), expected) self.assertEqual(args, (req,)) def test_handler_order(self): o = OpenerDirector() handlers = [] for meths, handler_order in [ ([("http_open", "return self")], 500), (["http_open"], 0), ]: class MockHandlerSubclass(MockHandler): pass h = MockHandlerSubclass(meths) h.handler_order = handler_order handlers.append(h) o.add_handler(h) r = o.open("http://example.com/") # handlers called in reverse order, thanks to their sort order self.assertEqual(o.calls[0][0], handlers[1]) self.assertEqual(o.calls[1][0], handlers[0]) def test_raise(self): # raising URLError stops processing of request o = OpenerDirector() meth_spec = [ [("http_open", "raise")], [("http_open", "return self")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") self.assertRaises(urllib2.URLError, o.open, req) self.assertEqual(o.calls, [(handlers[0], "http_open", (req,), {})]) ## def test_error(self): ## # XXX this doesn't actually seem to be used in standard library, ## # but should really be tested anyway... def test_http_error(self): # XXX http_error_default # http errors are a special case o = OpenerDirector() meth_spec = [ [("http_open", "error 302")], [("http_error_400", "raise"), "http_open"], [("http_error_302", "return response"), "http_error_303", "http_error"], [("http_error_302")], ] handlers = add_ordered_mock_handlers(o, meth_spec) class Unknown: def __eq__(self, other): return True req = Request("http://example.com/") r = o.open(req) assert len(o.calls) == 2 calls = [(handlers[0], "http_open", (req,)), (handlers[2], "http_error_302", (req, Unknown(), 302, "", {}))] for expected, got in zip(calls, o.calls): handler, method_name, args = expected self.assertEqual((handler, method_name), got[:2]) self.assertEqual(args, got[2]) def test_processors(self): # *_request / *_response methods get called appropriately o = OpenerDirector() meth_spec = [ [("http_request", "return request"), ("http_response", "return response")], [("http_request", "return request"), ("http_response", "return response")], ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://example.com/") r = o.open(req) # processor methods are called on *all* handlers that define them, # not just the first handler that handles the request calls = [ (handlers[0], "http_request"), (handlers[1], "http_request"), (handlers[0], "http_response"), (handlers[1], "http_response")] for i, (handler, name, args, kwds) in enumerate(o.calls): if i < 2: # *_request self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 1) self.assertIsInstance(args[0], Request) else: # *_response self.assertEqual((handler, name), calls[i]) self.assertEqual(len(args), 2) self.assertIsInstance(args[0], Request) # response from opener.open is None, because there's no # handler that defines http_open to handle it if args[1] is not None: self.assertIsInstance(args[1], MockResponse) def sanepathname2url(path): import urllib urlpath = urllib.pathname2url(path) if os.name == "nt" and urlpath.startswith("///"): urlpath = urlpath[2:] # XXX don't ask me about the mac... return urlpath class HandlerTests(unittest.TestCase): def test_ftp(self): class MockFTPWrapper: def __init__(self, data): self.data = data def retrfile(self, filename, filetype): self.filename, self.filetype = filename, filetype return StringIO.StringIO(self.data), len(self.data) def close(self): pass class NullFTPHandler(urllib2.FTPHandler): def __init__(self, data): self.data = data def connect_ftp(self, user, passwd, host, port, dirs, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.user, self.passwd = user, passwd self.host, self.port = host, port self.dirs = dirs self.ftpwrapper = MockFTPWrapper(self.data) return self.ftpwrapper import ftplib data = "rheum rhaponicum" h = NullFTPHandler(data) o = h.parent = MockOpener() for url, host, port, user, passwd, type_, dirs, filename, mimetype in [ ("ftp://localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://%25parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "%parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://%2542parrot@localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "%42parrot", "", "I", ["foo", "bar"], "baz.html", "text/html"), ("ftp://localhost:80/foo/bar/", "localhost", 80, "", "", "D", ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", [], "baz.gif", None), # XXX really this should guess image/gif ]: req = Request(url) req.timeout = None r = h.ftp_open(req) # ftp authentication not yet implemented by FTPHandler self.assertEqual(h.user, user) self.assertEqual(h.passwd, passwd) self.assertEqual(h.host, socket.gethostbyname(host)) self.assertEqual(h.port, port) self.assertEqual(h.dirs, dirs) self.assertEqual(h.ftpwrapper.filename, filename) self.assertEqual(h.ftpwrapper.filetype, type_) headers = r.info() self.assertEqual(headers.get("Content-type"), mimetype) self.assertEqual(int(headers["Content-length"]), len(data)) def test_file(self): import rfc822, socket h = urllib2.FileHandler() o = h.parent = MockOpener() TESTFN = test_support.TESTFN urlpath = sanepathname2url(os.path.abspath(TESTFN)) towrite = "hello, world\n" urls = [ "file://localhost%s" % urlpath, "file://%s" % urlpath, "file://%s%s" % (socket.gethostbyname('localhost'), urlpath), ] try: localaddr = socket.gethostbyname(socket.gethostname()) except socket.gaierror: localaddr = '' if localaddr: urls.append("file://%s%s" % (localaddr, urlpath)) for url in urls: f = open(TESTFN, "wb") try: try: f.write(towrite) finally: f.close() r = h.file_open(Request(url)) try: data = r.read() headers = r.info() respurl = r.geturl() finally: r.close() stats = os.stat(TESTFN) modified = rfc822.formatdate(stats.st_mtime) finally: os.remove(TESTFN) self.assertEqual(data, towrite) self.assertEqual(headers["Content-type"], "text/plain") self.assertEqual(headers["Content-length"], "13") self.assertEqual(headers["Last-modified"], modified) self.assertEqual(respurl, url) for url in [ "file://localhost:80%s" % urlpath, "file:///file_does_not_exist.txt", "file://%s:80%s/%s" % (socket.gethostbyname('localhost'), os.getcwd(), TESTFN), "file://somerandomhost.ontheinternet.com%s/%s" % (os.getcwd(), TESTFN), ]: try: f = open(TESTFN, "wb") try: f.write(towrite) finally: f.close() self.assertRaises(urllib2.URLError, h.file_open, Request(url)) finally: os.remove(TESTFN) h = urllib2.FileHandler() o = h.parent = MockOpener() # XXXX why does // mean ftp (and /// mean not ftp!), and where # is file: scheme specified? I think this is really a bug, and # what was intended was to distinguish between URLs like: # file:/blah.txt (a file) # file://localhost/blah.txt (a file) # file:///blah.txt (a file) # file://ftp.example.com/blah.txt (an ftp URL) for url, ftp in [ ("file://ftp.example.com//foo.txt", True), ("file://ftp.example.com///foo.txt", False), # XXXX bug: fails with OSError, should be URLError ("file://ftp.example.com/foo.txt", False), ("file://somehost//foo/something.txt", True), ("file://localhost//foo/something.txt", False), ]: req = Request(url) try: h.file_open(req) # XXXX remove OSError when bug fixed except (urllib2.URLError, OSError): self.assertTrue(not ftp) else: self.assertTrue(o.req is req) self.assertEqual(req.type, "ftp") self.assertEqual(req.type == "ftp", ftp) def test_http(self): h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() url = "http://example.com/" for method, data in [("GET", None), ("POST", "blah")]: req = Request(url, data, {"Foo": "bar"}) req.timeout = None req.add_unredirected_header("Spam", "eggs") http = MockHTTPClass() r = h.do_open(http, req) # result attributes r.read; r.readline # wrapped MockFile methods r.info; r.geturl # addinfourl methods r.code, r.msg == 200, "OK" # added from MockHTTPClass.getreply() hdrs = r.info() hdrs.get; hdrs.has_key # r.info() gives dict from .getreply() self.assertEqual(r.geturl(), url) self.assertEqual(http.host, "example.com") self.assertEqual(http.level, 0) self.assertEqual(http.method, method) self.assertEqual(http.selector, "/") self.assertEqual(http.req_headers, [("Connection", "close"), ("Foo", "bar"), ("Spam", "eggs")]) self.assertEqual(http.data, data) # check socket.error converted to URLError http.raise_on_endheaders = True self.assertRaises(urllib2.URLError, h.do_open, http, req) # check adding of standard headers o.addheaders = [("Spam", "eggs")] for data in "", None: # POST, GET req = Request("http://example.com/", data) r = MockResponse(200, "OK", {}, "") newreq = h.do_request_(req) if data is None: # GET self.assertNotIn("Content-length", req.unredirected_hdrs) self.assertNotIn("Content-type", req.unredirected_hdrs) else: # POST self.assertEqual(req.unredirected_hdrs["Content-length"], "0") self.assertEqual(req.unredirected_hdrs["Content-type"], "application/x-www-form-urlencoded") # XXX the details of Host could be better tested self.assertEqual(req.unredirected_hdrs["Host"], "example.com") self.assertEqual(req.unredirected_hdrs["Spam"], "eggs") # don't clobber existing headers req.add_unredirected_header("Content-length", "foo") req.add_unredirected_header("Content-type", "bar") req.add_unredirected_header("Host", "baz") req.add_unredirected_header("Spam", "foo") newreq = h.do_request_(req) self.assertEqual(req.unredirected_hdrs["Content-length"], "foo") self.assertEqual(req.unredirected_hdrs["Content-type"], "bar") self.assertEqual(req.unredirected_hdrs["Host"], "baz") self.assertEqual(req.unredirected_hdrs["Spam"], "foo") def test_http_doubleslash(self): # Checks that the presence of an unnecessary double slash in a url doesn't break anything # Previously, a double slash directly after the host could cause incorrect parsing of the url h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() data = "" ds_urls = [ "http://example.com/foo/bar/baz.html", "http://example.com//foo/bar/baz.html", "http://example.com/foo//bar/baz.html", "http://example.com/foo/bar//baz.html", ] for ds_url in ds_urls: ds_req = Request(ds_url, data) # Check whether host is determined correctly if there is no proxy np_ds_req = h.do_request_(ds_req) self.assertEqual(np_ds_req.unredirected_hdrs["Host"],"example.com") # Check whether host is determined correctly if there is a proxy ds_req.set_proxy("someproxy:3128",None) p_ds_req = h.do_request_(ds_req) self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com") def test_fixpath_in_weirdurls(self): # Issue4493: urllib2 to supply '/' when to urls where path does not # start with'/' h = urllib2.AbstractHTTPHandler() o = h.parent = MockOpener() weird_url = 'http://www.python.org?getspam' req = Request(weird_url) newreq = h.do_request_(req) self.assertEqual(newreq.get_host(),'www.python.org') self.assertEqual(newreq.get_selector(),'/?getspam') url_without_path = 'http://www.python.org' req = Request(url_without_path) newreq = h.do_request_(req) self.assertEqual(newreq.get_host(),'www.python.org') self.assertEqual(newreq.get_selector(),'') def test_errors(self): h = urllib2.HTTPErrorProcessor() o = h.parent = MockOpener() url = "http://example.com/" req = Request(url) # all 2xx are passed through r = MockResponse(200, "OK", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called r = MockResponse(202, "Accepted", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called r = MockResponse(206, "Partial content", {}, "", url) newr = h.http_response(req, r) self.assertTrue(r is newr) self.assertTrue(not hasattr(o, "proto")) # o.error not called # anything else calls o.error (and MockOpener returns None, here) r = MockResponse(502, "Bad gateway", {}, "", url) self.assertTrue(h.http_response(req, r) is None) self.assertEqual(o.proto, "http") # o.error called self.assertEqual(o.args, (req, r, 502, "Bad gateway", {})) def test_cookies(self): cj = MockCookieJar() h = urllib2.HTTPCookieProcessor(cj) o = h.parent = MockOpener() req = Request("http://example.com/") r = MockResponse(200, "OK", {}, "") newreq = h.http_request(req) self.assertTrue(cj.ach_req is req is newreq) self.assertEqual(req.get_origin_req_host(), "example.com") self.assertTrue(not req.is_unverifiable()) newr = h.http_response(req, r) self.assertTrue(cj.ec_req is req) self.assertTrue(cj.ec_r is r is newr) def test_redirect(self): from_url = "http://example.com/a.html" to_url = "http://example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() # ordinary redirect behaviour for code in 301, 302, 303, 307: for data in None, "blah\nblah\n": method = getattr(h, "http_error_%s" % code) req = Request(from_url, data) req.add_header("Nonsense", "viking=withhold") req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT if data is not None: req.add_header("Content-Length", str(len(data))) req.add_unredirected_header("Spam", "spam") try: method(req, MockFile(), code, "Blah", MockHeaders({"location": to_url})) except urllib2.HTTPError: # 307 in response to POST requires user OK self.assertEqual(code, 307) self.assertIsNotNone(data) self.assertEqual(o.req.get_full_url(), to_url) try: self.assertEqual(o.req.get_method(), "GET") except AttributeError: self.assertTrue(not o.req.has_data()) # now it's a GET, there should not be headers regarding content # (possibly dragged from before being a POST) headers = [x.lower() for x in o.req.headers] self.assertNotIn("content-length", headers) self.assertNotIn("content-type", headers) self.assertEqual(o.req.headers["Nonsense"], "viking=withhold") self.assertNotIn("Spam", o.req.headers) self.assertNotIn("Spam", o.req.unredirected_hdrs) # loop detection req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT def redirect(h, req, url=to_url): h.http_error_302(req, MockFile(), 302, "Blah", MockHeaders({"location": url})) # Note that the *original* request shares the same record of # redirections with the sub-requests caused by the redirections. # detect infinite loop redirect of a URL to itself req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/") count = count + 1 except urllib2.HTTPError: # don't stop until max_repeats, because cookies may introduce state self.assertEqual(count, urllib2.HTTPRedirectHandler.max_repeats) # detect endless non-repeating chain of redirects req = Request(from_url, origin_req_host="example.com") count = 0 req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT try: while 1: redirect(h, req, "http://example.com/%d" % count) count = count + 1 except urllib2.HTTPError: self.assertEqual(count, urllib2.HTTPRedirectHandler.max_redirections) def test_invalid_redirect(self): from_url = "http://example.com/a.html" valid_schemes = ['http', 'https', 'ftp'] invalid_schemes = ['file', 'imap', 'ldap'] schemeless_url = "example.com/b.html" h = urllib2.HTTPRedirectHandler() o = h.parent = MockOpener() req = Request(from_url) req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT for scheme in invalid_schemes: invalid_url = scheme + '://' + schemeless_url self.assertRaises(urllib2.HTTPError, h.http_error_302, req, MockFile(), 302, "Security Loophole", MockHeaders({"location": invalid_url})) for scheme in valid_schemes: valid_url = scheme + '://' + schemeless_url h.http_error_302(req, MockFile(), 302, "That's fine", MockHeaders({"location": valid_url})) self.assertEqual(o.req.get_full_url(), valid_url) def test_cookie_redirect(self): # cookies shouldn't leak into redirected requests from cookielib import CookieJar from test.test_cookielib import interact_netscape cj = CookieJar() interact_netscape(cj, "http://www.example.com/", "spam=eggs") hh = MockHTTPHandler(302, "Location: http://www.cracker.com/\r\n\r\n") hdeh = urllib2.HTTPDefaultErrorHandler() hrh = urllib2.HTTPRedirectHandler() cp = urllib2.HTTPCookieProcessor(cj) o = build_test_opener(hh, hdeh, hrh, cp) o.open("http://www.example.com/") self.assertTrue(not hh.req.has_header("Cookie")) def test_redirect_fragment(self): redirected_url = 'http://www.example.com/index.html#OK\r\n\r\n' hh = MockHTTPHandler(302, 'Location: ' + redirected_url) hdeh = urllib2.HTTPDefaultErrorHandler() hrh = urllib2.HTTPRedirectHandler() o = build_test_opener(hh, hdeh, hrh) fp = o.open('http://www.example.com') self.assertEqual(fp.geturl(), redirected_url.strip()) def test_proxy(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) o.add_handler(ph) meth_spec = [ [("http_open", "return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("http://acme.example.com/") self.assertEqual(req.get_host(), "acme.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) def test_proxy_no_proxy(self): os.environ['no_proxy'] = 'python.org' o = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com")) o.add_handler(ph) req = Request("http://www.perl.org/") self.assertEqual(req.get_host(), "www.perl.org") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com") req = Request("http://www.python.org") self.assertEqual(req.get_host(), "www.python.org") r = o.open(req) self.assertEqual(req.get_host(), "www.python.org") del os.environ['no_proxy'] def test_proxy_https(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) meth_spec = [ [("https_open","return response")] ] handlers = add_ordered_mock_handlers(o, meth_spec) req = Request("https://www.example.com/") self.assertEqual(req.get_host(), "www.example.com") r = o.open(req) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual([(handlers[0], "https_open")], [tup[0:2] for tup in o.calls]) def test_proxy_https_proxy_authorization(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) o.add_handler(ph) https_handler = MockHTTPSHandler() o.add_handler(https_handler) req = Request("https://www.example.com/") req.add_header("Proxy-Authorization","FooBar") req.add_header("User-Agent","Grail") self.assertEqual(req.get_host(), "www.example.com") self.assertIsNone(req._tunnel_host) r = o.open(req) # Verify Proxy-Authorization gets tunneled to request. # httpsconn req_headers do not have the Proxy-Authorization header but # the req will have. self.assertNotIn(("Proxy-Authorization","FooBar"), https_handler.httpconn.req_headers) self.assertIn(("User-Agent","Grail"), https_handler.httpconn.req_headers) self.assertIsNotNone(req._tunnel_host) self.assertEqual(req.get_host(), "proxy.example.com:3128") self.assertEqual(req.get_header("Proxy-authorization"),"FooBar") def test_basic_auth(self, quote_char='"'): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm=%s%s%s\r\n\r\n' % (quote_char, realm, quote_char) ) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected" ) def test_basic_auth_with_single_quoted_realm(self): self.test_basic_auth(quote_char="'") def test_basic_auth_with_unquoted_realm(self): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm=%s\r\n\r\n' % realm) opener.add_handler(auth_handler) opener.add_handler(http_handler) msg = "Basic Auth Realm was unquoted" with test_support.check_warnings((msg, UserWarning)): self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected" ) def test_proxy_basic_auth(self): opener = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) opener.add_handler(ph) password_manager = MockPasswordManager() auth_handler = urllib2.ProxyBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(auth_handler) opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Proxy-authorization", realm, http_handler, password_manager, "http://acme.example.com:3128/protected", "proxy.example.com:3128", ) def test_basic_and_digest_auth_handlers(self): # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40* # response (http://python.org/sf/1479302), where it should instead # return None to allow another handler (especially # HTTPBasicAuthHandler) to handle the response. # Also (http://python.org/sf/14797027, RFC 2617 section 1.2), we must # try digest first (since it's the strongest auth scheme), so we record # order of calls here to check digest comes first: class RecordingOpenerDirector(OpenerDirector): def __init__(self): OpenerDirector.__init__(self) self.recorded = [] def record(self, info): self.recorded.append(info) class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("digest") urllib2.HTTPDigestAuthHandler.http_error_401(self, *args, **kwds) class TestBasicAuthHandler(urllib2.HTTPBasicAuthHandler): def http_error_401(self, *args, **kwds): self.parent.record("basic") urllib2.HTTPBasicAuthHandler.http_error_401(self, *args, **kwds) opener = RecordingOpenerDirector() password_manager = MockPasswordManager() digest_handler = TestDigestAuthHandler(password_manager) basic_handler = TestBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) opener.add_handler(basic_handler) opener.add_handler(digest_handler) opener.add_handler(http_handler) # check basic auth isn't blocked by digest handler failing self._test_basic_auth(opener, basic_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected", ) # check digest was tried before basic (twice, because # _test_basic_auth called .open() twice) self.assertEqual(opener.recorded, ["digest", "basic"]*2) def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): import base64 user, password = "wile", "coyote" # .add_password() fed through to password manager auth_handler.add_password(realm, request_url, user, password) self.assertEqual(realm, password_manager.realm) self.assertEqual(request_url, password_manager.url) self.assertEqual(user, password_manager.user) self.assertEqual(password, password_manager.password) r = opener.open(request_url) # should have asked the password manager for the username/password self.assertEqual(password_manager.target_realm, realm) self.assertEqual(password_manager.target_url, protected_url) # expect one request without authorization, then one with self.assertEqual(len(http_handler.requests), 2) self.assertFalse(http_handler.requests[0].has_header(auth_header)) userpass = '%s:%s' % (user, password) auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip() self.assertEqual(http_handler.requests[1].get_header(auth_header), auth_hdr_value) self.assertEqual(http_handler.requests[1].unredirected_hdrs[auth_header], auth_hdr_value) # if the password manager can't find a password, the handler won't # handle the HTTP auth error password_manager.user = password_manager.password = None http_handler.reset() r = opener.open(request_url) self.assertEqual(len(http_handler.requests), 1) self.assertFalse(http_handler.requests[0].has_header(auth_header)) class MiscTests(unittest.TestCase): def test_build_opener(self): class MyHTTPHandler(urllib2.HTTPHandler): pass class FooHandler(urllib2.BaseHandler): def foo_open(self): pass class BarHandler(urllib2.BaseHandler): def bar_open(self): pass build_opener = urllib2.build_opener o = build_opener(FooHandler, BarHandler) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # can take a mix of classes and instances o = build_opener(FooHandler, BarHandler()) self.opener_has_handler(o, FooHandler) self.opener_has_handler(o, BarHandler) # subclasses of default handlers override default handlers o = build_opener(MyHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) # a particular case of overriding: default handlers can be passed # in explicitly o = build_opener() self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler) self.opener_has_handler(o, urllib2.HTTPHandler) o = build_opener(urllib2.HTTPHandler()) self.opener_has_handler(o, urllib2.HTTPHandler) # Issue2670: multiple handlers sharing the same base class class MyOtherHTTPHandler(urllib2.HTTPHandler): pass o = build_opener(MyHTTPHandler, MyOtherHTTPHandler) self.opener_has_handler(o, MyHTTPHandler) self.opener_has_handler(o, MyOtherHTTPHandler) def opener_has_handler(self, opener, handler_class): for h in opener.handlers: if h.__class__ == handler_class: break else: self.assertTrue(False) class RequestTests(unittest.TestCase): def setUp(self): self.get = urllib2.Request("http://www.python.org/~jeremy/") self.post = urllib2.Request("http://www.python.org/~jeremy/", "data", headers={"X-Test": "test"}) def test_method(self): self.assertEqual("POST", self.post.get_method()) self.assertEqual("GET", self.get.get_method()) def test_add_data(self): self.assertTrue(not self.get.has_data()) self.assertEqual("GET", self.get.get_method()) self.get.add_data("spam") self.assertTrue(self.get.has_data()) self.assertEqual("POST", self.get.get_method()) def test_get_full_url(self): self.assertEqual("http://www.python.org/~jeremy/", self.get.get_full_url()) def test_selector(self): self.assertEqual("/~jeremy/", self.get.get_selector()) req = urllib2.Request("http://www.python.org/") self.assertEqual("/", req.get_selector()) def test_get_type(self): self.assertEqual("http", self.get.get_type()) def test_get_host(self): self.assertEqual("www.python.org", self.get.get_host()) def test_get_host_unquote(self): req = urllib2.Request("http://www.%70ython.org/") self.assertEqual("www.python.org", req.get_host()) def test_proxy(self): self.assertTrue(not self.get.has_proxy()) self.get.set_proxy("www.perl.org", "http") self.assertTrue(self.get.has_proxy()) self.assertEqual("www.python.org", self.get.get_origin_req_host()) self.assertEqual("www.perl.org", self.get.get_host()) def test_wrapped_url(self): req = Request("") self.assertEqual("www.python.org", req.get_host()) def test_url_fragment(self): req = Request("http://www.python.org/?qs=query#fragment=true") self.assertEqual("/?qs=query", req.get_selector()) req = Request("http://www.python.org/#fun=true") self.assertEqual("/", req.get_selector()) # Issue 11703: geturl() omits fragment in the original URL. url = 'http://docs.python.org/library/urllib2.html#OK' req = Request(url) self.assertEqual(req.get_full_url(), url) def test_HTTPError_interface(self): """ Issue 13211 reveals that HTTPError didn't implement the URLError interface even though HTTPError is a subclass of URLError. >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) >>> assert hasattr(err, 'reason') >>> err.reason 'something bad happened' """ def test_HTTPError_interface_call(self): """ Issue 15701= - HTTPError interface has info method available from URLError. """ err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs='Content-Length:42', fp=None) self.assertTrue(hasattr(err, 'reason')) assert hasattr(err, 'reason') assert hasattr(err, 'info') assert callable(err.info) try: err.info() except AttributeError: self.fail("err.info() failed") self.assertEqual(err.info(), "Content-Length:42") def test_main(verbose=None): from test import test_urllib2 test_support.run_doctest(test_urllib2, verbose) test_support.run_doctest(urllib2, verbose) tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, RequestTests) test_support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) gevent-1.1.0/greentest/2.7pypy/test_urllib2_localnet.py0000644000076500000000000004702512666555342023644 0ustar jmaddenwheel00000000000000import urlparse import urllib2 import BaseHTTPServer import unittest import hashlib from test import test_support mimetools = test_support.import_module('mimetools', deprecated=True) threading = test_support.import_module('threading') # Loopback http server infrastructure class LoopbackHttpServer(BaseHTTPServer.HTTPServer): """HTTP server w/ a few modifications that make it useful for loopback testing purposes. """ def __init__(self, server_address, RequestHandlerClass): BaseHTTPServer.HTTPServer.__init__(self, server_address, RequestHandlerClass) # Set the timeout of our listening socket really low so # that we can stop the server easily. self.socket.settimeout(1.0) def get_request(self): """BaseHTTPServer method, overridden.""" request, client_address = self.socket.accept() # It's a loopback connection, so setting the timeout # really low shouldn't affect anything, but should make # deadlocks less likely to occur. request.settimeout(10.0) return (request, client_address) class LoopbackHttpServerThread(threading.Thread): """Stoppable thread that runs a loopback http server.""" def __init__(self, request_handler): threading.Thread.__init__(self) self._stop = False self.ready = threading.Event() request_handler.protocol_version = "HTTP/1.0" self.httpd = LoopbackHttpServer(('127.0.0.1', 0), request_handler) #print "Serving HTTP on %s port %s" % (self.httpd.server_name, # self.httpd.server_port) self.port = self.httpd.server_port def stop(self): """Stops the webserver if it's currently running.""" # Set the stop flag. self._stop = True self.join() def run(self): self.ready.set() while not self._stop: self.httpd.handle_request() # Authentication infrastructure class DigestAuthHandler: """Handler for performing digest authentication.""" def __init__(self): self._request_num = 0 self._nonces = [] self._users = {} self._realm_name = "Test Realm" self._qop = "auth" def set_qop(self, qop): self._qop = qop def set_users(self, users): assert isinstance(users, dict) self._users = users def set_realm(self, realm): self._realm_name = realm def _generate_nonce(self): self._request_num += 1 nonce = hashlib.md5(str(self._request_num)).hexdigest() self._nonces.append(nonce) return nonce def _create_auth_dict(self, auth_str): first_space_index = auth_str.find(" ") auth_str = auth_str[first_space_index+1:] parts = auth_str.split(",") auth_dict = {} for part in parts: name, value = part.split("=") name = name.strip() if value[0] == '"' and value[-1] == '"': value = value[1:-1] else: value = value.strip() auth_dict[name] = value return auth_dict def _validate_auth(self, auth_dict, password, method, uri): final_dict = {} final_dict.update(auth_dict) final_dict["password"] = password final_dict["method"] = method final_dict["uri"] = uri HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict HA1 = hashlib.md5(HA1_str).hexdigest() HA2_str = "%(method)s:%(uri)s" % final_dict HA2 = hashlib.md5(HA2_str).hexdigest() final_dict["HA1"] = HA1 final_dict["HA2"] = HA2 response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \ "%(cnonce)s:%(qop)s:%(HA2)s" % final_dict response = hashlib.md5(response_str).hexdigest() return response == auth_dict["response"] def _return_auth_challenge(self, request_handler): request_handler.send_response(407, "Proxy Authentication Required") request_handler.send_header("Content-Type", "text/html") request_handler.send_header( 'Proxy-Authenticate', 'Digest realm="%s", ' 'qop="%s",' 'nonce="%s", ' % \ (self._realm_name, self._qop, self._generate_nonce())) # XXX: Not sure if we're supposed to add this next header or # not. #request_handler.send_header('Connection', 'close') request_handler.end_headers() request_handler.wfile.write("Proxy Authentication Required.") return False def handle_request(self, request_handler): """Performs digest authentication on the given HTTP request handler. Returns True if authentication was successful, False otherwise. If no users have been set, then digest auth is effectively disabled and this method will always return True. """ if len(self._users) == 0: return True if 'Proxy-Authorization' not in request_handler.headers: return self._return_auth_challenge(request_handler) else: auth_dict = self._create_auth_dict( request_handler.headers['Proxy-Authorization'] ) if auth_dict["username"] in self._users: password = self._users[ auth_dict["username"] ] else: return self._return_auth_challenge(request_handler) if not auth_dict.get("nonce") in self._nonces: return self._return_auth_challenge(request_handler) else: self._nonces.remove(auth_dict["nonce"]) auth_validated = False # MSIE uses short_path in its validation, but Python's # urllib2 uses the full path, so we're going to see if # either of them works here. for path in [request_handler.path, request_handler.short_path]: if self._validate_auth(auth_dict, password, request_handler.command, path): auth_validated = True if not auth_validated: return self._return_auth_challenge(request_handler) return True # Proxy test infrastructure class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler): """This is a 'fake proxy' that makes it look like the entire internet has gone down due to a sudden zombie invasion. It main utility is in providing us with authentication support for testing. """ def __init__(self, digest_auth_handler, *args, **kwargs): # This has to be set before calling our parent's __init__(), which will # try to call do_GET(). self.digest_auth_handler = digest_auth_handler BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs) def log_message(self, format, *args): # Uncomment the next line for debugging. #sys.stderr.write(format % args) pass def do_GET(self): (scm, netloc, path, params, query, fragment) = urlparse.urlparse( self.path, 'http') self.short_path = path if self.digest_auth_handler.handle_request(self): self.send_response(200, "OK") self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write("You've reached %s!
    " % self.path) self.wfile.write("Our apologies, but our server is down due to " "a sudden zombie invasion.") # Test cases class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() def tearDown(self): test_support.threading_cleanup(*self._threads) class ProxyAuthTests(BaseTestCase): URL = "http://localhost" USER = "tester" PASSWD = "test123" REALM = "TestRealm" def setUp(self): super(ProxyAuthTests, self).setUp() self.digest_auth_handler = DigestAuthHandler() self.digest_auth_handler.set_users({self.USER: self.PASSWD}) self.digest_auth_handler.set_realm(self.REALM) def create_fake_proxy_handler(*args, **kwargs): return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs) self.server = LoopbackHttpServerThread(create_fake_proxy_handler) self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port handler = urllib2.ProxyHandler({"http" : proxy_url}) self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler() self.opener = urllib2.build_opener(handler, self.proxy_digest_handler) def tearDown(self): self.server.stop() super(ProxyAuthTests, self).tearDown() def test_proxy_with_bad_password_raises_httperror(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD+"bad") self.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_with_no_password_raises_httperror(self): self.digest_auth_handler.set_qop("auth") self.assertRaises(urllib2.HTTPError, self.opener.open, self.URL) def test_proxy_qop_auth_works(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth") result = self.opener.open(self.URL) while result.read(): pass result.close() def test_proxy_qop_auth_int_works_or_throws_urlerror(self): self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth-int") try: result = self.opener.open(self.URL) except urllib2.URLError: # It's okay if we don't support auth-int, but we certainly # shouldn't receive any kind of exception here other than # a URLError. result = None if result: while result.read(): pass result.close() def GetRequestHandler(responses): class FakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version = "TestHTTP/" requests = [] headers_received = [] port = 80 def do_GET(self): body = self.send_head() if body: self.wfile.write(body) def do_POST(self): content_length = self.headers['Content-Length'] post_data = self.rfile.read(int(content_length)) self.do_GET() self.requests.append(post_data) def send_head(self): FakeHTTPRequestHandler.headers_received = self.headers self.requests.append(self.path) response_code, headers, body = responses.pop(0) self.send_response(response_code) for (header, value) in headers: self.send_header(header, value % self.port) if body: self.send_header('Content-type', 'text/plain') self.end_headers() return body self.end_headers() def log_message(self, *args): pass return FakeHTTPRequestHandler class TestUrlopen(BaseTestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. """ def setUp(self): proxy_handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(proxy_handler) urllib2.install_opener(opener) super(TestUrlopen, self).setUp() def start_server(self, responses): handler = GetRequestHandler(responses) self.server = LoopbackHttpServerThread(handler) self.server.start() self.server.ready.wait() port = self.server.port handler.port = port return handler def test_redirection(self): expected_response = 'We got here...' responses = [ (302, [('Location', 'http://localhost:%s/somewhere_else')], ''), (200, [], expected_response) ] handler = self.start_server(responses) try: f = urllib2.urlopen('http://localhost:%s/' % handler.port) data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/', '/somewhere_else']) finally: self.server.stop() def test_404(self): expected_response = 'Bad bad bad...' handler = self.start_server([(404, [], expected_response)]) try: try: urllib2.urlopen('http://localhost:%s/weeble' % handler.port) except urllib2.URLError, f: pass else: self.fail('404 should raise URLError') data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/weeble']) finally: self.server.stop() def test_200(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port) data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/bizarre']) finally: self.server.stop() def test_200_with_parameters(self): expected_response = 'pycon 2008...' handler = self.start_server([(200, [], expected_response)]) try: f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port, 'get=with_feeling') data = f.read() f.close() self.assertEqual(data, expected_response) self.assertEqual(handler.requests, ['/bizarre', 'get=with_feeling']) finally: self.server.stop() def test_sending_headers(self): handler = self.start_server([(200, [], "we don't care")]) try: req = urllib2.Request("http://localhost:%s/" % handler.port, headers={'Range': 'bytes=20-39'}) urllib2.urlopen(req) self.assertEqual(handler.headers_received['Range'], 'bytes=20-39') finally: self.server.stop() def test_basic(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) for attr in ("read", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " "urlopen lacks the %s attribute" % attr) try: self.assertTrue(open_url.read(), "calling 'read' failed") finally: open_url.close() finally: self.server.stop() def test_info(self): handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) info_obj = open_url.info() self.assertIsInstance(info_obj, mimetools.Message, "object returned by 'info' is not an " "instance of mimetools.Message") self.assertEqual(info_obj.getsubtype(), "plain") finally: self.server.stop() def test_geturl(self): # Make sure same URL as opened is returned by geturl. handler = self.start_server([(200, [], "we don't care")]) try: open_url = urllib2.urlopen("http://localhost:%s" % handler.port) url = open_url.geturl() self.assertEqual(url, "http://localhost:%s" % handler.port) finally: self.server.stop() def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. # as indicated by the comment below, this might fail with some ISP, # so we run the test only when -unetwork/-uall is specified to # mitigate the problem a bit (see #17564) test_support.requires('network') self.assertRaises(IOError, # Given that both VeriSign and various ISPs have in # the past or are presently hijacking various invalid # domain name requests in an attempt to boost traffic # to their own sites, finding a domain name to use # for this test is difficult. RFC2606 leads one to # believe that '.invalid' should work, but experience # seemed to indicate otherwise. Single character # TLDs are likely to remain invalid, so this seems to # be the best choice. The trailing '.' prevents a # related problem: The normal DNS resolver appends # the domain names from the search path if there is # no '.' the end and, and if one of those domains # implements a '*' rule a result is returned. # However, none of this will prevent the test from # failing if the ISP hijacks all invalid domain # requests. The real solution would be to be able to # parameterize the framework with a mock resolver. urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./") def test_iteration(self): expected_response = "pycon 2008..." handler = self.start_server([(200, [], expected_response)]) try: data = urllib2.urlopen("http://localhost:%s" % handler.port) for line in data: self.assertEqual(line, expected_response) finally: self.server.stop() def ztest_line_iteration(self): lines = ["We\n", "got\n", "here\n", "verylong " * 8192 + "\n"] expected_response = "".join(lines) handler = self.start_server([(200, [], expected_response)]) try: data = urllib2.urlopen("http://localhost:%s" % handler.port) for index, line in enumerate(data): self.assertEqual(line, lines[index], "Fetched line number %s doesn't match expected:\n" " Expected length was %s, got %s" % (index, len(lines[index]), len(line))) finally: self.server.stop() self.assertEqual(index + 1, len(lines)) def test_main(): # We will NOT depend on the network resource flag # (Lib/test/regrtest.py -u network) since all tests here are only # localhost. However, if this is a bad rationale, then uncomment # the next line. #test_support.requires("network") test_support.run_unittest(ProxyAuthTests, TestUrlopen) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_urllib2net.py0000644000076500000000000002770212666555342022472 0ustar jmaddenwheel00000000000000import unittest from test import test_support from test.test_urllib2 import sanepathname2url import socket import urllib2 import os import sys TIMEOUT = 60 # seconds def _retry_thrice(func, exc, *args, **kwargs): for i in range(3): try: return func(*args, **kwargs) except exc, last_exc: continue except: raise raise last_exc def _wrap_with_retry_thrice(func, exc): def wrapped(*args, **kwargs): return _retry_thrice(func, exc, *args, **kwargs) return wrapped # Connecting to remote hosts is flaky. Make it more robust by retrying # the connection several times. _urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError) class AuthTests(unittest.TestCase): """Tests urllib2 authentication features.""" ## Disabled at the moment since there is no page under python.org which ## could be used to HTTP authentication. # # def test_basic_auth(self): # import httplib # # test_url = "http://www.python.org/test/test_urllib2/basic_auth" # test_hostport = "www.python.org" # test_realm = 'Test Realm' # test_user = 'test.test_urllib2net' # test_password = 'blah' # # # failure # try: # _urlopen_with_retry(test_url) # except urllib2.HTTPError, exc: # self.assertEqual(exc.code, 401) # else: # self.fail("urlopen() should have failed with 401") # # # success # auth_handler = urllib2.HTTPBasicAuthHandler() # auth_handler.add_password(test_realm, test_hostport, # test_user, test_password) # opener = urllib2.build_opener(auth_handler) # f = opener.open('http://localhost/') # response = _urlopen_with_retry("http://www.python.org/") # # # The 'userinfo' URL component is deprecated by RFC 3986 for security # # reasons, let's not implement it! (it's already implemented for proxy # # specification strings (that is, URLs or authorities specifying a # # proxy), so we must keep that) # self.assertRaises(httplib.InvalidURL, # urllib2.urlopen, "http://evil:thing@example.com") class CloseSocketTest(unittest.TestCase): def test_close(self): import httplib # calling .close() on urllib2's response objects should close the # underlying socket # delve deep into response to fetch socket._socketobject response = _urlopen_with_retry("http://www.example.com/") abused_fileobject = response.fp #self.assertIs(abused_fileobject.__class__, socket._fileobject) JAM gevent: disable httpresponse = abused_fileobject._sock self.assertIs(httpresponse.__class__, httplib.HTTPResponse) fileobject = httpresponse.fp #self.assertIs(fileobject.__class__, socket._fileobject) JAM gevent: disable self.assertTrue(not fileobject.closed) response.close() self.assertTrue(fileobject.closed) class OtherNetworkTests(unittest.TestCase): def setUp(self): if 0: # for debugging import logging logger = logging.getLogger("test_urllib2net") logger.addHandler(logging.StreamHandler()) # XXX The rest of these tests aren't very good -- they don't check much. # They do sometimes catch some major disasters, though. def test_ftp(self): urls = [ 'ftp://ftp.kernel.org/pub/linux/kernel/README', 'ftp://ftp.kernel.org/pub/linux/kernel/non-existent-file', #'ftp://ftp.kernel.org/pub/leenox/kernel/test', 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC' '/research-reports/00README-Legal-Rules-Regs', ] self._test_urls(urls, self._extra_handlers()) def test_file(self): TESTFN = test_support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') f.close() urls = [ 'file:'+sanepathname2url(os.path.abspath(TESTFN)), ('file:///nonsensename/etc/passwd', None, urllib2.URLError), ] self._test_urls(urls, self._extra_handlers(), retry=True) finally: os.remove(TESTFN) self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file') # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes. ## def test_cnri(self): ## if socket.gethostname() == 'bitdiddle': ## localhost = 'bitdiddle.cnri.reston.va.us' ## elif socket.gethostname() == 'bitdiddle.concentric.net': ## localhost = 'localhost' ## else: ## localhost = None ## if localhost is not None: ## urls = [ ## 'file://%s/etc/passwd' % localhost, ## 'http://%s/simple/' % localhost, ## 'http://%s/digest/' % localhost, ## 'http://%s/not/found.h' % localhost, ## ] ## bauth = HTTPBasicAuthHandler() ## bauth.add_password('basic_test_realm', localhost, 'jhylton', ## 'password') ## dauth = HTTPDigestAuthHandler() ## dauth.add_password('digest_test_realm', localhost, 'jhylton', ## 'password') ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def test_urlwithfrag(self): urlwith_frag = "https://docs.python.org/2/glossary.html#glossary" with test_support.transient_internet(urlwith_frag): req = urllib2.Request(urlwith_frag) res = urllib2.urlopen(req) self.assertEqual(res.geturl(), "https://docs.python.org/2/glossary.html#glossary") def test_fileno(self): req = urllib2.Request("http://www.example.com") opener = urllib2.build_opener() res = opener.open(req) try: res.fileno() except AttributeError: self.fail("HTTPResponse object should return a valid fileno") finally: res.close() def test_custom_headers(self): url = "http://www.example.com" with test_support.transient_internet(url): opener = urllib2.build_opener() request = urllib2.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent') def test_sites_no_connection_close(self): # Some sites do not send Connection: close header. # Verify that those work properly. (#issue12576) URL = 'http://www.imdb.com' # No Connection:close with test_support.transient_internet(URL): req = urllib2.urlopen(URL) res = req.read() self.assertTrue(res) def _test_urls(self, urls, handlers, retry=True): import time import logging debug = logging.getLogger("test_urllib2").debug urlopen = urllib2.build_opener(*handlers).open if retry: urlopen = _wrap_with_retry_thrice(urlopen, urllib2.URLError) for url in urls: if isinstance(url, tuple): url, req, expected_err = url else: req = expected_err = None with test_support.transient_internet(url): debug(url) try: f = urlopen(url, req, TIMEOUT) except EnvironmentError as err: debug(err) if expected_err: msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" % (expected_err, url, req, type(err), err)) self.assertIsInstance(err, expected_err, msg) except urllib2.URLError as err: if isinstance(err[0], socket.timeout): print >>sys.stderr, "" % url continue else: raise else: try: with test_support.transient_internet(url): buf = f.read() debug("read %d bytes" % len(buf)) except socket.timeout: print >>sys.stderr, "" % url f.close() debug("******** next url coming up...") time.sleep(0.1) def _extra_handlers(self): handlers = [] cfh = urllib2.CacheFTPHandler() self.addCleanup(cfh.clear_cache) cfh.setTimeout(1) handlers.append(cfh) return handlers class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) def test_http_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url) finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) def test_http_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = "http://www.example.com" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) def test_http_timeout(self): url = "http://www.example.com" with test_support.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) FTP_HOST = "ftp://ftp.mirror.nl/pub/gnu/" def test_ftp_basic(self): self.assertIsNone(socket.getdefaulttimeout()) with test_support.transient_internet(self.FTP_HOST, timeout=None): u = _urlopen_with_retry(self.FTP_HOST) self.assertIsNone(u.fp.fp._sock.gettimeout()) def test_ftp_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_ftp_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout(),) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(u.fp.fp._sock.gettimeout()) def test_ftp_timeout(self): with test_support.transient_internet(self.FTP_HOST): u = _urlopen_with_retry(self.FTP_HOST, timeout=60) self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_main(): test_support.requires("network") test_support.run_unittest(AuthTests, OtherNetworkTests, CloseSocketTest, TimeoutTest, ) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/test_wsgiref.py0000644000076500000000000004611212666555342022052 0ustar jmaddenwheel00000000000000from __future__ import nested_scopes # Backward compat for 2.1 from unittest import TestCase from wsgiref.util import setup_testing_defaults from wsgiref.headers import Headers from wsgiref.handlers import BaseHandler, BaseCGIHandler from wsgiref import util from wsgiref.validate import validator from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app from wsgiref.simple_server import make_server from StringIO import StringIO from SocketServer import BaseServer import os import re import sys from test import test_support class MockServer(WSGIServer): """Non-socket HTTP server""" def __init__(self, server_address, RequestHandlerClass): BaseServer.__init__(self, server_address, RequestHandlerClass) self.server_bind() def server_bind(self): host, port = self.server_address self.server_name = host self.server_port = port self.setup_environ() class MockHandler(WSGIRequestHandler): """Non-socket HTTP handler""" def setup(self): self.connection = self.request self.rfile, self.wfile = self.connection def finish(self): pass def hello_app(environ,start_response): start_response("200 OK", [ ('Content-Type','text/plain'), ('Date','Mon, 05 Jun 2006 18:49:54 GMT') ]) return ["Hello, world!"] def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"): server = make_server("", 80, app, MockServer, MockHandler) inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr sys.stderr = err try: server.finish_request((inp,out), ("127.0.0.1",8888)) finally: sys.stderr = olderr return out.getvalue(), err.getvalue() def compare_generic_iter(make_it,match): """Utility to compare a generic 2.1/2.2+ iterator with an iterable If running under Python 2.2+, this tests the iterator using iter()/next(), as well as __getitem__. 'make_it' must be a function returning a fresh iterator to be tested (since this may test the iterator twice).""" it = make_it() n = 0 for item in match: if not it[n]==item: raise AssertionError n+=1 try: it[n] except IndexError: pass else: raise AssertionError("Too many items from __getitem__",it) try: iter, StopIteration except NameError: pass else: # Only test iter mode under 2.2+ it = make_it() if not iter(it) is it: raise AssertionError for item in match: if not it.next()==item: raise AssertionError try: it.next() except StopIteration: pass else: raise AssertionError("Too many items from .next()",it) class IntegrationTests(TestCase): def check_hello(self, out, has_length=True): self.assertEqual(out, "HTTP/1.0 200 OK\r\n" "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n" "Content-Type: text/plain\r\n" "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" + (has_length and "Content-Length: 13\r\n" or "") + "\r\n" "Hello, world!" ) def test_plain_hello(self): out, err = run_amock() self.check_hello(out) def test_validated_hello(self): out, err = run_amock(validator(hello_app)) # the middleware doesn't support len(), so content-length isn't there self.check_hello(out, has_length=False) def test_simple_validation_error(self): def bad_app(environ,start_response): start_response("200 OK", ('Content-Type','text/plain')) return ["Hello, world!"] out, err = run_amock(validator(bad_app)) self.assertTrue(out.endswith( "A server error occurred. Please contact the administrator." )) self.assertEqual( err.splitlines()[-2], "AssertionError: Headers (('Content-Type', 'text/plain')) must" " be of type list: " ) class UtilityTests(TestCase): def checkShift(self,sn_in,pi_in,part,sn_out,pi_out): env = {'SCRIPT_NAME':sn_in,'PATH_INFO':pi_in} util.setup_testing_defaults(env) self.assertEqual(util.shift_path_info(env),part) self.assertEqual(env['PATH_INFO'],pi_out) self.assertEqual(env['SCRIPT_NAME'],sn_out) return env def checkDefault(self, key, value, alt=None): # Check defaulting when empty env = {} util.setup_testing_defaults(env) if isinstance(value, StringIO): self.assertIsInstance(env[key], StringIO) else: self.assertEqual(env[key], value) # Check existing value env = {key:alt} util.setup_testing_defaults(env) self.assertIs(env[key], alt) def checkCrossDefault(self,key,value,**kw): util.setup_testing_defaults(kw) self.assertEqual(kw[key],value) def checkAppURI(self,uri,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.application_uri(kw),uri) def checkReqURI(self,uri,query=1,**kw): util.setup_testing_defaults(kw) self.assertEqual(util.request_uri(kw,query),uri) def checkFW(self,text,size,match): def make_it(text=text,size=size): return util.FileWrapper(StringIO(text),size) compare_generic_iter(make_it,match) it = make_it() self.assertFalse(it.filelike.closed) for item in it: pass self.assertFalse(it.filelike.closed) it.close() self.assertTrue(it.filelike.closed) def testSimpleShifts(self): self.checkShift('','/', '', '/', '') self.checkShift('','/x', 'x', '/x', '') self.checkShift('/','', None, '/', '') self.checkShift('/a','/x/y', 'x', '/a/x', '/y') self.checkShift('/a','/x/', 'x', '/a/x', '/') def testNormalizedShifts(self): self.checkShift('/a/b', '/../y', '..', '/a', '/y') self.checkShift('', '/../y', '..', '', '/y') self.checkShift('/a/b', '//y', 'y', '/a/b/y', '') self.checkShift('/a/b', '//y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '/./y', 'y', '/a/b/y', '') self.checkShift('/a/b', '/./y/', 'y', '/a/b/y', '/') self.checkShift('/a/b', '///./..//y/.//', '..', '/a', '/y/') self.checkShift('/a/b', '///', '', '/a/b/', '') self.checkShift('/a/b', '/.//', '', '/a/b/', '') self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/') self.checkShift('/a/b', '/.', None, '/a/b', '') def testDefaults(self): for key, value in [ ('SERVER_NAME','127.0.0.1'), ('SERVER_PORT', '80'), ('SERVER_PROTOCOL','HTTP/1.0'), ('HTTP_HOST','127.0.0.1'), ('REQUEST_METHOD','GET'), ('SCRIPT_NAME',''), ('PATH_INFO','/'), ('wsgi.version', (1,0)), ('wsgi.run_once', 0), ('wsgi.multithread', 0), ('wsgi.multiprocess', 0), ('wsgi.input', StringIO("")), ('wsgi.errors', StringIO()), ('wsgi.url_scheme','http'), ]: self.checkDefault(key,value) def testCrossDefaults(self): self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="1") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="yes") self.checkCrossDefault('wsgi.url_scheme',"http",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on") def testGuessScheme(self): self.assertEqual(util.guess_scheme({}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"on"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https") def testAppURIs(self): self.checkAppURI("http://127.0.0.1/") self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkAppURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkAppURI("http://spam.example.com:2071/", HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071") self.checkAppURI("http://spam.example.com/", SERVER_NAME="spam.example.com") self.checkAppURI("http://127.0.0.1/", HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com") self.checkAppURI("https://127.0.0.1/", HTTPS="on") self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000", HTTP_HOST=None) def testReqURIs(self): self.checkReqURI("http://127.0.0.1/") self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") self.checkReqURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam", SCRIPT_NAME="/spammity", PATH_INFO="/spam") self.checkReqURI("http://127.0.0.1/spammity/sp%E4m", SCRIPT_NAME="/spammity", PATH_INFO="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam;ham", SCRIPT_NAME="/spammity", PATH_INFO="/spam;ham") self.checkReqURI("http://127.0.0.1/spammity/spam;cookie=1234,5678", SCRIPT_NAME="/spammity", PATH_INFO="/spam;cookie=1234,5678") self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") self.checkReqURI("http://127.0.0.1/spammity/spam?s%E4y=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="s%E4y=ni") self.checkReqURI("http://127.0.0.1/spammity/spam", 0, SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") def testFileWrapper(self): self.checkFW("xyz"*50, 120, ["xyz"*40,"xyz"*10]) def testHopByHop(self): for hop in ( "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization " "TE Trailers Transfer-Encoding Upgrade" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.assertTrue(util.is_hop_by_hop(alt)) # Not comprehensive, just a few random header names for hop in ( "Accept Cache-Control Date Pragma Trailer Via Warning" ).split(): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.assertFalse(util.is_hop_by_hop(alt)) class HeaderTests(TestCase): def testMappingInterface(self): test = [('x','y')] self.assertEqual(len(Headers([])),0) self.assertEqual(len(Headers(test[:])),1) self.assertEqual(Headers(test[:]).keys(), ['x']) self.assertEqual(Headers(test[:]).values(), ['y']) self.assertEqual(Headers(test[:]).items(), test) self.assertIsNot(Headers(test).items(), test) # must be copy! h=Headers([]) del h['foo'] # should not raise an error h['Foo'] = 'bar' for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__: self.assertTrue(m('foo')) self.assertTrue(m('Foo')) self.assertTrue(m('FOO')) self.assertFalse(m('bar')) self.assertEqual(h['foo'],'bar') h['foo'] = 'baz' self.assertEqual(h['FOO'],'baz') self.assertEqual(h.get_all('foo'),['baz']) self.assertEqual(h.get("foo","whee"), "baz") self.assertEqual(h.get("zoo","whee"), "whee") self.assertEqual(h.setdefault("foo","whee"), "baz") self.assertEqual(h.setdefault("zoo","whee"), "whee") self.assertEqual(h["foo"],"baz") self.assertEqual(h["zoo"],"whee") def testRequireList(self): self.assertRaises(TypeError, Headers, "foo") def testExtras(self): h = Headers([]) self.assertEqual(str(h),'\r\n') h.add_header('foo','bar',baz="spam") self.assertEqual(h['foo'], 'bar; baz="spam"') self.assertEqual(str(h),'foo: bar; baz="spam"\r\n\r\n') h.add_header('Foo','bar',cheese=None) self.assertEqual(h.get_all('foo'), ['bar; baz="spam"', 'bar; cheese']) self.assertEqual(str(h), 'foo: bar; baz="spam"\r\n' 'Foo: bar; cheese\r\n' '\r\n' ) class ErrorHandler(BaseCGIHandler): """Simple handler subclass for testing BaseHandler""" # BaseHandler records the OS environment at import time, but envvars # might have been changed later by other tests, which trips up # HandlerTests.testEnviron(). os_environ = dict(os.environ.items()) def __init__(self,**kw): setup_testing_defaults(kw) BaseCGIHandler.__init__( self, StringIO(''), StringIO(), StringIO(), kw, multithread=True, multiprocess=True ) class TestHandler(ErrorHandler): """Simple handler subclass for testing BaseHandler, w/error passthru""" def handle_error(self): raise # for testing, we want to see what's happening class HandlerTests(TestCase): def checkEnvironAttrs(self, handler): env = handler.environ for attr in [ 'version','multithread','multiprocess','run_once','file_wrapper' ]: if attr=='file_wrapper' and handler.wsgi_file_wrapper is None: continue self.assertEqual(getattr(handler,'wsgi_'+attr),env['wsgi.'+attr]) def checkOSEnviron(self,handler): empty = {}; setup_testing_defaults(empty) env = handler.environ from os import environ for k,v in environ.items(): if k not in empty: self.assertEqual(env[k],v) for k,v in empty.items(): self.assertIn(k, env) def testEnviron(self): h = TestHandler(X="Y") h.setup_environ() self.checkEnvironAttrs(h) self.checkOSEnviron(h) self.assertEqual(h.environ["X"],"Y") def testCGIEnviron(self): h = BaseCGIHandler(None,None,None,{}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': self.assertIn(key, h.environ) def testScheme(self): h=TestHandler(HTTPS="on"); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'https') h=TestHandler(); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'http') def testAbstractMethods(self): h = BaseHandler() for name in [ '_flush','get_stdin','get_stderr','add_cgi_vars' ]: self.assertRaises(NotImplementedError, getattr(h,name)) self.assertRaises(NotImplementedError, h._write, "test") def testContentLength(self): # Demo one reason iteration is better than write()... ;) def trivial_app1(e,s): s('200 OK',[]) return [e['wsgi.url_scheme']] def trivial_app2(e,s): s('200 OK',[])(e['wsgi.url_scheme']) return [] def trivial_app4(e,s): # Simulate a response to a HEAD request s('200 OK',[('Content-Length', '12345')]) return [] h = TestHandler() h.run(trivial_app1) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 4\r\n" "\r\n" "http") h = TestHandler() h.run(trivial_app2) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n" "http") h = TestHandler() h.run(trivial_app4) self.assertEqual(h.stdout.getvalue(), b'Status: 200 OK\r\n' b'Content-Length: 12345\r\n' b'\r\n') def testBasicErrorOutput(self): def non_error_app(e,s): s('200 OK',[]) return [] def error_app(e,s): raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(non_error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n") self.assertEqual(h.stderr.getvalue(),"") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: %s\r\n" "Content-Type: text/plain\r\n" "Content-Length: %d\r\n" "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)) self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1) def testErrorAfterOutput(self): MSG = "Some output has been sent" def error_app(e,s): s("200 OK",[])(MSG) raise AssertionError("This should be caught by handler") h = ErrorHandler() h.run(error_app) self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n"+MSG) self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1) def testHeaderFormats(self): def non_error_app(e,s): s('200 OK',[]) return [] stdpat = ( r"HTTP/%s 200 OK\r\n" r"Date: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n" r"%s" r"Content-Length: 0\r\n" r"\r\n" ) shortpat = ( "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n" ) for ssw in "FooBar/1.0", None: sw = ssw and "Server: %s\r\n" % ssw or "" for version in "1.0", "1.1": for proto in "HTTP/0.9", "HTTP/1.0", "HTTP/1.1": h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = False h.http_version = version h.server_software = ssw h.run(non_error_app) self.assertEqual(shortpat,h.stdout.getvalue()) h = TestHandler(SERVER_PROTOCOL=proto) h.origin_server = True h.http_version = version h.server_software = ssw h.run(non_error_app) if proto=="HTTP/0.9": self.assertEqual(h.stdout.getvalue(),"") else: self.assertTrue( re.match(stdpat%(version,sw), h.stdout.getvalue()), (stdpat%(version,sw), h.stdout.getvalue()) ) def testCloseOnError(self): side_effects = {'close_called': False} MSG = b"Some output has been sent" def error_app(e,s): s("200 OK",[])(MSG) class CrashyIterable(object): def __iter__(self): while True: yield b'blah' raise AssertionError("This should be caught by handler") def close(self): side_effects['close_called'] = True return CrashyIterable() h = ErrorHandler() h.run(error_app) self.assertEqual(side_effects['close_called'], True) def test_main(): test_support.run_unittest(__name__) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/2.7pypy/version0000644000076500000000000000000612666555342020373 0ustar jmaddenwheel000000000000002.7.8 gevent-1.1.0/greentest/2.7pypy/wrongcert.pem0000644000076500000000000000353012666555342021505 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw eSHj5jpC8iZKjCHBn+mAi4cQ514= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/0000755000076500000000000000000012666555433016044 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.4/badcert.pem0000644000076500000000000000361012666555342020152 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/badkey.pem0000644000076500000000000000416212666555342020010 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/0000755000076500000000000000000012666555433017304 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.4/capath/0e4015b9.00000644000076500000000000000167412666555342020445 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/4e1295a3.00000644000076500000000000000145612666555342020447 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/5ed36f99.00000644000076500000000000000501112666555342020537 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/6e88d7b8.00000644000076500000000000000145612666555342020551 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/99d0fa06.00000644000076500000000000000501112666555342020523 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/capath/ce7b8643.00000644000076500000000000000167412666555342020541 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/dh1024.pem0000644000076500000000000000045412666555342017453 0ustar jmaddenwheel00000000000000-----BEGIN DH PARAMETERS----- MIGHAoGBAIbzw1s9CT8SV5yv6L7esdAdZYZjPi3qWFs61CYTFFQnf2s/d09NYaJt rrvJhIzWavqnue71qXCf83/J3nz3FEwUU/L0mGyheVbsSHiI64wUo3u50wK5Igo0 RNs/LD0irs7m0icZ//hijafTU+JOBiuA8zMI+oZfU7BGuc9XrUprAgEC -----END DH PARAMETERS----- Generated with: openssl dhparam -out dh1024.pem 1024 gevent-1.1.0/greentest/3.4/https_svn_python_org_root.pem0000644000076500000000000000501112666555342024106 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/keycert.passwd.pem0000644000076500000000000000344612666555342021523 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/keycert.pem0000644000076500000000000000336712666555342020225 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/keycert2.pem0000644000076500000000000000340312666555342020276 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJnsJZVrppL+W5I9 zGQrrawWwE5QJpBK9nWw17mXrZ03R1cD9BamLGivVISbPlRlAVnZBEyh1ATpsB7d CUQ+WHEvALquvx4+Yw5l+fXeiYRjrLRBYZuVy8yNtXzU3iWcGObcYRkUdiXdOyP7 sLF2YZHRvQZpzgDBKkrraeQ81w21AgMBAAECgYBEm7n07FMHWlE+0kT0sXNsLYfy YE+QKZnJw9WkaDN+zFEEPELkhZVt5BjsMraJr6v2fIEqF0gGGJPkbenffVq2B5dC lWUOxvJHufMK4sM3Cp6s/gOp3LP+QkzVnvJSfAyZU6l+4PGX5pLdUsXYjPxgzjzL S36tF7/2Uv1WePyLUQJBAMsPhYzUXOPRgmbhcJiqi9A9c3GO8kvSDYTCKt3VMnqz HBn6MQ4VQasCD1F+7jWTI0FU/3vdw8non/Fj8hhYqZcCQQDCDRdvmZqDiZnpMqDq L6ZSrLTVtMvZXZbgwForaAD9uHj51TME7+eYT7EG2YCgJTXJ4YvRJEnPNyskwdKt vTSTAkEAtaaN/vyemEJ82BIGStwONNw0ILsSr5cZ9tBHzqiA/tipY+e36HRFiXhP QcU9zXlxyWkDH8iz9DSAmE2jbfoqwwJANlMJ65E543cjIlitGcKLMnvtCCLcKpb7 xSG0XJB6Lo11OKPJ66jp0gcFTSCY1Lx2CXVd+gfJrfwI1Pp562+bhwJBAJ9IfDPU R8OpO9v1SGd8x33Owm7uXOpB9d63/T70AD1QOXjKUC4eXYbt0WWfWuny/RNPRuyh w7DXSfUF+kPKolU= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICXTCCAcagAwIBAgIJAIO3upAG445fMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTAeFw0x MDEwMDkxNTAxMDBaFw0yMDEwMDYxNTAxMDBaMGIxCzAJBgNVBAYTAlhZMRcwFQYD VQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZv dW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTCBnzANBgkqhkiG9w0BAQEF AAOBjQAwgYkCgYEAmewllWumkv5bkj3MZCutrBbATlAmkEr2dbDXuZetnTdHVwP0 FqYsaK9UhJs+VGUBWdkETKHUBOmwHt0JRD5YcS8Auq6/Hj5jDmX59d6JhGOstEFh m5XLzI21fNTeJZwY5txhGRR2Jd07I/uwsXZhkdG9BmnOAMEqSutp5DzXDbUCAwEA AaMbMBkwFwYDVR0RBBAwDoIMZmFrZWhvc3RuYW1lMA0GCSqGSIb3DQEBBQUAA4GB AH+iMClLLGSaKWgwXsmdVo4FhTZZHo8Uprrtg3N9FxEeE50btpDVQysgRt5ias3K m+bME9zbKwvbVWD5zZdjus4pDgzwF/iHyccL8JyYhxOvS/9zmvAtFXj/APIIbZFp IT75d9f88ScIGEtknZQejnrdhB64tYki/EqluiuKBqKD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/keycert3.pem0000644000076500000000000000772212666555342020307 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLgD0kAKDb5cFyP jbwNfR5CtewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM 9z2j1OlaN+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZ aggEdkj1TsSsv1zWIYKlPIjlvhuxAgMBAAECgYA0aH+T2Vf3WOPv8KdkcJg6gCRe yJKXOWgWRcicx/CUzOEsTxmFIDPLxqAWA3k7v0B+3vjGw5Y9lycV/5XqXNoQI14j y09iNsumds13u5AKkGdTJnZhQ7UKdoVHfuP44ZdOv/rJ5/VD6F4zWywpe90pcbK+ AWDVtusgGQBSieEl1QJBAOyVrUG5l2yoUBtd2zr/kiGm/DYyXlIthQO/A3/LngDW 5/ydGxVsT7lAVOgCsoT+0L4efTh90PjzW8LPQrPBWVMCQQDS3h/FtYYd5lfz+FNL 9CEe1F1w9l8P749uNUD0g317zv1tatIqVCsQWHfVHNdVvfQ+vSFw38OORO00Xqs9 1GJrAkBkoXXEkxCZoy4PteheO/8IWWLGGr6L7di6MzFl1lIqwT6D8L9oaV2vynFT DnKop0pa09Unhjyw57KMNmSE2SUJAkEArloTEzpgRmCq4IK2/NpCeGdHS5uqRlbh 1VIa/xGps7EWQl5Mn8swQDel/YP3WGHTjfx7pgSegQfkyaRtGpZ9OQJAa9Vumj8m JAAtI0Bnga8hgQx7BhTQY4CadDxyiRGOGYhwUzYVCqkb2sbVRH9HnwUaJT7cWBY3 RnJdHOMXWem7/w== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443281 (0xb09264b1f2da21d1) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:c2:e0:0f:49:00:28:36:f9:70:5c:8f:8d:bc:0d: 7d:1e:42:b5:ec:1d:5c:2f:a4:31:70:16:0f:c0:cb: c6:24:d3:be:13:16:ee:a5:67:97:03:a6:df:a9:99: 96:cc:c7:2a:fb:11:7f:4e:65:4f:8a:5e:82:21:4c: f7:3d:a3:d4:e9:5a:37:e7:22:fd:7e:cd:53:6d:93: 34:de:9c:ad:84:a2:37:be:c5:8d:82:4f:e3:ae:23: f3:be:a7:75:2c:72:0f:ea:f3:ca:cd:fc:e9:3f:b5: af:56:99:6a:08:04:76:48:f5:4e:c4:ac:bf:5c:d6: 21:82:a5:3c:88:e5:be:1b:b1 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption 2f:42:5f:a3:09:2c:fa:51:88:c7:37:7f:ea:0e:63:f0:a2:9a: e5:5a:e2:c8:20:f0:3f:60:bc:c8:0f:b6:c6:76:ce:db:83:93: f5:a3:33:67:01:8e:04:cd:00:9a:73:fd:f3:35:86:fa:d7:13: e2:46:c6:9d:c0:29:53:d4:a9:90:b8:77:4b:e6:83:76:e4:92: d6:9c:50:cf:43:d0:c6:01:77:61:9a:de:9b:70:f7:72:cd:59: 00:31:69:d9:b4:ca:06:9c:6d:c3:c7:80:8c:68:e6:b5:a2:f8: ef:1d:bb:16:9f:77:77:ef:87:62:22:9b:4d:69:a4:3a:1a:f1: 21:5e:8c:32:ac:92:fd:15:6b:18:c2:7f:15:0d:98:30:ca:75: 8f:1a:71:df:da:1d:b2:ef:9a:e8:2d:2e:02:fd:4a:3c:aa:96: 0b:06:5d:35:b3:3d:24:87:4b:e0:b0:58:60:2f:45:ac:2e:48: 8a:b0:99:10:65:27:ff:cc:b1:d8:fd:bd:26:6b:b9:0c:05:2a: f4:45:63:35:51:07:ed:83:85:fe:6f:69:cb:bb:40:a8:ae:b6: 3b:56:4a:2d:a4:ed:6d:11:2c:4d:ed:17:24:fd:47:bc:d3:41: a2:d3:06:fe:0c:90:d8:d8:94:26:c4:ff:cc:a1:d8:42:77:eb: fc:a9:94:71 -----BEGIN CERTIFICATE----- MIICpDCCAYwCCQCwkmSx8toh0TANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBfMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRIwEAYDVQQDEwlsb2NhbGhv c3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMLgD0kAKDb5cFyPjbwNfR5C tewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM9z2j1Ola N+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZaggEdkj1 TsSsv1zWIYKlPIjlvhuxAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAC9CX6MJLPpR iMc3f+oOY/CimuVa4sgg8D9gvMgPtsZ2ztuDk/WjM2cBjgTNAJpz/fM1hvrXE+JG xp3AKVPUqZC4d0vmg3bkktacUM9D0MYBd2Ga3ptw93LNWQAxadm0ygacbcPHgIxo 5rWi+O8duxafd3fvh2Iim01ppDoa8SFejDKskv0VaxjCfxUNmDDKdY8acd/aHbLv mugtLgL9SjyqlgsGXTWzPSSHS+CwWGAvRawuSIqwmRBlJ//Msdj9vSZruQwFKvRF YzVRB+2Dhf5vacu7QKiutjtWSi2k7W0RLE3tFyT9R7zTQaLTBv4MkNjYlCbE/8yh 2EJ36/yplHE= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/keycert4.pem0000644000076500000000000000773112666555342020310 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK5UQiMI5VkNs2Qv L7gUaiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2 NkX0ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1 L2OQhEx1GM6RydHdgX69G64LXcY5AgMBAAECgYAhsRMfJkb9ERLMl/oG/5sLQu9L pWDKt6+ZwdxzlZbggQ85CMYshjLKIod2DLL/sLf2x1PRXyRG131M1E3k8zkkz6de R1uDrIN/x91iuYzfLQZGh8bMY7Yjd2eoroa6R/7DjpElGejLxOAaDWO0ST2IFQy9 myTGS2jSM97wcXfsSQJBANP3jelJoS5X6BRjTSneY21wcocxVuQh8pXpErALVNsT drrFTeaBuZp7KvbtnIM5g2WRNvaxLZlAY/hXPJvi6ncCQQDSix1cebml6EmPlEZS Mm8gwI2F9ufUunwJmBJcz826Do0ZNGByWDAM/JQZH4FX4GfAFNuj8PUb+GQfadkx i1DPAkEA0lVsNHojvuDsIo8HGuzarNZQT2beWjJ1jdxh9t7HrTx7LIps6rb/fhOK Zs0R6gVAJaEbcWAPZ2tFyECInAdnsQJAUjaeXXjuxFkjOFym5PvqpvhpivEx78Bu JPTr3rAKXmfGMxxfuOa0xK1wSyshP6ZR/RBn/+lcXPKubhHQDOegwwJAJF1DBQnN +/tLmOPULtDwfP4Zixn+/8GmGOahFoRcu6VIGHmRilJTn6MOButw7Glv2YdeC6l/ e83Gq6ffLVfKNQ== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443282 (0xb09264b1f2da21d2) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=fakehostname Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:ae:54:42:23:08:e5:59:0d:b3:64:2f:2f:b8:14: 6a:20:dd:15:eb:cd:51:74:63:53:80:c7:01:ed:d9: cf:36:0b:64:d1:3a:f6:1f:60:3b:d5:42:49:2d:7a: b4:9e:5f:4f:95:44:bb:41:19:c8:6a:f4:7b:75:76: 36:45:f4:66:85:34:1d:cf:d4:69:8e:2a:c7:b2:c7: 9a:7e:52:61:9a:48:c6:12:67:91:fe:d2:c8:72:4a: d7:35:1a:1a:55:34:fc:bc:58:a8:8b:86:0a:d1:79: 76:ac:75:2f:63:90:84:4c:75:18:ce:91:c9:d1:dd: 81:7e:bd:1b:ae:0b:5d:c6:39 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption ad:45:8a:8e:ef:c6:ef:04:41:5c:2c:4a:84:dc:02:76:0c:d0: 66:0f:f0:16:04:58:4d:fd:68:b7:b8:d3:a8:41:a5:5c:3c:6f: 65:3c:d1:f8:ce:43:35:e7:41:5f:53:3d:c9:2c:c3:7d:fc:56: 4a:fa:47:77:38:9d:bb:97:28:0a:3b:91:19:7f:bc:74:ae:15: 6b:bd:20:36:67:45:a5:1e:79:d7:75:e6:89:5c:6d:54:84:d1: 95:d7:a7:b4:33:3c:af:37:c4:79:8f:5e:75:dc:75:c2:18:fb: 61:6f:2d:dc:38:65:5b:ba:67:28:d0:88:d7:8d:b9:23:5a:8e: e8:c6:bb:db:ce:d5:b8:41:2a:ce:93:08:b6:95:ad:34:20:18: d5:3b:37:52:74:50:0b:07:2c:b0:6d:a4:4c:7b:f4:e0:fd:d1: af:17:aa:20:cd:62:e3:f0:9d:37:69:db:41:bd:d4:1c:fb:53: 20:da:88:9d:76:26:67:ce:01:90:a7:80:1d:a9:5b:39:73:68: 54:0a:d1:2a:03:1b:8f:3c:43:5d:5d:c4:51:f1:a7:e7:11:da: 31:2c:49:06:af:04:f4:b8:3c:99:c4:20:b9:06:36:a2:00:92: 61:1d:0c:6d:24:05:e2:82:e1:47:db:a0:5f:ba:b9:fb:ba:fa: 49:12:1e:ce -----BEGIN CERTIFICATE----- MIICpzCCAY8CCQCwkmSx8toh0jANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBiMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRUwEwYDVQQDEwxmYWtlaG9z dG5hbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK5UQiMI5VkNs2QvL7gU aiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2NkX0 ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1L2OQ hEx1GM6RydHdgX69G64LXcY5AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAK1Fio7v xu8EQVwsSoTcAnYM0GYP8BYEWE39aLe406hBpVw8b2U80fjOQzXnQV9TPcksw338 Vkr6R3c4nbuXKAo7kRl/vHSuFWu9IDZnRaUeedd15olcbVSE0ZXXp7QzPK83xHmP XnXcdcIY+2FvLdw4ZVu6ZyjQiNeNuSNajujGu9vO1bhBKs6TCLaVrTQgGNU7N1J0 UAsHLLBtpEx79OD90a8XqiDNYuPwnTdp20G91Bz7UyDaiJ12JmfOAZCngB2pWzlz aFQK0SoDG488Q11dxFHxp+cR2jEsSQavBPS4PJnEILkGNqIAkmEdDG0kBeKC4Ufb oF+6ufu6+kkSHs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/nokia.pem0000644000076500000000000000360312666555342017651 0ustar jmaddenwheel00000000000000# Certificate for projects.developer.nokia.com:443 (see issue 13034) -----BEGIN CERTIFICATE----- MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/nullbytecert.pem0000644000076500000000000001247312666555342021271 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 0 (0x0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Validity Not Before: Aug 7 13:11:52 2013 GMT Not After : Aug 7 13:12:52 2013 GMT Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3: 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97: 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2: 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1: 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4: 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8: a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02: 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75: ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91: 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d: 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30: 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7: f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12: f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5: ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb: d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f: 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da: 2f:85 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C X509v3 Key Usage: Digital Signature, Non Repudiation, Key Encipherment X509v3 Subject Alternative Name: ************************************************************* WARNING: The values for DNS, email and URI are WRONG. OpenSSL doesn't print the text after a NULL byte. ************************************************************* DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 Signature Algorithm: sha1WithRSAEncryption ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5: a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44: 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37: 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3: 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86: de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac: 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4: 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60: d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5: 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60: 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6: 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d: 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e: 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6: c1:ca:a9:94 -----BEGIN CERTIFICATE----- MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL 08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/nullcert.pem0000644000076500000000000000000012666555342020364 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.4/pycacert.pem0000644000076500000000000001032312666555342020357 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 12723342612721443280 (0xb09264b1f2da21d0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Jan 2 19:47:07 2023 GMT Subject: C=XY, O=Python Software Foundation CA, CN=our-ca-server Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:e7:de:e9:e3:0c:9f:00:b6:a1:fd:2b:5b:96:d2: 6f:cc:e0:be:86:b9:20:5e:ec:03:7a:55:ab:ea:a4: e9:f9:49:85:d2:66:d5:ed:c7:7a:ea:56:8e:2d:8f: e7:42:e2:62:28:a9:9f:d6:1b:8e:eb:b5:b4:9c:9f: 14:ab:df:e6:94:8b:76:1d:3e:6d:24:61:ed:0c:bf: 00:8a:61:0c:df:5c:c8:36:73:16:00:cd:47:ba:6d: a4:a4:74:88:83:23:0a:19:fc:09:a7:3c:4a:4b:d3: e7:1d:2d:e4:ea:4c:54:21:f3:26:db:89:37:18:d4: 02:bb:40:32:5f:a4:ff:2d:1c:f7:d4:bb:ec:8e:cf: 5c:82:ac:e6:7c:08:6c:48:85:61:07:7f:25:e0:5c: e0:bc:34:5f:e0:b9:04:47:75:c8:47:0b:8d:bc:d6: c8:68:5f:33:83:62:d2:20:44:35:b1:ad:81:1a:8a: cd:bc:35:b0:5c:8b:47:d6:18:e9:9c:18:97:cc:01: 3c:29:cc:e8:1e:e4:e4:c1:b8:de:e7:c2:11:18:87: 5a:93:34:d8:a6:25:f7:14:71:eb:e4:21:a2:d2:0f: 2e:2e:d4:62:00:35:d3:d6:ef:5c:60:4b:4c:a9:14: e2:dd:15:58:46:37:33:26:b7:e7:2e:5d:ed:42:e4: c5:4d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Authority Key Identifier: keyid:BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption 7d:0a:f5:cb:8d:d3:5d:bd:99:8e:f8:2b:0f:ba:eb:c2:d9:a6: 27:4f:2e:7b:2f:0e:64:d8:1c:35:50:4e:ee:fc:90:b9:8d:6d: a8:c5:c6:06:b0:af:f3:2d:bf:3b:b8:42:07:dd:18:7d:6d:95: 54:57:85:18:60:47:2f:eb:78:1b:f9:e8:17:fd:5a:0d:87:17: 28:ac:4c:6a:e6:bc:29:f4:f4:55:70:29:42:de:85:ea:ab:6c: 23:06:64:30:75:02:8e:53:bc:5e:01:33:37:cc:1e:cd:b8:a4: fd:ca:e4:5f:65:3b:83:1c:86:f1:55:02:a0:3a:8f:db:91:b7: 40:14:b4:e7:8d:d2:ee:73:ba:e3:e5:34:2d:bc:94:6f:4e:24: 06:f7:5f:8b:0e:a7:8e:6b:de:5e:75:f4:32:9a:50:b1:44:33: 9a:d0:05:e2:78:82:ff:db:da:8a:63:eb:a9:dd:d1:bf:a0:61: ad:e3:9e:8a:24:5d:62:0e:e7:4c:91:7f:ef:df:34:36:3b:2f: 5d:f5:84:b2:2f:c4:6d:93:96:1a:6f:30:28:f1:da:12:9a:64: b4:40:33:1d:bd:de:2b:53:a8:ea:be:d6:bc:4e:96:f5:44:fb: 32:18:ae:d5:1f:f6:69:af:b6:4e:7b:1d:58:ec:3b:a9:53:a3: 5e:58:c8:9e -----BEGIN CERTIFICATE----- MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/ AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni 0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx 6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2 2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4 QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1 Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf 9mmvtk57HVjsO6lTo15YyJ4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/pycakey.pem0000644000076500000000000000325012666555342020213 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDn3unjDJ8AtqH9 K1uW0m/M4L6GuSBe7AN6VavqpOn5SYXSZtXtx3rqVo4tj+dC4mIoqZ/WG47rtbSc nxSr3+aUi3YdPm0kYe0MvwCKYQzfXMg2cxYAzUe6baSkdIiDIwoZ/AmnPEpL0+cd LeTqTFQh8ybbiTcY1AK7QDJfpP8tHPfUu+yOz1yCrOZ8CGxIhWEHfyXgXOC8NF/g uQRHdchHC4281shoXzODYtIgRDWxrYEais28NbBci0fWGOmcGJfMATwpzOge5OTB uN7nwhEYh1qTNNimJfcUcevkIaLSDy4u1GIANdPW71xgS0ypFOLdFVhGNzMmt+cu Xe1C5MVNAgMBAAECggEBAJPM7QuUrPn4cLN/Ysd15lwTWn9oHDFFgkYFvCs66gXE ju/6Kx2BjWE4wTJby09AHM/MqB0DvguT7Mf1Q2j3tPQ1HZowg8OwRDleuwp6KIls jBbhL0Jdl/5HC67ktWvZ9wNvO/wFG1rQfT6FVajf9LUbWEaSZbOG2SLhHfsHorzu xjTJaI3bQ/0+79B1exwk5ruwhzFRd/XpY8hls7D/RfPIuHDlBghkW3N59KFWrf5h 6bNEh2THm0+IyGcGqs0FD+QCOXyvsjwSUswqrr2ctLREOeDcd5ReUjSxYgjcJRrm J7ceIY/+uwDJxw/OlnmBvF6pQMkKwYW2gFztu+g2t4UCgYEA/9yo01Exz4crxXsy tAlnDJM++nZcm07rtFjTKHUfKY/cCgNTa8udM0svnfwlid/dpgLsI38gx04HHC1i EZ4acz+ToIWedLxM0nq73//xeRWEazOvCz1mMTZaMldahTWAyzN8qVK2B/625Yy4 wNYWyweBBwEB8MzaCs73spksXOsCgYEA5/7wvhiofYGFAfMuANeJIwDL2OtBnoOv mVNfCmi3GC38fzwyi5ZpskWDiS2woJ+LQfs9Qu4EcZbUFLd7gbeOvb5gmFUtYope LitUUKunIR18MkQ+mQDBpQPQPhk4QJP5reCbWkrfTu7b5o/iS41s6fBTFmuzhLcT C71vFdCyeKcCgYAiCCqYeOtELDmBOeLDmaCQRqGQ1N96dOPbCBmF/xYXBCCDYG/f HaUaJnz96YTgstsbcrYP/p/Qgqtlbw/lQf9IpwMuzbcG1ejt8g89OyDWNyt2ytgU iaUnFJCos3/Byh0Iah/BsdOueo2/OJl2ZMOBW80orlSgv86cs2y037TL4wKBgQDm OOyW+MlbowhnIvfoBfwlLEkefnej4nKD6WRLZBcue5Qyf355X06Mhsc9foXlH+6G D9h/bswiHNdhp6N82rdgPGiHQx/CxiUoE/+b/nvgNO5mw6qLE2EXbG1e8pAMJcyE bHw+YkawggDfELI036fRj5gki8SeUz8nS1nNgElbyQKBgCRDX9Jh+MwSLu4QBWdt /fi+lv3K6kun/fI7EOV1vCV/j871tICu7pu5BrOLxAHqoVfU9AUX299/2KjCb5pv kjogiUK6qWCWBlfuqDNWGCoUGt1rhznUva0nNjSMy5rinBhhjpROZC2pw48lOluP UuvXsaPph7GTqPuy4Kab12YC -----END PRIVATE KEY----- gevent-1.1.0/greentest/3.4/revocation.crl0000644000076500000000000000116112666555342020715 0ustar jmaddenwheel00000000000000-----BEGIN X509 CRL----- MIIBpjCBjwIBATANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJYWTEmMCQGA1UE CgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNVBAMMDW91ci1j YS1zZXJ2ZXIXDTEzMTEyMTE3MDg0N1oXDTIzMDkzMDE3MDg0N1qgDjAMMAoGA1Ud FAQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQCNJXC2mVKauEeN3LlQ3ZtM5gkH3ExH +i4bmJjtJn497WwvvoIeUdrmVXgJQR93RtV37hZwN0SXMLlNmUZPH4rHhihayw4m unCzVj/OhCCY7/TPjKuJ1O/0XhaLBpBVjQN7R/1ujoRKbSia/CD3vcn7Fqxzw7LK fSRCKRGTj1CZiuxrphtFchwALXSiFDy9mr2ZKhImcyq1PydfgEzU78APpOkMQsIC UNJ/cf3c9emzf+dUtcMEcejQ3mynBo4eIGg1EW42bz4q4hSjzQlKcBV0muw5qXhc HOxH2iTFhQ7SrvVuK/dM14rYM4B5mSX3nRC1kNmXpS9j3wJDhuwmjHed -----END X509 CRL----- gevent-1.1.0/greentest/3.4/selfsigned_pythontestdotnet.pem0000644000076500000000000000167412666555342024420 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/sha256.pem0000644000076500000000000002023012666555342017553 0ustar jmaddenwheel00000000000000# Certificate chain for https://sha256.tbs-internet.com 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC -----BEGIN CERTIFICATE----- MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0 LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49 IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0 UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN 21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q -----END CERTIFICATE----- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root -----BEGIN CERTIFICATE----- MIIFVjCCBD6gAwIBAgIQXpDZ0ETJMV02WTx3GTnhhTANBgkqhkiG9w0BAQUFADBv MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDYyNDE5MDYzMFow gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgOkO3f7wzN6 rOjg45tR5vjBfzK7qmV9IBxb/QW9EEXxG+E7FNhZqQLtwGBKoSsHTnQqV75wWMk0 9tinWvftBkSpj5sTi/8cbzJfUvTSVYh3Qxv6AVVjMMH/ruLjE6y+4PoaPs8WoYAQ ts5R4Z1g8c/WnTepLst2x0/Wv7GmuoQi+gXvHU6YrBiu7XkeYhzc95QdviWSJRDk owhb5K43qhcvjRmBfO/paGlCliDGZp8mHwrI21mwobWpVjTxZRwYO3bd4+TGcI4G Ie5wmHwE8F7SK1tgSqbBacKjDa93j7txKkfz/Yd2n7TGqOXiHPsJpG655vrKtnXk 9vs1zoDeJQIDAQABo4IBljCCAZIwHQYDVR0OBBYEFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMCAGA1UdJQQZ MBcGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAYBgNVHSAEETAPMA0GCysGAQQBgOU3 AgQBMHsGA1UdHwR0MHIwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL0Fk ZFRydXN0RXh0ZXJuYWxDQVJvb3QuY3JsMDagNKAyhjBodHRwOi8vY3JsLmNvbW9k by5uZXQvQWRkVHJ1c3RFeHRlcm5hbENBUm9vdC5jcmwwgYAGCCsGAQUFBwEBBHQw cjA4BggrBgEFBQcwAoYsaHR0cDovL2NydC5jb21vZG9jYS5jb20vQWRkVHJ1c3RV VE5TR0NDQS5jcnQwNgYIKwYBBQUHMAKGKmh0dHA6Ly9jcnQuY29tb2RvLm5ldC9B ZGRUcnVzdFVUTlNHQ0NBLmNydDARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcN AQEFBQADggEBAK2zEzs+jcIrVK9oDkdDZNvhuBYTdCfpxfFs+OAujW0bIfJAy232 euVsnJm6u/+OrqKudD2tad2BbejLLXhMZViaCmK7D9nrXHx4te5EP8rL19SUVqLY 1pTnv5dhNgEgvA7n5lIzDSYs7yRLsr7HJsYPr6SeYSuZizyX1SNz7ooJ32/F3X98 RB0Mlc/E0OyOrkQ9/y5IrnpnaSora8CnUrV5XNOg+kyCz9edCyx4D5wXYcwZPVWz 8aDqquESrezPyjtfi4WRO4s/VD3HLZvOxzMrWAVYCDG9FxaOhF0QGuuG1F7F3GKV v6prNyCl016kRl2j1UT+a7gLd8fA25A4C9E= -----END CERTIFICATE----- 2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEZjCCA06gAwIBAgIQUSYKkxzif5zDpV954HKugjANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw0wNTA2MDcwODA5MTBaFw0xOTA2MjQxOTA2MzBaMG8xCzAJBgNVBAYT AlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0 ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB IFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39xoz5vIABC05 4E5b7R+8bA/Ntfojts7emxEzl6QpTH2Tn71KvJPtAxrjj8/lbVBa1pcplFqAsEl6 2y6V/bjKvzc4LR4+kUGtcFbH8E8/6DKedMrIkFTpxl8PeJ2aQDwOrGGqXhSPnoeh alDc15pOrwWzpnGUnHGzUGAKxxOdOAeGAqjpqGkmGJCrTLBPI6s6T4TY386f4Wlv u9dC12tE5Met7m1BX3JacQg3s3llpFmglDf3AC8NwpJy2tA4ctsUqEXEXSp9t7TW xO6szRNEt8kr3UMAJfphuWlqWCMRt6czj1Z1WfXNKddGtworZbbTQm8Vsrh7++/p XVPVNFonAgMBAAGjgdgwgdUwHwYDVR0jBBgwFoAUUzLRs89/+uDxoF2FTpLSnkUd tE8wHQYDVR0OBBYEFK29mHo0tCb3+sQmVO8DveAky1QaMA4GA1UdDwEB/wQEAwIB BjAPBgNVHRMBAf8EBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIBAjAgBgNVHSUEGTAX BgorBgEEAYI3CgMDBglghkgBhvhCBAEwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDov L2NybC51c2VydHJ1c3QuY29tL1VUTi1EQVRBQ29ycFNHQy5jcmwwDQYJKoZIhvcN AQEFBQADggEBAMbuUxdoFLJRIh6QWA2U/b3xcOWGLcM2MY9USEbnLQg3vGwKYOEO rVE04BKT6b64q7gmtOmWPSiPrmQH/uAB7MXjkesYoPF1ftsK5p+R26+udd8jkWjd FwBaS/9kbHDrARrQkNnHptZt9hPk/7XJ0h4qy7ElQyZ42TCbTg0evmnv3+r+LbPM +bDdtRTKkdSytaX7ARmjR3mfnYyVhzT4HziS2jamEfpr62vp3EV4FTkG101B5CHI 3C+H0be/SGB1pWLLJN47YaApIKa+xWycxOkKaSLvkTr6Jq/RW0GnOuL4OAdCq8Fb +M5tug8EPzI0rNwEKNdwMBQmBsTkm5jVz3g= -----END CERTIFICATE----- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6 E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK 4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv 2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3 mfnGV/TJVTl4uix5yaaIK/QI -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/ssl_cert.pem0000644000076500000000000000154312666555342020367 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.4/ssl_key.passwd.pem0000644000076500000000000000170312666555342021520 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- gevent-1.1.0/greentest/3.4/ssl_key.pem0000644000076500000000000000162412666555342020222 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- gevent-1.1.0/greentest/3.4/test_httplib.py0000644000076500000000000010573112666555342021131 0ustar jmaddenwheel00000000000000import errno from http import client import io import os import array import socket import unittest TestCase = unittest.TestCase from test import support here = os.path.dirname(__file__) # Self-signed cert file for 'localhost' CERT_localhost = os.path.join(here, 'keycert.pem') # Self-signed cert file for 'fakehostname' CERT_fakehostname = os.path.join(here, 'keycert2.pem') # Self-signed cert file for self-signed.pythontest.net CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem') HOST = support.HOST class FakeSocket: def __init__(self, text, fileclass=io.BytesIO): if isinstance(text, str): text = text.encode("ascii") self.text = text self.fileclass = fileclass self.data = b'' def sendall(self, data): self.data += data def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise client.UnimplementedFileMode() return self.fileclass(self.text) class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): # When sendall() is called with pipe_trigger, raise EPIPE. FakeSocket.__init__(self, text) self.pipe_trigger = pipe_trigger def sendall(self, data): if self.pipe_trigger in data: raise socket.error(errno.EPIPE, "gotcha") self.data += data def close(self): pass class NoEOFBytesIO(io.BytesIO): """Like BytesIO, but raises AssertionError on EOF. This is used below to test that http.client doesn't try to read more from the underlying file than it should. """ def read(self, n=-1): data = io.BytesIO.read(self, n) if data == b'': raise AssertionError('caller tried to read past EOF') return data def readline(self, length=None): data = io.BytesIO.readline(self, length) if data == b'': raise AssertionError('caller tried to read past EOF') return data class HeaderTests(TestCase): def test_auto_headers(self): # Some headers are added automatically, but should not be added by # .request() if they are explicitly set. class HeaderCountingBuffer(list): def __init__(self): self.count = {} def append(self, item): kv = item.split(b':') if len(kv) > 1: # item is a 'Key: Value' header string lcKey = kv[0].decode('ascii').lower() self.count.setdefault(lcKey, 0) self.count[lcKey] += 1 list.append(self, item) for explicit_header in True, False: for header in 'Content-length', 'Host', 'Accept-encoding': conn = client.HTTPConnection('example.com') conn.sock = FakeSocket('blahblahblah') conn._buffer = HeaderCountingBuffer() body = 'spamspamspam' headers = {} if explicit_header: headers[header] = str(len(body)) conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) def test_content_length_0(self): class ContentLengthChecker(list): def __init__(self): list.__init__(self) self.content_length = None def append(self, item): kv = item.split(b':', 1) if len(kv) > 1 and kv[0].lower() == b'content-length': self.content_length = kv[1].strip() list.append(self, item) # POST with empty body conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request('POST', '/', '') self.assertEqual(conn._buffer.content_length, b'0', 'Header Content-Length not set') # PUT request with empty body conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn._buffer = ContentLengthChecker() conn.request('PUT', '/', '') self.assertEqual(conn._buffer.content_length, b'0', 'Header Content-Length not set') def test_putheader(self): conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length', 42) self.assertIn(b'Content-length: 42', conn._buffer) def test_ipv6host_header(self): # Default host header on IPv6 transaction should wrapped by [] if # its actual IPv6 address expected = b'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \ b'Accept-Encoding: identity\r\n\r\n' conn = client.HTTPConnection('[2001::]:81') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) expected = b'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \ b'Accept-Encoding: identity\r\n\r\n' conn = client.HTTPConnection('[2001:102A::]') sock = FakeSocket('') conn.sock = sock conn.request('GET', '/foo') self.assertTrue(sock.data.startswith(expected)) class BasicTest(TestCase): def test_status_lines(self): # Test HTTP status lines body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(0), b'') # Issue #20007 self.assertFalse(resp.isclosed()) self.assertFalse(resp.closed) self.assertEqual(resp.read(), b"Text") self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) self.assertRaises(client.BadStatusLine, resp.begin) def test_bad_status_repr(self): exc = client.BadStatusLine('') self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''') def test_partial_reads(self): # if we have a length, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), b'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), b'xt') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_partial_readintos(self): # if we have a length, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() b = bytearray(2) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'Te') self.assertFalse(resp.isclosed()) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'xt') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_partial_reads_no_content_length(self): # when no length is present, the socket should be gracefully closed when # all data was read body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), b'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), b'xt') self.assertEqual(resp.read(1), b'') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_partial_readintos_no_content_length(self): # when no length is present, the socket should be gracefully closed when # all data was read body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() b = bytearray(2) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'Te') self.assertFalse(resp.isclosed()) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'xt') n = resp.readinto(b) self.assertEqual(n, 0) self.assertTrue(resp.isclosed()) def test_partial_reads_incomplete_body(self): # if the server shuts down the connection before the whole # content-length is delivered, the socket is gracefully closed body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(2), b'Te') self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), b'xt') self.assertEqual(resp.read(1), b'') self.assertTrue(resp.isclosed()) def test_partial_readintos_incomplete_body(self): # if the server shuts down the connection before the whole # content-length is delivered, the socket is gracefully closed body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() b = bytearray(2) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'Te') self.assertFalse(resp.isclosed()) n = resp.readinto(b) self.assertEqual(n, 2) self.assertEqual(bytes(b), b'xt') n = resp.readinto(b) self.assertEqual(n, 0) self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_host_port(self): # Check invalid host_port for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(client.InvalidURL, client.HTTPConnection, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), ("www.python.org:", "www.python.org", 80), ("www.python.org", "www.python.org", 80), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80), ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", 80)): c = client.HTTPConnection(hp) self.assertEqual(h, c.host) self.assertEqual(p, c.port) def test_response_headers(self): # test response with multiple message headers with the same field name. text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE"; ' 'Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = client.HTTPResponse(s) r.begin() cookies = r.getheader("Set-Cookie") self.assertEqual(cookies, hdr) def test_read_head(self): # Test that the library doesn't attempt to read any data # from a HEAD request. (Tickles SF bug #622042.) sock = FakeSocket( 'HTTP/1.1 200 OK\r\n' 'Content-Length: 14432\r\n' '\r\n', NoEOFBytesIO) resp = client.HTTPResponse(sock, method="HEAD") resp.begin() if resp.read(): self.fail("Did not expect response from HEAD request") def test_readinto_head(self): # Test that the library doesn't attempt to read any data # from a HEAD request. (Tickles SF bug #622042.) sock = FakeSocket( 'HTTP/1.1 200 OK\r\n' 'Content-Length: 14432\r\n' '\r\n', NoEOFBytesIO) resp = client.HTTPResponse(sock, method="HEAD") resp.begin() b = bytearray(5) if resp.readinto(b) != 0: self.fail("Did not expect response from HEAD request") self.assertEqual(bytes(b), b'\x00'*5) def test_too_many_headers(self): headers = '\r\n'.join('Header%d: foo' % i for i in range(client._MAXHEADERS + 1)) + '\r\n' text = ('HTTP/1.1 200 OK\r\n' + headers) s = FakeSocket(text) r = client.HTTPResponse(s) self.assertRaisesRegex(client.HTTPException, r"got more than \d+ headers", r.begin) def test_send_file(self): expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' b'Accept-Encoding: identity\r\nContent-Length:') with open(__file__, 'rb') as body: conn = client.HTTPConnection('example.com') sock = FakeSocket(body) conn.sock = sock conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected), '%r != %r' % (sock.data[:len(expected)], expected)) def test_send(self): expected = b'this is a test this is only a test' conn = client.HTTPConnection('example.com') sock = FakeSocket(None) conn.sock = sock conn.send(expected) self.assertEqual(expected, sock.data) sock.data = b'' conn.send(array.array('b', expected)) self.assertEqual(expected, sock.data) sock.data = b'' conn.send(io.BytesIO(expected)) self.assertEqual(expected, sock.data) def test_send_updating_file(self): def data(): yield 'data' yield None yield 'data_two' class UpdatingFile(): mode = 'r' d = data() def read(self, blocksize=-1): return self.d.__next__() expected = b'data' conn = client.HTTPConnection('example.com') sock = FakeSocket("") conn.sock = sock conn.send(UpdatingFile()) self.assertEqual(sock.data, expected) def test_send_iter(self): expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \ b'\r\nonetwothree' def body(): yield b"one" yield b"two" yield b"three" conn = client.HTTPConnection('example.com') sock = FakeSocket("") conn.sock = sock conn.request('GET', '/foo', body(), {'Content-Length': '11'}) self.assertEqual(sock.data, expected) def test_send_type_error(self): # See: Issue #12676 conn = client.HTTPConnection('example.com') conn.sock = FakeSocket('') with self.assertRaises(TypeError): conn.request('POST', 'test', conn) def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello worl\r\n' '3\r\n' 'd! \r\n' '8\r\n' 'and now \r\n' '22\r\n' 'for something completely different\r\n' ) expected = b'hello world! and now for something completely different' sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), expected) resp.close() # Various read sizes for n in range(1, 12): sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(n) + resp.read(n) + resp.read(), expected) resp.close() for x in ('', 'foo\r\n'): sock = FakeSocket(chunked_start + x) resp = client.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except client.IncompleteRead as i: self.assertEqual(i.partial, expected) expected_message = 'IncompleteRead(%d bytes read)' % len(expected) self.assertEqual(repr(i), expected_message) self.assertEqual(str(i), expected_message) else: self.fail('IncompleteRead expected') finally: resp.close() def test_readinto_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello worl\r\n' '3\r\n' 'd! \r\n' '8\r\n' 'and now \r\n' '22\r\n' 'for something completely different\r\n' ) expected = b'hello world! and now for something completely different' nexpected = len(expected) b = bytearray(128) sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() n = resp.readinto(b) self.assertEqual(b[:nexpected], expected) self.assertEqual(n, nexpected) resp.close() # Various read sizes for n in range(1, 12): sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() m = memoryview(b) i = resp.readinto(m[0:n]) i += resp.readinto(m[i:n + i]) i += resp.readinto(m[i:]) self.assertEqual(b[:nexpected], expected) self.assertEqual(i, nexpected) resp.close() for x in ('', 'foo\r\n'): sock = FakeSocket(chunked_start + x) resp = client.HTTPResponse(sock, method="GET") resp.begin() try: n = resp.readinto(b) except client.IncompleteRead as i: self.assertEqual(i.partial, expected) expected_message = 'IncompleteRead(%d bytes read)' % len(expected) self.assertEqual(repr(i), expected_message) self.assertEqual(str(i), expected_message) else: self.fail('IncompleteRead expected') finally: resp.close() def test_chunked_head(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello world\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="HEAD") resp.begin() self.assertEqual(resp.read(), b'') self.assertEqual(resp.status, 200) self.assertEqual(resp.reason, 'OK') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_readinto_chunked_head(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' 'a\r\n' 'hello world\r\n' '1\r\n' 'd\r\n' ) sock = FakeSocket(chunked_start + '0\r\n') resp = client.HTTPResponse(sock, method="HEAD") resp.begin() b = bytearray(5) n = resp.readinto(b) self.assertEqual(n, 0) self.assertEqual(bytes(b), b'\x00'*5) self.assertEqual(resp.status, 200) self.assertEqual(resp.reason, 'OK') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) def test_negative_content_length(self): sock = FakeSocket( 'HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), b'Hello\r\n') self.assertTrue(resp.isclosed()) def test_incomplete_read(self): sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n') resp = client.HTTPResponse(sock, method="GET") resp.begin() try: resp.read() except client.IncompleteRead as i: self.assertEqual(i.partial, b'Hello\r\n') self.assertEqual(repr(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertEqual(str(i), "IncompleteRead(7 bytes read, 3 more expected)") self.assertTrue(resp.isclosed()) else: self.fail('IncompleteRead expected') def test_epipe(self): sock = EPipeSocket( "HTTP/1.0 401 Authorization Required\r\n" "Content-type: text/html\r\n" "WWW-Authenticate: Basic realm=\"example\"\r\n", b"Content-Length") conn = client.HTTPConnection("example.com") conn.sock = sock self.assertRaises(socket.error, lambda: conn.request("PUT", "/url", "body")) resp = conn.getresponse() self.assertEqual(401, resp.status) self.assertEqual("Basic realm=\"example\"", resp.getheader("www-authenticate")) # Test lines overflowing the max line size (_MAXLINE in http.client) def test_overflowing_status_line(self): body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n" resp = client.HTTPResponse(FakeSocket(body)) self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin) def test_overflowing_header_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n' ) resp = client.HTTPResponse(FakeSocket(body)) self.assertRaises(client.LineTooLong, resp.begin) def test_overflowing_chunked_line(self): body = ( 'HTTP/1.1 200 OK\r\n' 'Transfer-Encoding: chunked\r\n\r\n' + '0' * 65536 + 'a\r\n' 'hello world\r\n' '0\r\n' ) resp = client.HTTPResponse(FakeSocket(body)) resp.begin() self.assertRaises(client.LineTooLong, resp.read) def test_early_eof(self): # Test httpresponse with no \r\n termination, body = "HTTP/1.1 200 Ok" sock = FakeSocket(body) resp = client.HTTPResponse(sock) resp.begin() self.assertEqual(resp.read(), b'') self.assertTrue(resp.isclosed()) self.assertFalse(resp.closed) resp.close() self.assertTrue(resp.closed) class OfflineTest(TestCase): def test_responses(self): self.assertEqual(client.responses[client.NOT_FOUND], "Not Found") class SourceAddressTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.serv) self.source_port = support.find_unused_port() self.serv.listen(5) self.conn = None def tearDown(self): if self.conn: self.conn.close() self.conn = None self.serv.close() self.serv = None def testHTTPConnectionSourceAddress(self): self.conn = client.HTTPConnection(HOST, self.port, source_address=('', self.source_port)) self.conn.connect() self.assertEqual(self.conn.sock.getsockname()[1], self.source_port) @unittest.skipIf(not hasattr(client, 'HTTPSConnection'), 'http.client.HTTPSConnection not defined') def testHTTPSConnectionSourceAddress(self): self.conn = client.HTTPSConnection(HOST, self.port, source_address=('', self.source_port)) # We don't test anything here other the constructor not barfing as # this code doesn't deal with setting up an active running SSL server # for an ssl_wrapped connect() to actually return from. class TimeoutTest(TestCase): PORT = None def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) TimeoutTest.PORT = support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): self.serv.close() self.serv = None def testTimeoutAttribute(self): # This will prove that the timeout gets through HTTPConnection # and into the socket. # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() # no timeout -- do not use global socket default self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT, timeout=None) httpConn.connect() finally: socket.setdefaulttimeout(None) self.assertEqual(httpConn.sock.gettimeout(), None) httpConn.close() # a value httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30) httpConn.connect() self.assertEqual(httpConn.sock.gettimeout(), 30) httpConn.close() class HTTPSTest(TestCase): def setUp(self): if not hasattr(client, 'HTTPSConnection'): self.skipTest('ssl support required') def make_server(self, certfile): from test.ssl_servers import make_https_server return make_https_server(self, certfile=certfile) def test_attributes(self): # simple test to check it's storing the timeout h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30) self.assertEqual(h.timeout, 30) def _check_svn_python_org(self, resp): # Just a simple check that everything went fine server_string = resp.getheader('server') self.assertIn('Apache', server_string) def test_networked(self): # Default settings: no cert verification is done support.requires('network') with support.transient_internet('svn.python.org'): h = client.HTTPSConnection('svn.python.org', 443) h.request('GET', '/') resp = h.getresponse() self._check_svn_python_org(resp) def test_networked_good_cert(self): # We feed the server's cert as a validating cert import ssl support.requires('network') with support.transient_internet('self-signed.pythontest.net'): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_selfsigned_pythontestdotnet) h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context) h.request('GET', '/') resp = h.getresponse() server_string = resp.getheader('server') self.assertIn('nginx', server_string) def test_networked_bad_cert(self): # We feed a "CA" cert that is unrelated to the server's cert import ssl support.requires('network') with support.transient_internet('svn.python.org'): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_localhost) h = client.HTTPSConnection('svn.python.org', 443, context=context) with self.assertRaises(ssl.SSLError): h.request('GET', '/') def test_local_good_hostname(self): # The (valid) cert validates the HTTP hostname import ssl server = self.make_server(CERT_localhost) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_localhost) h = client.HTTPSConnection('localhost', server.port, context=context) h.request('GET', '/nonexistent') resp = h.getresponse() self.assertEqual(resp.status, 404) del server def test_local_bad_hostname(self): # The (valid) cert doesn't validate the HTTP hostname import ssl server = self.make_server(CERT_fakehostname) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERT_fakehostname) h = client.HTTPSConnection('localhost', server.port, context=context) with self.assertRaises(ssl.CertificateError): h.request('GET', '/') # Same with explicit check_hostname=True h = client.HTTPSConnection('localhost', server.port, context=context, check_hostname=True) with self.assertRaises(ssl.CertificateError): h.request('GET', '/') # With check_hostname=False, the mismatching is ignored h = client.HTTPSConnection('localhost', server.port, context=context, check_hostname=False) h.request('GET', '/nonexistent') resp = h.getresponse() self.assertEqual(resp.status, 404) del server @unittest.skipIf(not hasattr(client, 'HTTPSConnection'), 'http.client.HTTPSConnection not available') def test_host_port(self): # Check invalid host_port for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(client.InvalidURL, client.HTTPSConnection, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:443", "www.python.org", 443), ("www.python.org:", "www.python.org", 443), ("www.python.org", "www.python.org", 443), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443), ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", 443)): c = client.HTTPSConnection(hp) self.assertEqual(h, c.host) self.assertEqual(p, c.port) class RequestBodyTest(TestCase): """Test cases where a request includes a message body.""" def setUp(self): self.conn = client.HTTPConnection('example.com') self.conn.sock = self.sock = FakeSocket("") self.conn.sock = self.sock def get_headers_and_fp(self): f = io.BytesIO(self.sock.data) f.readline() # read the request line message = client.parse_headers(f) return message, f def test_manual_content_length(self): # Set an incorrect content-length so that we can verify that # it will not be over-ridden by the library. self.conn.request("PUT", "/url", "body", {"Content-Length": "42"}) message, f = self.get_headers_and_fp() self.assertEqual("42", message.get("content-length")) self.assertEqual(4, len(f.read())) def test_ascii_body(self): self.conn.request("PUT", "/url", "body") message, f = self.get_headers_and_fp() self.assertEqual("text/plain", message.get_content_type()) self.assertIsNone(message.get_charset()) self.assertEqual("4", message.get("content-length")) self.assertEqual(b'body', f.read()) def test_latin1_body(self): self.conn.request("PUT", "/url", "body\xc1") message, f = self.get_headers_and_fp() self.assertEqual("text/plain", message.get_content_type()) self.assertIsNone(message.get_charset()) self.assertEqual("5", message.get("content-length")) self.assertEqual(b'body\xc1', f.read()) def test_bytes_body(self): self.conn.request("PUT", "/url", b"body\xc1") message, f = self.get_headers_and_fp() self.assertEqual("text/plain", message.get_content_type()) self.assertIsNone(message.get_charset()) self.assertEqual("5", message.get("content-length")) self.assertEqual(b'body\xc1', f.read()) def test_file_body(self): self.addCleanup(support.unlink, support.TESTFN) with open(support.TESTFN, "w") as f: f.write("body") with open(support.TESTFN) as f: self.conn.request("PUT", "/url", f) message, f = self.get_headers_and_fp() self.assertEqual("text/plain", message.get_content_type()) self.assertIsNone(message.get_charset()) self.assertEqual("4", message.get("content-length")) self.assertEqual(b'body', f.read()) def test_binary_file_body(self): self.addCleanup(support.unlink, support.TESTFN) with open(support.TESTFN, "wb") as f: f.write(b"body\xc1") with open(support.TESTFN, "rb") as f: self.conn.request("PUT", "/url", f) message, f = self.get_headers_and_fp() self.assertEqual("text/plain", message.get_content_type()) self.assertIsNone(message.get_charset()) self.assertEqual("5", message.get("content-length")) self.assertEqual(b'body\xc1', f.read()) class HTTPResponseTest(TestCase): def setUp(self): body = "HTTP/1.1 200 Ok\r\nMy-Header: first-value\r\nMy-Header: \ second-value\r\n\r\nText" sock = FakeSocket(body) self.resp = client.HTTPResponse(sock) self.resp.begin() def test_getting_header(self): header = self.resp.getheader('My-Header') self.assertEqual(header, 'first-value, second-value') header = self.resp.getheader('My-Header', 'some default') self.assertEqual(header, 'first-value, second-value') def test_getting_nonexistent_header_with_string_default(self): header = self.resp.getheader('No-Such-Header', 'default-value') self.assertEqual(header, 'default-value') def test_getting_nonexistent_header_with_iterable_default(self): header = self.resp.getheader('No-Such-Header', ['default', 'values']) self.assertEqual(header, 'default, values') header = self.resp.getheader('No-Such-Header', ('default', 'values')) self.assertEqual(header, 'default, values') def test_getting_nonexistent_header_without_default(self): header = self.resp.getheader('No-Such-Header') self.assertEqual(header, None) def test_getting_header_defaultint(self): header = self.resp.getheader('No-Such-Header',default=42) self.assertEqual(header, 42) def test_main(verbose=None): support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTest, RequestBodyTest, SourceAddressTest, HTTPResponseTest) if __name__ == '__main__': test_main() gevent-1.1.0/greentest/3.4/test_selectors.py0000644000076500000000000003415712666555342021471 0ustar jmaddenwheel00000000000000import errno import os import random import selectors import signal import socket import sys from test import support from time import sleep import unittest import unittest.mock try: from time import monotonic as time except ImportError: from time import time as time try: import resource except ImportError: resource = None if hasattr(socket, 'socketpair'): socketpair = socket.socketpair else: def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): with socket.socket(family, type, proto) as l: l.bind((support.HOST, 0)) l.listen(3) c = socket.socket(family, type, proto) try: c.connect(l.getsockname()) caddr = c.getsockname() while True: a, addr = l.accept() # check that we've got the correct client if addr == caddr: return c, a a.close() except OSError: c.close() raise def find_ready_matching(ready, flag): match = [] for key, events in ready: if events & flag: match.append(key.fileobj) return match class BaseSelectorTestCase(unittest.TestCase): def make_socketpair(self): rd, wr = socketpair() self.addCleanup(rd.close) self.addCleanup(wr.close) return rd, wr def test_register(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertIsInstance(key, selectors.SelectorKey) self.assertEqual(key.fileobj, rd) self.assertEqual(key.fd, rd.fileno()) self.assertEqual(key.events, selectors.EVENT_READ) self.assertEqual(key.data, "data") # register an unknown event self.assertRaises(ValueError, s.register, 0, 999999) # register an invalid FD self.assertRaises(ValueError, s.register, -10, selectors.EVENT_READ) # register twice self.assertRaises(KeyError, s.register, rd, selectors.EVENT_READ) # register the same FD, but with a different object self.assertRaises(KeyError, s.register, rd.fileno(), selectors.EVENT_READ) def test_unregister(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.unregister(rd) # unregister an unknown file obj self.assertRaises(KeyError, s.unregister, 999999) # unregister twice self.assertRaises(KeyError, s.unregister, rd) def test_unregister_after_fd_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(r) s.unregister(w) @unittest.skipUnless(os.name == 'posix', "requires posix") def test_unregister_after_fd_close_and_reuse(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd2, wr2 = self.make_socketpair() rd.close() wr.close() os.dup2(rd2.fileno(), r) os.dup2(wr2.fileno(), w) self.addCleanup(os.close, r) self.addCleanup(os.close, w) s.unregister(r) s.unregister(w) def test_unregister_after_socket_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(rd) s.unregister(wr) def test_modify(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ) # modify events key2 = s.modify(rd, selectors.EVENT_WRITE) self.assertNotEqual(key.events, key2.events) self.assertEqual(key2, s.get_key(rd)) s.unregister(rd) # modify data d1 = object() d2 = object() key = s.register(rd, selectors.EVENT_READ, d1) key2 = s.modify(rd, selectors.EVENT_READ, d2) self.assertEqual(key.events, key2.events) self.assertNotEqual(key.data, key2.data) self.assertEqual(key2, s.get_key(rd)) self.assertEqual(key2.data, d2) # modify unknown file obj self.assertRaises(KeyError, s.modify, 999999, selectors.EVENT_READ) # modify use a shortcut d3 = object() s.register = unittest.mock.Mock() s.unregister = unittest.mock.Mock() s.modify(rd, selectors.EVENT_READ, d3) self.assertFalse(s.register.called) self.assertFalse(s.unregister.called) def test_close(self): s = self.SELECTOR() self.addCleanup(s.close) mapping = s.get_map() rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) s.close() self.assertRaises(KeyError, s.get_key, rd) self.assertRaises(KeyError, s.get_key, wr) self.assertRaises(KeyError, mapping.__getitem__, rd) self.assertRaises(KeyError, mapping.__getitem__, wr) def test_get_key(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertEqual(key, s.get_key(rd)) # unknown file obj self.assertRaises(KeyError, s.get_key, 999999) def test_get_map(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() keys = s.get_map() self.assertFalse(keys) self.assertEqual(len(keys), 0) self.assertEqual(list(keys), []) key = s.register(rd, selectors.EVENT_READ, "data") self.assertIn(rd, keys) self.assertEqual(key, keys[rd]) self.assertEqual(len(keys), 1) self.assertEqual(list(keys), [rd.fileno()]) self.assertEqual(list(keys.values()), [key]) # unknown file obj with self.assertRaises(KeyError): keys[999999] # Read-only mapping with self.assertRaises(TypeError): del keys[rd] def test_select(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) wr_key = s.register(wr, selectors.EVENT_WRITE) result = s.select() for key, events in result: self.assertTrue(isinstance(key, selectors.SelectorKey)) self.assertTrue(events) self.assertFalse(events & ~(selectors.EVENT_READ | selectors.EVENT_WRITE)) self.assertEqual([(wr_key, selectors.EVENT_WRITE)], result) def test_context_manager(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() with s as sel: sel.register(rd, selectors.EVENT_READ) sel.register(wr, selectors.EVENT_WRITE) self.assertRaises(KeyError, s.get_key, rd) self.assertRaises(KeyError, s.get_key, wr) def test_fileno(self): s = self.SELECTOR() self.addCleanup(s.close) if hasattr(s, 'fileno'): fd = s.fileno() self.assertTrue(isinstance(fd, int)) self.assertGreaterEqual(fd, 0) def test_selector(self): s = self.SELECTOR() self.addCleanup(s.close) NUM_SOCKETS = 12 MSG = b" This is a test." MSG_LEN = len(MSG) readers = [] writers = [] r2w = {} w2r = {} for i in range(NUM_SOCKETS): rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) readers.append(rd) writers.append(wr) r2w[rd] = wr w2r[wr] = rd bufs = [] while writers: ready = s.select() ready_writers = find_ready_matching(ready, selectors.EVENT_WRITE) if not ready_writers: self.fail("no sockets ready for writing") wr = random.choice(ready_writers) wr.send(MSG) for i in range(10): ready = s.select() ready_readers = find_ready_matching(ready, selectors.EVENT_READ) if ready_readers: break # there might be a delay between the write to the write end and # the read end is reported ready sleep(0.1) else: self.fail("no sockets ready for reading") self.assertEqual([w2r[wr]], ready_readers) rd = ready_readers[0] buf = rd.recv(MSG_LEN) self.assertEqual(len(buf), MSG_LEN) bufs.append(buf) s.unregister(r2w[rd]) s.unregister(rd) writers.remove(r2w[rd]) self.assertEqual(bufs, [MSG] * NUM_SOCKETS) @unittest.skipIf(sys.platform == 'win32', 'select.select() cannot be used with empty fd sets') def test_empty_select(self): # Issue #23009: Make sure EpollSelector.select() works when no FD is # registered. s = self.SELECTOR() self.addCleanup(s.close) self.assertEqual(s.select(timeout=0), []) def test_timeout(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(wr, selectors.EVENT_WRITE) t = time() self.assertEqual(1, len(s.select(0))) self.assertEqual(1, len(s.select(-1))) self.assertLess(time() - t, 0.5) s.unregister(wr) s.register(rd, selectors.EVENT_READ) t = time() self.assertFalse(s.select(0)) self.assertFalse(s.select(-1)) self.assertLess(time() - t, 0.5) t0 = time() self.assertFalse(s.select(1)) t1 = time() dt = t1 - t0 # Tolerate 2.0 seconds for very slow buildbots self.assertTrue(0.8 <= dt <= 2.0, dt) @unittest.skipUnless(hasattr(signal, "alarm"), "signal.alarm() required for this test") def test_select_interrupt(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() orig_alrm_handler = signal.signal(signal.SIGALRM, lambda *args: None) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) self.addCleanup(signal.alarm, 0) signal.alarm(1) s.register(rd, selectors.EVENT_READ) t = time() self.assertFalse(s.select(2)) self.assertLess(time() - t, 2.5) class ScalableSelectorMixIn: # see issue #18963 for why it's skipped on older OS X versions @support.requires_mac_ver(10, 5) @unittest.skipUnless(resource, "Test needs resource module") def test_above_fd_setsize(self): # A scalable implementation should have no problem with more than # FD_SETSIZE file descriptors. Since we don't know the value, we just # try to set the soft RLIMIT_NOFILE to the hard RLIMIT_NOFILE ceiling. soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) try: resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard)) self.addCleanup(resource.setrlimit, resource.RLIMIT_NOFILE, (soft, hard)) NUM_FDS = min(hard, 2**16) except (OSError, ValueError): NUM_FDS = soft # guard for already allocated FDs (stdin, stdout...) NUM_FDS -= 32 s = self.SELECTOR() self.addCleanup(s.close) for i in range(NUM_FDS // 2): try: rd, wr = self.make_socketpair() except OSError: # too many FDs, skip - note that we should only catch EMFILE # here, but apparently *BSD and Solaris can fail upon connect() # or bind() with EADDRNOTAVAIL, so let's be safe self.skipTest("FD limit reached") try: s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) except OSError as e: if e.errno == errno.ENOSPC: # this can be raised by epoll if we go over # fs.epoll.max_user_watches sysctl self.skipTest("FD limit reached") raise self.assertEqual(NUM_FDS // 2, len(s.select())) class DefaultSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.DefaultSelector class SelectSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.SelectSelector @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") class PollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'PollSelector', None) @unittest.skipUnless(hasattr(selectors, 'EpollSelector'), "Test needs selectors.EpollSelector") class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'EpollSelector', None) @unittest.skipUnless(hasattr(selectors, 'KqueueSelector'), "Test needs selectors.KqueueSelector)") class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'KqueueSelector', None) def test_main(): tests = [DefaultSelectorTestCase, SelectSelectorTestCase, PollSelectorTestCase, EpollSelectorTestCase, KqueueSelectorTestCase] support.run_unittest(*tests) support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/3.4/test_ssl.py0000644000076500000000000040127012666555342020261 0ustar jmaddenwheel00000000000000# Test the support for SSL and sockets import sys import unittest from test import support import socket import select import time import datetime import gc import os import errno import pprint import tempfile import urllib.request import traceback import asyncore import weakref import platform import functools ssl = support.import_module("ssl") PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) HOST = support.HOST def data_file(*name): return os.path.join(os.path.dirname(__file__), *name) # The custom key and certificate files used in test_ssl are generated # using Lib/test/make_ssl_certs.py. # Other certificates are simply fetched from the Internet servers they # are meant to authenticate. CERTFILE = data_file("keycert.pem") BYTES_CERTFILE = os.fsencode(CERTFILE) ONLYCERT = data_file("ssl_cert.pem") ONLYKEY = data_file("ssl_key.pem") BYTES_ONLYCERT = os.fsencode(ONLYCERT) BYTES_ONLYKEY = os.fsencode(ONLYKEY) CERTFILE_PROTECTED = data_file("keycert.passwd.pem") ONLYKEY_PROTECTED = data_file("ssl_key.passwd.pem") KEY_PASSWORD = "somepass" CAPATH = data_file("capath") BYTES_CAPATH = os.fsencode(CAPATH) CAFILE_NEURONIO = data_file("capath", "4e1295a3.0") CAFILE_CACERT = data_file("capath", "5ed36f99.0") # empty CRL CRLFILE = data_file("revocation.crl") # Two keys and certs signed by the same CA (for SNI tests) SIGNED_CERTFILE = data_file("keycert3.pem") SIGNED_CERTFILE2 = data_file("keycert4.pem") SIGNING_CA = data_file("pycacert.pem") REMOTE_HOST = "self-signed.pythontest.net" REMOTE_ROOT_CERT = data_file("selfsigned_pythontestdotnet.pem") EMPTYCERT = data_file("nullcert.pem") BADCERT = data_file("badcert.pem") WRONGCERT = data_file("XXXnonexisting.pem") BADKEY = data_file("badkey.pem") NOKIACERT = data_file("nokia.pem") NULLBYTECERT = data_file("nullbytecert.pem") DHFILE = data_file("dh1024.pem") BYTES_DHFILE = os.fsencode(DHFILE) def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) if support.verbose: sys.stdout.write(prefix + exc_format) def can_clear_options(): # 0.9.8m or higher return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15) def no_sslv2_implies_sslv3_hello(): # 0.9.7h or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15) def have_verify_flags(): # 0.9.8 or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 0, 15) def asn1time(cert_time): # Some versions of OpenSSL ignore seconds, see #18207 # 0.9.8.i if ssl._OPENSSL_API_VERSION == (0, 9, 8, 9, 15): fmt = "%b %d %H:%M:%S %Y GMT" dt = datetime.datetime.strptime(cert_time, fmt) dt = dt.replace(second=0) cert_time = dt.strftime(fmt) # %d adds leading zero but ASN1_TIME_print() uses leading space if cert_time[4] == "0": cert_time = cert_time[:4] + " " + cert_time[5:] return cert_time # Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2 def skip_if_broken_ubuntu_ssl(func): if hasattr(ssl, 'PROTOCOL_SSLv2'): @functools.wraps(func) def f(*args, **kwargs): try: ssl.SSLContext(ssl.PROTOCOL_SSLv2) except ssl.SSLError: if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and platform.linux_distribution() == ('debian', 'squeeze/sid', '')): raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour") return func(*args, **kwargs) return f else: return func needs_sni = unittest.skipUnless(ssl.HAS_SNI, "SNI support needed for this test") class BasicSocketTests(unittest.TestCase): def test_constants(self): ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED ssl.OP_CIPHER_SERVER_PREFERENCE ssl.OP_SINGLE_DH_USE if ssl.HAS_ECDH: ssl.OP_SINGLE_ECDH_USE if ssl.OPENSSL_VERSION_INFO >= (1, 0): ssl.OP_NO_COMPRESSION self.assertIn(ssl.HAS_SNI, {True, False}) self.assertIn(ssl.HAS_ECDH, {True, False}) def test_random(self): v = ssl.RAND_status() if support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) data, is_cryptographic = ssl.RAND_pseudo_bytes(16) self.assertEqual(len(data), 16) self.assertEqual(is_cryptographic, v == 1) if v: data = ssl.RAND_bytes(16) self.assertEqual(len(data), 16) else: self.assertRaises(ssl.SSLError, ssl.RAND_bytes, 16) # negative num is invalid self.assertRaises(ValueError, ssl.RAND_bytes, -5) self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5) if hasattr(ssl, 'RAND_egd'): self.assertRaises(TypeError, ssl.RAND_egd, 1) self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) ssl.RAND_add("this is a random string", 75.0) @unittest.skipUnless(os.name == 'posix', 'requires posix') def test_random_fork(self): status = ssl.RAND_status() if not status: self.fail("OpenSSL's PRNG has insufficient randomness") rfd, wfd = os.pipe() pid = os.fork() if pid == 0: try: os.close(rfd) child_random = ssl.RAND_pseudo_bytes(16)[0] self.assertEqual(len(child_random), 16) os.write(wfd, child_random) os.close(wfd) except BaseException: os._exit(1) else: os._exit(0) else: os.close(wfd) self.addCleanup(os.close, rfd) _, status = os.waitpid(pid, 0) self.assertEqual(status, 0) child_random = os.read(rfd, 16) self.assertEqual(len(child_random), 16) parent_random = ssl.RAND_pseudo_bytes(16)[0] self.assertEqual(len(parent_random), 16) self.assertNotEqual(child_random, parent_random) def test_parse_cert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['issuer'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) # Note the next three asserts will fail if the keys are regenerated self.assertEqual(p['notAfter'], asn1time('Oct 5 23:01:56 2020 GMT')) self.assertEqual(p['notBefore'], asn1time('Oct 8 23:01:56 2010 GMT')) self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') self.assertEqual(p['subject'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) # Issue #13034: the subjectAltName in some certificates # (notably projects.developer.nokia.com:443) wasn't parsed p = ssl._ssl._test_decode_cert(NOKIACERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subjectAltName'], (('DNS', 'projects.developer.nokia.com'), ('DNS', 'projects.forum.nokia.com')) ) # extra OCSP and AIA fields self.assertEqual(p['OCSP'], ('http://ocsp.verisign.com',)) self.assertEqual(p['caIssuers'], ('http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cer',)) self.assertEqual(p['crlDistributionPoints'], ('http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl',)) def test_parse_cert_CVE_2013_4238(self): p = ssl._ssl._test_decode_cert(NULLBYTECERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") subject = ((('countryName', 'US'),), (('stateOrProvinceName', 'Oregon'),), (('localityName', 'Beaverton'),), (('organizationName', 'Python Software Foundation'),), (('organizationalUnitName', 'Python Core Development'),), (('commonName', 'null.python.org\x00example.org'),), (('emailAddress', 'python-dev@python.org'),)) self.assertEqual(p['subject'], subject) self.assertEqual(p['issuer'], subject) if ssl._OPENSSL_API_VERSION >= (0, 9, 8): san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '2001:DB8:0:0:0:0:0:1\n')) else: # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '')) self.assertEqual(p['subjectAltName'], san) def test_DER_to_PEM(self): with open(CAFILE_CACERT, 'r') as f: pem = f.read() d1 = ssl.PEM_cert_to_DER_cert(pem) p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) self.assertEqual(d1, d2) if not p2.startswith(ssl.PEM_HEADER + '\n'): self.fail("DER-to-PEM didn't include correct header:\n%r\n" % p2) if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'): self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2) def test_openssl_version(self): n = ssl.OPENSSL_VERSION_NUMBER t = ssl.OPENSSL_VERSION_INFO s = ssl.OPENSSL_VERSION self.assertIsInstance(n, int) self.assertIsInstance(t, tuple) self.assertIsInstance(s, str) # Some sanity checks follow # >= 0.9 self.assertGreaterEqual(n, 0x900000) # < 3.0 self.assertLess(n, 0x30000000) major, minor, fix, patch, status = t self.assertGreaterEqual(major, 0) self.assertLess(major, 3) self.assertGreaterEqual(minor, 0) self.assertLess(minor, 256) self.assertGreaterEqual(fix, 0) self.assertLess(fix, 256) self.assertGreaterEqual(patch, 0) self.assertLessEqual(patch, 63) self.assertGreaterEqual(status, 0) self.assertLessEqual(status, 15) # Version string as returned by {Open,Libre}SSL, the format might change if "LibreSSL" in s: self.assertTrue(s.startswith("LibreSSL {:d}.{:d}".format(major, minor)), (s, t)) else: self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), (s, t)) @support.cpython_only def test_refcycle(self): # Issue #7943: an SSL object doesn't create reference cycles with # itself. s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) with support.check_warnings(("", ResourceWarning)): del ss self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # Methods on an unconnected SSLSocket propagate the original # OSError raise by the underlying socket object. s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s) as ss: self.assertRaises(OSError, ss.recv, 1) self.assertRaises(OSError, ss.recv_into, bytearray(b'x')) self.assertRaises(OSError, ss.recvfrom, 1) self.assertRaises(OSError, ss.recvfrom_into, bytearray(b'x'), 1) self.assertRaises(OSError, ss.send, b'x') self.assertRaises(OSError, ss.sendto, b'x', ('0.0.0.0', 0)) def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the # original socket should be retained. for timeout in (None, 0.0, 5.0): s = socket.socket(socket.AF_INET) s.settimeout(timeout) with ssl.wrap_socket(s) as ss: self.assertEqual(timeout, ss.gettimeout()) def test_errors(self): sock = socket.socket() self.assertRaisesRegex(ValueError, "certfile must be specified", ssl.wrap_socket, sock, keyfile=CERTFILE) self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True) self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True, certfile="") with ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) as s: self.assertRaisesRegex(ValueError, "can't connect in server-side mode", s.connect, (HOST, 8080)) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=CERTFILE, keyfile=WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=WRONGCERT, keyfile=WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) def test_match_hostname(self): def ok(cert, hostname): ssl.match_hostname(cert, hostname) def fail(cert, hostname): self.assertRaises(ssl.CertificateError, ssl.match_hostname, cert, hostname) cert = {'subject': ((('commonName', 'example.com'),),)} ok(cert, 'example.com') ok(cert, 'ExAmple.cOm') fail(cert, 'www.example.com') fail(cert, '.example.com') fail(cert, 'example.org') fail(cert, 'exampleXcom') cert = {'subject': ((('commonName', '*.a.com'),),)} ok(cert, 'foo.a.com') fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') # only match one left-most wildcard cert = {'subject': ((('commonName', 'f*.com'),),)} ok(cert, 'foo.com') ok(cert, 'f.com') fail(cert, 'bar.com') fail(cert, 'foo.a.com') fail(cert, 'bar.foo.com') # NULL bytes are bad, CVE-2013-4073 cert = {'subject': ((('commonName', 'null.python.org\x00example.org'),),)} ok(cert, 'null.python.org\x00example.org') # or raise an error? fail(cert, 'example.org') fail(cert, 'null.python.org') # error cases with wildcards cert = {'subject': ((('commonName', '*.*.a.com'),),)} fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') cert = {'subject': ((('commonName', 'a.*.com'),),)} fail(cert, 'a.foo.com') fail(cert, 'a..com') fail(cert, 'a.com') # wildcard doesn't match IDNA prefix 'xn--' idna = 'püthon.python.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, idna) cert = {'subject': ((('commonName', 'x*.python.org'),),)} fail(cert, idna) cert = {'subject': ((('commonName', 'xn--p*.python.org'),),)} fail(cert, idna) # wildcard in first fragment and IDNA A-labels in sequent fragments # are supported. idna = 'www*.pythön.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, 'www.pythön.org'.encode("idna").decode("ascii")) ok(cert, 'www1.pythön.org'.encode("idna").decode("ascii")) fail(cert, 'ftp.pythön.org'.encode("idna").decode("ascii")) fail(cert, 'pythön.org'.encode("idna").decode("ascii")) # Slightly fake real-world example cert = {'notAfter': 'Jun 26 21:41:46 2011 GMT', 'subject': ((('commonName', 'linuxfrz.org'),),), 'subjectAltName': (('DNS', 'linuxfr.org'), ('DNS', 'linuxfr.com'), ('othername', ''))} ok(cert, 'linuxfr.org') ok(cert, 'linuxfr.com') # Not a "DNS" entry fail(cert, '') # When there is a subjectAltName, commonName isn't used fail(cert, 'linuxfrz.org') # A pristine real-world example cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),), (('commonName', 'mail.google.com'),))} ok(cert, 'mail.google.com') fail(cert, 'gmail.com') # Only commonName is considered fail(cert, 'California') # Neither commonName nor subjectAltName cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),))} fail(cert, 'mail.google.com') # No DNS entry in subjectAltName but a commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('commonName', 'mail.google.com'),)), 'subjectAltName': (('othername', 'blabla'), )} ok(cert, 'mail.google.com') # No DNS entry subjectAltName and no commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),)), 'subjectAltName': (('othername', 'blabla'),)} fail(cert, 'google.com') # Empty cert / no cert self.assertRaises(ValueError, ssl.match_hostname, None, 'example.com') self.assertRaises(ValueError, ssl.match_hostname, {}, 'example.com') # Issue #17980: avoid denials of service by refusing more than one # wildcard per fragment. cert = {'subject': ((('commonName', 'a*b.com'),),)} ok(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b.co*'),),)} fail(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b*.com'),),)} with self.assertRaises(ssl.CertificateError) as cm: ssl.match_hostname(cert, 'axxbxxc.com') self.assertIn("too many wildcards", str(cm.exception)) def test_server_side(self): # server_hostname doesn't work for server sockets ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with socket.socket() as sock: self.assertRaises(ValueError, ctx.wrap_socket, sock, True, server_hostname="some.hostname") def test_unknown_channel_binding(self): # should raise ValueError for unknown type s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s) as ss: with self.assertRaises(ValueError): ss.get_channel_binding("unknown-type") @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): # unconnected should return None for known type s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) # the same for server-side s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) def test_dealloc_warn(self): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) r = repr(ss) with self.assertWarns(ResourceWarning) as cm: ss = None support.gc_collect() self.assertIn(r, str(cm.warning.args[0])) def test_get_default_verify_paths(self): paths = ssl.get_default_verify_paths() self.assertEqual(len(paths), 6) self.assertIsInstance(paths, ssl.DefaultVerifyPaths) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE paths = ssl.get_default_verify_paths() self.assertEqual(paths.cafile, CERTFILE) self.assertEqual(paths.capath, CAPATH) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_certificates(self): self.assertTrue(ssl.enum_certificates("CA")) self.assertTrue(ssl.enum_certificates("ROOT")) self.assertRaises(TypeError, ssl.enum_certificates) self.assertRaises(WindowsError, ssl.enum_certificates, "") trust_oids = set() for storename in ("CA", "ROOT"): store = ssl.enum_certificates(storename) self.assertIsInstance(store, list) for element in store: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 3) cert, enc, trust = element self.assertIsInstance(cert, bytes) self.assertIn(enc, {"x509_asn", "pkcs_7_asn"}) self.assertIsInstance(trust, (set, bool)) if isinstance(trust, set): trust_oids.update(trust) serverAuth = "1.3.6.1.5.5.7.3.1" self.assertIn(serverAuth, trust_oids) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_crls(self): self.assertTrue(ssl.enum_crls("CA")) self.assertRaises(TypeError, ssl.enum_crls) self.assertRaises(WindowsError, ssl.enum_crls, "") crls = ssl.enum_crls("CA") self.assertIsInstance(crls, list) for element in crls: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 2) self.assertIsInstance(element[0], bytes) self.assertIn(element[1], {"x509_asn", "pkcs_7_asn"}) def test_asn1object(self): expected = (129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertEqual(val, expected) self.assertEqual(val.nid, 129) self.assertEqual(val.shortname, 'serverAuth') self.assertEqual(val.longname, 'TLS Web Server Authentication') self.assertEqual(val.oid, '1.3.6.1.5.5.7.3.1') self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object, 'serverAuth') val = ssl._ASN1Object.fromnid(129) self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object.fromnid, -1) with self.assertRaisesRegex(ValueError, "unknown NID 100000"): ssl._ASN1Object.fromnid(100000) for i in range(1000): try: obj = ssl._ASN1Object.fromnid(i) except ValueError: pass else: self.assertIsInstance(obj.nid, int) self.assertIsInstance(obj.shortname, str) self.assertIsInstance(obj.longname, str) self.assertIsInstance(obj.oid, (str, type(None))) val = ssl._ASN1Object.fromname('TLS Web Server Authentication') self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertEqual(ssl._ASN1Object.fromname('serverAuth'), expected) self.assertEqual(ssl._ASN1Object.fromname('1.3.6.1.5.5.7.3.1'), expected) with self.assertRaisesRegex(ValueError, "unknown object 'serverauth'"): ssl._ASN1Object.fromname('serverauth') def test_purpose_enum(self): val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertIsInstance(ssl.Purpose.SERVER_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.SERVER_AUTH, val) self.assertEqual(ssl.Purpose.SERVER_AUTH.nid, 129) self.assertEqual(ssl.Purpose.SERVER_AUTH.shortname, 'serverAuth') self.assertEqual(ssl.Purpose.SERVER_AUTH.oid, '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.2') self.assertIsInstance(ssl.Purpose.CLIENT_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.CLIENT_AUTH, val) self.assertEqual(ssl.Purpose.CLIENT_AUTH.nid, 130) self.assertEqual(ssl.Purpose.CLIENT_AUTH.shortname, 'clientAuth') self.assertEqual(ssl.Purpose.CLIENT_AUTH.oid, '1.3.6.1.5.5.7.3.2') def test_unsupported_dtls(self): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) with self.assertRaises(NotImplementedError) as cx: ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE) self.assertEqual(str(cx.exception), "only stream sockets are supported") ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with self.assertRaises(NotImplementedError) as cx: ctx.wrap_socket(s) self.assertEqual(str(cx.exception), "only stream sockets are supported") class ContextTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_constructor(self): for protocol in PROTOCOLS: ssl.SSLContext(protocol) self.assertRaises(TypeError, ssl.SSLContext) self.assertRaises(ValueError, ssl.SSLContext, -1) self.assertRaises(ValueError, ssl.SSLContext, 42) @skip_if_broken_ubuntu_ssl def test_protocol(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.protocol, proto) def test_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") @skip_if_broken_ubuntu_ssl def test_options(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3, ctx.options) ctx.options |= ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1, ctx.options) if can_clear_options(): ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3, ctx.options) ctx.options = 0 self.assertEqual(0, ctx.options) else: with self.assertRaises(ValueError): ctx.options = 0 def test_verify_mode(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Default value self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) ctx.verify_mode = ssl.CERT_OPTIONAL self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL) ctx.verify_mode = ssl.CERT_REQUIRED self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) ctx.verify_mode = ssl.CERT_NONE self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) with self.assertRaises(TypeError): ctx.verify_mode = None with self.assertRaises(ValueError): ctx.verify_mode = 42 @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_verify_flags(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # default value tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT | tf) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_CHAIN self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_CHAIN) ctx.verify_flags = ssl.VERIFY_DEFAULT self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT) # supports any value ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT) with self.assertRaises(TypeError): ctx.verify_flags = None def test_load_cert_chain(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Combined key and cert in a single file ctx.load_cert_chain(CERTFILE, keyfile=None) ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE) self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE) with self.assertRaises(OSError) as cm: ctx.load_cert_chain(WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(BADCERT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(EMPTYCERT) # Separate key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_cert_chain(ONLYCERT, ONLYKEY) ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY) ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYCERT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYKEY) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT) # Mismatching key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"): ctx.load_cert_chain(CAFILE_CACERT, ONLYKEY) # Password protected key and cert ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD) ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD.encode()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=bytearray(KEY_PASSWORD.encode())) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD.encode()) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, bytearray(KEY_PASSWORD.encode())) with self.assertRaisesRegex(TypeError, "should be a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=True) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password="badpass") with self.assertRaisesRegex(ValueError, "cannot be longer"): # openssl has a fixed limit on the password buffer. # PEM_BUFSIZE is generally set to 1kb. # Return a string larger than this. ctx.load_cert_chain(CERTFILE_PROTECTED, password=b'a' * 102400) # Password callback def getpass_unicode(): return KEY_PASSWORD def getpass_bytes(): return KEY_PASSWORD.encode() def getpass_bytearray(): return bytearray(KEY_PASSWORD.encode()) def getpass_badpass(): return "badpass" def getpass_huge(): return b'a' * (1024 * 1024) def getpass_bad_type(): return 9 def getpass_exception(): raise Exception('getpass error') class GetPassCallable: def __call__(self): return KEY_PASSWORD def getpass(self): return KEY_PASSWORD ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_unicode) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytes) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytearray) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable().getpass) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_badpass) with self.assertRaisesRegex(ValueError, "cannot be longer"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_huge) with self.assertRaisesRegex(TypeError, "must return a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bad_type) with self.assertRaisesRegex(Exception, "getpass error"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_exception) # Make sure the password function isn't called if it isn't needed ctx.load_cert_chain(CERTFILE, password=getpass_exception) def test_load_verify_locations(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(CERTFILE) ctx.load_verify_locations(cafile=CERTFILE, capath=None) ctx.load_verify_locations(BYTES_CERTFILE) ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None) self.assertRaises(TypeError, ctx.load_verify_locations) self.assertRaises(TypeError, ctx.load_verify_locations, None, None, None) with self.assertRaises(OSError) as cm: ctx.load_verify_locations(WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_verify_locations(BADCERT) ctx.load_verify_locations(CERTFILE, CAPATH) ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH) # Issue #10989: crash if the second argument type is invalid self.assertRaises(TypeError, ctx.load_verify_locations, None, True) def test_load_verify_cadata(self): # test cadata with open(CAFILE_CACERT) as f: cacert_pem = f.read() cacert_der = ssl.PEM_cert_to_DER_cert(cacert_pem) with open(CAFILE_NEURONIO) as f: neuronio_pem = f.read() neuronio_der = ssl.PEM_cert_to_DER_cert(neuronio_pem) # test PEM ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 0) ctx.load_verify_locations(cadata=cacert_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 1) ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = "\n".join((cacert_pem, neuronio_pem)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # with junk around the certs ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = ["head", cacert_pem, "other", neuronio_pem, "again", neuronio_pem, "tail"] ctx.load_verify_locations(cadata="\n".join(combined)) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # test DER ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(cadata=cacert_der) ctx.load_verify_locations(cadata=neuronio_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=cacert_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = b"".join((cacert_der, neuronio_der)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # error cases ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_verify_locations, cadata=object) with self.assertRaisesRegex(ssl.SSLError, "no start line"): ctx.load_verify_locations(cadata="broken") with self.assertRaisesRegex(ssl.SSLError, "not enough data"): ctx.load_verify_locations(cadata=b"broken") def test_load_dh_params(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_dh_params(DHFILE) if os.name != 'nt': ctx.load_dh_params(BYTES_DHFILE) self.assertRaises(TypeError, ctx.load_dh_params) self.assertRaises(TypeError, ctx.load_dh_params, None) with self.assertRaises(FileNotFoundError) as cm: ctx.load_dh_params(WRONGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) @skip_if_broken_ubuntu_ssl def test_session_stats(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.session_stats(), { 'number': 0, 'connect': 0, 'connect_good': 0, 'connect_renegotiate': 0, 'accept': 0, 'accept_good': 0, 'accept_renegotiate': 0, 'hits': 0, 'misses': 0, 'timeouts': 0, 'cache_full': 0, }) def test_set_default_verify_paths(self): # There's not much we can do to test that it acts as expected, # so just check it doesn't crash or raise an exception. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_default_verify_paths() @unittest.skipUnless(ssl.HAS_ECDH, "ECDH disabled on this OpenSSL build") def test_set_ecdh_curve(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ecdh_curve("prime256v1") ctx.set_ecdh_curve(b"prime256v1") self.assertRaises(TypeError, ctx.set_ecdh_curve) self.assertRaises(TypeError, ctx.set_ecdh_curve, None) self.assertRaises(ValueError, ctx.set_ecdh_curve, "foo") self.assertRaises(ValueError, ctx.set_ecdh_curve, b"foo") @needs_sni def test_sni_callback(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # set_servername_callback expects a callable, or None self.assertRaises(TypeError, ctx.set_servername_callback) self.assertRaises(TypeError, ctx.set_servername_callback, 4) self.assertRaises(TypeError, ctx.set_servername_callback, "") self.assertRaises(TypeError, ctx.set_servername_callback, ctx) def dummycallback(sock, servername, ctx): pass ctx.set_servername_callback(None) ctx.set_servername_callback(dummycallback) @needs_sni def test_sni_callback_refcycle(self): # Reference cycles through the servername callback are detected # and cleared. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) def dummycallback(sock, servername, ctx, cycle=ctx): pass ctx.set_servername_callback(dummycallback) wr = weakref.ref(ctx) del ctx, dummycallback gc.collect() self.assertIs(wr(), None) def test_cert_store_stats(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_cert_chain(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 1}) ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 1, 'crl': 0, 'x509': 2}) def test_get_ca_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.get_ca_certs(), []) # CERTFILE is not flagged as X509v3 Basic Constraints: CA:TRUE ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.get_ca_certs(), []) # but CAFILE_CACERT is a CA cert ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.get_ca_certs(), [{'issuer': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'notAfter': asn1time('Mar 29 12:29:49 2033 GMT'), 'notBefore': asn1time('Mar 30 12:29:49 2003 GMT'), 'serialNumber': '00', 'crlDistributionPoints': ('https://www.cacert.org/revoke.crl',), 'subject': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'version': 3}]) with open(CAFILE_CACERT) as f: pem = f.read() der = ssl.PEM_cert_to_DER_cert(pem) self.assertEqual(ctx.get_ca_certs(True), [der]) def test_load_default_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.SERVER_AUTH) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.CLIENT_AUTH) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_default_certs, None) self.assertRaises(TypeError, ctx.load_default_certs, 'SERVER_AUTH') @unittest.skipIf(sys.platform == "win32", "not-Windows specific") def test_load_default_certs_env(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() self.assertEqual(ctx.cert_store_stats(), {"crl": 0, "x509": 1, "x509_ca": 0}) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_load_default_certs_env_windows(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() stats = ctx.cert_store_stats() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() stats["x509"] += 1 self.assertEqual(ctx.cert_store_stats(), stats) def test_create_default_context(self): ctx = ssl.create_default_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) with open(SIGNING_CA) as f: cadata = f.read() ctx = ssl.create_default_context(cafile=SIGNING_CA, capath=CAPATH, cadata=cadata) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_DH_USE", 0), getattr(ssl, "OP_SINGLE_DH_USE", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_ECDH_USE", 0), getattr(ssl, "OP_SINGLE_ECDH_USE", 0), ) def test__create_stdlib_context(self): ctx = ssl._create_stdlib_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertFalse(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1, cert_reqs=ssl.CERT_REQUIRED, check_hostname=True) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(purpose=ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) def test_check_hostname(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertFalse(ctx.check_hostname) # Requires CERT_REQUIRED or CERT_OPTIONAL with self.assertRaises(ValueError): ctx.check_hostname = True ctx.verify_mode = ssl.CERT_REQUIRED self.assertFalse(ctx.check_hostname) ctx.check_hostname = True self.assertTrue(ctx.check_hostname) ctx.verify_mode = ssl.CERT_OPTIONAL ctx.check_hostname = True self.assertTrue(ctx.check_hostname) # Cannot set CERT_NONE with check_hostname enabled with self.assertRaises(ValueError): ctx.verify_mode = ssl.CERT_NONE ctx.check_hostname = False self.assertFalse(ctx.check_hostname) class SSLErrorTests(unittest.TestCase): def test_str(self): # The str() of a SSLError doesn't include the errno e = ssl.SSLError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) # Same for a subclass e = ssl.SSLZeroReturnError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) def test_lib_reason(self): # Test the library and reason attributes ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) self.assertEqual(cm.exception.library, 'PEM') self.assertEqual(cm.exception.reason, 'NO_START_LINE') s = str(cm.exception) self.assertTrue(s.startswith("[PEM: NO_START_LINE] no start line"), s) def test_subclass(self): # Check that the appropriate SSLError subclass is raised # (this only tests one of them) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with socket.socket() as s: s.bind(("127.0.0.1", 0)) s.listen(5) c = socket.socket() c.connect(s.getsockname()) c.setblocking(False) with ctx.wrap_socket(c, False, do_handshake_on_connect=False) as c: with self.assertRaises(ssl.SSLWantReadError) as cm: c.do_handshake() s = str(cm.exception) self.assertTrue(s.startswith("The operation did not complete (read)"), s) # For compatibility self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ) class NetworkedTests(unittest.TestCase): def test_connect(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) try: s.connect((REMOTE_HOST, 443)) self.assertEqual({}, s.getpeercert()) finally: s.close() # this should fail because we have no verification certs s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED) self.assertRaisesRegex(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # this should succeed because we specify the root cert s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: s.connect((REMOTE_HOST, 443)) self.assertTrue(s.getpeercert()) finally: s.close() def test_connect_ex(self): # Issue #11326: check connect_ex() implementation with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: self.assertEqual(0, s.connect_ex((REMOTE_HOST, 443))) self.assertTrue(s.getpeercert()) finally: s.close() def test_non_blocking_connect_ex(self): # Issue #11326: non-blocking connect_ex() should allow handshake # to proceed after the socket gets ready. with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.setblocking(False) rc = s.connect_ex((REMOTE_HOST, 443)) # EWOULDBLOCK under Windows, EINPROGRESS elsewhere self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK)) # Wait for connect to finish select.select([], [s], [], 5.0) # Non-blocking handshake while True: try: s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], [], 5.0) except ssl.SSLWantWriteError: select.select([], [s], [], 5.0) # SSL established self.assertTrue(s.getpeercert()) finally: s.close() def test_timeout_connect_ex(self): # Issue #12065: on a timeout, connect_ex() should return the original # errno (mimicking the behaviour of non-SSL sockets). with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.settimeout(0.0000001) rc = s.connect_ex((REMOTE_HOST, 443)) if rc == 0: self.skipTest("REMOTE_HOST responded too quickly") self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) finally: s.close() def test_connect_ex_error(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: rc = s.connect_ex((REMOTE_HOST, 444)) # Issue #19919: Windows machines or VMs hosted on Windows # machines sometimes return EWOULDBLOCK. errors = ( errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.EWOULDBLOCK, ) self.assertIn(rc, errors) finally: s.close() def test_connect_with_context(self): with support.transient_internet(REMOTE_HOST): # Same as test_connect, but with a separately created context ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: self.assertEqual({}, s.getpeercert()) finally: s.close() # Same with a server hostname s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname=REMOTE_HOST) s.connect((REMOTE_HOST, 443)) s.close() # This should fail because we have no verification certs ctx.verify_mode = ssl.CERT_REQUIRED s = ctx.wrap_socket(socket.socket(socket.AF_INET)) self.assertRaisesRegex(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # This should succeed because we specify the root cert ctx.load_verify_locations(REMOTE_ROOT_CERT) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_capath(self): # Verify server certificates using the `capath` argument # NOTE: the subject hashing algorithm has been changed between # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must # contain both versions of each certificate (same content, different # filename) for this test to be portable across OpenSSL releases. with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() # Same with a bytes `capath` argument ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=BYTES_CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_cadata(self): with open(REMOTE_ROOT_CERT) as f: pem = f.read() der = ssl.PEM_cert_to_DER_cert(pem) with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=pem) with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) # same with DER ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=der) with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't # delay closing the underlying "real socket" (here tested with its # file descriptor, hence skipping the test under Windows). with support.transient_internet(REMOTE_HOST): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) ss.connect((REMOTE_HOST, 443)) fd = ss.fileno() f = ss.makefile() f.close() # The fd is still open os.read(fd, 0) # Closing the SSL socket should close the fd too ss.close() gc.collect() with self.assertRaises(OSError) as e: os.read(fd, 0) self.assertEqual(e.exception.errno, errno.EBADF) def test_non_blocking_handshake(self): with support.transient_internet(REMOTE_HOST): s = socket.socket(socket.AF_INET) s.connect((REMOTE_HOST, 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], []) except ssl.SSLWantWriteError: select.select([], [s], []) s.close() if support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) def test_get_server_certificate(self): def _test_get_server_certificate(host, port, cert=None): with support.transient_internet(host): pem = ssl.get_server_certificate((host, port), ssl.PROTOCOL_SSLv23) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) try: pem = ssl.get_server_certificate((host, port), ssl.PROTOCOL_SSLv23, ca_certs=CERTFILE) except ssl.SSLError as x: #should fail if support.verbose: sys.stdout.write("%s\n" % x) else: self.fail("Got server certificate %s for %s:%s!" % (pem, host, port)) pem = ssl.get_server_certificate((host, port), ssl.PROTOCOL_SSLv23, ca_certs=cert) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) if support.verbose: sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem)) _test_get_server_certificate(REMOTE_HOST, 443, REMOTE_ROOT_CERT) if support.IPV6_ENABLED: _test_get_server_certificate('ipv6.google.com', 443) def test_ciphers(self): remote = (REMOTE_HOST, 443) with support.transient_internet(remote[0]): with ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s: s.connect(remote) with ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s: s.connect(remote) # Error checking can happen at instantiation or when connecting with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): with socket.socket(socket.AF_INET) as sock: s = ssl.wrap_socket(sock, cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx") s.connect(remote) def test_algorithms(self): # Issue #8484: all algorithms should be available when verifying a # certificate. # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) # sha256.tbs-internet.com needs SNI to use the correct certificate if not ssl.HAS_SNI: self.skipTest("SNI needed for this test") # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host) remote = ("sha256.tbs-internet.com", 443) sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") with support.transient_internet("sha256.tbs-internet.com"): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(sha256_cert) s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname="sha256.tbs-internet.com") try: s.connect(remote) if support.verbose: sys.stdout.write("\nCipher with %r is %r\n" % (remote, s.cipher())) sys.stdout.write("Certificate is:\n%s\n" % pprint.pformat(s.getpeercert())) finally: s.close() def test_get_ca_certs_capath(self): # capath certs are loaded on request with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) self.assertEqual(ctx.get_ca_certs(), []) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() self.assertEqual(len(ctx.get_ca_certs()), 1) @needs_sni def test_context_setget(self): # Check that the context of a connected socket can be replaced. with support.transient_internet(REMOTE_HOST): ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = socket.socket(socket.AF_INET) with ctx1.wrap_socket(s) as ss: ss.connect((REMOTE_HOST, 443)) self.assertIs(ss.context, ctx1) self.assertIs(ss._sslobj.context, ctx1) ss.context = ctx2 self.assertIs(ss.context, ctx2) self.assertIs(ss._sslobj.context, ctx2) try: import threading except ImportError: _have_threads = False else: _have_threads = True from test.ssl_servers import make_https_server class ThreadedEchoServer(threading.Thread): class ConnectionHandler(threading.Thread): """A mildly complicated class, because we want it to work both with and without the SSL wrapper around the socket connection, so that we can test the STARTTLS functionality.""" def __init__(self, server, connsock, addr): self.server = server self.running = False self.sock = connsock self.addr = addr self.sock.setblocking(1) self.sslconn = None threading.Thread.__init__(self) self.daemon = True def wrap_conn(self): try: self.sslconn = self.server.context.wrap_socket( self.sock, server_side=True) self.server.selected_protocols.append(self.sslconn.selected_npn_protocol()) except (ssl.SSLError, ConnectionResetError) as e: # We treat ConnectionResetError as though it were an # SSLError - OpenSSL on Ubuntu abruptly closes the # connection when asked to use an unsupported protocol. # # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n") self.running = False self.server.stop() self.close() return False else: if self.server.context.verify_mode == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") sys.stdout.write(" server: selected protocol is now " + str(self.sslconn.selected_npn_protocol()) + "\n") return True def read(self): if self.sslconn: return self.sslconn.read() else: return self.sock.recv(1024) def write(self, bytes): if self.sslconn: return self.sslconn.write(bytes) else: return self.sock.send(bytes) def close(self): if self.sslconn: self.sslconn.close() else: self.sock.close() def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif (self.server.starttls_server and stripped == b'STARTTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write(b"OK\n") if not self.wrap_conn(): return elif (self.server.starttls_server and self.sslconn and stripped == b'ENDTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read ENDTLS from client, sending OK...\n") self.write(b"OK\n") self.sock = self.sslconn.unwrap() self.sslconn = None if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: connection is now unencrypted...\n") elif stripped == b'CB tls-unique': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read CB tls-unique from client, sending our CB data...\n") data = self.sslconn.get_channel_binding("tls-unique") self.write(repr(data).encode("us-ascii") + b"\n") else: if (support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n" % (msg, ctype, msg.lower(), ctype)) self.write(msg.lower()) except OSError: if self.server.chatty: handle_error("Test server failure:\n") self.close() self.running = False # normally, we'd just stop here, but for the test # harness, we want to stop the server self.server.stop() def __init__(self, certificate=None, ssl_version=None, certreqs=None, cacerts=None, chatty=True, connectionchatty=False, starttls_server=False, npn_protocols=None, ciphers=None, context=None): if context: self.context = context else: self.context = ssl.SSLContext(ssl_version if ssl_version is not None else ssl.PROTOCOL_TLSv1) self.context.verify_mode = (certreqs if certreqs is not None else ssl.CERT_NONE) if cacerts: self.context.load_verify_locations(cacerts) if certificate: self.context.load_cert_chain(certificate) if npn_protocols: self.context.set_npn_protocols(npn_protocols) if ciphers: self.context.set_ciphers(ciphers) self.chatty = chatty self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() self.port = support.bind_port(self.sock) self.flag = None self.active = False self.selected_protocols = [] self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): self.stop() self.join() def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.sock.settimeout(0.05) self.sock.listen(5) self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + repr(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn, connaddr) handler.start() handler.join() except socket.timeout: pass except KeyboardInterrupt: self.stop() self.sock.close() def stop(self): self.active = False class AsyncoreEchoServer(threading.Thread): # this one's based on asyncore.dispatcher class EchoServer (asyncore.dispatcher): class ConnectionHandler (asyncore.dispatcher_with_send): def __init__(self, conn, certfile): self.socket = ssl.wrap_socket(conn, server_side=True, certfile=certfile, do_handshake_on_connect=False) asyncore.dispatcher_with_send.__init__(self, self.socket) self._ssl_accepting = True self._do_ssl_handshake() def readable(self): if isinstance(self.socket, ssl.SSLSocket): while self.socket.pending() > 0: self.handle_read_event() return True def _do_ssl_handshake(self): try: self.socket.do_handshake() except (ssl.SSLWantReadError, ssl.SSLWantWriteError): return except ssl.SSLEOFError: return self.handle_close() except ssl.SSLError: raise except OSError as err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() else: data = self.recv(1024) if support.verbose: sys.stdout.write(" server: read %s from client\n" % repr(data)) if not data: self.close() else: self.send(data.lower()) def handle_close(self): self.close() if support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): raise def __init__(self, certfile): self.certfile = certfile sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(sock, '') asyncore.dispatcher.__init__(self, sock) self.listen(5) def handle_accepted(self, sock_obj, addr): if support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) def handle_error(self): raise def __init__(self, certfile): self.flag = None self.active = False self.server = self.EchoServer(certfile) self.port = self.server.port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): if support.verbose: sys.stdout.write(" cleanup: stopping server.\n") self.stop() if support.verbose: sys.stdout.write(" cleanup: joining server thread.\n") self.join() if support.verbose: sys.stdout.write(" cleanup: successfully joined.\n") def start (self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.active = True if self.flag: self.flag.set() while self.active: try: asyncore.loop(1) except: pass def stop(self): self.active = False self.server.close() def bad_cert_test(certfile): """ Launch a server with CERT_REQUIRED, and check that trying to connect to it with the given client certificate fails. """ server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False, connectionchatty=False) with server: try: with socket.socket() as sock: s = ssl.wrap_socket(sock, certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError as x: if support.verbose: sys.stdout.write("\nSSLError is %s\n" % x.args[1]) except OSError as x: if support.verbose: sys.stdout.write("\nOSError is %s\n" % x.args[1]) except OSError as x: if x.errno != errno.ENOENT: raise if support.verbose: sys.stdout.write("\OSError is %s\n" % str(x)) else: raise AssertionError("Use of invalid cert should have failed!") def server_params_test(client_context, server_context, indata=b"FOO\n", chatty=True, connectionchatty=False, sni_name=None): """ Launch a server, connect a client to it and try various reads and writes. """ stats = {} server = ThreadedEchoServer(context=server_context, chatty=chatty, connectionchatty=False) with server: with client_context.wrap_socket(socket.socket(), server_hostname=sni_name) as s: s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(arg) outdata = s.read() if connectionchatty: if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): raise AssertionError( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if connectionchatty: if support.verbose: sys.stdout.write(" client: closing connection.\n") stats.update({ 'compression': s.compression(), 'cipher': s.cipher(), 'peercert': s.getpeercert(), 'client_npn_protocol': s.selected_npn_protocol() }) s.close() stats['server_npn_protocols'] = server.selected_protocols return stats def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None, server_options=0, client_options=0): if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) client_context = ssl.SSLContext(client_protocol) client_context.options |= client_options server_context = ssl.SSLContext(server_protocol) server_context.options |= server_options # NOTE: we must enable "ALL" ciphers on the client, otherwise an # SSLv23 client will send an SSLv3 hello (rather than SSLv2) # starting from OpenSSL 1.0.0 (see issue #8322). if client_context.protocol == ssl.PROTOCOL_SSLv23: client_context.set_ciphers("ALL") for ctx in (client_context, server_context): ctx.verify_mode = certsreqs ctx.load_cert_chain(CERTFILE) ctx.load_verify_locations(CERTFILE) try: server_params_test(client_context, server_context, chatty=False, connectionchatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except OSError as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) class ThreadedTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_echo(self): """Basic test of an SSL client connecting to a server""" if support.verbose: sys.stdout.write("\n") for protocol in PROTOCOLS: with self.subTest(protocol=ssl._PROTOCOL_NAMES[protocol]): context = ssl.SSLContext(protocol) context.load_cert_chain(CERTFILE) server_params_test(context, context, chatty=True, connectionchatty=True) def test_getpeercert(self): if support.verbose: sys.stdout.write("\n") context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket(), do_handshake_on_connect=False) s.connect((HOST, server.port)) # getpeercert() raise ValueError while the handshake isn't # done. with self.assertRaises(ValueError): s.getpeercert() s.do_handshake() cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() if support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: self.fail("No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): self.fail( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") self.assertIn('notBefore', cert) self.assertIn('notAfter', cert) before = ssl.cert_time_to_seconds(cert['notBefore']) after = ssl.cert_time_to_seconds(cert['notAfter']) self.assertLess(before, after) s.close() @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_crl_check(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(SIGNING_CA) tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(context.verify_flags, ssl.VERIFY_DEFAULT | tf) # VERIFY_DEFAULT should pass server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # VERIFY_CRL_CHECK_LEAF without a loaded CRL file fails context.verify_flags |= ssl.VERIFY_CRL_CHECK_LEAF server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: with self.assertRaisesRegex(ssl.SSLError, "certificate verify failed"): s.connect((HOST, server.port)) # now load a CRL file. The CRL file is signed by the CA. context.load_verify_locations(CRLFILE) server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") def test_check_hostname(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.check_hostname = True context.load_verify_locations(SIGNING_CA) # correct hostname should verify server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket(), server_hostname="localhost") as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # incorrect hostname should raise an exception server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket(), server_hostname="invalid") as s: with self.assertRaisesRegex(ssl.CertificateError, "hostname 'invalid' doesn't match 'localhost'"): s.connect((HOST, server.port)) # missing server_hostname arg should cause an exception, too server = ThreadedEchoServer(context=server_context, chatty=True) with server: with socket.socket() as s: with self.assertRaisesRegex(ValueError, "check_hostname requires server_hostname"): context.wrap_socket(s) def test_empty_cert(self): """Connecting with an empty cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "nullcert.pem")) def test_malformed_cert(self): """Connecting with a badly formatted certificate (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badcert.pem")) def test_nonexisting_cert(self): """Connecting with a non-existing cert file""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "wrongcert.pem")) def test_malformed_key(self): """Connecting with a badly formatted key (syntax error)""" bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir, "badkey.pem")) def test_rude_shutdown(self): """A brutal shutdown of an SSL server should raise an OSError in the client when attempting handshake. """ listener_ready = threading.Event() listener_gone = threading.Event() s = socket.socket() port = support.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, # and sets Event `listener_gone` to let the main thread know # the socket is gone. def listener(): s.listen(5) listener_ready.set() newsock, addr = s.accept() newsock.close() s.close() listener_gone.set() def connector(): listener_ready.wait() with socket.socket() as c: c.connect((HOST, port)) listener_gone.wait() try: ssl_sock = ssl.wrap_socket(c) except OSError: pass else: self.fail('connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) t.start() try: connector() finally: t.join() @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv2'), "OpenSSL is compiled without SSLv2 support") def test_protocol_sslv2(self): """Connecting to an SSLv2 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) # SSLv23 client with specific SSL options if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl def test_protocol_sslv23(self): """Connecting to an SSLv23 server with various client options""" if support.verbose: sys.stdout.write("\n") if hasattr(ssl, 'PROTOCOL_SSLv2'): try: try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except OSError as x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) # Server with specific SSL options if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, server_options=ssl.OP_NO_SSLv3) # Will choose TLSv1 try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False, server_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv3'), "OpenSSL is compiled without SSLv3 support") def test_protocol_sslv3(self): """Connecting to an SSLv3 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) @skip_if_broken_ubuntu_ssl def test_protocol_tlsv1(self): """Connecting to a TLSv1 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_1"), "TLS version 1.1 not supported.") def test_protocol_tlsv1_1(self): """Connecting to a TLSv1.1 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, True) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_1) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, True) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_2"), "TLS version 1.2 not supported.") def test_protocol_tlsv1_2(self): """Connecting to a TLSv1.2 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_2, True, server_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2, client_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2,) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_2) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_2, True) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_2, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_2, False) def test_starttls(self): """Switching from clear text to encrypted and back again.""" msgs = (b"msg 1", b"MSG 2", b"STARTTLS", b"MSG 3", b"msg 4", b"ENDTLS", b"msg 5", b"msg 6") server = ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, starttls_server=True, chatty=True, connectionchatty=True) wrapped = False with server: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) if support.verbose: sys.stdout.write("\n") for indata in msgs: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) if wrapped: conn.write(indata) outdata = conn.read() else: s.send(indata) outdata = s.recv(1024) msg = outdata.strip().lower() if indata == b"STARTTLS" and msg.startswith(b"ok"): # STARTTLS ok, switch to secure mode if support.verbose: sys.stdout.write( " client: read %r from server, starting TLS...\n" % msg) conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) wrapped = True elif indata == b"ENDTLS" and msg.startswith(b"ok"): # ENDTLS ok, switch back to clear text if support.verbose: sys.stdout.write( " client: read %r from server, ending TLS...\n" % msg) s = conn.unwrap() wrapped = False else: if support.verbose: sys.stdout.write( " client: read %r from server\n" % msg) if support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write(b"over\n") else: s.send(b"over\n") if wrapped: conn.close() else: s.close() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" server = make_https_server(self, certfile=CERTFILE) # try to connect if support.verbose: sys.stdout.write('\n') with open(CERTFILE, 'rb') as f: d1 = f.read() d2 = '' # now fetch the same data from the HTTPS server url = 'https://localhost:%d/%s' % ( server.port, os.path.split(CERTFILE)[1]) context = ssl.create_default_context(cafile=CERTFILE) f = urllib.request.urlopen(url, context=context) try: dlen = f.info().get("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) if support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) finally: f.close() self.assertEqual(d1, d2) def test_asyncore_server(self): """Check the example asyncore integration.""" indata = "TEST MESSAGE of mixed case\n" if support.verbose: sys.stdout.write("\n") indata = b"FOO\n" server = AsyncoreEchoServer(CERTFILE) with server: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(indata) outdata = s.read() if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): self.fail( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() if support.verbose: sys.stdout.write(" client: connection closed.\n") def test_recv_send(self): """Test recv(), send() and friends.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray(b"\0"*100) count = s.recv_into(b) return b[:count] def _recvfrom_into(): b = bytearray(b"\0"*100) count, addr = s.recvfrom_into(b) return b[:count] # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]), ('sendall', s.sendall, True, []), ] recv_methods = [ ('recv', s.recv, True, []), ('recvfrom', s.recvfrom, False, ["some.address"]), ('recv_into', _recv_into, True, []), ('recvfrom_into', _recvfrom_into, False, []), ] data_prefix = "PREFIX_" for meth_name, send_meth, expect_success, args in send_methods: indata = (data_prefix + meth_name).encode('ascii') try: send_meth(indata, *args) outdata = s.read() if outdata != indata.lower(): self.fail( "While sending with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to send with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) for meth_name, recv_meth, expect_success, args in recv_methods: indata = (data_prefix + meth_name).encode('ascii') try: s.send(indata) outdata = recv_meth(*args) if outdata != indata.lower(): self.fail( "While receiving with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to receive with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) # consume data s.read() # Make sure sendmsg et al are disallowed to avoid # inadvertent disclosure of data and/or corruption # of the encrypted data stream self.assertRaises(NotImplementedError, s.sendmsg, [b"data"]) self.assertRaises(NotImplementedError, s.recvmsg, 100) self.assertRaises(NotImplementedError, s.recvmsg_into, bytearray(100)) s.write(b"over\n") s.close() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) started = threading.Event() finish = False def serve(): server.listen(5) started.set() conns = [] while not finish: r, w, e = select.select([server], [], [], 0.1) if server in r: # Let the socket hang around rather than having # it closed by garbage collection. conns.append(server.accept()[0]) for sock in conns: sock.close() t = threading.Thread(target=serve) t.start() started.wait() try: try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c.connect((host, port)) # Will attempt handshake and time out self.assertRaisesRegex(socket.timeout, "timed out", ssl.wrap_socket, c) finally: c.close() try: c = socket.socket(socket.AF_INET) c = ssl.wrap_socket(c) c.settimeout(0.2) # Will attempt handshake and time out self.assertRaisesRegex(socket.timeout, "timed out", c.connect, (host, port)) finally: c.close() finally: finish = True t.join() server.close() def test_server_accept(self): # Issue #16357: accept() on a SSLSocket created through # SSLContext.wrap_socket(). context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) server = context.wrap_socket(server, server_side=True) evt = threading.Event() remote = None peer = None def serve(): nonlocal remote, peer server.listen(5) # Block on the accept and wait on the connection to close. evt.set() remote, peer = server.accept() remote.recv(1) t = threading.Thread(target=serve) t.start() # Client wait until server setup and perform a connect. evt.wait() client = context.wrap_socket(socket.socket()) client.connect((host, port)) client_addr = client.getsockname() client.close() t.join() remote.close() server.close() # Sanity checks. self.assertIsInstance(remote, ssl.SSLSocket) self.assertEqual(peer, client_addr) def test_getpeercert_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with context.wrap_socket(socket.socket()) as sock: with self.assertRaises(OSError) as cm: sock.getpeercert() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_do_handshake_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with context.wrap_socket(socket.socket()) as sock: with self.assertRaises(OSError) as cm: sock.do_handshake() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_default_ciphers(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) try: # Force a set of weak ciphers on our client context context.set_ciphers("DES") except ssl.SSLError: self.skipTest("no DES cipher available") with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: with context.wrap_socket(socket.socket()) as s: with self.assertRaises(OSError): s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0])) @unittest.skipUnless(ssl.HAS_ECDH, "test requires ECDH-enabled OpenSSL") def test_default_ecdh_curve(self): # Issue #21015: elliptic curve-based Diffie Hellman key exchange # should be enabled by default on SSL contexts. context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.load_cert_chain(CERTFILE) # Prior to OpenSSL 1.0.0, ECDH ciphers have to be enabled # explicitly using the 'ECCdraft' cipher alias. Otherwise, # our default cipher list should prefer ECDH-based ciphers # automatically. if ssl.OPENSSL_VERSION_INFO < (1, 0, 0): context.set_ciphers("ECCdraft:ECDH") with ThreadedEchoServer(context=context) as server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) self.assertIn("ECDH", s.cipher()[0]) @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): """Test tls-unique channel binding.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # get the data cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got channel binding data: {0!r}\n" .format(cb_data)) # check if it is sane self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 # and compare with the peers version s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(cb_data).encode("us-ascii")) s.close() # now, again s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) new_cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got another channel binding data: {0!r}\n" .format(new_cb_data)) # is it really unique self.assertNotEqual(cb_data, new_cb_data) self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(new_cb_data).encode("us-ascii")) s.close() def test_compression(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) if support.verbose: sys.stdout.write(" got compression: {!r}\n".format(stats['compression'])) self.assertIn(stats['compression'], { None, 'ZLIB', 'RLE' }) @unittest.skipUnless(hasattr(ssl, 'OP_NO_COMPRESSION'), "ssl.OP_NO_COMPRESSION needed for this test") def test_compression_disabled(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.options |= ssl.OP_NO_COMPRESSION stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['compression'], None) def test_dh_params(self): # Check we can get a connection with ephemeral Diffie-Hellman context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.load_dh_params(DHFILE) context.set_ciphers("kEDH") stats = server_params_test(context, context, chatty=True, connectionchatty=True) cipher = stats["cipher"][0] parts = cipher.split("-") if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts: self.fail("Non-DH cipher: " + cipher[0]) def test_selected_npn_protocol(self): # selected_npn_protocol() is None unless NPN is used context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['client_npn_protocol'], None) @unittest.skipUnless(ssl.HAS_NPN, "NPN support needed for this test") def test_npn_protocols(self): server_protocols = ['http/1.1', 'spdy/2'] protocol_tests = [ (['http/1.1', 'spdy/2'], 'http/1.1'), (['spdy/2', 'http/1.1'], 'http/1.1'), (['spdy/2', 'test'], 'spdy/2'), (['abc', 'def'], 'abc') ] for client_protocols, expected in protocol_tests: server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_npn_protocols(server_protocols) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_npn_protocols(client_protocols) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) msg = "failed trying %s (s) and %s (c).\n" \ "was expecting %s, but got %%s from the %%s" \ % (str(server_protocols), str(client_protocols), str(expected)) client_result = stats['client_npn_protocol'] self.assertEqual(client_result, expected, msg % (client_result, "client")) server_result = stats['server_npn_protocols'][-1] \ if len(stats['server_npn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) def sni_contexts(self): server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) other_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) other_context.load_cert_chain(SIGNED_CERTFILE2) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.verify_mode = ssl.CERT_REQUIRED client_context.load_verify_locations(SIGNING_CA) return server_context, other_context, client_context def check_common_name(self, stats, name): cert = stats['peercert'] self.assertIn((('commonName', name),), cert['subject']) @needs_sni def test_sni_callback(self): calls = [] server_context, other_context, client_context = self.sni_contexts() def servername_cb(ssl_sock, server_name, initial_context): calls.append((server_name, initial_context)) if server_name is not None: ssl_sock.context = other_context server_context.set_servername_callback(servername_cb) stats = server_params_test(client_context, server_context, chatty=True, sni_name='supermessage') # The hostname was fetched properly, and the certificate was # changed for the connection. self.assertEqual(calls, [("supermessage", server_context)]) # CERTFILE4 was selected self.check_common_name(stats, 'fakehostname') calls = [] # The callback is called with server_name=None stats = server_params_test(client_context, server_context, chatty=True, sni_name=None) self.assertEqual(calls, [(None, server_context)]) self.check_common_name(stats, 'localhost') # Check disabling the callback calls = [] server_context.set_servername_callback(None) stats = server_params_test(client_context, server_context, chatty=True, sni_name='notfunny') # Certificate didn't change self.check_common_name(stats, 'localhost') self.assertEqual(calls, []) @needs_sni def test_sni_callback_alert(self): # Returning a TLS alert is reflected to the connecting client server_context, other_context, client_context = self.sni_contexts() def cb_returning_alert(ssl_sock, server_name, initial_context): return ssl.ALERT_DESCRIPTION_ACCESS_DENIED server_context.set_servername_callback(cb_returning_alert) with self.assertRaises(ssl.SSLError) as cm: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED') @needs_sni def test_sni_callback_raising(self): # Raising fails the connection with a TLS handshake failure alert. server_context, other_context, client_context = self.sni_contexts() def cb_raising(ssl_sock, server_name, initial_context): 1/0 server_context.set_servername_callback(cb_raising) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'SSLV3_ALERT_HANDSHAKE_FAILURE') self.assertIn("ZeroDivisionError", stderr.getvalue()) @needs_sni def test_sni_callback_wrong_return_type(self): # Returning the wrong return type terminates the TLS connection # with an internal error alert. server_context, other_context, client_context = self.sni_contexts() def cb_wrong_return_type(ssl_sock, server_name, initial_context): return "foo" server_context.set_servername_callback(cb_wrong_return_type) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_INTERNAL_ERROR') self.assertIn("TypeError", stderr.getvalue()) def test_read_write_after_close_raises_valuerror(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket()) s.connect((HOST, server.port)) s.close() self.assertRaises(ValueError, s.read, 1024) self.assertRaises(ValueError, s.write, b'hello') def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/3.4/test_subprocess.py0000644000076500000000000032444112666555342021654 0ustar jmaddenwheel00000000000000import unittest from test import script_helper from test import support import subprocess import sys import signal import io import locale import os import errno import tempfile import time import re import selectors import sysconfig import warnings import select import shutil import gc import textwrap try: import threading except ImportError: threading = None mswindows = (sys.platform == "win32") # # Depends on the following external programs: Python # if mswindows: SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), ' 'os.O_BINARY);') else: SETBINARY = '' try: mkstemp = tempfile.mkstemp except AttributeError: # tempfile.mkstemp is not available def mkstemp(): """Replacement for mkstemp, calling mktemp.""" fname = tempfile.mktemp() return os.open(fname, os.O_RDWR|os.O_CREAT), fname class BaseTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). support.reap_children() def tearDown(self): for inst in subprocess._active: inst.wait() subprocess._cleanup() self.assertFalse(subprocess._active, "subprocess._active not empty") def assertStderrEqual(self, stderr, expected, msg=None): # In a debug build, stuff like "[6580 refs]" is printed to stderr at # shutdown time. That frustrates tests trying to check stderr produced # from a spawned Python process. actual = support.strip_python_stderr(stderr) # strip_python_stderr also strips whitespace, so we do too. expected = expected.strip() self.assertEqual(actual, expected, msg) class PopenTestException(Exception): pass class PopenExecuteChildRaises(subprocess.Popen): """Popen subclass for testing cleanup of subprocess.PIPE filehandles when _execute_child fails. """ def _execute_child(self, *args, **kwargs): raise PopenTestException("Forced Exception for Test") class ProcessTestCase(BaseTestCase): def test_io_buffered_by_default(self): p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: self.assertIsInstance(p.stdin, io.BufferedIOBase) self.assertIsInstance(p.stdout, io.BufferedIOBase) self.assertIsInstance(p.stderr, io.BufferedIOBase) finally: p.stdin.close() p.stdout.close() p.stderr.close() p.wait() def test_io_unbuffered_works(self): p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) try: self.assertIsInstance(p.stdin, io.RawIOBase) self.assertIsInstance(p.stdout, io.RawIOBase) self.assertIsInstance(p.stderr, io.RawIOBase) finally: p.stdin.close() p.stdout.close() p.stderr.close() p.wait() def test_call_seq(self): # call() function with sequence argument rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) def test_call_timeout(self): # call() function with timeout argument; we want to test that the child # process gets killed when the timeout expires. If the child isn't # killed, this call will deadlock since subprocess.call waits for the # child. self.assertRaises(subprocess.TimeoutExpired, subprocess.call, [sys.executable, "-c", "while True: pass"], timeout=0.1) def test_check_call_zero(self): # check_call() function with zero return code rc = subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(0)"]) self.assertEqual(rc, 0) def test_check_call_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(c.exception.returncode, 47) def test_check_output(self): # check_output() function with zero return code output = subprocess.check_output( [sys.executable, "-c", "print('BDFL')"]) self.assertIn(b'BDFL', output) def test_check_output_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_output( [sys.executable, "-c", "import sys; sys.exit(5)"]) self.assertEqual(c.exception.returncode, 5) def test_check_output_stderr(self): # check_output() function stderr redirected to stdout output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"], stderr=subprocess.STDOUT) self.assertIn(b'BDFL', output) def test_check_output_stdin_arg(self): # check_output() can be called with stdin set to a file tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stdout.write(sys.stdin.read().upper())"], stdin=tf) self.assertIn(b'PEAR', output) def test_check_output_input_arg(self): # check_output() can be called with input set to a string output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stdout.write(sys.stdin.read().upper())"], input=b'pear') self.assertIn(b'PEAR', output) def test_check_output_stdout_arg(self): # check_output() refuses to accept 'stdout' argument with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print('will not be run')"], stdout=sys.stdout) self.fail("Expected ValueError when stdout arg supplied.") self.assertIn('stdout', c.exception.args[0]) def test_check_output_stdin_with_input_arg(self): # check_output() refuses to accept 'stdin' with 'input' tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print('will not be run')"], stdin=tf, input=b'hare') self.fail("Expected ValueError when stdin and input args supplied.") self.assertIn('stdin', c.exception.args[0]) self.assertIn('input', c.exception.args[0]) def test_check_output_timeout(self): # check_output() function with timeout arg with self.assertRaises(subprocess.TimeoutExpired) as c: output = subprocess.check_output( [sys.executable, "-c", "import sys, time\n" "sys.stdout.write('BDFL')\n" "sys.stdout.flush()\n" "time.sleep(3600)"], # Some heavily loaded buildbots (sparc Debian 3.x) require # this much time to start and print. timeout=3) self.fail("Expected TimeoutExpired.") self.assertEqual(c.exception.output, b'BDFL') def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() newenv["FRUIT"] = "banana" rc = subprocess.call([sys.executable, "-c", 'import sys, os;' 'sys.exit(os.getenv("FRUIT")=="banana")'], env=newenv) self.assertEqual(rc, 1) def test_invalid_args(self): # Popen() called with invalid arguments should raise TypeError # but Popen.__del__ should not complain (issue #12085) with support.captured_stderr() as s: self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1) argcount = subprocess.Popen.__init__.__code__.co_argcount too_many_args = [0] * (argcount + 1) self.assertRaises(TypeError, subprocess.Popen, *too_many_args) self.assertEqual(s.getvalue(), '') def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print("banana")'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) p.wait() self.assertEqual(p.stdin, None) def test_stdout_none(self): # .stdout is None when not redirected, and the child's stdout will # be inherited from the parent. In order to test this we run a # subprocess in a subprocess: # this_test # \-- subprocess created by this test (parent) # \-- subprocess created by the parent subprocess (child) # The parent doesn't specify stdout, so the child will use the # parent's stdout. This test checks that the message printed by the # child goes to the parent stdout. The parent also checks that the # child's stdout is None. See #11963. code = ('import sys; from subprocess import Popen, PIPE;' 'p = Popen([sys.executable, "-c", "print(\'test_stdout_none\')"],' ' stdin=PIPE, stderr=PIPE);' 'p.wait(); assert p.stdout is None;') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), b'test_stdout_none') def test_stderr_none(self): # .stderr is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print("banana")'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stdin.close) p.wait() self.assertEqual(p.stderr, None) def _assert_python(self, pre_args, **kwargs): # We include sys.exit() to prevent the test runner from hanging # whenever python is found. args = pre_args + ["import sys; sys.exit(47)"] p = subprocess.Popen(args, **kwargs) p.wait() self.assertEqual(47, p.returncode) def test_executable(self): # Check that the executable argument works. # # On Unix (non-Mac and non-Windows), Python looks at args[0] to # determine where its standard library is, so we need the directory # of args[0] to be valid for the Popen() call to Python to succeed. # See also issue #16170 and issue #7774. doesnotexist = os.path.join(os.path.dirname(sys.executable), "doesnotexist") self._assert_python([doesnotexist, "-c"], executable=sys.executable) def test_executable_takes_precedence(self): # Check that the executable argument takes precedence over args[0]. # # Verify first that the call succeeds without the executable arg. pre_args = [sys.executable, "-c"] self._assert_python(pre_args) self.assertRaises(FileNotFoundError, self._assert_python, pre_args, executable="doesnotexist") @unittest.skipIf(mswindows, "executable argument replaces shell") def test_executable_replaces_shell(self): # Check that the executable argument replaces the default shell # when shell=True. self._assert_python([], executable=sys.executable, shell=True) # For use in the test_cwd* tests below. def _normalize_cwd(self, cwd): # Normalize an expected cwd (for Tru64 support). # We can't use os.path.realpath since it doesn't expand Tru64 {memb} # strings. See bug #1063571. original_cwd = os.getcwd() os.chdir(cwd) cwd = os.getcwd() os.chdir(original_cwd) return cwd # For use in the test_cwd* tests below. def _split_python_path(self): # Return normalized (python_dir, python_base). python_path = os.path.realpath(sys.executable) return os.path.split(python_path) # For use in the test_cwd* tests below. def _assert_cwd(self, expected_cwd, python_arg, **kwargs): # Invoke Python via Popen, and assert that (1) the call succeeds, # and that (2) the current working directory of the child process # matches *expected_cwd*. p = subprocess.Popen([python_arg, "-c", "import os, sys; " "sys.stdout.write(os.getcwd()); " "sys.exit(47)"], stdout=subprocess.PIPE, **kwargs) self.addCleanup(p.stdout.close) p.wait() self.assertEqual(47, p.returncode) normcase = os.path.normcase self.assertEqual(normcase(expected_cwd), normcase(p.stdout.read().decode("utf-8"))) def test_cwd(self): # Check that cwd changes the cwd for the child process. temp_dir = tempfile.gettempdir() temp_dir = self._normalize_cwd(temp_dir) self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir) @unittest.skipIf(mswindows, "pending resolution of issue #15533") def test_cwd_with_relative_arg(self): # Check that Popen looks for args[0] relative to cwd if args[0] # is relative. python_dir, python_base = self._split_python_path() rel_python = os.path.join(os.curdir, python_base) with support.temp_cwd('test_cwd_with_relative_arg', quiet=True) as wrong_dir: # gevent: use distinct name, avoid Travis CI failure # Before calling with the correct cwd, confirm that the call fails # without cwd and with the wrong cwd. self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python]) self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python], cwd=wrong_dir) python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, rel_python, cwd=python_dir) @unittest.skipIf(mswindows, "pending resolution of issue #15533") def test_cwd_with_relative_executable(self): # Check that Popen looks for executable relative to cwd if executable # is relative (and that executable takes precedence over args[0]). python_dir, python_base = self._split_python_path() rel_python = os.path.join(os.curdir, python_base) doesntexist = "somethingyoudonthave" with support.temp_cwd('test_cwd_with_relative_executable', quiet=True) as wrong_dir: # gevent: use distinct name, avoid Travis CI failure # Before calling with the correct cwd, confirm that the call fails # without cwd and with the wrong cwd. self.assertRaises(FileNotFoundError, subprocess.Popen, [doesntexist], executable=rel_python) self.assertRaises(FileNotFoundError, subprocess.Popen, [doesntexist], executable=rel_python, cwd=wrong_dir) python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, doesntexist, executable=rel_python, cwd=python_dir) def test_cwd_with_absolute_arg(self): # Check that Popen can find the executable when the cwd is wrong # if args[0] is an absolute path. python_dir, python_base = self._split_python_path() abs_python = os.path.join(python_dir, python_base) rel_python = os.path.join(os.curdir, python_base) with script_helper.temp_dir() as wrong_dir: # Before calling with an absolute path, confirm that using a # relative path fails. self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python], cwd=wrong_dir) wrong_dir = self._normalize_cwd(wrong_dir) self._assert_cwd(wrong_dir, abs_python, cwd=wrong_dir) @unittest.skipIf(sys.base_prefix != sys.prefix, 'Test is not venv-compatible') def test_executable_with_cwd(self): python_dir, python_base = self._split_python_path() python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, "somethingyoudonthave", executable=sys.executable, cwd=python_dir) @unittest.skipIf(sys.base_prefix != sys.prefix, 'Test is not venv-compatible') @unittest.skipIf(sysconfig.is_python_build(), "need an installed Python. See #7774") def test_executable_without_cwd(self): # For a normal installation, it should work without 'cwd' # argument. For test runs in the build directory, see #7774. self._assert_cwd(os.getcwd(), "somethingyoudonthave", executable=sys.executable) def test_stdin_pipe(self): # stdin redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.stdin.write(b"pear") p.stdin.close() p.wait() self.assertEqual(p.returncode, 1) def test_stdin_filedes(self): # stdin is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() os.write(d, b"pear") os.lseek(d, 0, 0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=d) p.wait() self.assertEqual(p.returncode, 1) def test_stdin_fileobj(self): # stdin is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b"pear") tf.seek(0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=tf) p.wait() self.assertEqual(p.returncode, 1) def test_stdout_pipe(self): # stdout redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), b"orange") def test_stdout_filedes(self): # stdout is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), b"orange") def test_stdout_fileobj(self): # stdout is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), b"orange") def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.addCleanup(p.stderr.close) self.assertStderrEqual(p.stderr.read(), b"strawberry") def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertStderrEqual(os.read(d, 1024), b"strawberry") def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), b"strawberry") def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.addCleanup(p.stdout.close) self.assertStderrEqual(p.stdout.read(), b"appleorange") def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), b"appleorange") def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). # To avoid printing the text on stdout, we do something similar to # test_stdout_none (see above). The parent subprocess calls the child # subprocess passing stdout=1, and this test uses stdout=PIPE in # order to capture and check the output of the parent. See #11963. code = ('import sys, subprocess; ' 'rc = subprocess.call([sys.executable, "-c", ' ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), ' 'b\'test with stdout=1\'))"], stdout=1); ' 'assert rc == 18') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), b'test with stdout=1') def test_stdout_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'for i in range(10240):' 'print("x" * 1024)'], stdout=subprocess.DEVNULL) p.wait() self.assertEqual(p.stdout, None) def test_stderr_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'import sys\n' 'for i in range(10240):' 'sys.stderr.write("x" * 1024)'], stderr=subprocess.DEVNULL) p.wait() self.assertEqual(p.stderr, None) def test_stdin_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdin.read(1)'], stdin=subprocess.DEVNULL) p.wait() self.assertEqual(p.stdin, None) def test_env(self): newenv = os.environ.copy() newenv["FRUIT"] = "orange" with subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, env=newenv) as p: stdout, stderr = p.communicate() self.assertEqual(stdout, b"orange") # Windows requires at least the SYSTEMROOT environment variable to start # Python @unittest.skipIf(sys.platform == 'win32', 'cannot test an empty env on Windows') @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') is not None, 'the python library cannot be loaded ' 'with an empty environment') def test_empty_env(self): with subprocess.Popen([sys.executable, "-c", 'import os; ' 'print(list(os.environ.keys()))'], stdout=subprocess.PIPE, env={}) as p: stdout, stderr = p.communicate() self.assertIn(stdout.strip(), (b"[]", # Mac OS X adds __CF_USER_TEXT_ENCODING variable to an empty # environment b"['__CF_USER_TEXT_ENCODING']")) def test_communicate_stdin(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.communicate(b"pear") self.assertEqual(p.returncode, 1) def test_communicate_stdout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("pineapple")'], stdout=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, b"pineapple") self.assertEqual(stderr, None) def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertStderrEqual(stderr, b"pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) (stdout, stderr) = p.communicate(b"banana") self.assertEqual(stdout, b"banana") self.assertStderrEqual(stderr, b"pineapple") def test_communicate_timeout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os,time;' 'sys.stderr.write("pineapple\\n");' 'time.sleep(1);' 'sys.stderr.write("pear\\n");' 'sys.stdout.write(sys.stdin.read())'], universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.assertRaises(subprocess.TimeoutExpired, p.communicate, "banana", timeout=0.3) # Make sure we can keep waiting for it, and that we get the whole output # after it completes. (stdout, stderr) = p.communicate() self.assertEqual(stdout, "banana") self.assertStderrEqual(stderr.encode(), b"pineapple\npear\n") def test_communicate_timeout_large_ouput(self): # Test an expiring timeout while the child is outputting lots of data. p = subprocess.Popen([sys.executable, "-c", 'import sys,os,time;' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));'], stdout=subprocess.PIPE) self.assertRaises(subprocess.TimeoutExpired, p.communicate, timeout=0.4) (stdout, _) = p.communicate() self.assertEqual(len(stdout), 4 * 64 * 1024) # Test for the fd leak reported in http://bugs.python.org/issue2791. def test_communicate_pipe_fd_leak(self): for stdin_pipe in (False, True): for stdout_pipe in (False, True): for stderr_pipe in (False, True): options = {} if stdin_pipe: options['stdin'] = subprocess.PIPE if stdout_pipe: options['stdout'] = subprocess.PIPE if stderr_pipe: options['stderr'] = subprocess.PIPE if not options: continue p = subprocess.Popen((sys.executable, "-c", "pass"), **options) p.communicate() if p.stdin is not None: self.assertTrue(p.stdin.closed) if p.stdout is not None: self.assertTrue(p.stdout.closed) if p.stderr is not None: self.assertTrue(p.stderr.closed) def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"]) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, None) def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. x, y = os.pipe() os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' 'sys.stderr.write("x" * %d);' 'sys.stdout.write(sys.stdin.read())' % support.PIPE_MAX_SIZE], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) string_to_write = b"a" * support.PIPE_MAX_SIZE (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.stdin.write(b"banana") (stdout, stderr) = p.communicate(b"split") self.assertEqual(stdout, b"bananasplit") self.assertStderrEqual(stderr, b"") def test_universal_newlines(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'buf = sys.stdout.buffer;' 'buf.write(sys.stdin.readline().encode());' 'buf.flush();' 'buf.write(b"line2\\n");' 'buf.flush();' 'buf.write(sys.stdin.read().encode());' 'buf.flush();' 'buf.write(b"line4\\n");' 'buf.flush();' 'buf.write(b"line5\\r\\n");' 'buf.flush();' 'buf.write(b"line6\\r");' 'buf.flush();' 'buf.write(b"\\nline7");' 'buf.flush();' 'buf.write(b"\\nline8");'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=1) p.stdin.write("line1\n") p.stdin.flush() self.assertEqual(p.stdout.readline(), "line1\n") p.stdin.write("line3\n") p.stdin.close() self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.readline(), "line2\n") self.assertEqual(p.stdout.read(6), "line3\n") self.assertEqual(p.stdout.read(), "line4\nline5\nline6\nline7\nline8") def test_universal_newlines_communicate(self): # universal newlines through communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'buf = sys.stdout.buffer;' 'buf.write(b"line2\\n");' 'buf.flush();' 'buf.write(b"line4\\n");' 'buf.flush();' 'buf.write(b"line5\\r\\n");' 'buf.flush();' 'buf.write(b"line6\\r");' 'buf.flush();' 'buf.write(b"\\nline7");' 'buf.flush();' 'buf.write(b"\\nline8");'], stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate() self.assertEqual(stdout, "line2\nline4\nline5\nline6\nline7\nline8") def test_universal_newlines_communicate_stdin(self): # universal newlines through communicate(), with only stdin p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + textwrap.dedent(''' s = sys.stdin.readline() assert s == "line1\\n", repr(s) s = sys.stdin.read() assert s == "line3\\n", repr(s) ''')], stdin=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate("line1\nline3\n") self.assertEqual(p.returncode, 0) def test_universal_newlines_communicate_input_none(self): # Test communicate(input=None) with universal newlines. # # We set stdout to PIPE because, as of this writing, a different # code path is tested when the number of pipes is zero or one. p = subprocess.Popen([sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) p.communicate() self.assertEqual(p.returncode, 0) def test_universal_newlines_communicate_stdin_stdout_stderr(self): # universal newlines through communicate(), with stdin, stdout, stderr p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + textwrap.dedent(''' s = sys.stdin.buffer.readline() sys.stdout.buffer.write(s) sys.stdout.buffer.write(b"line2\\r") sys.stderr.buffer.write(b"eline2\\n") s = sys.stdin.buffer.read() sys.stdout.buffer.write(s) sys.stdout.buffer.write(b"line4\\n") sys.stdout.buffer.write(b"line5\\r\\n") sys.stderr.buffer.write(b"eline6\\r") sys.stderr.buffer.write(b"eline7\\r\\nz") ''')], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate("line1\nline3\n") self.assertEqual(p.returncode, 0) self.assertEqual("line1\nline2\nline3\nline4\nline5\n", stdout) # Python debug build push something like "[42442 refs]\n" # to stderr at exit of subprocess. # Don't use assertStderrEqual because it strips CR and LF from output. self.assertTrue(stderr.startswith("eline2\neline6\neline7\n")) def test_universal_newlines_communicate_encodings(self): # Check that universal newlines mode works for various encodings, # in particular for encodings in the UTF-16 and UTF-32 families. # See issue #15595. # # UTF-16 and UTF-32-BE are sufficient to check both with BOM and # without, and UTF-16 and UTF-32. import _bootlocale for encoding in ['utf-16', 'utf-32-be']: old_getpreferredencoding = _bootlocale.getpreferredencoding # Indirectly via io.TextIOWrapper, Popen() defaults to # locale.getpreferredencoding(False) and earlier in Python 3.2 to # locale.getpreferredencoding(). def getpreferredencoding(do_setlocale=True): return encoding code = ("import sys; " r"sys.stdout.buffer.write('1\r\n2\r3\n4'.encode('%s'))" % encoding) args = [sys.executable, '-c', code] try: _bootlocale.getpreferredencoding = getpreferredencoding # We set stdin to be non-None because, as of this writing, # a different code path is used when the number of pipes is # zero or one. popen = subprocess.Popen(args, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = popen.communicate(input='') finally: _bootlocale.getpreferredencoding = old_getpreferredencoding self.assertEqual(stdout, '1\n2\n3\n4') def test_no_leaking(self): # Make sure we leak no resources if not mswindows: max_handles = 1026 # too much for most UNIX systems else: max_handles = 2050 # too much for (at least some) Windows setups handles = [] tmpdir = tempfile.mkdtemp() try: for i in range(max_handles): try: tmpfile = os.path.join(tmpdir, support.TESTFN) handles.append(os.open(tmpfile, os.O_WRONLY|os.O_CREAT)) except OSError as e: if e.errno != errno.EMFILE: raise break else: self.skipTest("failed to reach the file descriptor limit " "(tried %d)" % max_handles) # Close a couple of them (should be enough for a subprocess) for i in range(10): os.close(handles.pop()) # Loop creating some subprocesses. If one of them leaks some fds, # the next loop iteration will fail by reaching the max fd limit. for i in range(15): p = subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate(b"lime")[0] self.assertEqual(data, b"lime") finally: for h in handles: os.close(h) shutil.rmtree(tmpdir) def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), '"a b c" d e') self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']), 'ab\\"c \\ d') self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']), 'ab\\"c " \\\\" d') self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']), 'a\\\\\\b "de fg" h') self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']), 'a\\\\\\"b c d') self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']), '"a\\\\b c" d e') self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']), '"a\\\\b\\ c" d e') self.assertEqual(subprocess.list2cmdline(['ab', '']), 'ab ""') def test_poll(self): p = subprocess.Popen([sys.executable, "-c", "import os; os.read(0, 1)"], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) self.assertIsNone(p.poll()) os.write(p.stdin.fileno(), b'A') p.wait() # Subsequent invocations should just return the returncode self.assertEqual(p.poll(), 0) def test_wait(self): p = subprocess.Popen([sys.executable, "-c", "pass"]) self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) def test_wait_timeout(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(0.3)"]) with self.assertRaises(subprocess.TimeoutExpired) as c: p.wait(timeout=0.0001) self.assertIn("0.0001", str(c.exception)) # For coverage of __str__. # Some heavily loaded buildbots (sparc Debian 3.x) require this much # time to start. self.assertEqual(p.wait(timeout=3), 0) def test_invalid_bufsize(self): # an invalid type of the bufsize argument should raise # TypeError. with self.assertRaises(TypeError): subprocess.Popen([sys.executable, "-c", "pass"], "orange") def test_bufsize_is_none(self): # bufsize=None should be the same as bufsize=0. p = subprocess.Popen([sys.executable, "-c", "pass"], None) self.assertEqual(p.wait(), 0) # Again with keyword arg p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) self.assertEqual(p.wait(), 0) def _test_bufsize_equal_one(self, line, expected, universal_newlines): # subprocess may deadlock with bufsize=1, see issue #21332 with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.readline());" "sys.stdout.flush()"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=1, universal_newlines=universal_newlines) as p: p.stdin.write(line) # expect that it flushes the line in text mode os.close(p.stdin.fileno()) # close it without flushing the buffer read_line = p.stdout.readline() try: p.stdin.close() except OSError: pass p.stdin = None self.assertEqual(p.returncode, 0) self.assertEqual(read_line, expected) def test_bufsize_equal_one_text_mode(self): # line is flushed in text mode with bufsize=1. # we should get the full line in return line = "line\n" self._test_bufsize_equal_one(line, line, universal_newlines=True) def test_bufsize_equal_one_binary_mode(self): # line is not flushed in binary mode with bufsize=1. # we should get empty response line = b'line' + os.linesep.encode() # assume ascii-based locale self._test_bufsize_equal_one(line, b'', universal_newlines=False) def test_leaking_fds_on_error(self): # see bug #5179: Popen leaks file descriptors to PIPEs if # the child fails to execute; this will eventually exhaust # the maximum number of open fds. 1024 seems a very common # value for that limit, but Windows has 2048, so we loop # 1024 times (each call leaked two fds). for i in range(1024): with self.assertRaises(OSError) as c: subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # ignore errors that indicate the command was not found if c.exception.errno not in (errno.ENOENT, errno.EACCES): raise c.exception @unittest.skipIf(threading is None, "threading required") def test_double_close_on_error(self): # Issue #18851 fds = [] def open_fds(): for i in range(20): fds.extend(os.pipe()) time.sleep(0.001) t = threading.Thread(target=open_fds) t.start() try: with self.assertRaises(EnvironmentError): subprocess.Popen(['nonexisting_i_hope'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: t.join() exc = None for fd in fds: # If a double close occurred, some of those fds will # already have been closed by mistake, and os.close() # here will raise. try: os.close(fd) except OSError as e: exc = e if exc is not None: raise exc @unittest.skipIf(threading is None, "threading required") def test_threadsafe_wait(self): """Issue21291: Popen.wait() needs to be threadsafe for returncode.""" proc = subprocess.Popen([sys.executable, '-c', 'import time; time.sleep(12)']) self.assertEqual(proc.returncode, None) results = [] def kill_proc_timer_thread(): results.append(('thread-start-poll-result', proc.poll())) # terminate it from the thread and wait for the result. proc.kill() proc.wait() results.append(('thread-after-kill-and-wait', proc.returncode)) # this wait should be a no-op given the above. proc.wait() results.append(('thread-after-second-wait', proc.returncode)) # This is a timing sensitive test, the failure mode is # triggered when both the main thread and this thread are in # the wait() call at once. The delay here is to allow the # main thread to most likely be blocked in its wait() call. t = threading.Timer(0.2, kill_proc_timer_thread) t.start() if mswindows: expected_errorcode = 1 else: # Should be -9 because of the proc.kill() from the thread. expected_errorcode = -9 # Wait for the process to finish; the thread should kill it # long before it finishes on its own. Supplying a timeout # triggers a different code path for better coverage. proc.wait(timeout=20) self.assertEqual(proc.returncode, expected_errorcode, msg="unexpected result in wait from main thread") # This should be a no-op with no change in returncode. proc.wait() self.assertEqual(proc.returncode, expected_errorcode, msg="unexpected result in second main wait.") t.join() # Ensure that all of the thread results are as expected. # When a race condition occurs in wait(), the returncode could # be set by the wrong thread that doesn't actually have it # leading to an incorrect value. self.assertEqual([('thread-start-poll-result', None), ('thread-after-kill-and-wait', expected_errorcode), ('thread-after-second-wait', expected_errorcode)], results) def test_issue8780(self): # Ensure that stdout is inherited from the parent # if stdout=PIPE is not used code = ';'.join(( 'import subprocess, sys', 'retcode = subprocess.call(' "[sys.executable, '-c', 'print(\"Hello World!\")'])", 'assert retcode == 0')) output = subprocess.check_output([sys.executable, '-c', code]) self.assertTrue(output.startswith(b'Hello World!'), ascii(output)) def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released ifhandle, ifname = mkstemp() ofhandle, ofname = mkstemp() efhandle, efname = mkstemp() try: subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle, stderr=efhandle) except OSError: os.close(ifhandle) os.remove(ifname) os.close(ofhandle) os.remove(ofname) os.close(efhandle) os.remove(efname) self.assertFalse(os.path.exists(ifname)) self.assertFalse(os.path.exists(ofname)) self.assertFalse(os.path.exists(efname)) def test_communicate_epipe(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.communicate(b"x" * 2**20) def test_communicate_epipe_only_stdin(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) p.wait() p.communicate(b"x" * 2**20) @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), "Requires signal.SIGUSR1") @unittest.skipUnless(hasattr(os, 'kill'), "Requires os.kill") @unittest.skipUnless(hasattr(os, 'getppid'), "Requires os.getppid") def test_communicate_eintr(self): # Issue #12493: communicate() should handle EINTR def handler(signum, frame): pass old_handler = signal.signal(signal.SIGUSR1, handler) self.addCleanup(signal.signal, signal.SIGUSR1, old_handler) args = [sys.executable, "-c", 'import os, signal;' 'os.kill(os.getppid(), signal.SIGUSR1)'] for stream in ('stdout', 'stderr'): kw = {stream: subprocess.PIPE} with subprocess.Popen(args, **kw) as process: # communicate() will be interrupted by SIGUSR1 process.communicate() # This test is Linux-ish specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") def test_failed_child_execute_fd_leak(self): """Test for the fork() failure fd leak reported in issue16327.""" fd_directory = '/proc/%d/fd' % os.getpid() fds_before_popen = os.listdir(fd_directory) with self.assertRaises(PopenTestException): PopenExecuteChildRaises( [sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # NOTE: This test doesn't verify that the real _execute_child # does not close the file descriptors itself on the way out # during an exception. Code inspection has confirmed that. fds_after_exception = os.listdir(fd_directory) self.assertEqual(fds_before_popen, fds_after_exception) @unittest.skipIf(mswindows, "POSIX specific tests") class POSIXProcessTestCase(BaseTestCase): def setUp(self): super().setUp() self._nonexistent_dir = "/_this/pa.th/does/not/exist" def _get_chdir_exception(self): try: os.chdir(self._nonexistent_dir) except OSError as e: # This avoids hard coding the errno value or the OS perror() # string and instead capture the exception that we want to see # below for comparison. desired_exception = e desired_exception.strerror += ': ' + repr(self._nonexistent_dir) else: self.fail("chdir to nonexistant directory %s succeeded." % self._nonexistent_dir) return desired_exception def test_exception_cwd(self): """Test error in the child raised in the parent for a bad cwd.""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([sys.executable, "-c", ""], cwd=self._nonexistent_dir) except OSError as e: # Test that the child process chdir failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_exception_bad_executable(self): """Test error in the child raised in the parent for a bad executable.""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([sys.executable, "-c", ""], executable=self._nonexistent_dir) except OSError as e: # Test that the child process exec failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_exception_bad_args_0(self): """Test error in the child raised in the parent for a bad args[0].""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([self._nonexistent_dir, "-c", ""]) except OSError as e: # Test that the child process exec failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_restore_signals(self): # Code coverage for both values of restore_signals to make sure it # at least does not blow up. # A test for behavior would be complex. Contributions welcome. subprocess.call([sys.executable, "-c", ""], restore_signals=True) subprocess.call([sys.executable, "-c", ""], restore_signals=False) def test_start_new_session(self): # For code coverage of calling setsid(). We don't care if we get an # EPERM error from it depending on the test execution environment, that # still indicates that it was called. try: output = subprocess.check_output( [sys.executable, "-c", "import os; print(os.getpgid(os.getpid()))"], start_new_session=True) except OSError as e: if e.errno != errno.EPERM: raise else: parent_pgid = os.getpgid(os.getpid()) child_pgid = int(output) self.assertNotEqual(parent_pgid, child_pgid) def test_run_abort(self): # returncode handles signal termination with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import os; os.abort()']) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT) def test_preexec(self): # DISCLAIMER: Setting environment variables is *not* a good use # of a preexec_fn. This is merely a test. p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), b"apple") def test_preexec_exception(self): def raise_it(): raise ValueError("What if two swallows carried a coconut?") try: p = subprocess.Popen([sys.executable, "-c", ""], preexec_fn=raise_it) except subprocess.SubprocessError as e: self.assertTrue( subprocess._posixsubprocess, "Expected a ValueError from the preexec_fn") except ValueError as e: self.assertIn("coconut", e.args[0]) else: self.fail("Exception raised by preexec_fn did not make it " "to the parent process.") class _TestExecuteChildPopen(subprocess.Popen): """Used to test behavior at the end of _execute_child.""" def __init__(self, testcase, *args, **kwargs): self._testcase = testcase subprocess.Popen.__init__(self, *args, **kwargs) def _execute_child(self, *args, **kwargs): try: subprocess.Popen._execute_child(self, *args, **kwargs) finally: # Open a bunch of file descriptors and verify that # none of them are the same as the ones the Popen # instance is using for stdin/stdout/stderr. devzero_fds = [os.open("/dev/zero", os.O_RDONLY) for _ in range(8)] try: for fd in devzero_fds: self._testcase.assertNotIn( fd, (self.stdin.fileno(), self.stdout.fileno(), self.stderr.fileno()), msg="At least one fd was closed early.") finally: for fd in devzero_fds: os.close(fd) @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") def test_preexec_errpipe_does_not_double_close_pipes(self): """Issue16140: Don't double close pipes on preexec error.""" def raise_it(): raise subprocess.SubprocessError( "force the _execute_child() errpipe_data path.") with self.assertRaises(subprocess.SubprocessError): self._TestExecuteChildPopen( self, [sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=raise_it) def test_preexec_gc_module_failure(self): # This tests the code that disables garbage collection if the child # process will execute any Python. def raise_runtime_error(): raise RuntimeError("this shouldn't escape") enabled = gc.isenabled() orig_gc_disable = gc.disable orig_gc_isenabled = gc.isenabled try: gc.disable() self.assertFalse(gc.isenabled()) subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) self.assertFalse(gc.isenabled(), "Popen enabled gc when it shouldn't.") gc.enable() self.assertTrue(gc.isenabled()) subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) self.assertTrue(gc.isenabled(), "Popen left gc disabled.") gc.disable = raise_runtime_error self.assertRaises(RuntimeError, subprocess.Popen, [sys.executable, '-c', ''], preexec_fn=lambda: None) del gc.isenabled # force an AttributeError self.assertRaises(AttributeError, subprocess.Popen, [sys.executable, '-c', ''], preexec_fn=lambda: None) finally: gc.disable = orig_gc_disable gc.isenabled = orig_gc_isenabled if not enabled: gc.disable() def test_args_string(self): # args is a string fd, fname = mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) self.assertEqual(p.returncode, 47) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], startupinfo=47) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], creationflags=47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen(["echo $FRUIT"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple") def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen("echo $FRUIT", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple") def test_call_string(self): # call() function with string argument on UNIX fd, fname = mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.chmod(fname, 0o700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) def test_specific_shell(self): # Issue #9265: Incorrect name passed as arg[0]. shells = [] for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']: for name in ['bash', 'ksh']: sh = os.path.join(prefix, name) if os.path.isfile(sh): shells.append(sh) if not shells: # Will probably work for any shell but csh. self.skipTest("bash or ksh required for this test") sh = '/bin/sh' if os.path.isfile(sh) and not os.path.islink(sh): # Test will fail if /bin/sh is a symlink to csh. shells.append(sh) for sh in shells: p = subprocess.Popen("echo $0", executable=sh, shell=True, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii')) def _kill_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. # Also set the SIGINT handler to the default to make sure it's not # being ignored (some tests rely on that.) old_handler = signal.signal(signal.SIGINT, signal.default_int_handler) try: p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: signal.signal(signal.SIGINT, old_handler) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) return p @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) p.communicate() def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() self.assertIn(b'KeyboardInterrupt', stderr) self.assertNotEqual(p.wait(), 0) def test_kill(self): p = self._kill_process('kill') _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') self.assertEqual(p.wait(), -signal.SIGKILL) def test_terminate(self): p = self._kill_process('terminate') _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') self.assertEqual(p.wait(), -signal.SIGTERM) def test_send_signal_dead(self): # Sending a signal to a dead process self._kill_dead_process('send_signal', signal.SIGINT) def test_kill_dead(self): # Killing a dead process self._kill_dead_process('kill') def test_terminate_dead(self): # Terminating a dead process self._kill_dead_process('terminate') def _save_fds(self, save_fds): fds = [] for fd in save_fds: inheritable = os.get_inheritable(fd) saved = os.dup(fd) fds.append((fd, saved, inheritable)) return fds def _restore_fds(self, fds): for fd, saved, inheritable in fds: os.dup2(saved, fd, inheritable=inheritable) os.close(saved) def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed stdin = 0 saved_fds = self._save_fds(fds) for fd, saved, inheritable in saved_fds: if fd == 0: stdin = saved break try: for fd in fds: os.close(fd) out, err = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() err = support.strip_python_stderr(err) self.assertEqual((out, err), (b'apple', b'orange')) finally: self._restore_fds(saved_fds) def test_close_fd_0(self): self.check_close_std_fds([0]) def test_close_fd_1(self): self.check_close_std_fds([1]) def test_close_fd_2(self): self.check_close_std_fds([2]) def test_close_fds_0_1(self): self.check_close_std_fds([0, 1]) def test_close_fds_0_2(self): self.check_close_std_fds([0, 2]) def test_close_fds_1_2(self): self.check_close_std_fds([1, 2]) def test_close_fds_0_1_2(self): # Issue #10806: test that subprocess pipes still work properly with # all standard fds closed. self.check_close_std_fds([0, 1, 2]) def test_small_errpipe_write_fd(self): """Issue #15798: Popen should work when stdio fds are available.""" new_stdin = os.dup(0) new_stdout = os.dup(1) try: os.close(0) os.close(1) # Side test: if errpipe_write fails to have its CLOEXEC # flag set this should cause the parent to think the exec # failed. Extremely unlikely: everyone supports CLOEXEC. subprocess.Popen([ sys.executable, "-c", "print('AssertionError:0:CLOEXEC failure.')"]).wait() finally: # Restore original stdin and stdout os.dup2(new_stdin, 0) os.dup2(new_stdout, 1) os.close(new_stdin) os.close(new_stdout) def test_remapping_std_fds(self): # open up some temporary files temps = [mkstemp() for i in range(3)] try: temp_fds = [fd for fd, fname in temps] # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # write some data to what will become stdin, and rewind os.write(temp_fds[1], b"STDIN") os.lseek(temp_fds[1], 0, 0) # move the standard file descriptors out of the way saved_fds = self._save_fds(range(3)) try: # duplicate the file objects over the standard fd's for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # now use those files in the "wrong" order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=temp_fds[1], stdout=temp_fds[2], stderr=temp_fds[0]) p.wait() finally: self._restore_fds(saved_fds) for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(temp_fds[2], 1024) err = support.strip_python_stderr(os.read(temp_fds[0], 1024)) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) def check_swap_fds(self, stdin_no, stdout_no, stderr_no): # open up some temporary files temps = [mkstemp() for i in range(3)] temp_fds = [fd for fd, fname in temps] try: # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # save a copy of the standard file descriptors saved_fds = self._save_fds(range(3)) try: # duplicate the temp files over the standard fd's 0, 1, 2 for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # write some data to what will become stdin, and rewind os.write(stdin_no, b"STDIN") os.lseek(stdin_no, 0, 0) # now use those files in the given order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=stdin_no, stdout=stdout_no, stderr=stderr_no) p.wait() for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(stdout_no, 1024) err = support.strip_python_stderr(os.read(stderr_no, 1024)) finally: self._restore_fds(saved_fds) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) # When duping fds, if there arises a situation where one of the fds is # either 0, 1 or 2, it is possible that it is overwritten (#12607). # This tests all combinations of this. def test_swap_fds(self): self.check_swap_fds(0, 1, 2) self.check_swap_fds(0, 2, 1) self.check_swap_fds(1, 0, 2) self.check_swap_fds(1, 2, 0) self.check_swap_fds(2, 0, 1) self.check_swap_fds(2, 1, 0) def test_surrogates_error_message(self): def prepare(): raise ValueError("surrogate:\uDCff") try: subprocess.call( [sys.executable, "-c", "pass"], preexec_fn=prepare) except ValueError as err: # Pure Python implementations keeps the message self.assertIsNone(subprocess._posixsubprocess) self.assertEqual(str(err), "surrogate:\uDCff") except subprocess.SubprocessError as err: # _posixsubprocess uses a default message self.assertIsNotNone(subprocess._posixsubprocess) self.assertEqual(str(err), "Exception occurred in preexec_fn.") else: self.fail("Expected ValueError or subprocess.SubprocessError") def test_undecodable_env(self): for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')): encoded_value = value.encode("ascii", "surrogateescape") # test str with surrogates script = "import os; print(ascii(os.getenv(%s)))" % repr(key) env = os.environ.copy() env[key] = value # Use C locale to get ASCII for the locale encoding to force # surrogate-escaping of \xFF in the child process; otherwise it can # be decoded as-is if the default locale is latin-1. env['LC_ALL'] = 'C' if sys.platform.startswith("aix"): # On AIX, the C locale uses the Latin1 encoding decoded_value = encoded_value.decode("latin1", "surrogateescape") else: # On other UNIXes, the C locale uses the ASCII encoding decoded_value = value stdout = subprocess.check_output( [sys.executable, "-c", script], env=env) stdout = stdout.rstrip(b'\n\r') self.assertEqual(stdout.decode('ascii'), ascii(decoded_value)) # test bytes key = key.encode("ascii", "surrogateescape") script = "import os; print(ascii(os.getenvb(%s)))" % repr(key) env = os.environ.copy() env[key] = encoded_value stdout = subprocess.check_output( [sys.executable, "-c", script], env=env) stdout = stdout.rstrip(b'\n\r') self.assertEqual(stdout.decode('ascii'), ascii(encoded_value)) def test_bytes_program(self): abs_program = os.fsencode(sys.executable) path, program = os.path.split(sys.executable) program = os.fsencode(program) # absolute bytes path exitcode = subprocess.call([abs_program, "-c", "pass"]) self.assertEqual(exitcode, 0) # absolute bytes path as a string cmd = b"'" + abs_program + b"' -c pass" exitcode = subprocess.call(cmd, shell=True) self.assertEqual(exitcode, 0) # bytes program, unicode PATH env = os.environ.copy() env["PATH"] = path exitcode = subprocess.call([program, "-c", "pass"], env=env) self.assertEqual(exitcode, 0) # bytes program, bytes PATH envb = os.environb.copy() envb[b"PATH"] = os.fsencode(path) exitcode = subprocess.call([program, "-c", "pass"], env=envb) self.assertEqual(exitcode, 0) def test_pipe_cloexec(self): sleeper = support.findfile("input_reader.py", subdir="subprocessdata") fd_status = support.findfile("fd_status.py", subdir="subprocessdata") p1 = subprocess.Popen([sys.executable, sleeper], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) self.addCleanup(p1.communicate, b'') p2 = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=False) output, error = p2.communicate() result_fds = set(map(int, output.split(b','))) unwanted_fds = set([p1.stdin.fileno(), p1.stdout.fileno(), p1.stderr.fileno()]) self.assertFalse(result_fds & unwanted_fds, "Expected no fds from %r to be open in child, " "found %r" % (unwanted_fds, result_fds & unwanted_fds)) def test_pipe_cloexec_real_tools(self): qcat = support.findfile("qcat.py", subdir="subprocessdata") qgrep = support.findfile("qgrep.py", subdir="subprocessdata") subdata = b'zxcvbn' data = subdata * 4 + b'\n' p1 = subprocess.Popen([sys.executable, qcat], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=False) p2 = subprocess.Popen([sys.executable, qgrep, subdata], stdin=p1.stdout, stdout=subprocess.PIPE, close_fds=False) self.addCleanup(p1.wait) self.addCleanup(p2.wait) def kill_p1(): try: p1.terminate() except ProcessLookupError: pass def kill_p2(): try: p2.terminate() except ProcessLookupError: pass self.addCleanup(kill_p1) self.addCleanup(kill_p2) p1.stdin.write(data) p1.stdin.close() readfiles, ignored1, ignored2 = select.select([p2.stdout], [], [], 10) self.assertTrue(readfiles, "The child hung") self.assertEqual(p2.stdout.read(), data) p1.stdout.close() p2.stdout.close() def test_close_fds(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") fds = os.pipe() self.addCleanup(os.close, fds[0]) self.addCleanup(os.close, fds[1]) open_fds = set(fds) # add a bunch more fds for _ in range(9): fd = os.open(os.devnull, os.O_RDONLY) self.addCleanup(os.close, fd) open_fds.add(fd) for fd in open_fds: os.set_inheritable(fd, True) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=False) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertEqual(remaining_fds & open_fds, open_fds, "Some fds were closed") p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertFalse(remaining_fds & open_fds, "Some fds were left open") self.assertIn(1, remaining_fds, "Subprocess failed") # Keep some of the fd's we opened open in the subprocess. # This tests _posixsubprocess.c's proper handling of fds_to_keep. fds_to_keep = set(open_fds.pop() for _ in range(8)) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, pass_fds=()) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertFalse(remaining_fds & fds_to_keep & open_fds, "Some fds not in pass_fds were left open") self.assertIn(1, remaining_fds, "Subprocess failed") @unittest.skipIf(sys.platform.startswith("freebsd") and os.stat("/dev").st_dev == os.stat("/dev/fd").st_dev, "Requires fdescfs mounted on /dev/fd on FreeBSD.") def test_close_fds_when_max_fd_is_lowered(self): """Confirm that issue21618 is fixed (may fail under valgrind).""" fd_status = support.findfile("fd_status.py", subdir="subprocessdata") # This launches the meat of the test in a child process to # avoid messing with the larger unittest processes maximum # number of file descriptors. # This process launches: # +--> Process that lowers its RLIMIT_NOFILE aftr setting up # a bunch of high open fds above the new lower rlimit. # Those are reported via stdout before launching a new # process with close_fds=False to run the actual test: # +--> The TEST: This one launches a fd_status.py # subprocess with close_fds=True so we can find out if # any of the fds above the lowered rlimit are still open. p = subprocess.Popen([sys.executable, '-c', textwrap.dedent( ''' import os, resource, subprocess, sys, textwrap open_fds = set() # Add a bunch more fds to pass down. for _ in range(40): fd = os.open(os.devnull, os.O_RDONLY) open_fds.add(fd) # Leave a two pairs of low ones available for use by the # internal child error pipe and the stdout pipe. # We also leave 10 more open as some Python buildbots run into # "too many open files" errors during the test if we do not. for fd in sorted(open_fds)[:14]: os.close(fd) open_fds.remove(fd) for fd in open_fds: #self.addCleanup(os.close, fd) os.set_inheritable(fd, True) max_fd_open = max(open_fds) # Communicate the open_fds to the parent unittest.TestCase process. print(','.join(map(str, sorted(open_fds)))) sys.stdout.flush() rlim_cur, rlim_max = resource.getrlimit(resource.RLIMIT_NOFILE) try: # 29 is lower than the highest fds we are leaving open. resource.setrlimit(resource.RLIMIT_NOFILE, (29, rlim_max)) # Launch a new Python interpreter with our low fd rlim_cur that # inherits open fds above that limit. It then uses subprocess # with close_fds=True to get a report of open fds in the child. # An explicit list of fds to check is passed to fd_status.py as # letting fd_status rely on its default logic would miss the # fds above rlim_cur as it normally only checks up to that limit. subprocess.Popen( [sys.executable, '-c', textwrap.dedent(""" import subprocess, sys subprocess.Popen([sys.executable, %r] + [str(x) for x in range({max_fd})], close_fds=True).wait() """.format(max_fd=max_fd_open+1))], close_fds=False).wait() finally: resource.setrlimit(resource.RLIMIT_NOFILE, (rlim_cur, rlim_max)) ''' % fd_status)], stdout=subprocess.PIPE) output, unused_stderr = p.communicate() output_lines = output.splitlines() self.assertEqual(len(output_lines), 2, msg="expected exactly two lines of output:\n%r" % output) opened_fds = set(map(int, output_lines[0].strip().split(b','))) remaining_fds = set(map(int, output_lines[1].strip().split(b','))) self.assertFalse(remaining_fds & opened_fds, msg="Some fds were left open.") # Mac OS X Tiger (10.4) has a kernel bug: sometimes, the file # descriptor of a pipe closed in the parent process is valid in the # child process according to fstat(), but the mode of the file # descriptor is invalid, and read or write raise an error. @support.requires_mac_ver(10, 5) def test_pass_fds(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") open_fds = set() for x in range(5): fds = os.pipe() self.addCleanup(os.close, fds[0]) self.addCleanup(os.close, fds[1]) os.set_inheritable(fds[0], True) os.set_inheritable(fds[1], True) open_fds.update(fds) for fd in open_fds: p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, pass_fds=(fd, )) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) to_be_closed = open_fds - {fd} self.assertIn(fd, remaining_fds, "fd to be passed not passed") self.assertFalse(remaining_fds & to_be_closed, "fd to be closed passed") # pass_fds overrides close_fds with a warning. with self.assertWarns(RuntimeWarning) as context: self.assertFalse(subprocess.call( [sys.executable, "-c", "import sys; sys.exit(0)"], close_fds=False, pass_fds=(fd, ))) self.assertIn('overriding close_fds', str(context.warning)) def test_pass_fds_inheritable(self): script = support.findfile("fd_status.py", subdir="subprocessdata") inheritable, non_inheritable = os.pipe() self.addCleanup(os.close, inheritable) self.addCleanup(os.close, non_inheritable) os.set_inheritable(inheritable, True) os.set_inheritable(non_inheritable, False) pass_fds = (inheritable, non_inheritable) args = [sys.executable, script] args += list(map(str, pass_fds)) p = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True, pass_fds=pass_fds) output, ignored = p.communicate() fds = set(map(int, output.split(b','))) # the inheritable file descriptor must be inherited, so its inheritable # flag must be set in the child process after fork() and before exec() self.assertEqual(fds, set(pass_fds), "output=%a" % output) # inheritable flag must not be changed in the parent process self.assertEqual(os.get_inheritable(inheritable), True) self.assertEqual(os.get_inheritable(non_inheritable), False) def test_stdout_stdin_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdout=inout, stdin=inout) p.wait() def test_stdout_stderr_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdout=inout, stderr=inout) p.wait() def test_stderr_stdin_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stderr=inout, stdin=inout) p.wait() def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(0, p.returncode, "sigchild_ignore.py exited" " non-zero with this error:\n%s" % stderr.decode('utf-8')) def test_select_unbuffered(self): # Issue #11459: bufsize=0 should really set the pipes as # unbuffered (and therefore let select() work properly). select = support.import_module("select") p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple")'], stdout=subprocess.PIPE, bufsize=0) f = p.stdout self.addCleanup(f.close) try: self.assertEqual(f.read(4), b"appl") self.assertIn(f, select.select([f], [], [], 0.0)[0]) finally: p.wait() def test_zombie_fast_process_del(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, it wouldn't be added to subprocess._active, and would # remain a zombie. # spawn a Popen, and delete its reference before it exits p = subprocess.Popen([sys.executable, "-c", 'import sys, time;' 'time.sleep(0.2)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) def test_leak_fast_process_del_killed(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, and the process got killed by a signal, it would never # be removed from subprocess._active, which triggered a FD and memory # leak. # spawn a Popen, delete its reference and kill it p = subprocess.Popen([sys.executable, "-c", 'import time;' 'time.sleep(3)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p os.kill(pid, signal.SIGKILL) # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) # let some time for the process to exit, and create a new Popen: this # should trigger the wait() of p time.sleep(0.2) with self.assertRaises(OSError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass # p should have been wait()ed on, and removed from the _active list self.assertRaises(OSError, os.waitpid, pid, 0) self.assertNotIn(ident, [id(o) for o in subprocess._active]) def test_close_fds_after_preexec(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") # this FD is used as dup2() target by preexec_fn, and should be closed # in the child process fd = os.dup(1) self.addCleanup(os.close, fd) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, preexec_fn=lambda: os.dup2(1, fd)) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertNotIn(fd, remaining_fds) @support.cpython_only def test_fork_exec(self): # Issue #22290: fork_exec() must not crash on memory allocation failure # or other errors import _posixsubprocess gc_enabled = gc.isenabled() try: # Use a preexec function and enable the garbage collector # to force fork_exec() to re-enable the garbage collector # on error. func = lambda: None gc.enable() executable_list = "exec" # error: must be a sequence for args, exe_list, cwd, env_list in ( (123, [b"exe"], None, [b"env"]), ([b"arg"], 123, None, [b"env"]), ([b"arg"], [b"exe"], 123, [b"env"]), ([b"arg"], [b"exe"], None, 123), ): with self.assertRaises(TypeError): _posixsubprocess.fork_exec( args, exe_list, True, [], cwd, env_list, -1, -1, -1, -1, 1, 2, 3, 4, True, True, func) finally: if not gc_enabled: gc.disable() @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_MAXIMIZE # Since Python is a console process, it won't be affected # by wShowWindow, but the argument should be silently # ignored subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) def test_creationflags(self): # creationflags argument CREATE_NEW_CONSOLE = 16 sys.stderr.write(" a DOS box should flash briefly ...\n") subprocess.call(sys.executable + ' -c "import time; time.sleep(0.25)"', creationflags=CREATE_NEW_CONSOLE) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], stdout=subprocess.PIPE, close_fds=True) def test_close_fds(self): # close file descriptors rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"], close_fds=True) self.assertEqual(rc, 47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn(b"physalis", p.stdout.read()) def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn(b"physalis", p.stdout.read()) def test_call_string(self): # call() function with string argument on Windows rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) def _kill_process(self, method, *args): # Some win32 buildbot raises EOFError if stdin is inherited p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') returncode = p.wait() self.assertNotEqual(returncode, 0) def _kill_dead_process(self, method, *args): p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() sys.exit(42) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') rc = p.wait() self.assertEqual(rc, 42) def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) def test_kill(self): self._kill_process('kill') def test_terminate(self): self._kill_process('terminate') def test_send_signal_dead(self): self._kill_dead_process('send_signal', signal.SIGTERM) def test_kill_dead(self): self._kill_dead_process('kill') def test_terminate_dead(self): self._kill_dead_process('terminate') class CommandTests(unittest.TestCase): def test_getoutput(self): self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy') self.assertEqual(subprocess.getstatusoutput('echo xyzzy'), (0, 'xyzzy')) # we use mkdtemp in the next line to create an empty directory # under our exclusive control; from that, we can invent a pathname # that we _know_ won't exist. This is guaranteed to fail. dir = None try: dir = tempfile.mkdtemp() name = os.path.join(dir, "foo") status, output = subprocess.getstatusoutput( ("type " if mswindows else "cat ") + name) self.assertNotEqual(status, 0) finally: if dir is not None: os.rmdir(dir) @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") class ProcessTestCaseNoPoll(ProcessTestCase): def setUp(self): self.orig_selector = subprocess._PopenSelector subprocess._PopenSelector = selectors.SelectSelector ProcessTestCase.setUp(self) def tearDown(self): subprocess._PopenSelector = self.orig_selector ProcessTestCase.tearDown(self) class HelperFunctionTests(unittest.TestCase): @unittest.skipIf(mswindows, "errno and EINTR make no sense on windows") def test_eintr_retry_call(self): record_calls = [] def fake_os_func(*args): record_calls.append(args) if len(record_calls) == 2: raise OSError(errno.EINTR, "fake interrupted system call") return tuple(reversed(args)) self.assertEqual((999, 256), subprocess._eintr_retry_call(fake_os_func, 256, 999)) self.assertEqual([(256, 999)], record_calls) # This time there will be an EINTR so it will loop once. self.assertEqual((666,), subprocess._eintr_retry_call(fake_os_func, 666)) self.assertEqual([(256, 999), (666,), (666,)], record_calls) @unittest.skipUnless(mswindows, "Windows-specific tests") class CommandsWithSpaces (BaseTestCase): def setUp(self): super().setUp() f, fname = mkstemp(".py", "te st") self.fname = fname.lower () os.write(f, b"import sys;" b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))" ) os.close(f) def tearDown(self): os.remove(self.fname) super().tearDown() def with_spaces(self, *args, **kwargs): kwargs['stdout'] = subprocess.PIPE p = subprocess.Popen(*args, **kwargs) self.addCleanup(p.stdout.close) self.assertEqual( p.stdout.read ().decode("mbcs"), "2 [%r, 'ab cd']" % self.fname ) def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd"), shell=1) def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1) def test_noshell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd")) def test_noshell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"]) class ContextManagerTests(BaseTestCase): def test_pipe(self): with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write('stdout');" "sys.stderr.write('stderr');"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: self.assertEqual(proc.stdout.read(), b"stdout") self.assertStderrEqual(proc.stderr.read(), b"stderr") self.assertTrue(proc.stdout.closed) self.assertTrue(proc.stderr.closed) def test_returncode(self): with subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(100)"]) as proc: pass # __exit__ calls wait(), so the returncode should be set self.assertEqual(proc.returncode, 100) def test_communicate_stdin(self): with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.exit(sys.stdin.read() == 'context')"], stdin=subprocess.PIPE) as proc: proc.communicate(b"context") self.assertEqual(proc.returncode, 1) def test_invalid_args(self): with self.assertRaises(FileNotFoundError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass def test_broken_pipe_cleanup(self): """Broken pipe error should not prevent wait() (Issue 21619)""" proc = subprocess.Popen([sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, bufsize=support.PIPE_MAX_SIZE*2) proc = proc.__enter__() # Prepare to send enough data to overflow any OS pipe buffering and # guarantee a broken pipe error. Data is held in BufferedWriter # buffer until closed. proc.stdin.write(b'x' * support.PIPE_MAX_SIZE) self.assertIsNone(proc.returncode) # EPIPE expected under POSIX; EINVAL under Windows self.assertRaises(OSError, proc.__exit__, None, None, None) self.assertEqual(proc.returncode, 0) self.assertTrue(proc.stdin.closed) def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, CommandTests, ProcessTestCaseNoPoll, HelperFunctionTests, CommandsWithSpaces, ContextManagerTests, ) support.run_unittest(*unit_tests) support.reap_children() if __name__ == "__main__": unittest.main() gevent-1.1.0/greentest/3.4/test_threading.py0000644000076500000000000011450612666555342021430 0ustar jmaddenwheel00000000000000""" Tests for the threading module. """ import test.support from test.support import verbose, strip_python_stderr, import_module, cpython_only from test.script_helper import assert_python_ok, assert_python_failure import random import re import sys _thread = import_module('_thread') threading = import_module('threading') import time import unittest import weakref import os import subprocess from test import lock_tests # Between fork() and exec(), only async-safe functions are allowed (issues # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', 'hp-ux11') # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print('task %s will run for %.1f usec' % (self.name, delay * 1e6)) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print(self.nrunning.get(), 'tasks are running') self.testcase.assertTrue(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print('task', self.name, 'done') with self.mutex: self.nrunning.dec() self.testcase.assertTrue(self.nrunning.get() >= 0) if verbose: print('%s is finished. %d tasks are running' % (self.name, self.nrunning.get())) class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test.support.threading_setup() def tearDown(self): test.support.threading_cleanup(*self._threads) test.support.reap_children() class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) self.assertEqual(t.ident, None) self.assertTrue(re.match('', repr(t))) t.start() if verbose: print('waiting for all tasks to complete') for t in threads: t.join() self.assertTrue(not t.is_alive()) self.assertNotEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assertTrue(re.match('', repr(t))) if verbose: print('all tasks done') self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertFalse(threading.currentThread().ident is None) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] _thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print('with 256kB thread stack size...') try: threading.stack_size(262144) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print('with 1MB thread stack size...') try: threading.stack_size(0x100000) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = _thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assertIn(tid, threading._active) self.assertIsInstance(threading._active[tid], threading._DummyThread) del threading._active[tid] # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. def test_PyThreadState_SetAsyncExc(self): ctypes = import_module("ctypes") set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # First check it works when setting the exception from the same thread. tid = threading.get_ident() try: result = set_async_exc(ctypes.c_long(tid), exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: pass except AsyncExc: pass else: # This code is unreachable but it reflects the intent. If we wanted # to be smarter the above loop wouldn't be infinite. self.fail("AsyncExc not raised") try: self.assertEqual(result, 1) # one thread state modified except UnboundLocalError: # The exception was raised too quickly for us to get the result. pass # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = threading.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print(" started worker thread") # Try a thread id that doesn't make sense. if verbose: print(" trying nonsensical thread id") result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print(" waiting for worker thread to get started") ret = worker_started.wait() self.assertTrue(ret) if verbose: print(" verifying worker hasn't exited") self.assertTrue(not t.finished) if verbose: print(" attempting to raise asynch exception in worker") result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print(" waiting for worker to say it caught the exception") worker_saw_exception.wait(timeout=10) self.assertTrue(t.finished) if verbose: print(" all OK -- joining worker") if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise threading.ThreadError() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(threading.ThreadError, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. import_module("ctypes") rc, out, err = assert_python_failure("-c", """if 1: import ctypes, sys, time, _thread # This lock is used as a simple event variable. ready = _thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) _thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown assert_python_ok("-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print('program blocked; aborting') os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown rc, out, err = assert_python_ok("-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print("Woke up, sleep function is:", sleep) threading.Thread(target=child).start() raise SystemExit """) self.assertEqual(out.strip(), b"Woke up, sleep function is: ") self.assertEqual(err, b"") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getswitchinterval() try: for i in range(1, 100): sys.setswitchinterval(i * 0.0002) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertNotIn(t, l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setswitchinterval(old_interval) def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertIsNone(weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertIsNone(weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) def test_old_threading_api(self): # Just a quick sanity check to make sure the old method names are # still present t = threading.Thread() t.isDaemon() t.setDaemon(True) t.getName() t.setName("name") t.isAlive() e = threading.Event() e.isSet() threading.activeCount() def test_repr_daemon(self): t = threading.Thread() self.assertFalse('daemon' in repr(t)) t.daemon = True self.assertTrue('daemon' in repr(t)) def test_deamon_param(self): t = threading.Thread() self.assertFalse(t.daemon) t = threading.Thread(daemon=False) self.assertFalse(t.daemon) t = threading.Thread(daemon=True) self.assertTrue(t.daemon) @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') def test_dummy_thread_after_fork(self): # Issue #14308: a dummy thread in the active list doesn't mess up # the after-fork mechanism. code = """if 1: import _thread, threading, os, time def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() _thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: os.wait() """ _, out, err = assert_python_ok("-c", code) self.assertEqual(out, b'') self.assertEqual(err, b'') @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_is_alive_after_fork(self): # Try hard to trigger #18418: is_alive() could sometimes be True on # threads that vanished after a fork. old_interval = sys.getswitchinterval() self.addCleanup(sys.setswitchinterval, old_interval) # Make the bug more likely to manifest. sys.setswitchinterval(1e-6) for i in range(20): t = threading.Thread(target=lambda: None) t.start() self.addCleanup(t.join) pid = os.fork() if pid == 0: os._exit(1 if t.is_alive() else 0) else: pid, status = os.waitpid(pid, 0) self.assertEqual(0, status) def test_main_thread(self): main = threading.main_thread() self.assertEqual(main.name, 'MainThread') self.assertEqual(main.ident, threading.current_thread().ident) self.assertEqual(main.ident, threading.get_ident()) def f(): self.assertNotEqual(threading.main_thread().ident, threading.current_thread().ident) th = threading.Thread(target=f) th.start() th.join() @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork(self): code = """if 1: import os, threading pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) else: os.waitpid(pid, 0) """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "MainThread\nTrue\nTrue\n") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork_from_nonmain_thread(self): code = """if 1: import os, threading, sys def f(): pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) # stdout is fully buffered because not a tty, # we have to flush before exit. sys.stdout.flush() else: os.waitpid(pid, 0) th = threading.Thread(target=f) th.start() th.join() """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "Thread-1\nTrue\nTrue\n") def test_tstate_lock(self): # Test an implementation detail of Thread objects. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() time.sleep(0.01) # The tstate lock is None until the thread is started t = threading.Thread(target=f) self.assertIs(t._tstate_lock, None) t.start() started.acquire() self.assertTrue(t.is_alive()) # The tstate lock can't be acquired when the thread is running # (or suspended). tstate_lock = t._tstate_lock self.assertFalse(tstate_lock.acquire(timeout=0), False) finish.release() # When the thread ends, the state_lock can be successfully # acquired. self.assertTrue(tstate_lock.acquire(timeout=5), False) # But is_alive() is still True: we hold _tstate_lock now, which # prevents is_alive() from knowing the thread's end-of-life C code # is done. self.assertTrue(t.is_alive()) # Let is_alive() find out the C code is done. tstate_lock.release() self.assertFalse(t.is_alive()) # And verify the thread disposed of _tstate_lock. self.assertTrue(t._tstate_lock is None) def test_repr_stopped(self): # Verify that "stopped" shows up in repr(Thread) appropriately. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() t = threading.Thread(target=f) t.start() started.acquire() self.assertIn("started", repr(t)) finish.release() # "stopped" should appear in the repr in a reasonable amount of time. # Implementation detail: as of this writing, that's trivially true # if .join() is called, and almost trivially true if .is_alive() is # called. The detail we're testing here is that "stopped" shows up # "all on its own". LOOKING_FOR = "stopped" for i in range(500): if LOOKING_FOR in repr(t): break time.sleep(0.01) self.assertIn(LOOKING_FOR, repr(t)) # we waited at least 5 seconds def test_BoundedSemaphore_limit(self): # BoundedSemaphore should raise ValueError if released too often. for limit in range(1, 10): bs = threading.BoundedSemaphore(limit) threads = [threading.Thread(target=bs.acquire) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() threads = [threading.Thread(target=bs.release) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() self.assertRaises(ValueError, bs.release) @cpython_only def test_frame_tstate_tracing(self): # Issue #14432: Crash when a generator is created in a C thread that is # destroyed while the generator is still used. The issue was that a # generator contains a frame, and the frame kept a reference to the # Python state of the destroyed C thread. The crash occurs when a trace # function is setup. def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "generator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call import _testcapi _testcapi.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print('end of thread') # stdout is fully buffered because not a tty, we have to flush # before exit. sys.stdout.flush() \n""" + script rc, out, err = assert_python_ok("-c", script) data = out.decode().replace('\r', '') self.assertEqual(data, "end of main\nend of thread\n") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print('end of main') t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_4_daemon_threads(self): # Check that a daemon thread cannot crash the interpreter on shutdown # by manipulating internal structures that are being disposed of in # the main thread. script = """if True: import os import random import sys import time import threading thread_has_run = set() def random_io(): '''Loop for a while sleeping random tiny amounts and doing some I/O.''' while True: in_f = open(os.__file__, 'rb') stuff = in_f.read(200) null_f = open(os.devnull, 'wb') null_f.write(stuff) time.sleep(random.random() / 1995) null_f.close() in_f.close() thread_has_run.add(threading.current_thread()) def main(): count = 0 for _ in range(40): new_thread = threading.Thread(target=random_io) new_thread.daemon = True new_thread.start() count += 1 while len(thread_has_run) < count: time.sleep(0.001) # Trigger process shutdown sys.exit(0) main() """ rc, out, err = assert_python_ok('-c', script) self.assertFalse(err) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): # Issue #13817: fork() would deadlock in a multithreaded program with # the ad-hoc TLS implementation. def do_fork_and_wait(): # just fork a child process and wait it pid = os.fork() if pid > 0: os.waitpid(pid, 0) else: os._exit(0) # start a bunch of threads that will fork() child processes threads = [] for i in range(16): t = threading.Thread(target=do_fork_and_wait) threads.append(t) t.start() for t in threads: t.join() @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_clear_threads_states_after_fork(self): # Issue #17094: check that threads states are cleared after fork() # start a bunch of threads threads = [] for i in range(16): t = threading.Thread(target=lambda : time.sleep(0.3)) threads.append(t) t.start() pid = os.fork() if pid == 0: # check that threads states have been cleared if len(sys._current_frames()) == 1: os._exit(0) else: os._exit(1) else: _, status = os.waitpid(pid, 0) self.assertEqual(0, status) for t in threads: t.join() class SubinterpThreadingTests(BaseTestCase): def test_threads_join(self): # Non-daemon threads should be joined at subinterpreter shutdown # (issue #18808) r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") def test_threads_join_2(self): # Same as above, but a delay gets introduced after the thread's # Python code returned but before the thread state is deleted. # To achieve this, we register a thread-local object which sleeps # a bit when deallocated. r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time class Sleeper: def __del__(self): time.sleep(0.05) tls = threading.local() def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) tls.x = Sleeper() os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") @cpython_only def test_daemon_threads_fatal_error(self): subinterp_code = r"""if 1: import os import threading import time def f(): # Make sure the daemon thread is still running when # Py_EndInterpreter is called. time.sleep(10) threading.Thread(target=f, daemon=True).start() """ script = r"""if 1: import _testcapi _testcapi.run_in_subinterp(%r) """ % (subinterp_code,) with test.support.SuppressCrashReport(): rc, out, err = assert_python_failure("-c", script) self.assertIn("Fatal Python error: Py_EndInterpreter: " "not the last thread", err.decode()) class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) def test_releasing_unacquired_lock(self): lock = threading.Lock() self.assertRaises(RuntimeError, lock.release) @unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(), 'test macosx problem') def test_recursion_limit(self): # Issue 9670 # test that excessive recursion within a non-main thread causes # an exception rather than crashing the interpreter on platforms # like Mac OS X or FreeBSD which have small default stack sizes # for threads script = """if True: import threading def recurse(): return recurse() def outer(): try: recurse() except RuntimeError: pass w = threading.Thread(target=outer) w.start() w.join() print('end of main thread') """ expected_output = "end of main thread\n" p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() data = stdout.decode().replace('\r', '') self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode()) self.assertEqual(data, expected_output) def test_print_exception(self): script = r"""if True: import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_1(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) sys.stderr = None running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_2(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 sys.stderr = None t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') self.assertNotIn("Unhandled exception", err.decode()) class TimerTests(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) self.callback_args = [] self.callback_event = threading.Event() def test_init_immutable_default_args(self): # Issue 17435: constructor defaults were mutable objects, they could be # mutated via the object attributes and affect other Timer objects. timer1 = threading.Timer(0.01, self._callback_spy) timer1.start() self.callback_event.wait() timer1.args.append("blah") timer1.kwargs["foo"] = "bar" self.callback_event.clear() timer2 = threading.Timer(0.01, self._callback_spy) timer2.start() self.callback_event.wait() self.assertEqual(len(self.callback_args), 2) self.assertEqual(self.callback_args, [((), {}), ((), {})]) def _callback_spy(self, *args, **kwargs): self.callback_args.append((args[:], kwargs.copy())) self.callback_event.set() class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class PyRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._PyRLock) @unittest.skipIf(threading._CRLock is None, 'RLock not implemented in C') class CRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._CRLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) @unittest.skip("not on gevent") def test_reset_internal_locks(self): pass class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) class BarrierTests(lock_tests.BarrierTests): barriertype = staticmethod(threading.Barrier) if __name__ == "__main__": unittest.main() gevent-1.1.0/greentest/3.4/version0000644000076500000000000000000612666555342017447 0ustar jmaddenwheel000000000000003.4.3 gevent-1.1.0/greentest/3.5/0000755000076500000000000000000012666555433016045 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.5/badcert.pem0000644000076500000000000000361012666555342020153 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/badkey.pem0000644000076500000000000000416212666555342020011 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/0000755000076500000000000000000012666555433017305 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.5/capath/0e4015b9.00000644000076500000000000000167412666555342020446 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/4e1295a3.00000644000076500000000000000145612666555342020450 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/5ed36f99.00000644000076500000000000000501112666555342020540 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/6e88d7b8.00000644000076500000000000000145612666555342020552 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX 9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/99d0fa06.00000644000076500000000000000501112666555342020524 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/capath/ce7b8643.00000644000076500000000000000167412666555342020542 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/dh1024.pem0000644000076500000000000000045412666555342017454 0ustar jmaddenwheel00000000000000-----BEGIN DH PARAMETERS----- MIGHAoGBAIbzw1s9CT8SV5yv6L7esdAdZYZjPi3qWFs61CYTFFQnf2s/d09NYaJt rrvJhIzWavqnue71qXCf83/J3nz3FEwUU/L0mGyheVbsSHiI64wUo3u50wK5Igo0 RNs/LD0irs7m0icZ//hijafTU+JOBiuA8zMI+oZfU7BGuc9XrUprAgEC -----END DH PARAMETERS----- Generated with: openssl dhparam -out dh1024.pem 1024 gevent-1.1.0/greentest/3.5/keycert.passwd.pem0000644000076500000000000000344612666555342021524 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/keycert.pem0000644000076500000000000000336712666555342020226 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/keycert2.pem0000644000076500000000000000340312666555342020277 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJnsJZVrppL+W5I9 zGQrrawWwE5QJpBK9nWw17mXrZ03R1cD9BamLGivVISbPlRlAVnZBEyh1ATpsB7d CUQ+WHEvALquvx4+Yw5l+fXeiYRjrLRBYZuVy8yNtXzU3iWcGObcYRkUdiXdOyP7 sLF2YZHRvQZpzgDBKkrraeQ81w21AgMBAAECgYBEm7n07FMHWlE+0kT0sXNsLYfy YE+QKZnJw9WkaDN+zFEEPELkhZVt5BjsMraJr6v2fIEqF0gGGJPkbenffVq2B5dC lWUOxvJHufMK4sM3Cp6s/gOp3LP+QkzVnvJSfAyZU6l+4PGX5pLdUsXYjPxgzjzL S36tF7/2Uv1WePyLUQJBAMsPhYzUXOPRgmbhcJiqi9A9c3GO8kvSDYTCKt3VMnqz HBn6MQ4VQasCD1F+7jWTI0FU/3vdw8non/Fj8hhYqZcCQQDCDRdvmZqDiZnpMqDq L6ZSrLTVtMvZXZbgwForaAD9uHj51TME7+eYT7EG2YCgJTXJ4YvRJEnPNyskwdKt vTSTAkEAtaaN/vyemEJ82BIGStwONNw0ILsSr5cZ9tBHzqiA/tipY+e36HRFiXhP QcU9zXlxyWkDH8iz9DSAmE2jbfoqwwJANlMJ65E543cjIlitGcKLMnvtCCLcKpb7 xSG0XJB6Lo11OKPJ66jp0gcFTSCY1Lx2CXVd+gfJrfwI1Pp562+bhwJBAJ9IfDPU R8OpO9v1SGd8x33Owm7uXOpB9d63/T70AD1QOXjKUC4eXYbt0WWfWuny/RNPRuyh w7DXSfUF+kPKolU= -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICXTCCAcagAwIBAgIJAIO3upAG445fMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTAeFw0x MDEwMDkxNTAxMDBaFw0yMDEwMDYxNTAxMDBaMGIxCzAJBgNVBAYTAlhZMRcwFQYD VQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZv dW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTCBnzANBgkqhkiG9w0BAQEF AAOBjQAwgYkCgYEAmewllWumkv5bkj3MZCutrBbATlAmkEr2dbDXuZetnTdHVwP0 FqYsaK9UhJs+VGUBWdkETKHUBOmwHt0JRD5YcS8Auq6/Hj5jDmX59d6JhGOstEFh m5XLzI21fNTeJZwY5txhGRR2Jd07I/uwsXZhkdG9BmnOAMEqSutp5DzXDbUCAwEA AaMbMBkwFwYDVR0RBBAwDoIMZmFrZWhvc3RuYW1lMA0GCSqGSIb3DQEBBQUAA4GB AH+iMClLLGSaKWgwXsmdVo4FhTZZHo8Uprrtg3N9FxEeE50btpDVQysgRt5ias3K m+bME9zbKwvbVWD5zZdjus4pDgzwF/iHyccL8JyYhxOvS/9zmvAtFXj/APIIbZFp IT75d9f88ScIGEtknZQejnrdhB64tYki/EqluiuKBqKD -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/keycert3.pem0000644000076500000000000000772212666555342020310 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLgD0kAKDb5cFyP jbwNfR5CtewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM 9z2j1OlaN+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZ aggEdkj1TsSsv1zWIYKlPIjlvhuxAgMBAAECgYA0aH+T2Vf3WOPv8KdkcJg6gCRe yJKXOWgWRcicx/CUzOEsTxmFIDPLxqAWA3k7v0B+3vjGw5Y9lycV/5XqXNoQI14j y09iNsumds13u5AKkGdTJnZhQ7UKdoVHfuP44ZdOv/rJ5/VD6F4zWywpe90pcbK+ AWDVtusgGQBSieEl1QJBAOyVrUG5l2yoUBtd2zr/kiGm/DYyXlIthQO/A3/LngDW 5/ydGxVsT7lAVOgCsoT+0L4efTh90PjzW8LPQrPBWVMCQQDS3h/FtYYd5lfz+FNL 9CEe1F1w9l8P749uNUD0g317zv1tatIqVCsQWHfVHNdVvfQ+vSFw38OORO00Xqs9 1GJrAkBkoXXEkxCZoy4PteheO/8IWWLGGr6L7di6MzFl1lIqwT6D8L9oaV2vynFT DnKop0pa09Unhjyw57KMNmSE2SUJAkEArloTEzpgRmCq4IK2/NpCeGdHS5uqRlbh 1VIa/xGps7EWQl5Mn8swQDel/YP3WGHTjfx7pgSegQfkyaRtGpZ9OQJAa9Vumj8m JAAtI0Bnga8hgQx7BhTQY4CadDxyiRGOGYhwUzYVCqkb2sbVRH9HnwUaJT7cWBY3 RnJdHOMXWem7/w== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443281 (0xb09264b1f2da21d1) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:c2:e0:0f:49:00:28:36:f9:70:5c:8f:8d:bc:0d: 7d:1e:42:b5:ec:1d:5c:2f:a4:31:70:16:0f:c0:cb: c6:24:d3:be:13:16:ee:a5:67:97:03:a6:df:a9:99: 96:cc:c7:2a:fb:11:7f:4e:65:4f:8a:5e:82:21:4c: f7:3d:a3:d4:e9:5a:37:e7:22:fd:7e:cd:53:6d:93: 34:de:9c:ad:84:a2:37:be:c5:8d:82:4f:e3:ae:23: f3:be:a7:75:2c:72:0f:ea:f3:ca:cd:fc:e9:3f:b5: af:56:99:6a:08:04:76:48:f5:4e:c4:ac:bf:5c:d6: 21:82:a5:3c:88:e5:be:1b:b1 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption 2f:42:5f:a3:09:2c:fa:51:88:c7:37:7f:ea:0e:63:f0:a2:9a: e5:5a:e2:c8:20:f0:3f:60:bc:c8:0f:b6:c6:76:ce:db:83:93: f5:a3:33:67:01:8e:04:cd:00:9a:73:fd:f3:35:86:fa:d7:13: e2:46:c6:9d:c0:29:53:d4:a9:90:b8:77:4b:e6:83:76:e4:92: d6:9c:50:cf:43:d0:c6:01:77:61:9a:de:9b:70:f7:72:cd:59: 00:31:69:d9:b4:ca:06:9c:6d:c3:c7:80:8c:68:e6:b5:a2:f8: ef:1d:bb:16:9f:77:77:ef:87:62:22:9b:4d:69:a4:3a:1a:f1: 21:5e:8c:32:ac:92:fd:15:6b:18:c2:7f:15:0d:98:30:ca:75: 8f:1a:71:df:da:1d:b2:ef:9a:e8:2d:2e:02:fd:4a:3c:aa:96: 0b:06:5d:35:b3:3d:24:87:4b:e0:b0:58:60:2f:45:ac:2e:48: 8a:b0:99:10:65:27:ff:cc:b1:d8:fd:bd:26:6b:b9:0c:05:2a: f4:45:63:35:51:07:ed:83:85:fe:6f:69:cb:bb:40:a8:ae:b6: 3b:56:4a:2d:a4:ed:6d:11:2c:4d:ed:17:24:fd:47:bc:d3:41: a2:d3:06:fe:0c:90:d8:d8:94:26:c4:ff:cc:a1:d8:42:77:eb: fc:a9:94:71 -----BEGIN CERTIFICATE----- MIICpDCCAYwCCQCwkmSx8toh0TANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBfMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRIwEAYDVQQDEwlsb2NhbGhv c3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMLgD0kAKDb5cFyPjbwNfR5C tewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM9z2j1Ola N+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZaggEdkj1 TsSsv1zWIYKlPIjlvhuxAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAC9CX6MJLPpR iMc3f+oOY/CimuVa4sgg8D9gvMgPtsZ2ztuDk/WjM2cBjgTNAJpz/fM1hvrXE+JG xp3AKVPUqZC4d0vmg3bkktacUM9D0MYBd2Ga3ptw93LNWQAxadm0ygacbcPHgIxo 5rWi+O8duxafd3fvh2Iim01ppDoa8SFejDKskv0VaxjCfxUNmDDKdY8acd/aHbLv mugtLgL9SjyqlgsGXTWzPSSHS+CwWGAvRawuSIqwmRBlJ//Msdj9vSZruQwFKvRF YzVRB+2Dhf5vacu7QKiutjtWSi2k7W0RLE3tFyT9R7zTQaLTBv4MkNjYlCbE/8yh 2EJ36/yplHE= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/keycert4.pem0000644000076500000000000000773112666555342020311 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK5UQiMI5VkNs2Qv L7gUaiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2 NkX0ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1 L2OQhEx1GM6RydHdgX69G64LXcY5AgMBAAECgYAhsRMfJkb9ERLMl/oG/5sLQu9L pWDKt6+ZwdxzlZbggQ85CMYshjLKIod2DLL/sLf2x1PRXyRG131M1E3k8zkkz6de R1uDrIN/x91iuYzfLQZGh8bMY7Yjd2eoroa6R/7DjpElGejLxOAaDWO0ST2IFQy9 myTGS2jSM97wcXfsSQJBANP3jelJoS5X6BRjTSneY21wcocxVuQh8pXpErALVNsT drrFTeaBuZp7KvbtnIM5g2WRNvaxLZlAY/hXPJvi6ncCQQDSix1cebml6EmPlEZS Mm8gwI2F9ufUunwJmBJcz826Do0ZNGByWDAM/JQZH4FX4GfAFNuj8PUb+GQfadkx i1DPAkEA0lVsNHojvuDsIo8HGuzarNZQT2beWjJ1jdxh9t7HrTx7LIps6rb/fhOK Zs0R6gVAJaEbcWAPZ2tFyECInAdnsQJAUjaeXXjuxFkjOFym5PvqpvhpivEx78Bu JPTr3rAKXmfGMxxfuOa0xK1wSyshP6ZR/RBn/+lcXPKubhHQDOegwwJAJF1DBQnN +/tLmOPULtDwfP4Zixn+/8GmGOahFoRcu6VIGHmRilJTn6MOButw7Glv2YdeC6l/ e83Gq6ffLVfKNQ== -----END PRIVATE KEY----- Certificate: Data: Version: 1 (0x0) Serial Number: 12723342612721443282 (0xb09264b1f2da21d2) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Nov 13 19:47:07 2022 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=fakehostname Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:ae:54:42:23:08:e5:59:0d:b3:64:2f:2f:b8:14: 6a:20:dd:15:eb:cd:51:74:63:53:80:c7:01:ed:d9: cf:36:0b:64:d1:3a:f6:1f:60:3b:d5:42:49:2d:7a: b4:9e:5f:4f:95:44:bb:41:19:c8:6a:f4:7b:75:76: 36:45:f4:66:85:34:1d:cf:d4:69:8e:2a:c7:b2:c7: 9a:7e:52:61:9a:48:c6:12:67:91:fe:d2:c8:72:4a: d7:35:1a:1a:55:34:fc:bc:58:a8:8b:86:0a:d1:79: 76:ac:75:2f:63:90:84:4c:75:18:ce:91:c9:d1:dd: 81:7e:bd:1b:ae:0b:5d:c6:39 Exponent: 65537 (0x10001) Signature Algorithm: sha1WithRSAEncryption ad:45:8a:8e:ef:c6:ef:04:41:5c:2c:4a:84:dc:02:76:0c:d0: 66:0f:f0:16:04:58:4d:fd:68:b7:b8:d3:a8:41:a5:5c:3c:6f: 65:3c:d1:f8:ce:43:35:e7:41:5f:53:3d:c9:2c:c3:7d:fc:56: 4a:fa:47:77:38:9d:bb:97:28:0a:3b:91:19:7f:bc:74:ae:15: 6b:bd:20:36:67:45:a5:1e:79:d7:75:e6:89:5c:6d:54:84:d1: 95:d7:a7:b4:33:3c:af:37:c4:79:8f:5e:75:dc:75:c2:18:fb: 61:6f:2d:dc:38:65:5b:ba:67:28:d0:88:d7:8d:b9:23:5a:8e: e8:c6:bb:db:ce:d5:b8:41:2a:ce:93:08:b6:95:ad:34:20:18: d5:3b:37:52:74:50:0b:07:2c:b0:6d:a4:4c:7b:f4:e0:fd:d1: af:17:aa:20:cd:62:e3:f0:9d:37:69:db:41:bd:d4:1c:fb:53: 20:da:88:9d:76:26:67:ce:01:90:a7:80:1d:a9:5b:39:73:68: 54:0a:d1:2a:03:1b:8f:3c:43:5d:5d:c4:51:f1:a7:e7:11:da: 31:2c:49:06:af:04:f4:b8:3c:99:c4:20:b9:06:36:a2:00:92: 61:1d:0c:6d:24:05:e2:82:e1:47:db:a0:5f:ba:b9:fb:ba:fa: 49:12:1e:ce -----BEGIN CERTIFICATE----- MIICpzCCAY8CCQCwkmSx8toh0jANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 WjBiMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRUwEwYDVQQDEwxmYWtlaG9z dG5hbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK5UQiMI5VkNs2QvL7gU aiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2NkX0 ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1L2OQ hEx1GM6RydHdgX69G64LXcY5AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAK1Fio7v xu8EQVwsSoTcAnYM0GYP8BYEWE39aLe406hBpVw8b2U80fjOQzXnQV9TPcksw338 Vkr6R3c4nbuXKAo7kRl/vHSuFWu9IDZnRaUeedd15olcbVSE0ZXXp7QzPK83xHmP XnXcdcIY+2FvLdw4ZVu6ZyjQiNeNuSNajujGu9vO1bhBKs6TCLaVrTQgGNU7N1J0 UAsHLLBtpEx79OD90a8XqiDNYuPwnTdp20G91Bz7UyDaiJ12JmfOAZCngB2pWzlz aFQK0SoDG488Q11dxFHxp+cR2jEsSQavBPS4PJnEILkGNqIAkmEdDG0kBeKC4Ufb oF+6ufu6+kkSHs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/nokia.pem0000644000076500000000000000360312666555342017652 0ustar jmaddenwheel00000000000000# Certificate for projects.developer.nokia.com:443 (see issue 13034) -----BEGIN CERTIFICATE----- MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2 lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522 O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y 0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/nullbytecert.pem0000644000076500000000000001247312666555342021272 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 0 (0x0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Validity Not Before: Aug 7 13:11:52 2013 GMT Not After : Aug 7 13:12:52 2013 GMT Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3: 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97: 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2: 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1: 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4: 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8: a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02: 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75: ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91: 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d: 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30: 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7: f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12: f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5: ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb: d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f: 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da: 2f:85 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C X509v3 Key Usage: Digital Signature, Non Repudiation, Key Encipherment X509v3 Subject Alternative Name: ************************************************************* WARNING: The values for DNS, email and URI are WRONG. OpenSSL doesn't print the text after a NULL byte. ************************************************************* DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 Signature Algorithm: sha1WithRSAEncryption ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5: a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44: 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37: 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3: 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86: de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac: 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4: 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60: d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5: 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60: 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6: 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d: 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e: 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6: c1:ca:a9:94 -----BEGIN CERTIFICATE----- MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL 08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/nullcert.pem0000644000076500000000000000000012666555342020365 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/3.5/pycacert.pem0000644000076500000000000001032312666555342020360 0ustar jmaddenwheel00000000000000Certificate: Data: Version: 3 (0x2) Serial Number: 12723342612721443280 (0xb09264b1f2da21d0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Jan 4 19:47:07 2013 GMT Not After : Jan 2 19:47:07 2023 GMT Subject: C=XY, O=Python Software Foundation CA, CN=our-ca-server Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:e7:de:e9:e3:0c:9f:00:b6:a1:fd:2b:5b:96:d2: 6f:cc:e0:be:86:b9:20:5e:ec:03:7a:55:ab:ea:a4: e9:f9:49:85:d2:66:d5:ed:c7:7a:ea:56:8e:2d:8f: e7:42:e2:62:28:a9:9f:d6:1b:8e:eb:b5:b4:9c:9f: 14:ab:df:e6:94:8b:76:1d:3e:6d:24:61:ed:0c:bf: 00:8a:61:0c:df:5c:c8:36:73:16:00:cd:47:ba:6d: a4:a4:74:88:83:23:0a:19:fc:09:a7:3c:4a:4b:d3: e7:1d:2d:e4:ea:4c:54:21:f3:26:db:89:37:18:d4: 02:bb:40:32:5f:a4:ff:2d:1c:f7:d4:bb:ec:8e:cf: 5c:82:ac:e6:7c:08:6c:48:85:61:07:7f:25:e0:5c: e0:bc:34:5f:e0:b9:04:47:75:c8:47:0b:8d:bc:d6: c8:68:5f:33:83:62:d2:20:44:35:b1:ad:81:1a:8a: cd:bc:35:b0:5c:8b:47:d6:18:e9:9c:18:97:cc:01: 3c:29:cc:e8:1e:e4:e4:c1:b8:de:e7:c2:11:18:87: 5a:93:34:d8:a6:25:f7:14:71:eb:e4:21:a2:d2:0f: 2e:2e:d4:62:00:35:d3:d6:ef:5c:60:4b:4c:a9:14: e2:dd:15:58:46:37:33:26:b7:e7:2e:5d:ed:42:e4: c5:4d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Authority Key Identifier: keyid:BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption 7d:0a:f5:cb:8d:d3:5d:bd:99:8e:f8:2b:0f:ba:eb:c2:d9:a6: 27:4f:2e:7b:2f:0e:64:d8:1c:35:50:4e:ee:fc:90:b9:8d:6d: a8:c5:c6:06:b0:af:f3:2d:bf:3b:b8:42:07:dd:18:7d:6d:95: 54:57:85:18:60:47:2f:eb:78:1b:f9:e8:17:fd:5a:0d:87:17: 28:ac:4c:6a:e6:bc:29:f4:f4:55:70:29:42:de:85:ea:ab:6c: 23:06:64:30:75:02:8e:53:bc:5e:01:33:37:cc:1e:cd:b8:a4: fd:ca:e4:5f:65:3b:83:1c:86:f1:55:02:a0:3a:8f:db:91:b7: 40:14:b4:e7:8d:d2:ee:73:ba:e3:e5:34:2d:bc:94:6f:4e:24: 06:f7:5f:8b:0e:a7:8e:6b:de:5e:75:f4:32:9a:50:b1:44:33: 9a:d0:05:e2:78:82:ff:db:da:8a:63:eb:a9:dd:d1:bf:a0:61: ad:e3:9e:8a:24:5d:62:0e:e7:4c:91:7f:ef:df:34:36:3b:2f: 5d:f5:84:b2:2f:c4:6d:93:96:1a:6f:30:28:f1:da:12:9a:64: b4:40:33:1d:bd:de:2b:53:a8:ea:be:d6:bc:4e:96:f5:44:fb: 32:18:ae:d5:1f:f6:69:af:b6:4e:7b:1d:58:ec:3b:a9:53:a3: 5e:58:c8:9e -----BEGIN CERTIFICATE----- MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/ AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni 0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx 6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2 2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4 QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1 Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf 9mmvtk57HVjsO6lTo15YyJ4= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/pycakey.pem0000644000076500000000000000325012666555342020214 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDn3unjDJ8AtqH9 K1uW0m/M4L6GuSBe7AN6VavqpOn5SYXSZtXtx3rqVo4tj+dC4mIoqZ/WG47rtbSc nxSr3+aUi3YdPm0kYe0MvwCKYQzfXMg2cxYAzUe6baSkdIiDIwoZ/AmnPEpL0+cd LeTqTFQh8ybbiTcY1AK7QDJfpP8tHPfUu+yOz1yCrOZ8CGxIhWEHfyXgXOC8NF/g uQRHdchHC4281shoXzODYtIgRDWxrYEais28NbBci0fWGOmcGJfMATwpzOge5OTB uN7nwhEYh1qTNNimJfcUcevkIaLSDy4u1GIANdPW71xgS0ypFOLdFVhGNzMmt+cu Xe1C5MVNAgMBAAECggEBAJPM7QuUrPn4cLN/Ysd15lwTWn9oHDFFgkYFvCs66gXE ju/6Kx2BjWE4wTJby09AHM/MqB0DvguT7Mf1Q2j3tPQ1HZowg8OwRDleuwp6KIls jBbhL0Jdl/5HC67ktWvZ9wNvO/wFG1rQfT6FVajf9LUbWEaSZbOG2SLhHfsHorzu xjTJaI3bQ/0+79B1exwk5ruwhzFRd/XpY8hls7D/RfPIuHDlBghkW3N59KFWrf5h 6bNEh2THm0+IyGcGqs0FD+QCOXyvsjwSUswqrr2ctLREOeDcd5ReUjSxYgjcJRrm J7ceIY/+uwDJxw/OlnmBvF6pQMkKwYW2gFztu+g2t4UCgYEA/9yo01Exz4crxXsy tAlnDJM++nZcm07rtFjTKHUfKY/cCgNTa8udM0svnfwlid/dpgLsI38gx04HHC1i EZ4acz+ToIWedLxM0nq73//xeRWEazOvCz1mMTZaMldahTWAyzN8qVK2B/625Yy4 wNYWyweBBwEB8MzaCs73spksXOsCgYEA5/7wvhiofYGFAfMuANeJIwDL2OtBnoOv mVNfCmi3GC38fzwyi5ZpskWDiS2woJ+LQfs9Qu4EcZbUFLd7gbeOvb5gmFUtYope LitUUKunIR18MkQ+mQDBpQPQPhk4QJP5reCbWkrfTu7b5o/iS41s6fBTFmuzhLcT C71vFdCyeKcCgYAiCCqYeOtELDmBOeLDmaCQRqGQ1N96dOPbCBmF/xYXBCCDYG/f HaUaJnz96YTgstsbcrYP/p/Qgqtlbw/lQf9IpwMuzbcG1ejt8g89OyDWNyt2ytgU iaUnFJCos3/Byh0Iah/BsdOueo2/OJl2ZMOBW80orlSgv86cs2y037TL4wKBgQDm OOyW+MlbowhnIvfoBfwlLEkefnej4nKD6WRLZBcue5Qyf355X06Mhsc9foXlH+6G D9h/bswiHNdhp6N82rdgPGiHQx/CxiUoE/+b/nvgNO5mw6qLE2EXbG1e8pAMJcyE bHw+YkawggDfELI036fRj5gki8SeUz8nS1nNgElbyQKBgCRDX9Jh+MwSLu4QBWdt /fi+lv3K6kun/fI7EOV1vCV/j871tICu7pu5BrOLxAHqoVfU9AUX299/2KjCb5pv kjogiUK6qWCWBlfuqDNWGCoUGt1rhznUva0nNjSMy5rinBhhjpROZC2pw48lOluP UuvXsaPph7GTqPuy4Kab12YC -----END PRIVATE KEY----- gevent-1.1.0/greentest/3.5/revocation.crl0000644000076500000000000000116112666555342020716 0ustar jmaddenwheel00000000000000-----BEGIN X509 CRL----- MIIBpjCBjwIBATANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJYWTEmMCQGA1UE CgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNVBAMMDW91ci1j YS1zZXJ2ZXIXDTEzMTEyMTE3MDg0N1oXDTIzMDkzMDE3MDg0N1qgDjAMMAoGA1Ud FAQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQCNJXC2mVKauEeN3LlQ3ZtM5gkH3ExH +i4bmJjtJn497WwvvoIeUdrmVXgJQR93RtV37hZwN0SXMLlNmUZPH4rHhihayw4m unCzVj/OhCCY7/TPjKuJ1O/0XhaLBpBVjQN7R/1ujoRKbSia/CD3vcn7Fqxzw7LK fSRCKRGTj1CZiuxrphtFchwALXSiFDy9mr2ZKhImcyq1PydfgEzU78APpOkMQsIC UNJ/cf3c9emzf+dUtcMEcejQ3mynBo4eIGg1EW42bz4q4hSjzQlKcBV0muw5qXhc HOxH2iTFhQ7SrvVuK/dM14rYM4B5mSX3nRC1kNmXpS9j3wJDhuwmjHed -----END X509 CRL----- gevent-1.1.0/greentest/3.5/selfsigned_pythontestdotnet.pem0000644000076500000000000000167412666555342024421 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515 C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM= -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/sha256.pem0000644000076500000000000002023012666555342017554 0ustar jmaddenwheel00000000000000# Certificate chain for https://sha256.tbs-internet.com 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC -----BEGIN CERTIFICATE----- MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0 LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49 IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0 UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN 21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q -----END CERTIFICATE----- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root -----BEGIN CERTIFICATE----- MIIFVjCCBD6gAwIBAgIQXpDZ0ETJMV02WTx3GTnhhTANBgkqhkiG9w0BAQUFADBv MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDYyNDE5MDYzMFow gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg Q0EgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgOkO3f7wzN6 rOjg45tR5vjBfzK7qmV9IBxb/QW9EEXxG+E7FNhZqQLtwGBKoSsHTnQqV75wWMk0 9tinWvftBkSpj5sTi/8cbzJfUvTSVYh3Qxv6AVVjMMH/ruLjE6y+4PoaPs8WoYAQ ts5R4Z1g8c/WnTepLst2x0/Wv7GmuoQi+gXvHU6YrBiu7XkeYhzc95QdviWSJRDk owhb5K43qhcvjRmBfO/paGlCliDGZp8mHwrI21mwobWpVjTxZRwYO3bd4+TGcI4G Ie5wmHwE8F7SK1tgSqbBacKjDa93j7txKkfz/Yd2n7TGqOXiHPsJpG655vrKtnXk 9vs1zoDeJQIDAQABo4IBljCCAZIwHQYDVR0OBBYEFAdEdoWTKLx/bXjSCuv6TEvf 2YIfMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMCAGA1UdJQQZ MBcGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAYBgNVHSAEETAPMA0GCysGAQQBgOU3 AgQBMHsGA1UdHwR0MHIwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL0Fk ZFRydXN0RXh0ZXJuYWxDQVJvb3QuY3JsMDagNKAyhjBodHRwOi8vY3JsLmNvbW9k by5uZXQvQWRkVHJ1c3RFeHRlcm5hbENBUm9vdC5jcmwwgYAGCCsGAQUFBwEBBHQw cjA4BggrBgEFBQcwAoYsaHR0cDovL2NydC5jb21vZG9jYS5jb20vQWRkVHJ1c3RV VE5TR0NDQS5jcnQwNgYIKwYBBQUHMAKGKmh0dHA6Ly9jcnQuY29tb2RvLm5ldC9B ZGRUcnVzdFVUTlNHQ0NBLmNydDARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcN AQEFBQADggEBAK2zEzs+jcIrVK9oDkdDZNvhuBYTdCfpxfFs+OAujW0bIfJAy232 euVsnJm6u/+OrqKudD2tad2BbejLLXhMZViaCmK7D9nrXHx4te5EP8rL19SUVqLY 1pTnv5dhNgEgvA7n5lIzDSYs7yRLsr7HJsYPr6SeYSuZizyX1SNz7ooJ32/F3X98 RB0Mlc/E0OyOrkQ9/y5IrnpnaSora8CnUrV5XNOg+kyCz9edCyx4D5wXYcwZPVWz 8aDqquESrezPyjtfi4WRO4s/VD3HLZvOxzMrWAVYCDG9FxaOhF0QGuuG1F7F3GKV v6prNyCl016kRl2j1UT+a7gLd8fA25A4C9E= -----END CERTIFICATE----- 2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEZjCCA06gAwIBAgIQUSYKkxzif5zDpV954HKugjANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw0wNTA2MDcwODA5MTBaFw0xOTA2MjQxOTA2MzBaMG8xCzAJBgNVBAYT AlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0 ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB IFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39xoz5vIABC05 4E5b7R+8bA/Ntfojts7emxEzl6QpTH2Tn71KvJPtAxrjj8/lbVBa1pcplFqAsEl6 2y6V/bjKvzc4LR4+kUGtcFbH8E8/6DKedMrIkFTpxl8PeJ2aQDwOrGGqXhSPnoeh alDc15pOrwWzpnGUnHGzUGAKxxOdOAeGAqjpqGkmGJCrTLBPI6s6T4TY386f4Wlv u9dC12tE5Met7m1BX3JacQg3s3llpFmglDf3AC8NwpJy2tA4ctsUqEXEXSp9t7TW xO6szRNEt8kr3UMAJfphuWlqWCMRt6czj1Z1WfXNKddGtworZbbTQm8Vsrh7++/p XVPVNFonAgMBAAGjgdgwgdUwHwYDVR0jBBgwFoAUUzLRs89/+uDxoF2FTpLSnkUd tE8wHQYDVR0OBBYEFK29mHo0tCb3+sQmVO8DveAky1QaMA4GA1UdDwEB/wQEAwIB BjAPBgNVHRMBAf8EBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIBAjAgBgNVHSUEGTAX BgorBgEEAYI3CgMDBglghkgBhvhCBAEwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDov L2NybC51c2VydHJ1c3QuY29tL1VUTi1EQVRBQ29ycFNHQy5jcmwwDQYJKoZIhvcN AQEFBQADggEBAMbuUxdoFLJRIh6QWA2U/b3xcOWGLcM2MY9USEbnLQg3vGwKYOEO rVE04BKT6b64q7gmtOmWPSiPrmQH/uAB7MXjkesYoPF1ftsK5p+R26+udd8jkWjd FwBaS/9kbHDrARrQkNnHptZt9hPk/7XJ0h4qy7ElQyZ42TCbTg0evmnv3+r+LbPM +bDdtRTKkdSytaX7ARmjR3mfnYyVhzT4HziS2jamEfpr62vp3EV4FTkG101B5CHI 3C+H0be/SGB1pWLLJN47YaApIKa+xWycxOkKaSLvkTr6Jq/RW0GnOuL4OAdCq8Fb +M5tug8EPzI0rNwEKNdwMBQmBsTkm5jVz3g= -----END CERTIFICATE----- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC -----BEGIN CERTIFICATE----- MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6 E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK 4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv 2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3 mfnGV/TJVTl4uix5yaaIK/QI -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/ssl_cert.pem0000644000076500000000000000154312666555342020370 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7 6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1 CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX -----END CERTIFICATE----- gevent-1.1.0/greentest/3.5/ssl_key.passwd.pem0000644000076500000000000000170312666555342021521 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,1A8D9D2A02EC698A kJYbfZ8L0sfe9Oty3gw0aloNnY5E8fegRfQLZlNoxTl6jNt0nIwI8kDJ36CZgR9c u3FDJm/KqrfUoz8vW+qEnWhSG7QPX2wWGPHd4K94Yz/FgrRzZ0DoK7XxXq9gOtVA AVGQhnz32p+6WhfGsCr9ArXEwRZrTk/FvzEPaU5fHcoSkrNVAGX8IpSVkSDwEDQr Gv17+cfk99UV1OCza6yKHoFkTtrC+PZU71LomBabivS2Oc4B9hYuSR2hF01wTHP+ YlWNagZOOVtNz4oKK9x9eNQpmfQXQvPPTfusexKIbKfZrMvJoxcm1gfcZ0H/wK6P 6wmXSG35qMOOztCZNtperjs1wzEBXznyK8QmLcAJBjkfarABJX9vBEzZV0OUKhy+ noORFwHTllphbmydLhu6ehLUZMHPhzAS5UN7srtpSN81eerDMy0RMUAwA7/PofX1 94Me85Q8jP0PC9ETdsJcPqLzAPETEYu0ELewKRcrdyWi+tlLFrpE5KT/s5ecbl9l 7B61U4Kfd1PIXc/siINhU3A3bYK+845YyUArUOnKf1kEox7p1RpD7yFqVT04lRTo cibNKATBusXSuBrp2G6GNuhWEOSafWCKJQAzgCYIp6ZTV2khhMUGppc/2H3CF6cO zX0KtlPVZC7hLkB6HT8SxYUwF1zqWY7+/XPPdc37MeEZ87Q3UuZwqORLY+Z0hpgt L5JXBCoklZhCAaN2GqwFLXtGiRSRFGY7xXIhbDTlE65Wv1WGGgDLMKGE1gOz3yAo 2jjG1+yAHJUdE69XTFHSqSkvaloA1W03LdMXZ9VuQJ/ySXCie6ABAQ== -----END RSA PRIVATE KEY----- gevent-1.1.0/greentest/3.5/ssl_key.pem0000644000076500000000000000162412666555342020223 0ustar jmaddenwheel00000000000000-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0 ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5 oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F 0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/ SPIXQuT8RMPDVNQ= -----END PRIVATE KEY----- gevent-1.1.0/greentest/3.5/test_selectors.py0000644000076500000000000003665412666555342021476 0ustar jmaddenwheel00000000000000import errno import os import random import selectors import signal import socket import sys from test import support from time import sleep import unittest import unittest.mock from time import monotonic as time try: import resource except ImportError: resource = None if hasattr(socket, 'socketpair'): socketpair = socket.socketpair else: def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): with socket.socket(family, type, proto) as l: l.bind((support.HOST, 0)) l.listen() c = socket.socket(family, type, proto) try: c.connect(l.getsockname()) caddr = c.getsockname() while True: a, addr = l.accept() # check that we've got the correct client if addr == caddr: return c, a a.close() except OSError: c.close() raise def find_ready_matching(ready, flag): match = [] for key, events in ready: if events & flag: match.append(key.fileobj) return match class BaseSelectorTestCase(unittest.TestCase): def make_socketpair(self): rd, wr = socketpair() self.addCleanup(rd.close) self.addCleanup(wr.close) return rd, wr def test_register(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertIsInstance(key, selectors.SelectorKey) self.assertEqual(key.fileobj, rd) self.assertEqual(key.fd, rd.fileno()) self.assertEqual(key.events, selectors.EVENT_READ) self.assertEqual(key.data, "data") # register an unknown event self.assertRaises(ValueError, s.register, 0, 999999) # register an invalid FD self.assertRaises(ValueError, s.register, -10, selectors.EVENT_READ) # register twice self.assertRaises(KeyError, s.register, rd, selectors.EVENT_READ) # register the same FD, but with a different object self.assertRaises(KeyError, s.register, rd.fileno(), selectors.EVENT_READ) def test_unregister(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.unregister(rd) # unregister an unknown file obj self.assertRaises(KeyError, s.unregister, 999999) # unregister twice self.assertRaises(KeyError, s.unregister, rd) def test_unregister_after_fd_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(r) s.unregister(w) @unittest.skipUnless(os.name == 'posix', "requires posix") def test_unregister_after_fd_close_and_reuse(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd2, wr2 = self.make_socketpair() rd.close() wr.close() os.dup2(rd2.fileno(), r) os.dup2(wr2.fileno(), w) self.addCleanup(os.close, r) self.addCleanup(os.close, w) s.unregister(r) s.unregister(w) def test_unregister_after_socket_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(rd) s.unregister(wr) def test_modify(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ) # modify events key2 = s.modify(rd, selectors.EVENT_WRITE) self.assertNotEqual(key.events, key2.events) self.assertEqual(key2, s.get_key(rd)) s.unregister(rd) # modify data d1 = object() d2 = object() key = s.register(rd, selectors.EVENT_READ, d1) key2 = s.modify(rd, selectors.EVENT_READ, d2) self.assertEqual(key.events, key2.events) self.assertNotEqual(key.data, key2.data) self.assertEqual(key2, s.get_key(rd)) self.assertEqual(key2.data, d2) # modify unknown file obj self.assertRaises(KeyError, s.modify, 999999, selectors.EVENT_READ) # modify use a shortcut d3 = object() s.register = unittest.mock.Mock() s.unregister = unittest.mock.Mock() s.modify(rd, selectors.EVENT_READ, d3) self.assertFalse(s.register.called) self.assertFalse(s.unregister.called) def test_close(self): s = self.SELECTOR() self.addCleanup(s.close) mapping = s.get_map() rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) s.close() self.assertRaises(RuntimeError, s.get_key, rd) self.assertRaises(RuntimeError, s.get_key, wr) self.assertRaises(KeyError, mapping.__getitem__, rd) self.assertRaises(KeyError, mapping.__getitem__, wr) def test_get_key(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertEqual(key, s.get_key(rd)) # unknown file obj self.assertRaises(KeyError, s.get_key, 999999) def test_get_map(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() keys = s.get_map() self.assertFalse(keys) self.assertEqual(len(keys), 0) self.assertEqual(list(keys), []) key = s.register(rd, selectors.EVENT_READ, "data") self.assertIn(rd, keys) self.assertEqual(key, keys[rd]) self.assertEqual(len(keys), 1) self.assertEqual(list(keys), [rd.fileno()]) self.assertEqual(list(keys.values()), [key]) # unknown file obj with self.assertRaises(KeyError): keys[999999] # Read-only mapping with self.assertRaises(TypeError): del keys[rd] def test_select(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) wr_key = s.register(wr, selectors.EVENT_WRITE) result = s.select() for key, events in result: self.assertTrue(isinstance(key, selectors.SelectorKey)) self.assertTrue(events) self.assertFalse(events & ~(selectors.EVENT_READ | selectors.EVENT_WRITE)) self.assertEqual([(wr_key, selectors.EVENT_WRITE)], result) def test_context_manager(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() with s as sel: sel.register(rd, selectors.EVENT_READ) sel.register(wr, selectors.EVENT_WRITE) self.assertRaises(RuntimeError, s.get_key, rd) self.assertRaises(RuntimeError, s.get_key, wr) def test_fileno(self): s = self.SELECTOR() self.addCleanup(s.close) if hasattr(s, 'fileno'): fd = s.fileno() self.assertTrue(isinstance(fd, int)) self.assertGreaterEqual(fd, 0) def test_selector(self): s = self.SELECTOR() self.addCleanup(s.close) NUM_SOCKETS = 12 MSG = b" This is a test." MSG_LEN = len(MSG) readers = [] writers = [] r2w = {} w2r = {} for i in range(NUM_SOCKETS): rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) readers.append(rd) writers.append(wr) r2w[rd] = wr w2r[wr] = rd bufs = [] while writers: ready = s.select() ready_writers = find_ready_matching(ready, selectors.EVENT_WRITE) if not ready_writers: self.fail("no sockets ready for writing") wr = random.choice(ready_writers) wr.send(MSG) for i in range(10): ready = s.select() ready_readers = find_ready_matching(ready, selectors.EVENT_READ) if ready_readers: break # there might be a delay between the write to the write end and # the read end is reported ready sleep(0.1) else: self.fail("no sockets ready for reading") self.assertEqual([w2r[wr]], ready_readers) rd = ready_readers[0] buf = rd.recv(MSG_LEN) self.assertEqual(len(buf), MSG_LEN) bufs.append(buf) s.unregister(r2w[rd]) s.unregister(rd) writers.remove(r2w[rd]) self.assertEqual(bufs, [MSG] * NUM_SOCKETS) @unittest.skipIf(sys.platform == 'win32', 'select.select() cannot be used with empty fd sets') def test_empty_select(self): # Issue #23009: Make sure EpollSelector.select() works when no FD is # registered. s = self.SELECTOR() self.addCleanup(s.close) self.assertEqual(s.select(timeout=0), []) def test_timeout(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(wr, selectors.EVENT_WRITE) t = time() self.assertEqual(1, len(s.select(0))) self.assertEqual(1, len(s.select(-1))) self.assertLess(time() - t, 0.5) s.unregister(wr) s.register(rd, selectors.EVENT_READ) t = time() self.assertFalse(s.select(0)) self.assertFalse(s.select(-1)) self.assertLess(time() - t, 0.5) t0 = time() self.assertFalse(s.select(1)) t1 = time() dt = t1 - t0 # Tolerate 2.0 seconds for very slow buildbots self.assertTrue(0.8 <= dt <= 2.0, dt) @unittest.skipUnless(hasattr(signal, "alarm"), "signal.alarm() required for this test") def test_select_interrupt_exc(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() class InterruptSelect(Exception): pass def handler(*args): raise InterruptSelect orig_alrm_handler = signal.signal(signal.SIGALRM, handler) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) self.addCleanup(signal.alarm, 0) signal.alarm(1) s.register(rd, selectors.EVENT_READ) t = time() # select() is interrupted by a signal which raises an exception with self.assertRaises(InterruptSelect): s.select(30) # select() was interrupted before the timeout of 30 seconds self.assertLess(time() - t, 5.0) @unittest.skipUnless(hasattr(signal, "alarm"), "signal.alarm() required for this test") def test_select_interrupt_noraise(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() orig_alrm_handler = signal.signal(signal.SIGALRM, lambda *args: None) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) self.addCleanup(signal.alarm, 0) signal.alarm(1) s.register(rd, selectors.EVENT_READ) t = time() # select() is interrupted by a signal, but the signal handler doesn't # raise an exception, so select() should by retries with a recomputed # timeout self.assertFalse(s.select(1.5)) self.assertGreaterEqual(time() - t, 1.0) class ScalableSelectorMixIn: # see issue #18963 for why it's skipped on older OS X versions @support.requires_mac_ver(10, 5) @unittest.skipUnless(resource, "Test needs resource module") def test_above_fd_setsize(self): # A scalable implementation should have no problem with more than # FD_SETSIZE file descriptors. Since we don't know the value, we just # try to set the soft RLIMIT_NOFILE to the hard RLIMIT_NOFILE ceiling. soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) try: resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard)) self.addCleanup(resource.setrlimit, resource.RLIMIT_NOFILE, (soft, hard)) NUM_FDS = min(hard, 2**16) except (OSError, ValueError): NUM_FDS = soft # guard for already allocated FDs (stdin, stdout...) NUM_FDS -= 32 s = self.SELECTOR() self.addCleanup(s.close) for i in range(NUM_FDS // 2): try: rd, wr = self.make_socketpair() except OSError: # too many FDs, skip - note that we should only catch EMFILE # here, but apparently *BSD and Solaris can fail upon connect() # or bind() with EADDRNOTAVAIL, so let's be safe self.skipTest("FD limit reached") try: s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) except OSError as e: if e.errno == errno.ENOSPC: # this can be raised by epoll if we go over # fs.epoll.max_user_watches sysctl self.skipTest("FD limit reached") raise self.assertEqual(NUM_FDS // 2, len(s.select())) class DefaultSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.DefaultSelector class SelectSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.SelectSelector @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") class PollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'PollSelector', None) @unittest.skipUnless(hasattr(selectors, 'EpollSelector'), "Test needs selectors.EpollSelector") class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'EpollSelector', None) @unittest.skipUnless(hasattr(selectors, 'KqueueSelector'), "Test needs selectors.KqueueSelector)") class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'KqueueSelector', None) @unittest.skipUnless(hasattr(selectors, 'DevpollSelector'), "Test needs selectors.DevpollSelector") class DevpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'DevpollSelector', None) def test_main(): tests = [DefaultSelectorTestCase, SelectSelectorTestCase, PollSelectorTestCase, EpollSelectorTestCase, KqueueSelectorTestCase, DevpollSelectorTestCase] support.run_unittest(*tests) support.reap_children() if __name__ == "__main__": test_main() gevent-1.1.0/greentest/3.5/test_socket.py0000644000076500000000000061170112666555342020753 0ustar jmaddenwheel00000000000000import unittest from test import support import errno import io import itertools import socket import select import tempfile import time import traceback import queue import sys import os import array import platform import contextlib from weakref import proxy import signal import math import pickle import struct import random import string try: import multiprocessing except ImportError: multiprocessing = False try: import fcntl except ImportError: fcntl = None HOST = support.HOST MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ## test unicode string and carriage return try: import _thread as thread import threading except ImportError: thread = None threading = None try: import _socket except ImportError: _socket = None def _have_socket_can(): """Check whether CAN sockets are supported on this host.""" try: s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) except (AttributeError, OSError): return False else: s.close() return True def _have_socket_rds(): """Check whether RDS sockets are supported on this host.""" try: s = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) except (AttributeError, OSError): return False else: s.close() return True HAVE_SOCKET_CAN = _have_socket_can() HAVE_SOCKET_RDS = _have_socket_rds() # Size in bytes of the int type SIZEOF_INT = array.array("i").itemsize class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.serv) self.serv.listen() def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadSafeCleanupTestCase(unittest.TestCase): """Subclass of unittest.TestCase with thread-safe cleanup methods. This subclass protects the addCleanup() and doCleanups() methods with a recursive lock. """ if threading: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._cleanup_lock = threading.RLock() def addCleanup(self, *args, **kwargs): with self._cleanup_lock: return super().addCleanup(*args, **kwargs) def doCleanups(self, *args, **kwargs): with self._cleanup_lock: return super().doCleanups(*args, **kwargs) class SocketCANTest(unittest.TestCase): """To be able to run this test, a `vcan0` CAN interface can be created with the following commands: # modprobe vcan # ip link add dev vcan0 type vcan # ifconfig vcan0 up """ interface = 'vcan0' bufsize = 128 """The CAN frame structure is defined in : struct can_frame { canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ __u8 can_dlc; /* data length code: 0 .. 8 */ __u8 data[8] __attribute__((aligned(8))); }; """ can_frame_fmt = "=IB3x8s" can_frame_size = struct.calcsize(can_frame_fmt) """The Broadcast Management Command frame structure is defined in : struct bcm_msg_head { __u32 opcode; __u32 flags; __u32 count; struct timeval ival1, ival2; canid_t can_id; __u32 nframes; struct can_frame frames[0]; } `bcm_msg_head` must be 8 bytes aligned because of the `frames` member (see `struct can_frame` definition). Must use native not standard types for packing. """ bcm_cmd_msg_fmt = "@3I4l2I" bcm_cmd_msg_fmt += "x" * (struct.calcsize(bcm_cmd_msg_fmt) % 8) def setUp(self): self.s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) self.addCleanup(self.s.close) try: self.s.bind((self.interface,)) except OSError: self.skipTest('network interface `%s` does not exist' % self.interface) class SocketRDSTest(unittest.TestCase): """To be able to run this test, the `rds` kernel module must be loaded: # modprobe rds """ bufsize = 8192 def setUp(self): self.serv = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) self.addCleanup(self.serv.close) try: self.port = support.bind_port(self.serv) except OSError: self.skipTest('unable to bind RDS socket') class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceeded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = queue.Queue(1) self.server_crashed = False # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) try: self.__setUp() except: self.server_crashed = True raise finally: self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() if self.queue.qsize(): exc = self.queue.get() raise exc def clientRun(self, test_func): self.server_ready.wait() self.clientSetUp() self.client_ready.set() if self.server_crashed: self.clientTearDown() return if not hasattr(test_func, '__call__'): raise TypeError("test_func must be a callable function") try: test_func() except BaseException as e: self.queue.put(e) finally: self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedCANSocketTest(SocketCANTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketCANTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) try: self.cli.bind((self.interface,)) except OSError: # skipTest should not be called here, and will be called in the # server instead pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedRDSSocketTest(SocketRDSTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketRDSTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) try: # RDS sockets must be bound explicitly to send or receive data self.cli.bind((HOST, 0)) self.cli_addr = self.cli.getsockname() except OSError: # skipTest should not be called here, and will be called in the # server instead pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class SocketConnectedTest(ThreadedTCPSocketTest): """Socket tests for client-server connection. self.cli_conn is a client socket connected to the server. The setUp() method guarantees that it is connected to the server. """ def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) # The following classes are used by the sendmsg()/recvmsg() tests. # Combining, for instance, ConnectedStreamTestMixin and TCPTestBase # gives a drop-in replacement for SocketConnectedTest, but different # address families can be used, and the attributes serv_addr and # cli_addr will be set to the addresses of the endpoints. class SocketTestBase(unittest.TestCase): """A base class for socket tests. Subclasses must provide methods newSocket() to return a new socket and bindSock(sock) to bind it to an unused address. Creates a socket self.serv and sets self.serv_addr to its address. """ def setUp(self): self.serv = self.newSocket() self.bindServer() def bindServer(self): """Bind server socket and set self.serv_addr to its address.""" self.bindSock(self.serv) self.serv_addr = self.serv.getsockname() def tearDown(self): self.serv.close() self.serv = None class SocketListeningTestMixin(SocketTestBase): """Mixin to listen on the server socket.""" def setUp(self): super().setUp() self.serv.listen() class ThreadedSocketTestMixin(ThreadSafeCleanupTestCase, SocketTestBase, ThreadableTest): """Mixin to add client socket and allow client/server tests. Client socket is self.cli and its address is self.cli_addr. See ThreadableTest for usage information. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = self.newClientSocket() self.bindClient() def newClientSocket(self): """Return a new socket for use as client.""" return self.newSocket() def bindClient(self): """Bind client socket and set self.cli_addr to its address.""" self.bindSock(self.cli) self.cli_addr = self.cli.getsockname() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ConnectedStreamTestMixin(SocketListeningTestMixin, ThreadedSocketTestMixin): """Mixin to allow client/server stream tests with connected client. Server's socket representing connection to client is self.cli_conn and client's connection to server is self.serv_conn. (Based on SocketConnectedTest.) """ def setUp(self): super().setUp() # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None super().tearDown() def clientSetUp(self): super().clientSetUp() self.cli.connect(self.serv_addr) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None super().clientTearDown() class UnixSocketTestBase(SocketTestBase): """Base class for Unix-domain socket tests.""" # This class is used for file descriptor passing tests, so we # create the sockets in a private directory so that other users # can't send anything that might be problematic for a privileged # user running the tests. def setUp(self): self.dir_path = tempfile.mkdtemp() self.addCleanup(os.rmdir, self.dir_path) super().setUp() def bindSock(self, sock): path = tempfile.mktemp(dir=self.dir_path) sock.bind(path) self.addCleanup(support.unlink, path) class UnixStreamBase(UnixSocketTestBase): """Base class for Unix-domain SOCK_STREAM tests.""" def newSocket(self): return socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) class InetTestBase(SocketTestBase): """Base class for IPv4 socket tests.""" host = HOST def setUp(self): super().setUp() self.port = self.serv_addr[1] def bindSock(self, sock): support.bind_port(sock, host=self.host) class TCPTestBase(InetTestBase): """Base class for TCP-over-IPv4 tests.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_STREAM) class UDPTestBase(InetTestBase): """Base class for UDP-over-IPv4 tests.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_DGRAM) class SCTPStreamBase(InetTestBase): """Base class for SCTP tests in one-to-one (SOCK_STREAM) mode.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SCTP) class Inet6TestBase(InetTestBase): """Base class for IPv6 socket tests.""" host = support.HOSTv6 class UDP6TestBase(Inet6TestBase): """Base class for UDP-over-IPv6 tests.""" def newSocket(self): return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) # Test-skipping decorators for use with ThreadableTest. def skipWithClientIf(condition, reason): """Skip decorated test if condition is true, add client_skip decorator. If the decorated object is not a class, sets its attribute "client_skip" to a decorator which will return an empty function if the test is to be skipped, or the original function if it is not. This can be used to avoid running the client part of a skipped test when using ThreadableTest. """ def client_pass(*args, **kwargs): pass def skipdec(obj): retval = unittest.skip(reason)(obj) if not isinstance(obj, type): retval.client_skip = lambda f: client_pass return retval def noskipdec(obj): if not (isinstance(obj, type) or hasattr(obj, "client_skip")): obj.client_skip = lambda f: f return obj return skipdec if condition else noskipdec def requireAttrs(obj, *attributes): """Skip decorated test if obj is missing any of the given attributes. Sets client_skip attribute as skipWithClientIf() does. """ missing = [name for name in attributes if not hasattr(obj, name)] return skipWithClientIf( missing, "don't have " + ", ".join(name for name in missing)) def requireSocket(*args): """Skip decorated test if a socket cannot be created with given arguments. When an argument is given as a string, will use the value of that attribute of the socket module, or skip the test if it doesn't exist. Sets client_skip attribute as skipWithClientIf() does. """ err = None missing = [obj for obj in args if isinstance(obj, str) and not hasattr(socket, obj)] if missing: err = "don't have " + ", ".join(name for name in missing) else: callargs = [getattr(socket, obj) if isinstance(obj, str) else obj for obj in args] try: s = socket.socket(*callargs) except OSError as e: # XXX: check errno? err = str(e) else: s.close() return skipWithClientIf( err is not None, "can't create socket({0}): {1}".format( ", ".join(str(o) for o in args), err)) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): def test_SocketType_is_socketobject(self): import _socket self.assertTrue(socket.SocketType is _socket.socket) s = socket.socket() self.assertIsInstance(s, socket.SocketType) s.close() def test_repr(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) with s: self.assertIn('fd=%i' % s.fileno(), repr(s)) self.assertIn('family=%s' % socket.AF_INET, repr(s)) self.assertIn('type=%s' % socket.SOCK_STREAM, repr(s)) self.assertIn('proto=0', repr(s)) self.assertNotIn('raddr', repr(s)) s.bind(('127.0.0.1', 0)) self.assertIn('laddr', repr(s)) self.assertIn(str(s.getsockname()), repr(s)) self.assertIn('[closed]', repr(s)) self.assertNotIn('laddr', repr(s)) @unittest.skipUnless(_socket is not None, 'need _socket module') def test_csocket_repr(self): s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) try: expected = ('' % (s.fileno(), s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) finally: s.close() expected = ('' % (s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def testSocketError(self): # Testing socket module exceptions msg = "Error raising socket exception (%s)." with self.assertRaises(OSError, msg=msg % 'OSError'): raise OSError with self.assertRaises(OSError, msg=msg % 'socket.herror'): raise socket.herror with self.assertRaises(OSError, msg=msg % 'socket.gaierror'): raise socket.gaierror def testSendtoErrors(self): # Testing that sendto doesn't masks failures. See #10169. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) s.bind(('', 0)) sockname = s.getsockname() # 2 args with self.assertRaises(TypeError) as cm: s.sendto('\u2620', sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'str'") with self.assertRaises(TypeError) as cm: s.sendto(5j, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', None) self.assertIn('not NoneType',str(cm.exception)) # 3 args with self.assertRaises(TypeError) as cm: s.sendto('\u2620', 0, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'str'") with self.assertRaises(TypeError) as cm: s.sendto(5j, 0, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 0, None) self.assertIn('not NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 'bar', sockname) self.assertIn('an integer is required', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', None, None) self.assertIn('an integer is required', str(cm.exception)) # wrong number of args with self.assertRaises(TypeError) as cm: s.sendto(b'foo') self.assertIn('(1 given)', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 0, sockname, 4) self.assertIn('(4 given)', str(cm.exception)) def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except OSError: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except OSError: # Probably a similar problem as above; skip this test self.skipTest('name lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) def test_host_resolution(self): for addr in ['0.1.1.~1', '1+.1.1.1', '::1q', '::1::2', '1:1:1:1:1:1:1:1:1']: self.assertRaises(OSError, socket.gethostbyname, addr) self.assertRaises(OSError, socket.gethostbyaddr, addr) for addr in [support.HOST, '10.0.0.1', '255.255.255.255']: self.assertEqual(socket.gethostbyname(addr), addr) # we don't test support.HOSTv6 because there's a chance it doesn't have # a matching name entry (e.g. 'ip6-localhost') for host in [support.HOST]: self.assertIn(host, socket.gethostbyaddr(host)[2]) @unittest.skipUnless(hasattr(socket, 'sethostname'), "test needs socket.sethostname()") @unittest.skipUnless(hasattr(socket, 'gethostname'), "test needs socket.gethostname()") def test_sethostname(self): oldhn = socket.gethostname() try: socket.sethostname('new') except OSError as e: if e.errno == errno.EPERM: self.skipTest("test should be run as root") else: raise try: # running test as root! self.assertEqual(socket.gethostname(), 'new') # Should work with bytes objects too socket.sethostname(b'bar') self.assertEqual(socket.gethostname(), 'bar') finally: socket.sethostname(oldhn) @unittest.skipUnless(hasattr(socket, 'if_nameindex'), 'socket.if_nameindex() not available.') def testInterfaceNameIndex(self): interfaces = socket.if_nameindex() for index, name in interfaces: self.assertIsInstance(index, int) self.assertIsInstance(name, str) # interface indices are non-zero integers self.assertGreater(index, 0) _index = socket.if_nametoindex(name) self.assertIsInstance(_index, int) self.assertEqual(index, _index) _name = socket.if_indextoname(index) self.assertIsInstance(_name, str) self.assertEqual(name, _name) @unittest.skipUnless(hasattr(socket, 'if_nameindex'), 'socket.if_nameindex() not available.') def testInvalidInterfaceNameIndex(self): # test nonexistent interface index/name self.assertRaises(OSError, socket.if_indextoname, 0) self.assertRaises(OSError, socket.if_nametoindex, '_DEADBEEF') # test with invalid values self.assertRaises(TypeError, socket.if_nametoindex, 0) self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF') @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: if sys.getrefcount(__name__) != orig: self.fail("socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except OSError: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1<") def test_unusable_closed_socketio(self): with socket.socket() as sock: fp = sock.makefile("rb", buffering=0) self.assertTrue(fp.readable()) self.assertFalse(fp.writable()) self.assertFalse(fp.seekable()) fp.close() self.assertRaises(ValueError, fp.readable) self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.seekable) def test_pickle(self): sock = socket.socket() with sock: for protocol in range(pickle.HIGHEST_PROTOCOL + 1): self.assertRaises(TypeError, pickle.dumps, sock, protocol) for protocol in range(pickle.HIGHEST_PROTOCOL + 1): family = pickle.loads(pickle.dumps(socket.AF_INET, protocol)) self.assertEqual(family, socket.AF_INET) type = pickle.loads(pickle.dumps(socket.SOCK_STREAM, protocol)) self.assertEqual(type, socket.SOCK_STREAM) def test_listen_backlog(self): for backlog in 0, -1: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv: srv.bind((HOST, 0)) srv.listen(backlog) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv: srv.bind((HOST, 0)) srv.listen() @support.cpython_only def test_listen_backlog_overflow(self): # Issue 15989 import _testcapi srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') def test_flowinfo(self): self.assertRaises(OverflowError, socket.getnameinfo, (support.HOSTv6, 0, 0xffffffff), 0) with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s: self.assertRaises(OverflowError, s.bind, (support.HOSTv6, 0, -10)) def test_str_for_enums(self): # Make sure that the AF_* and SOCK_* constants have enum-like string # reprs. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: self.assertEqual(str(s.family), 'AddressFamily.AF_INET') self.assertEqual(str(s.type), 'SocketKind.SOCK_STREAM') @unittest.skipIf(os.name == 'nt', 'Will not work on Windows') def test_uknown_socket_family_repr(self): # Test that when created with a family that's not one of the known # AF_*/SOCK_* constants, socket.family just returns the number. # # To do this we fool socket.socket into believing it already has an # open fd because on this path it doesn't actually verify the family and # type and populates the socket object. # # On Windows this trick won't work, so the test is skipped. fd, _ = tempfile.mkstemp() with socket.socket(family=42424, type=13331, fileno=fd) as s: self.assertEqual(s.family, 42424) self.assertEqual(s.type, 13331) @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') class BasicCANTest(unittest.TestCase): def testCrucialConstants(self): socket.AF_CAN socket.PF_CAN socket.CAN_RAW @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testBCMConstants(self): socket.CAN_BCM # opcodes socket.CAN_BCM_TX_SETUP # create (cyclic) transmission task socket.CAN_BCM_TX_DELETE # remove (cyclic) transmission task socket.CAN_BCM_TX_READ # read properties of (cyclic) transmission task socket.CAN_BCM_TX_SEND # send one CAN frame socket.CAN_BCM_RX_SETUP # create RX content filter subscription socket.CAN_BCM_RX_DELETE # remove RX content filter subscription socket.CAN_BCM_RX_READ # read properties of RX content filter subscription socket.CAN_BCM_TX_STATUS # reply to TX_READ request socket.CAN_BCM_TX_EXPIRED # notification on performed transmissions (count=0) socket.CAN_BCM_RX_STATUS # reply to RX_READ request socket.CAN_BCM_RX_TIMEOUT # cyclic message is absent socket.CAN_BCM_RX_CHANGED # updated CAN frame (detected content change) def testCreateSocket(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: pass @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testCreateBCMSocket(self): with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) as s: pass def testBindAny(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: s.bind(('', )) def testTooLongInterfaceName(self): # most systems limit IFNAMSIZ to 16, take 1024 to be sure with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: self.assertRaisesRegex(OSError, 'interface name too long', s.bind, ('x' * 1024,)) @unittest.skipUnless(hasattr(socket, "CAN_RAW_LOOPBACK"), 'socket.CAN_RAW_LOOPBACK required for this test.') def testLoopback(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: for loopback in (0, 1): s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_LOOPBACK, loopback) self.assertEqual(loopback, s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_LOOPBACK)) @unittest.skipUnless(hasattr(socket, "CAN_RAW_FILTER"), 'socket.CAN_RAW_FILTER required for this test.') def testFilter(self): can_id, can_mask = 0x200, 0x700 can_filter = struct.pack("=II", can_id, can_mask) with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, can_filter) self.assertEqual(can_filter, s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, 8)) s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, bytearray(can_filter)) @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') @unittest.skipUnless(thread, 'Threading required for this test.') class CANTest(ThreadedCANSocketTest): def __init__(self, methodName='runTest'): ThreadedCANSocketTest.__init__(self, methodName=methodName) @classmethod def build_can_frame(cls, can_id, data): """Build a CAN frame.""" can_dlc = len(data) data = data.ljust(8, b'\x00') return struct.pack(cls.can_frame_fmt, can_id, can_dlc, data) @classmethod def dissect_can_frame(cls, frame): """Dissect a CAN frame.""" can_id, can_dlc, data = struct.unpack(cls.can_frame_fmt, frame) return (can_id, can_dlc, data[:can_dlc]) def testSendFrame(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) self.assertEqual(addr[0], self.interface) self.assertEqual(addr[1], socket.AF_CAN) def _testSendFrame(self): self.cf = self.build_can_frame(0x00, b'\x01\x02\x03\x04\x05') self.cli.send(self.cf) def testSendMaxFrame(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) def _testSendMaxFrame(self): self.cf = self.build_can_frame(0x00, b'\x07' * 8) self.cli.send(self.cf) def testSendMultiFrames(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf1, cf) cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf2, cf) def _testSendMultiFrames(self): self.cf1 = self.build_can_frame(0x07, b'\x44\x33\x22\x11') self.cli.send(self.cf1) self.cf2 = self.build_can_frame(0x12, b'\x99\x22\x33') self.cli.send(self.cf2) @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def _testBCM(self): cf, addr = self.cli.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) can_id, can_dlc, data = self.dissect_can_frame(cf) self.assertEqual(self.can_id, can_id) self.assertEqual(self.data, data) @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testBCM(self): bcm = socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) self.addCleanup(bcm.close) bcm.connect((self.interface,)) self.can_id = 0x123 self.data = bytes([0xc0, 0xff, 0xee]) self.cf = self.build_can_frame(self.can_id, self.data) opcode = socket.CAN_BCM_TX_SEND flags = 0 count = 0 ival1_seconds = ival1_usec = ival2_seconds = ival2_usec = 0 bcm_can_id = 0x0222 nframes = 1 assert len(self.cf) == 16 header = struct.pack(self.bcm_cmd_msg_fmt, opcode, flags, count, ival1_seconds, ival1_usec, ival2_seconds, ival2_usec, bcm_can_id, nframes, ) header_plus_frame = header + self.cf bytes_sent = bcm.send(header_plus_frame) self.assertEqual(bytes_sent, len(header_plus_frame)) @unittest.skipUnless(HAVE_SOCKET_RDS, 'RDS sockets required for this test.') class BasicRDSTest(unittest.TestCase): def testCrucialConstants(self): socket.AF_RDS socket.PF_RDS def testCreateSocket(self): with socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) as s: pass def testSocketBufferSize(self): bufsize = 16384 with socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, bufsize) s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, bufsize) @unittest.skipUnless(HAVE_SOCKET_RDS, 'RDS sockets required for this test.') @unittest.skipUnless(thread, 'Threading required for this test.') class RDSTest(ThreadedRDSSocketTest): def __init__(self, methodName='runTest'): ThreadedRDSSocketTest.__init__(self, methodName=methodName) def setUp(self): super().setUp() self.evt = threading.Event() def testSendAndRecv(self): data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) self.assertEqual(self.cli_addr, addr) def _testSendAndRecv(self): self.data = b'spam' self.cli.sendto(self.data, 0, (HOST, self.port)) def testPeek(self): data, addr = self.serv.recvfrom(self.bufsize, socket.MSG_PEEK) self.assertEqual(self.data, data) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) def _testPeek(self): self.data = b'spam' self.cli.sendto(self.data, 0, (HOST, self.port)) @requireAttrs(socket.socket, 'recvmsg') def testSendAndRecvMsg(self): data, ancdata, msg_flags, addr = self.serv.recvmsg(self.bufsize) self.assertEqual(self.data, data) @requireAttrs(socket.socket, 'sendmsg') def _testSendAndRecvMsg(self): self.data = b'hello ' * 10 self.cli.sendmsg([self.data], (), 0, (HOST, self.port)) def testSendAndRecvMulti(self): data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data1, data) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data2, data) def _testSendAndRecvMulti(self): self.data1 = b'bacon' self.cli.sendto(self.data1, 0, (HOST, self.port)) self.data2 = b'egg' self.cli.sendto(self.data2, 0, (HOST, self.port)) def testSelect(self): r, w, x = select.select([self.serv], [], [], 3.0) self.assertIn(self.serv, r) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) def _testSelect(self): self.data = b'select' self.cli.sendto(self.data, 0, (HOST, self.port)) def testCongestion(self): # wait until the sender is done self.evt.wait() def _testCongestion(self): # test the behavior in case of congestion self.data = b'fill' self.cli.setblocking(False) try: # try to lower the receiver's socket buffer size self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 16384) except OSError: pass with self.assertRaises(OSError) as cm: try: # fill the receiver's socket buffer while True: self.cli.sendto(self.data, 0, (HOST, self.port)) finally: # signal the receiver we're done self.evt.set() # sendto() should have failed with ENOBUFS self.assertEqual(cm.exception.errno, errno.ENOBUFS) # and we should have received a congestion notification through poll r, w, x = select.select([self.serv], [], [], 3.0) self.assertIn(self.serv, r) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicTCPTest(SocketConnectedTest): def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecv(self): # Testing large receive over TCP msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.serv_conn.send(MSG) def testOverFlowRecv(self): # Testing receive in chunks over TCP seg1 = self.cli_conn.recv(len(MSG) - 3) seg2 = self.cli_conn.recv(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecv(self): self.serv_conn.send(MSG) def testRecvFrom(self): # Testing large recvfrom() over TCP msg, addr = self.cli_conn.recvfrom(1024) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.serv_conn.send(MSG) def testOverFlowRecvFrom(self): # Testing recvfrom() in chunks over TCP seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) seg2, addr = self.cli_conn.recvfrom(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecvFrom(self): self.serv_conn.send(MSG) def testSendAll(self): # Testing sendall() with a 2048 byte string over TCP msg = b'' while 1: read = self.cli_conn.recv(1024) if not read: break msg += read self.assertEqual(msg, b'f' * 2048) def _testSendAll(self): big_chunk = b'f' * 2048 self.serv_conn.sendall(big_chunk) def testFromFd(self): # Testing fromfd() fd = self.cli_conn.fileno() sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) self.assertIsInstance(sock, socket.socket) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testFromFd(self): self.serv_conn.send(MSG) def testDup(self): # Testing dup() sock = self.cli_conn.dup() self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testDup(self): self.serv_conn.send(MSG) def testShutdown(self): # Testing shutdown() msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) # wait for _testShutdown to finish: on OS X, when the server # closes the connection the client also becomes disconnected, # and the client's shutdown call will fail. (Issue #4397.) self.done.wait() def _testShutdown(self): self.serv_conn.send(MSG) self.serv_conn.shutdown(2) testShutdown_overflow = support.cpython_only(testShutdown) @support.cpython_only def _testShutdown_overflow(self): import _testcapi self.serv_conn.send(MSG) # Issue 15989 self.assertRaises(OverflowError, self.serv_conn.shutdown, _testcapi.INT_MAX + 1) self.assertRaises(OverflowError, self.serv_conn.shutdown, 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) def testDetach(self): # Testing detach() fileno = self.cli_conn.fileno() f = self.cli_conn.detach() self.assertEqual(f, fileno) # cli_conn cannot be used anymore... self.assertTrue(self.cli_conn._closed) self.assertRaises(OSError, self.cli_conn.recv, 1024) self.cli_conn.close() # ...but we can create another socket using the (still open) # file descriptor sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f) self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testDetach(self): self.serv_conn.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicUDPTest(ThreadedUDPSocketTest): def __init__(self, methodName='runTest'): ThreadedUDPSocketTest.__init__(self, methodName=methodName) def testSendtoAndRecv(self): # Testing sendto() and Recv() over UDP msg = self.serv.recv(len(MSG)) self.assertEqual(msg, MSG) def _testSendtoAndRecv(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFrom(self): # Testing recvfrom() over UDP msg, addr = self.serv.recvfrom(len(MSG)) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFromNegative(self): # Negative lengths passed to recvfrom should give ValueError. self.assertRaises(ValueError, self.serv.recvfrom, -1) def _testRecvFromNegative(self): self.cli.sendto(MSG, 0, (HOST, self.port)) # Tests for the sendmsg()/recvmsg() interface. Where possible, the # same test code is used with different families and types of socket # (e.g. stream, datagram), and tests using recvmsg() are repeated # using recvmsg_into(). # # The generic test classes such as SendmsgTests and # RecvmsgGenericTests inherit from SendrecvmsgBase and expect to be # supplied with sockets cli_sock and serv_sock representing the # client's and the server's end of the connection respectively, and # attributes cli_addr and serv_addr holding their (numeric where # appropriate) addresses. # # The final concrete test classes combine these with subclasses of # SocketTestBase which set up client and server sockets of a specific # type, and with subclasses of SendrecvmsgBase such as # SendrecvmsgDgramBase and SendrecvmsgConnectedBase which map these # sockets to cli_sock and serv_sock and override the methods and # attributes of SendrecvmsgBase to fill in destination addresses if # needed when sending, check for specific flags in msg_flags, etc. # # RecvmsgIntoMixin provides a version of doRecvmsg() implemented using # recvmsg_into(). # XXX: like the other datagram (UDP) tests in this module, the code # here assumes that datagram delivery on the local machine will be # reliable. class SendrecvmsgBase(ThreadSafeCleanupTestCase): # Base class for sendmsg()/recvmsg() tests. # Time in seconds to wait before considering a test failed, or # None for no timeout. Not all tests actually set a timeout. fail_timeout = 3.0 def setUp(self): self.misc_event = threading.Event() super().setUp() def sendToServer(self, msg): # Send msg to the server. return self.cli_sock.send(msg) # Tuple of alternative default arguments for sendmsg() when called # via sendmsgToServer() (e.g. to include a destination address). sendmsg_to_server_defaults = () def sendmsgToServer(self, *args): # Call sendmsg() on self.cli_sock with the given arguments, # filling in any arguments which are not supplied with the # corresponding items of self.sendmsg_to_server_defaults, if # any. return self.cli_sock.sendmsg( *(args + self.sendmsg_to_server_defaults[len(args):])) def doRecvmsg(self, sock, bufsize, *args): # Call recvmsg() on sock with given arguments and return its # result. Should be used for tests which can use either # recvmsg() or recvmsg_into() - RecvmsgIntoMixin overrides # this method with one which emulates it using recvmsg_into(), # thus allowing the same test to be used for both methods. result = sock.recvmsg(bufsize, *args) self.registerRecvmsgResult(result) return result def registerRecvmsgResult(self, result): # Called by doRecvmsg() with the return value of recvmsg() or # recvmsg_into(). Can be overridden to arrange cleanup based # on the returned ancillary data, for instance. pass def checkRecvmsgAddress(self, addr1, addr2): # Called to compare the received address with the address of # the peer. self.assertEqual(addr1, addr2) # Flags that are normally unset in msg_flags msg_flags_common_unset = 0 for name in ("MSG_CTRUNC", "MSG_OOB"): msg_flags_common_unset |= getattr(socket, name, 0) # Flags that are normally set msg_flags_common_set = 0 # Flags set when a complete record has been received (e.g. MSG_EOR # for SCTP) msg_flags_eor_indicator = 0 # Flags set when a complete record has not been received # (e.g. MSG_TRUNC for datagram sockets) msg_flags_non_eor_indicator = 0 def checkFlags(self, flags, eor=None, checkset=0, checkunset=0, ignore=0): # Method to check the value of msg_flags returned by recvmsg[_into](). # # Checks that all bits in msg_flags_common_set attribute are # set in "flags" and all bits in msg_flags_common_unset are # unset. # # The "eor" argument specifies whether the flags should # indicate that a full record (or datagram) has been received. # If "eor" is None, no checks are done; otherwise, checks # that: # # * if "eor" is true, all bits in msg_flags_eor_indicator are # set and all bits in msg_flags_non_eor_indicator are unset # # * if "eor" is false, all bits in msg_flags_non_eor_indicator # are set and all bits in msg_flags_eor_indicator are unset # # If "checkset" and/or "checkunset" are supplied, they require # the given bits to be set or unset respectively, overriding # what the attributes require for those bits. # # If any bits are set in "ignore", they will not be checked, # regardless of the other inputs. # # Will raise Exception if the inputs require a bit to be both # set and unset, and it is not ignored. defaultset = self.msg_flags_common_set defaultunset = self.msg_flags_common_unset if eor: defaultset |= self.msg_flags_eor_indicator defaultunset |= self.msg_flags_non_eor_indicator elif eor is not None: defaultset |= self.msg_flags_non_eor_indicator defaultunset |= self.msg_flags_eor_indicator # Function arguments override defaults defaultset &= ~checkunset defaultunset &= ~checkset # Merge arguments with remaining defaults, and check for conflicts checkset |= defaultset checkunset |= defaultunset inboth = checkset & checkunset & ~ignore if inboth: raise Exception("contradictory set, unset requirements for flags " "{0:#x}".format(inboth)) # Compare with given msg_flags value mask = (checkset | checkunset) & ~ignore self.assertEqual(flags & mask, checkset & mask) class RecvmsgIntoMixin(SendrecvmsgBase): # Mixin to implement doRecvmsg() using recvmsg_into(). def doRecvmsg(self, sock, bufsize, *args): buf = bytearray(bufsize) result = sock.recvmsg_into([buf], *args) self.registerRecvmsgResult(result) self.assertGreaterEqual(result[0], 0) self.assertLessEqual(result[0], bufsize) return (bytes(buf[:result[0]]),) + result[1:] class SendrecvmsgDgramFlagsBase(SendrecvmsgBase): # Defines flags to be checked in msg_flags for datagram sockets. @property def msg_flags_non_eor_indicator(self): return super().msg_flags_non_eor_indicator | socket.MSG_TRUNC class SendrecvmsgSCTPFlagsBase(SendrecvmsgBase): # Defines flags to be checked in msg_flags for SCTP sockets. @property def msg_flags_eor_indicator(self): return super().msg_flags_eor_indicator | socket.MSG_EOR class SendrecvmsgConnectionlessBase(SendrecvmsgBase): # Base class for tests on connectionless-mode sockets. Users must # supply sockets on attributes cli and serv to be mapped to # cli_sock and serv_sock respectively. @property def serv_sock(self): return self.serv @property def cli_sock(self): return self.cli @property def sendmsg_to_server_defaults(self): return ([], [], 0, self.serv_addr) def sendToServer(self, msg): return self.cli_sock.sendto(msg, self.serv_addr) class SendrecvmsgConnectedBase(SendrecvmsgBase): # Base class for tests on connected sockets. Users must supply # sockets on attributes serv_conn and cli_conn (representing the # connections *to* the server and the client), to be mapped to # cli_sock and serv_sock respectively. @property def serv_sock(self): return self.cli_conn @property def cli_sock(self): return self.serv_conn def checkRecvmsgAddress(self, addr1, addr2): # Address is currently "unspecified" for a connected socket, # so we don't examine it pass class SendrecvmsgServerTimeoutBase(SendrecvmsgBase): # Base class to set a timeout on server's socket. def setUp(self): super().setUp() self.serv_sock.settimeout(self.fail_timeout) class SendmsgTests(SendrecvmsgServerTimeoutBase): # Tests for sendmsg() which can use any socket type and do not # involve recvmsg() or recvmsg_into(). def testSendmsg(self): # Send a simple message with sendmsg(). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsg(self): self.assertEqual(self.sendmsgToServer([MSG]), len(MSG)) def testSendmsgDataGenerator(self): # Send from buffer obtained from a generator (not a sequence). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgDataGenerator(self): self.assertEqual(self.sendmsgToServer((o for o in [MSG])), len(MSG)) def testSendmsgAncillaryGenerator(self): # Gather (empty) ancillary data from a generator. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgAncillaryGenerator(self): self.assertEqual(self.sendmsgToServer([MSG], (o for o in [])), len(MSG)) def testSendmsgArray(self): # Send data from an array instead of the usual bytes object. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgArray(self): self.assertEqual(self.sendmsgToServer([array.array("B", MSG)]), len(MSG)) def testSendmsgGather(self): # Send message data from more than one buffer (gather write). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgGather(self): self.assertEqual(self.sendmsgToServer([MSG[:3], MSG[3:]]), len(MSG)) def testSendmsgBadArgs(self): # Check that sendmsg() rejects invalid arguments. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgBadArgs(self): self.assertRaises(TypeError, self.cli_sock.sendmsg) self.assertRaises(TypeError, self.sendmsgToServer, b"not in an iterable") self.assertRaises(TypeError, self.sendmsgToServer, object()) self.assertRaises(TypeError, self.sendmsgToServer, [object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG, object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], object()) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [], object()) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [], 0, object()) self.sendToServer(b"done") def testSendmsgBadCmsg(self): # Check that invalid ancillary data items are rejected. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgBadCmsg(self): self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(object(), 0, b"data")]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, object(), b"data")]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, object())]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0)]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, b"data", 42)]) self.sendToServer(b"done") @requireAttrs(socket, "CMSG_SPACE") def testSendmsgBadMultiCmsg(self): # Check that invalid ancillary data items are rejected when # more than one item is present. self.assertEqual(self.serv_sock.recv(1000), b"done") @testSendmsgBadMultiCmsg.client_skip def _testSendmsgBadMultiCmsg(self): self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [0, 0, b""]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, b""), object()]) self.sendToServer(b"done") def testSendmsgExcessCmsgReject(self): # Check that sendmsg() rejects excess ancillary data items # when the number that can be sent is limited. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgExcessCmsgReject(self): if not hasattr(socket, "CMSG_SPACE"): # Can only send one item with self.assertRaises(OSError) as cm: self.sendmsgToServer([MSG], [(0, 0, b""), (0, 0, b"")]) self.assertIsNone(cm.exception.errno) self.sendToServer(b"done") def testSendmsgAfterClose(self): # Check that sendmsg() fails on a closed socket. pass def _testSendmsgAfterClose(self): self.cli_sock.close() self.assertRaises(OSError, self.sendmsgToServer, [MSG]) class SendmsgStreamTests(SendmsgTests): # Tests for sendmsg() which require a stream socket and do not # involve recvmsg() or recvmsg_into(). def testSendmsgExplicitNoneAddr(self): # Check that peer address can be specified as None. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgExplicitNoneAddr(self): self.assertEqual(self.sendmsgToServer([MSG], [], 0, None), len(MSG)) def testSendmsgTimeout(self): # Check that timeout works with sendmsg(). self.assertEqual(self.serv_sock.recv(512), b"a"*512) self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) def _testSendmsgTimeout(self): try: self.cli_sock.settimeout(0.03) with self.assertRaises(socket.timeout): while True: self.sendmsgToServer([b"a"*512]) finally: self.misc_event.set() # XXX: would be nice to have more tests for sendmsg flags argument. # Linux supports MSG_DONTWAIT when sending, but in general, it # only works when receiving. Could add other platforms if they # support it too. @skipWithClientIf(sys.platform not in {"linux"}, "MSG_DONTWAIT not known to work on this platform when " "sending") def testSendmsgDontWait(self): # Check that MSG_DONTWAIT in flags causes non-blocking behaviour. self.assertEqual(self.serv_sock.recv(512), b"a"*512) self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) @testSendmsgDontWait.client_skip def _testSendmsgDontWait(self): try: with self.assertRaises(OSError) as cm: while True: self.sendmsgToServer([b"a"*512], [], socket.MSG_DONTWAIT) self.assertIn(cm.exception.errno, (errno.EAGAIN, errno.EWOULDBLOCK)) finally: self.misc_event.set() class SendmsgConnectionlessTests(SendmsgTests): # Tests for sendmsg() which require a connectionless-mode # (e.g. datagram) socket, and do not involve recvmsg() or # recvmsg_into(). def testSendmsgNoDestAddr(self): # Check that sendmsg() fails when no destination address is # given for unconnected socket. pass def _testSendmsgNoDestAddr(self): self.assertRaises(OSError, self.cli_sock.sendmsg, [MSG]) self.assertRaises(OSError, self.cli_sock.sendmsg, [MSG], [], 0, None) class RecvmsgGenericTests(SendrecvmsgBase): # Tests for recvmsg() which can also be emulated using # recvmsg_into(), and can use any socket type. def testRecvmsg(self): # Receive a simple message with recvmsg[_into](). msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsg(self): self.sendToServer(MSG) def testRecvmsgExplicitDefaults(self): # Test recvmsg[_into]() with default arguments provided explicitly. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 0, 0) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgExplicitDefaults(self): self.sendToServer(MSG) def testRecvmsgShorter(self): # Receive a message smaller than buffer. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) + 42) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgShorter(self): self.sendToServer(MSG) # FreeBSD < 8 doesn't always set the MSG_TRUNC flag when a truncated # datagram is received (issue #13001). @support.requires_freebsd_version(8) def testRecvmsgTrunc(self): # Receive part of message, check for truncation indicators. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3) self.assertEqual(msg, MSG[:-3]) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=False) @support.requires_freebsd_version(8) def _testRecvmsgTrunc(self): self.sendToServer(MSG) def testRecvmsgShortAncillaryBuf(self): # Test ancillary data buffer too small to hold any ancillary data. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgShortAncillaryBuf(self): self.sendToServer(MSG) def testRecvmsgLongAncillaryBuf(self): # Test large ancillary data buffer. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgLongAncillaryBuf(self): self.sendToServer(MSG) def testRecvmsgAfterClose(self): # Check that recvmsg[_into]() fails on a closed socket. self.serv_sock.close() self.assertRaises(OSError, self.doRecvmsg, self.serv_sock, 1024) def _testRecvmsgAfterClose(self): pass def testRecvmsgTimeout(self): # Check that timeout works. try: self.serv_sock.settimeout(0.03) self.assertRaises(socket.timeout, self.doRecvmsg, self.serv_sock, len(MSG)) finally: self.misc_event.set() def _testRecvmsgTimeout(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) @requireAttrs(socket, "MSG_PEEK") def testRecvmsgPeek(self): # Check that MSG_PEEK in flags enables examination of pending # data without consuming it. # Receive part of data with MSG_PEEK. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3, 0, socket.MSG_PEEK) self.assertEqual(msg, MSG[:-3]) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) # Ignoring MSG_TRUNC here (so this test is the same for stream # and datagram sockets). Some wording in POSIX seems to # suggest that it needn't be set when peeking, but that may # just be a slip. self.checkFlags(flags, eor=False, ignore=getattr(socket, "MSG_TRUNC", 0)) # Receive all data with MSG_PEEK. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 0, socket.MSG_PEEK) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) # Check that the same data can still be received normally. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) @testRecvmsgPeek.client_skip def _testRecvmsgPeek(self): self.sendToServer(MSG) @requireAttrs(socket.socket, "sendmsg") def testRecvmsgFromSendmsg(self): # Test receiving with recvmsg[_into]() when message is sent # using sendmsg(). self.serv_sock.settimeout(self.fail_timeout) msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) @testRecvmsgFromSendmsg.client_skip def _testRecvmsgFromSendmsg(self): self.assertEqual(self.sendmsgToServer([MSG[:3], MSG[3:]]), len(MSG)) class RecvmsgGenericStreamTests(RecvmsgGenericTests): # Tests which require a stream socket and can use either recvmsg() # or recvmsg_into(). def testRecvmsgEOF(self): # Receive end-of-stream indicator (b"", peer socket closed). msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, 1024) self.assertEqual(msg, b"") self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=None) # Might not have end-of-record marker def _testRecvmsgEOF(self): self.cli_sock.close() def testRecvmsgOverflow(self): # Receive a message in more than one chunk. seg1, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=False) seg2, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, 1024) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testRecvmsgOverflow(self): self.sendToServer(MSG) class RecvmsgTests(RecvmsgGenericTests): # Tests for recvmsg() which can use any socket type. def testRecvmsgBadArgs(self): # Check that recvmsg() rejects invalid arguments. self.assertRaises(TypeError, self.serv_sock.recvmsg) self.assertRaises(ValueError, self.serv_sock.recvmsg, -1, 0, 0) self.assertRaises(ValueError, self.serv_sock.recvmsg, len(MSG), -1, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, [bytearray(10)], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, object(), 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, len(MSG), object(), 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, len(MSG), 0, object()) msg, ancdata, flags, addr = self.serv_sock.recvmsg(len(MSG), 0, 0) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgBadArgs(self): self.sendToServer(MSG) class RecvmsgIntoTests(RecvmsgIntoMixin, RecvmsgGenericTests): # Tests for recvmsg_into() which can use any socket type. def testRecvmsgIntoBadArgs(self): # Check that recvmsg_into() rejects invalid arguments. buf = bytearray(len(MSG)) self.assertRaises(TypeError, self.serv_sock.recvmsg_into) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, len(MSG), 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, buf, 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [object()], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [b"I'm not writable"], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf, object()], 0, 0) self.assertRaises(ValueError, self.serv_sock.recvmsg_into, [buf], -1, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf], object(), 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf], 0, object()) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into([buf], 0, 0) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf, bytearray(MSG)) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoBadArgs(self): self.sendToServer(MSG) def testRecvmsgIntoGenerator(self): # Receive into buffer obtained from a generator (not a sequence). buf = bytearray(len(MSG)) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into( (o for o in [buf])) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf, bytearray(MSG)) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoGenerator(self): self.sendToServer(MSG) def testRecvmsgIntoArray(self): # Receive into an array rather than the usual bytearray. buf = array.array("B", [0] * len(MSG)) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into([buf]) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf.tobytes(), MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoArray(self): self.sendToServer(MSG) def testRecvmsgIntoScatter(self): # Receive into multiple buffers (scatter write). b1 = bytearray(b"----") b2 = bytearray(b"0123456789") b3 = bytearray(b"--------------") nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into( [b1, memoryview(b2)[2:9], b3]) self.assertEqual(nbytes, len(b"Mary had a little lamb")) self.assertEqual(b1, bytearray(b"Mary")) self.assertEqual(b2, bytearray(b"01 had a 9")) self.assertEqual(b3, bytearray(b"little lamb---")) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoScatter(self): self.sendToServer(b"Mary had a little lamb") class CmsgMacroTests(unittest.TestCase): # Test the functions CMSG_LEN() and CMSG_SPACE(). Tests # assumptions used by sendmsg() and recvmsg[_into](), which share # code with these functions. # Match the definition in socketmodule.c try: import _testcapi except ImportError: socklen_t_limit = 0x7fffffff else: socklen_t_limit = min(0x7fffffff, _testcapi.INT_MAX) @requireAttrs(socket, "CMSG_LEN") def testCMSG_LEN(self): # Test CMSG_LEN() with various valid and invalid values, # checking the assumptions used by recvmsg() and sendmsg(). toobig = self.socklen_t_limit - socket.CMSG_LEN(0) + 1 values = list(range(257)) + list(range(toobig - 257, toobig)) # struct cmsghdr has at least three members, two of which are ints self.assertGreater(socket.CMSG_LEN(0), array.array("i").itemsize * 2) for n in values: ret = socket.CMSG_LEN(n) # This is how recvmsg() calculates the data size self.assertEqual(ret - socket.CMSG_LEN(0), n) self.assertLessEqual(ret, self.socklen_t_limit) self.assertRaises(OverflowError, socket.CMSG_LEN, -1) # sendmsg() shares code with these functions, and requires # that it reject values over the limit. self.assertRaises(OverflowError, socket.CMSG_LEN, toobig) self.assertRaises(OverflowError, socket.CMSG_LEN, sys.maxsize) @requireAttrs(socket, "CMSG_SPACE") def testCMSG_SPACE(self): # Test CMSG_SPACE() with various valid and invalid values, # checking the assumptions used by sendmsg(). toobig = self.socklen_t_limit - socket.CMSG_SPACE(1) + 1 values = list(range(257)) + list(range(toobig - 257, toobig)) last = socket.CMSG_SPACE(0) # struct cmsghdr has at least three members, two of which are ints self.assertGreater(last, array.array("i").itemsize * 2) for n in values: ret = socket.CMSG_SPACE(n) self.assertGreaterEqual(ret, last) self.assertGreaterEqual(ret, socket.CMSG_LEN(n)) self.assertGreaterEqual(ret, n + socket.CMSG_LEN(0)) self.assertLessEqual(ret, self.socklen_t_limit) last = ret self.assertRaises(OverflowError, socket.CMSG_SPACE, -1) # sendmsg() shares code with these functions, and requires # that it reject values over the limit. self.assertRaises(OverflowError, socket.CMSG_SPACE, toobig) self.assertRaises(OverflowError, socket.CMSG_SPACE, sys.maxsize) class SCMRightsTest(SendrecvmsgServerTimeoutBase): # Tests for file descriptor passing on Unix-domain sockets. # Invalid file descriptor value that's unlikely to evaluate to a # real FD even if one of its bytes is replaced with a different # value (which shouldn't actually happen). badfd = -0x5555 def newFDs(self, n): # Return a list of n file descriptors for newly-created files # containing their list indices as ASCII numbers. fds = [] for i in range(n): fd, path = tempfile.mkstemp() self.addCleanup(os.unlink, path) self.addCleanup(os.close, fd) os.write(fd, str(i).encode()) fds.append(fd) return fds def checkFDs(self, fds): # Check that the file descriptors in the given list contain # their correct list indices as ASCII numbers. for n, fd in enumerate(fds): os.lseek(fd, 0, os.SEEK_SET) self.assertEqual(os.read(fd, 1024), str(n).encode()) def registerRecvmsgResult(self, result): self.addCleanup(self.closeRecvmsgFDs, result) def closeRecvmsgFDs(self, recvmsg_result): # Close all file descriptors specified in the ancillary data # of the given return value from recvmsg() or recvmsg_into(). for cmsg_level, cmsg_type, cmsg_data in recvmsg_result[1]: if (cmsg_level == socket.SOL_SOCKET and cmsg_type == socket.SCM_RIGHTS): fds = array.array("i") fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) for fd in fds: os.close(fd) def createAndSendFDs(self, n): # Send n new file descriptors created by newFDs() to the # server, with the constant MSG as the non-ancillary data. self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", self.newFDs(n)))]), len(MSG)) def checkRecvmsgFDs(self, numfds, result, maxcmsgs=1, ignoreflags=0): # Check that constant MSG was received with numfds file # descriptors in a maximum of maxcmsgs control messages (which # must contain only complete integers). By default, check # that MSG_CTRUNC is unset, but ignore any flags in # ignoreflags. msg, ancdata, flags, addr = result self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertIsInstance(ancdata, list) self.assertLessEqual(len(ancdata), maxcmsgs) fds = array.array("i") for item in ancdata: self.assertIsInstance(item, tuple) cmsg_level, cmsg_type, cmsg_data = item self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertIsInstance(cmsg_data, bytes) self.assertEqual(len(cmsg_data) % SIZEOF_INT, 0) fds.frombytes(cmsg_data) self.assertEqual(len(fds), numfds) self.checkFDs(fds) def testFDPassSimple(self): # Pass a single FD (array read from bytes object). self.checkRecvmsgFDs(1, self.doRecvmsg(self.serv_sock, len(MSG), 10240)) def _testFDPassSimple(self): self.assertEqual( self.sendmsgToServer( [MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", self.newFDs(1)).tobytes())]), len(MSG)) def testMultipleFDPass(self): # Pass multiple FDs in a single array. self.checkRecvmsgFDs(4, self.doRecvmsg(self.serv_sock, len(MSG), 10240)) def _testMultipleFDPass(self): self.createAndSendFDs(4) @requireAttrs(socket, "CMSG_SPACE") def testFDPassCMSG_SPACE(self): # Test using CMSG_SPACE() to calculate ancillary buffer size. self.checkRecvmsgFDs( 4, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_SPACE(4 * SIZEOF_INT))) @testFDPassCMSG_SPACE.client_skip def _testFDPassCMSG_SPACE(self): self.createAndSendFDs(4) def testFDPassCMSG_LEN(self): # Test using CMSG_LEN() to calculate ancillary buffer size. self.checkRecvmsgFDs(1, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_LEN(4 * SIZEOF_INT)), # RFC 3542 says implementations may set # MSG_CTRUNC if there isn't enough space # for trailing padding. ignoreflags=socket.MSG_CTRUNC) def _testFDPassCMSG_LEN(self): self.createAndSendFDs(1) @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparate(self): # Pass two FDs in two separate arrays. Arrays may be combined # into a single control message by the OS. self.checkRecvmsgFDs(2, self.doRecvmsg(self.serv_sock, len(MSG), 10240), maxcmsgs=2) @testFDPassSeparate.client_skip @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparate(self): fd0, fd1 = self.newFDs(2) self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0])), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]), len(MSG)) @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparateMinSpace(self): # Pass two FDs in two separate arrays, receiving them into the # minimum space for two arrays. self.checkRecvmsgFDs(2, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT)), maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC) @testFDPassSeparateMinSpace.client_skip @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparateMinSpace(self): fd0, fd1 = self.newFDs(2) self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0])), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]), len(MSG)) def sendAncillaryIfPossible(self, msg, ancdata): # Try to send msg and ancdata to server, but if the system # call fails, just send msg with no ancillary data. try: nbytes = self.sendmsgToServer([msg], ancdata) except OSError as e: # Check that it was the system call that failed self.assertIsInstance(e.errno, int) nbytes = self.sendmsgToServer([msg]) self.assertEqual(nbytes, len(msg)) def testFDPassEmpty(self): # Try to pass an empty FD array. Can receive either no array # or an empty array. self.checkRecvmsgFDs(0, self.doRecvmsg(self.serv_sock, len(MSG), 10240), ignoreflags=socket.MSG_CTRUNC) def _testFDPassEmpty(self): self.sendAncillaryIfPossible(MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, b"")]) def testFDPassPartialInt(self): # Try to pass a truncated FD array. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, ignore=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 1) for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertLess(len(cmsg_data), SIZEOF_INT) def _testFDPassPartialInt(self): self.sendAncillaryIfPossible( MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [self.badfd]).tobytes()[:-1])]) @requireAttrs(socket, "CMSG_SPACE") def testFDPassPartialIntInMiddle(self): # Try to pass two FD arrays, the first of which is truncated. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, ignore=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 2) fds = array.array("i") # Arrays may have been combined in a single control message for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) self.assertLessEqual(len(fds), 2) self.checkFDs(fds) @testFDPassPartialIntInMiddle.client_skip def _testFDPassPartialIntInMiddle(self): fd0, fd1 = self.newFDs(2) self.sendAncillaryIfPossible( MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0, self.badfd]).tobytes()[:-1]), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]) def checkTruncatedHeader(self, result, ignoreflags=0): # Check that no ancillary data items are returned when data is # truncated inside the cmsghdr structure. msg, ancdata, flags, addr = result self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) def testCmsgTruncNoBufSize(self): # Check that no ancillary data is received when no buffer size # is specified. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG)), # BSD seems to set MSG_CTRUNC only # if an item has been partially # received. ignoreflags=socket.MSG_CTRUNC) def _testCmsgTruncNoBufSize(self): self.createAndSendFDs(1) def testCmsgTrunc0(self): # Check that no ancillary data is received when buffer size is 0. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 0), ignoreflags=socket.MSG_CTRUNC) def _testCmsgTrunc0(self): self.createAndSendFDs(1) # Check that no ancillary data is returned for various non-zero # (but still too small) buffer sizes. def testCmsgTrunc1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1)) def _testCmsgTrunc1(self): self.createAndSendFDs(1) def testCmsgTrunc2Int(self): # The cmsghdr structure has at least three members, two of # which are ints, so we still shouldn't see any ancillary # data. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), SIZEOF_INT * 2)) def _testCmsgTrunc2Int(self): self.createAndSendFDs(1) def testCmsgTruncLen0Minus1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_LEN(0) - 1)) def _testCmsgTruncLen0Minus1(self): self.createAndSendFDs(1) # The following tests try to truncate the control message in the # middle of the FD array. def checkTruncatedArray(self, ancbuf, maxdata, mindata=0): # Check that file descriptor data is truncated to between # mindata and maxdata bytes when received with buffer size # ancbuf, and that any complete file descriptor numbers are # valid. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbuf) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) if mindata == 0 and ancdata == []: return self.assertEqual(len(ancdata), 1) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertGreaterEqual(len(cmsg_data), mindata) self.assertLessEqual(len(cmsg_data), maxdata) fds = array.array("i") fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) self.checkFDs(fds) def testCmsgTruncLen0(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0) def _testCmsgTruncLen0(self): self.createAndSendFDs(1) def testCmsgTruncLen0Plus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1) def _testCmsgTruncLen0Plus1(self): self.createAndSendFDs(2) def testCmsgTruncLen1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT), maxdata=SIZEOF_INT) def _testCmsgTruncLen1(self): self.createAndSendFDs(2) def testCmsgTruncLen2Minus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1, maxdata=(2 * SIZEOF_INT) - 1) def _testCmsgTruncLen2Minus1(self): self.createAndSendFDs(2) class RFC3542AncillaryTest(SendrecvmsgServerTimeoutBase): # Test sendmsg() and recvmsg[_into]() using the ancillary data # features of the RFC 3542 Advanced Sockets API for IPv6. # Currently we can only handle certain data items (e.g. traffic # class, hop limit, MTU discovery and fragmentation settings) # without resorting to unportable means such as the struct module, # but the tests here are aimed at testing the ancillary data # handling in sendmsg() and recvmsg() rather than the IPv6 API # itself. # Test value to use when setting hop limit of packet hop_limit = 2 # Test value to use when setting traffic class of packet. # -1 means "use kernel default". traffic_class = -1 def ancillaryMapping(self, ancdata): # Given ancillary data list ancdata, return a mapping from # pairs (cmsg_level, cmsg_type) to corresponding cmsg_data. # Check that no (level, type) pair appears more than once. d = {} for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertNotIn((cmsg_level, cmsg_type), d) d[(cmsg_level, cmsg_type)] = cmsg_data return d def checkHopLimit(self, ancbufsize, maxhop=255, ignoreflags=0): # Receive hop limit into ancbufsize bytes of ancillary data # space. Check that data is MSG, ancillary data is not # truncated (but ignore any flags in ignoreflags), and hop # limit is between 0 and maxhop inclusive. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 1) self.assertIsInstance(ancdata[0], tuple) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertEqual(cmsg_type, socket.IPV6_HOPLIMIT) self.assertIsInstance(cmsg_data, bytes) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], maxhop) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testRecvHopLimit(self): # Test receiving the packet hop limit as ancillary data. self.checkHopLimit(ancbufsize=10240) @testRecvHopLimit.client_skip def _testRecvHopLimit(self): # Need to wait until server has asked to receive ancillary # data, as implementations are not required to buffer it # otherwise. self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testRecvHopLimitCMSG_SPACE(self): # Test receiving hop limit, using CMSG_SPACE to calculate buffer size. self.checkHopLimit(ancbufsize=socket.CMSG_SPACE(SIZEOF_INT)) @testRecvHopLimitCMSG_SPACE.client_skip def _testRecvHopLimitCMSG_SPACE(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Could test receiving into buffer sized using CMSG_LEN, but RFC # 3542 says portable applications must provide space for trailing # padding. Implementations may set MSG_CTRUNC if there isn't # enough space for the padding. @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSetHopLimit(self): # Test setting hop limit on outgoing packet and receiving it # at the other end. self.checkHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testSetHopLimit.client_skip def _testSetHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.assertEqual( self.sendmsgToServer([MSG], [(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]), len(MSG)) def checkTrafficClassAndHopLimit(self, ancbufsize, maxhop=255, ignoreflags=0): # Receive traffic class and hop limit into ancbufsize bytes of # ancillary data space. Check that data is MSG, ancillary # data is not truncated (but ignore any flags in ignoreflags), # and traffic class and hop limit are in range (hop limit no # more than maxhop). self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 2) ancmap = self.ancillaryMapping(ancdata) tcdata = ancmap[(socket.IPPROTO_IPV6, socket.IPV6_TCLASS)] self.assertEqual(len(tcdata), SIZEOF_INT) a = array.array("i") a.frombytes(tcdata) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) hldata = ancmap[(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT)] self.assertEqual(len(hldata), SIZEOF_INT) a = array.array("i") a.frombytes(hldata) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], maxhop) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testRecvTrafficClassAndHopLimit(self): # Test receiving traffic class and hop limit as ancillary data. self.checkTrafficClassAndHopLimit(ancbufsize=10240) @testRecvTrafficClassAndHopLimit.client_skip def _testRecvTrafficClassAndHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testRecvTrafficClassAndHopLimitCMSG_SPACE(self): # Test receiving traffic class and hop limit, using # CMSG_SPACE() to calculate buffer size. self.checkTrafficClassAndHopLimit( ancbufsize=socket.CMSG_SPACE(SIZEOF_INT) * 2) @testRecvTrafficClassAndHopLimitCMSG_SPACE.client_skip def _testRecvTrafficClassAndHopLimitCMSG_SPACE(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSetTrafficClassAndHopLimit(self): # Test setting traffic class and hop limit on outgoing packet, # and receiving them at the other end. self.checkTrafficClassAndHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testSetTrafficClassAndHopLimit.client_skip def _testSetTrafficClassAndHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.assertEqual( self.sendmsgToServer([MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class])), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]), len(MSG)) @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testOddCmsgSize(self): # Try to send ancillary data with first item one byte too # long. Fall back to sending with correct size if this fails, # and check that second item was handled correctly. self.checkTrafficClassAndHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testOddCmsgSize.client_skip def _testOddCmsgSize(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) try: nbytes = self.sendmsgToServer( [MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class]).tobytes() + b"\x00"), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]) except OSError as e: self.assertIsInstance(e.errno, int) nbytes = self.sendmsgToServer( [MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class])), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]) self.assertEqual(nbytes, len(MSG)) # Tests for proper handling of truncated ancillary data def checkHopLimitTruncatedHeader(self, ancbufsize, ignoreflags=0): # Receive hop limit into ancbufsize bytes of ancillary data # space, which should be too small to contain the ancillary # data header (if ancbufsize is None, pass no second argument # to recvmsg()). Check that data is MSG, MSG_CTRUNC is set # (unless included in ignoreflags), and no ancillary data is # returned. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() args = () if ancbufsize is None else (ancbufsize,) msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), *args) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testCmsgTruncNoBufSize(self): # Check that no ancillary data is received when no ancillary # buffer size is provided. self.checkHopLimitTruncatedHeader(ancbufsize=None, # BSD seems to set # MSG_CTRUNC only if an item # has been partially # received. ignoreflags=socket.MSG_CTRUNC) @testCmsgTruncNoBufSize.client_skip def _testCmsgTruncNoBufSize(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc0(self): # Check that no ancillary data is received when ancillary # buffer size is zero. self.checkHopLimitTruncatedHeader(ancbufsize=0, ignoreflags=socket.MSG_CTRUNC) @testSingleCmsgTrunc0.client_skip def _testSingleCmsgTrunc0(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Check that no ancillary data is returned for various non-zero # (but still too small) buffer sizes. @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc1(self): self.checkHopLimitTruncatedHeader(ancbufsize=1) @testSingleCmsgTrunc1.client_skip def _testSingleCmsgTrunc1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc2Int(self): self.checkHopLimitTruncatedHeader(ancbufsize=2 * SIZEOF_INT) @testSingleCmsgTrunc2Int.client_skip def _testSingleCmsgTrunc2Int(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTruncLen0Minus1(self): self.checkHopLimitTruncatedHeader(ancbufsize=socket.CMSG_LEN(0) - 1) @testSingleCmsgTruncLen0Minus1.client_skip def _testSingleCmsgTruncLen0Minus1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTruncInData(self): # Test truncation of a control message inside its associated # data. The message may be returned with its data truncated, # or not returned at all. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg( self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 1) if ancdata: cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertEqual(cmsg_type, socket.IPV6_HOPLIMIT) self.assertLess(len(cmsg_data), SIZEOF_INT) @testSingleCmsgTruncInData.client_skip def _testSingleCmsgTruncInData(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) def checkTruncatedSecondHeader(self, ancbufsize, ignoreflags=0): # Receive traffic class and hop limit into ancbufsize bytes of # ancillary data space, which should be large enough to # contain the first item, but too small to contain the header # of the second. Check that data is MSG, MSG_CTRUNC is set # (unless included in ignoreflags), and only one ancillary # data item is returned. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 1) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertIn(cmsg_type, {socket.IPV6_TCLASS, socket.IPV6_HOPLIMIT}) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) # Try the above test with various buffer sizes. @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc0(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT), ignoreflags=socket.MSG_CTRUNC) @testSecondCmsgTrunc0.client_skip def _testSecondCmsgTrunc0(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 1) @testSecondCmsgTrunc1.client_skip def _testSecondCmsgTrunc1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc2Int(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 2 * SIZEOF_INT) @testSecondCmsgTrunc2Int.client_skip def _testSecondCmsgTrunc2Int(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTruncLen0Minus1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(0) - 1) @testSecondCmsgTruncLen0Minus1.client_skip def _testSecondCmsgTruncLen0Minus1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecomdCmsgTruncInData(self): # Test truncation of the second of two control messages inside # its associated data. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg( self.serv_sock, len(MSG), socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) cmsg_types = {socket.IPV6_TCLASS, socket.IPV6_HOPLIMIT} cmsg_level, cmsg_type, cmsg_data = ancdata.pop(0) self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) cmsg_types.remove(cmsg_type) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) if ancdata: cmsg_level, cmsg_type, cmsg_data = ancdata.pop(0) self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) cmsg_types.remove(cmsg_type) self.assertLess(len(cmsg_data), SIZEOF_INT) self.assertEqual(ancdata, []) @testSecomdCmsgTruncInData.client_skip def _testSecomdCmsgTruncInData(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Derive concrete test classes for different socket types. class SendrecvmsgUDPTestBase(SendrecvmsgDgramFlagsBase, SendrecvmsgConnectionlessBase, ThreadedSocketTestMixin, UDPTestBase): pass @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUDPTest(SendmsgConnectionlessTests, SendrecvmsgUDPTestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUDPTest(RecvmsgTests, SendrecvmsgUDPTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUDPTest(RecvmsgIntoTests, SendrecvmsgUDPTestBase): pass class SendrecvmsgUDP6TestBase(SendrecvmsgDgramFlagsBase, SendrecvmsgConnectionlessBase, ThreadedSocketTestMixin, UDP6TestBase): def checkRecvmsgAddress(self, addr1, addr2): # Called to compare the received address with the address of # the peer, ignoring scope ID self.assertEqual(addr1[:-1], addr2[:-1]) @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUDP6Test(SendmsgConnectionlessTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUDP6Test(RecvmsgTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUDP6Test(RecvmsgIntoTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireAttrs(socket, "IPPROTO_IPV6") @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgRFC3542AncillaryUDP6Test(RFC3542AncillaryTest, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireAttrs(socket, "IPPROTO_IPV6") @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoRFC3542AncillaryUDP6Test(RecvmsgIntoMixin, RFC3542AncillaryTest, SendrecvmsgUDP6TestBase): pass class SendrecvmsgTCPTestBase(SendrecvmsgConnectedBase, ConnectedStreamTestMixin, TCPTestBase): pass @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgTCPTest(SendmsgStreamTests, SendrecvmsgTCPTestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgTCPTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgTCPTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoTCPTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgTCPTestBase): pass class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase, SendrecvmsgConnectedBase, ConnectedStreamTestMixin, SCTPStreamBase): pass @requireAttrs(socket.socket, "sendmsg") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgSCTPStreamTestBase): def testRecvmsgEOF(self): try: super(RecvmsgSCTPStreamTest, self).testRecvmsgEOF() except OSError as e: if e.errno != errno.ENOTCONN: raise self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876") @requireAttrs(socket.socket, "recvmsg_into") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgSCTPStreamTestBase): def testRecvmsgEOF(self): try: super(RecvmsgIntoSCTPStreamTest, self).testRecvmsgEOF() except OSError as e: if e.errno != errno.ENOTCONN: raise self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876") class SendrecvmsgUnixStreamTestBase(SendrecvmsgConnectedBase, ConnectedStreamTestMixin, UnixStreamBase): pass @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUnixStreamTest(SendmsgStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUnixStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUnixStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "sendmsg", "recvmsg") @requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgSCMRightsStreamTest(SCMRightsTest, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "sendmsg", "recvmsg_into") @requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoSCMRightsStreamTest(RecvmsgIntoMixin, SCMRightsTest, SendrecvmsgUnixStreamTestBase): pass # Test interrupting the interruptible send/receive methods with a # signal when a timeout is set. These tests avoid having multiple # threads alive during the test so that the OS cannot deliver the # signal to the wrong one. class InterruptedTimeoutBase(unittest.TestCase): # Base class for interrupted send/receive tests. Installs an # empty handler for SIGALRM and removes it on teardown, along with # any scheduled alarms. def setUp(self): super().setUp() orig_alrm_handler = signal.signal(signal.SIGALRM, lambda signum, frame: 1 / 0) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) self.addCleanup(self.setAlarm, 0) # Timeout for socket operations timeout = 4.0 # Provide setAlarm() method to schedule delivery of SIGALRM after # given number of seconds, or cancel it if zero, and an # appropriate time value to use. Use setitimer() if available. if hasattr(signal, "setitimer"): alarm_time = 0.05 def setAlarm(self, seconds): signal.setitimer(signal.ITIMER_REAL, seconds) else: # Old systems may deliver the alarm up to one second early alarm_time = 2 def setAlarm(self, seconds): signal.alarm(seconds) # Require siginterrupt() in order to ensure that system calls are # interrupted by default. @requireAttrs(signal, "siginterrupt") @unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"), "Don't have signal.alarm or signal.setitimer") class InterruptedRecvTimeoutTest(InterruptedTimeoutBase, UDPTestBase): # Test interrupting the recv*() methods with signals when a # timeout is set. def setUp(self): super().setUp() self.serv.settimeout(self.timeout) def checkInterruptedRecv(self, func, *args, **kwargs): # Check that func(*args, **kwargs) raises # errno of EINTR when interrupted by a signal. self.setAlarm(self.alarm_time) with self.assertRaises(ZeroDivisionError) as cm: func(*args, **kwargs) def testInterruptedRecvTimeout(self): self.checkInterruptedRecv(self.serv.recv, 1024) def testInterruptedRecvIntoTimeout(self): self.checkInterruptedRecv(self.serv.recv_into, bytearray(1024)) def testInterruptedRecvfromTimeout(self): self.checkInterruptedRecv(self.serv.recvfrom, 1024) def testInterruptedRecvfromIntoTimeout(self): self.checkInterruptedRecv(self.serv.recvfrom_into, bytearray(1024)) @requireAttrs(socket.socket, "recvmsg") def testInterruptedRecvmsgTimeout(self): self.checkInterruptedRecv(self.serv.recvmsg, 1024) @requireAttrs(socket.socket, "recvmsg_into") def testInterruptedRecvmsgIntoTimeout(self): self.checkInterruptedRecv(self.serv.recvmsg_into, [bytearray(1024)]) # Require siginterrupt() in order to ensure that system calls are # interrupted by default. @requireAttrs(signal, "siginterrupt") @unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"), "Don't have signal.alarm or signal.setitimer") @unittest.skipUnless(thread, 'Threading required for this test.') class InterruptedSendTimeoutTest(InterruptedTimeoutBase, ThreadSafeCleanupTestCase, SocketListeningTestMixin, TCPTestBase): # Test interrupting the interruptible send*() methods with signals # when a timeout is set. def setUp(self): super().setUp() self.serv_conn = self.newSocket() self.addCleanup(self.serv_conn.close) # Use a thread to complete the connection, but wait for it to # terminate before running the test, so that there is only one # thread to accept the signal. cli_thread = threading.Thread(target=self.doConnect) cli_thread.start() self.cli_conn, addr = self.serv.accept() self.addCleanup(self.cli_conn.close) cli_thread.join() self.serv_conn.settimeout(self.timeout) def doConnect(self): self.serv_conn.connect(self.serv_addr) def checkInterruptedSend(self, func, *args, **kwargs): # Check that func(*args, **kwargs), run in a loop, raises # OSError with an errno of EINTR when interrupted by a # signal. with self.assertRaises(ZeroDivisionError) as cm: while True: self.setAlarm(self.alarm_time) func(*args, **kwargs) # Issue #12958: The following tests have problems on OS X prior to 10.7 @support.requires_mac_ver(10, 7) def testInterruptedSendTimeout(self): self.checkInterruptedSend(self.serv_conn.send, b"a"*512) @support.requires_mac_ver(10, 7) def testInterruptedSendtoTimeout(self): # Passing an actual address here as Python's wrapper for # sendto() doesn't allow passing a zero-length one; POSIX # requires that the address is ignored since the socket is # connection-mode, however. self.checkInterruptedSend(self.serv_conn.sendto, b"a"*512, self.serv_addr) @support.requires_mac_ver(10, 7) @requireAttrs(socket.socket, "sendmsg") def testInterruptedSendmsgTimeout(self): self.checkInterruptedSend(self.serv_conn.sendmsg, [b"a"*512]) @unittest.skipUnless(thread, 'Threading required for this test.') class TCPCloserTest(ThreadedTCPSocketTest): def testClose(self): conn, addr = self.serv.accept() conn.close() sd = self.cli read, write, err = select.select([sd], [], [], 1.0) self.assertEqual(read, [sd]) self.assertEqual(sd.recv(1), b'') # Calling close() many times should be safe. conn.close() conn.close() def _testClose(self): self.cli.connect((HOST, self.port)) time.sleep(1.0) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicSocketPairTest(SocketPairTest): def __init__(self, methodName='runTest'): SocketPairTest.__init__(self, methodName=methodName) def _check_defaults(self, sock): self.assertIsInstance(sock, socket.socket) if hasattr(socket, 'AF_UNIX'): self.assertEqual(sock.family, socket.AF_UNIX) else: self.assertEqual(sock.family, socket.AF_INET) self.assertEqual(sock.type, socket.SOCK_STREAM) self.assertEqual(sock.proto, 0) def _testDefaults(self): self._check_defaults(self.cli) def testDefaults(self): self._check_defaults(self.serv) def testRecv(self): msg = self.serv.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.cli.send(MSG) def testSend(self): self.serv.send(MSG) def _testSend(self): msg = self.cli.recv(1024) self.assertEqual(msg, MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class NonBlockingTCPTests(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def testSetBlocking(self): # Testing whether set blocking works self.serv.setblocking(True) self.assertIsNone(self.serv.gettimeout()) self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() except OSError: pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") def _testSetBlocking(self): pass @support.cpython_only def testSetBlocking_overflow(self): # Issue 15989 import _testcapi if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX: self.skipTest('needs UINT_MAX < ULONG_MAX') self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) self.serv.setblocking(_testcapi.UINT_MAX + 1) self.assertIsNone(self.serv.gettimeout()) _testSetBlocking_overflow = support.cpython_only(_testSetBlocking) @unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'), 'test needs socket.SOCK_NONBLOCK') @support.requires_linux_version(2, 6, 28) def testInitNonBlocking(self): # reinit server socket self.serv.close() self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_NONBLOCK) self.port = support.bind_port(self.serv) self.serv.listen() # actual testing start = time.time() try: self.serv.accept() except OSError: pass end = time.time() self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.") def _testInitNonBlocking(self): pass def testInheritFlags(self): # Issue #7995: when calling accept() on a listening socket with a # timeout, the resulting socket should not be non-blocking. self.serv.settimeout(10) try: conn, addr = self.serv.accept() message = conn.recv(len(MSG)) finally: conn.close() self.serv.settimeout(None) def _testInheritFlags(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) time.sleep(0.5) self.cli.send(MSG) def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) try: conn, addr = self.serv.accept() except OSError: pass else: self.fail("Error trying to do non-blocking accept.") read, write, err = select.select([self.serv], [], []) if self.serv in read: conn, addr = self.serv.accept() self.assertIsNone(conn.gettimeout()) conn.close() else: self.fail("Error trying to do accept after select.") def _testAccept(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) def testConnect(self): # Testing non-blocking connect conn, addr = self.serv.accept() conn.close() def _testConnect(self): self.cli.settimeout(10) self.cli.connect((HOST, self.port)) def testRecv(self): # Testing non-blocking recv conn, addr = self.serv.accept() conn.setblocking(0) try: msg = conn.recv(len(MSG)) except OSError: pass else: self.fail("Error trying to do non-blocking recv.") read, write, err = select.select([conn], [], []) if conn in read: msg = conn.recv(len(MSG)) conn.close() self.assertEqual(msg, MSG) else: self.fail("Error during select call to non-blocking socket.") def _testRecv(self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class FileObjectClassTestCase(SocketConnectedTest): """Unit tests for the object returned by socket.makefile() self.read_file is the io object returned by makefile() on the client connection. You can read from this file to get output from the server. self.write_file is the io object returned by makefile() on the server connection. You can write to this file to send output to the client. """ bufsize = -1 # Use default buffer size encoding = 'utf-8' errors = 'strict' newline = None read_mode = 'rb' read_msg = MSG write_mode = 'wb' write_msg = MSG def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def setUp(self): self.evt1, self.evt2, self.serv_finished, self.cli_finished = [ threading.Event() for i in range(4)] SocketConnectedTest.setUp(self) self.read_file = self.cli_conn.makefile( self.read_mode, self.bufsize, encoding = self.encoding, errors = self.errors, newline = self.newline) def tearDown(self): self.serv_finished.set() self.read_file.close() self.assertTrue(self.read_file.closed) self.read_file = None SocketConnectedTest.tearDown(self) def clientSetUp(self): SocketConnectedTest.clientSetUp(self) self.write_file = self.serv_conn.makefile( self.write_mode, self.bufsize, encoding = self.encoding, errors = self.errors, newline = self.newline) def clientTearDown(self): self.cli_finished.set() self.write_file.close() self.assertTrue(self.write_file.closed) self.write_file = None SocketConnectedTest.clientTearDown(self) def testReadAfterTimeout(self): # Issue #7322: A file object must disallow further reads # after a timeout has occurred. self.cli_conn.settimeout(1) self.read_file.read(3) # First read raises a timeout self.assertRaises(socket.timeout, self.read_file.read, 1) # Second read is disallowed with self.assertRaises(OSError) as ctx: self.read_file.read(1) self.assertIn("cannot read from timed out object", str(ctx.exception)) def _testReadAfterTimeout(self): self.write_file.write(self.write_msg[0:3]) self.write_file.flush() self.serv_finished.wait() def testSmallRead(self): # Performing small file read test first_seg = self.read_file.read(len(self.read_msg)-3) second_seg = self.read_file.read(3) msg = first_seg + second_seg self.assertEqual(msg, self.read_msg) def _testSmallRead(self): self.write_file.write(self.write_msg) self.write_file.flush() def testFullRead(self): # read until EOF msg = self.read_file.read() self.assertEqual(msg, self.read_msg) def _testFullRead(self): self.write_file.write(self.write_msg) self.write_file.close() def testUnbufferedRead(self): # Performing unbuffered file read test buf = type(self.read_msg)() while 1: char = self.read_file.read(1) if not char: break buf += char self.assertEqual(buf, self.read_msg) def _testUnbufferedRead(self): self.write_file.write(self.write_msg) self.write_file.flush() def testReadline(self): # Performing file readline test line = self.read_file.readline() self.assertEqual(line, self.read_msg) def _testReadline(self): self.write_file.write(self.write_msg) self.write_file.flush() def testCloseAfterMakefile(self): # The file returned by makefile should keep the socket open. self.cli_conn.close() # read until EOF msg = self.read_file.read() self.assertEqual(msg, self.read_msg) def _testCloseAfterMakefile(self): self.write_file.write(self.write_msg) self.write_file.flush() def testMakefileAfterMakefileClose(self): self.read_file.close() msg = self.cli_conn.recv(len(MSG)) if isinstance(self.read_msg, str): msg = msg.decode() self.assertEqual(msg, self.read_msg) def _testMakefileAfterMakefileClose(self): self.write_file.write(self.write_msg) self.write_file.flush() def testClosedAttr(self): self.assertTrue(not self.read_file.closed) def _testClosedAttr(self): self.assertTrue(not self.write_file.closed) def testAttributes(self): self.assertEqual(self.read_file.mode, self.read_mode) self.assertEqual(self.read_file.name, self.cli_conn.fileno()) def _testAttributes(self): self.assertEqual(self.write_file.mode, self.write_mode) self.assertEqual(self.write_file.name, self.serv_conn.fileno()) def testRealClose(self): self.read_file.close() self.assertRaises(ValueError, self.read_file.fileno) self.cli_conn.close() self.assertRaises(OSError, self.cli_conn.getsockname) def _testRealClose(self): pass class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): """Repeat the tests from FileObjectClassTestCase with bufsize==0. In this case (and in this case only), it should be possible to create a file object, read a line from it, create another file object, read another line from it, without loss of data in the first file object's buffer. Note that http.client relies on this when reading multiple requests from the same socket.""" bufsize = 0 # Use unbuffered mode def testUnbufferedReadline(self): # Read a line, create a new file object, read another line with it line = self.read_file.readline() # first line self.assertEqual(line, b"A. " + self.write_msg) # first line self.read_file = self.cli_conn.makefile('rb', 0) line = self.read_file.readline() # second line self.assertEqual(line, b"B. " + self.write_msg) # second line def _testUnbufferedReadline(self): self.write_file.write(b"A. " + self.write_msg) self.write_file.write(b"B. " + self.write_msg) self.write_file.flush() def testMakefileClose(self): # The file returned by makefile should keep the socket open... self.cli_conn.close() msg = self.cli_conn.recv(1024) self.assertEqual(msg, self.read_msg) # ...until the file is itself closed self.read_file.close() self.assertRaises(OSError, self.cli_conn.recv, 1024) def _testMakefileClose(self): self.write_file.write(self.write_msg) self.write_file.flush() def testMakefileCloseSocketDestroy(self): refcount_before = sys.getrefcount(self.cli_conn) self.read_file.close() refcount_after = sys.getrefcount(self.cli_conn) self.assertEqual(refcount_before - 1, refcount_after) def _testMakefileCloseSocketDestroy(self): pass # Non-blocking ops # NOTE: to set `read_file` as non-blocking, we must call # `cli_conn.setblocking` and vice-versa (see setUp / clientSetUp). def testSmallReadNonBlocking(self): self.cli_conn.setblocking(False) self.assertEqual(self.read_file.readinto(bytearray(10)), None) self.assertEqual(self.read_file.read(len(self.read_msg) - 3), None) self.evt1.set() self.evt2.wait(1.0) first_seg = self.read_file.read(len(self.read_msg) - 3) if first_seg is None: # Data not arrived (can happen under Windows), wait a bit time.sleep(0.5) first_seg = self.read_file.read(len(self.read_msg) - 3) buf = bytearray(10) n = self.read_file.readinto(buf) self.assertEqual(n, 3) msg = first_seg + buf[:n] self.assertEqual(msg, self.read_msg) self.assertEqual(self.read_file.readinto(bytearray(16)), None) self.assertEqual(self.read_file.read(1), None) def _testSmallReadNonBlocking(self): self.evt1.wait(1.0) self.write_file.write(self.write_msg) self.write_file.flush() self.evt2.set() # Avoid cloding the socket before the server test has finished, # otherwise system recv() will return 0 instead of EWOULDBLOCK. self.serv_finished.wait(5.0) def testWriteNonBlocking(self): self.cli_finished.wait(5.0) # The client thread can't skip directly - the SkipTest exception # would appear as a failure. if self.serv_skipped: self.skipTest(self.serv_skipped) def _testWriteNonBlocking(self): self.serv_skipped = None self.serv_conn.setblocking(False) # Try to saturate the socket buffer pipe with repeated large writes. BIG = b"x" * support.SOCK_MAX_SIZE LIMIT = 10 # The first write() succeeds since a chunk of data can be buffered n = self.write_file.write(BIG) self.assertGreater(n, 0) for i in range(LIMIT): n = self.write_file.write(BIG) if n is None: # Succeeded break self.assertGreater(n, 0) else: # Let us know that this test didn't manage to establish # the expected conditions. This is not a failure in itself but, # if it happens repeatedly, the test should be fixed. self.serv_skipped = "failed to saturate the socket buffer" class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 1 # Default-buffered for reading; line-buffered for writing class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code class UnicodeReadFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'r' read_msg = MSG.decode('utf-8') write_mode = 'wb' write_msg = MSG newline = '' class UnicodeWriteFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'rb' read_msg = MSG write_mode = 'w' write_msg = MSG.decode('utf-8') newline = '' class UnicodeReadWriteFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'r' read_msg = MSG.decode('utf-8') write_mode = 'w' write_msg = MSG.decode('utf-8') newline = '' class NetworkConnectionTest(object): """Prove network connection.""" def clientSetUp(self): # We're inherited below by BasicTCPTest2, which also inherits # BasicTCPTest, which defines self.port referenced below. self.cli = socket.create_connection((HOST, self.port)) self.serv_conn = self.cli class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): """Tests that NetworkConnection does not break existing TCP functionality. """ class NetworkConnectionNoServer(unittest.TestCase): class MockSocket(socket.socket): def connect(self, *args): raise socket.timeout('timed out') @contextlib.contextmanager def mocked_socket_module(self): """Return a socket which times out on connect""" old_socket = socket.socket socket.socket = self.MockSocket try: yield finally: socket.socket = old_socket def test_connect(self): port = support.find_unused_port() cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(cli.close) with self.assertRaises(OSError) as cm: cli.connect((HOST, port)) self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection(self): # Issue #9792: errors raised by create_connection() should have # a proper errno attribute. port = support.find_unused_port() with self.assertRaises(OSError) as cm: socket.create_connection((HOST, port)) # Issue #16257: create_connection() calls getaddrinfo() against # 'localhost'. This may result in an IPV6 addr being returned # as well as an IPV4 one: # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), # (26, 2, 0, '', ('::1', 41230, 0, 0))] # # create_connection() enumerates through all the addresses returned # and if it doesn't successfully bind to any of them, it propagates # the last exception it encountered. # # On Solaris, ENETUNREACH is returned in this circumstance instead # of ECONNREFUSED. So, if that errno exists, add it to our list of # expected errnos. expected_errnos = [ errno.ECONNREFUSED, ] if hasattr(errno, 'ENETUNREACH'): expected_errnos.append(errno.ENETUNREACH) self.assertIn(cm.exception.errno, expected_errnos) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors # as generic socket errors. with self.mocked_socket_module(): with self.assertRaises(socket.timeout): socket.create_connection((HOST, 1234)) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.source_port = support.find_unused_port() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def _justAccept(self): conn, addr = self.serv.accept() conn.close() testFamily = _justAccept def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.family, 2) testSourceAddress = _justAccept def _testSourceAddress(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.addCleanup(self.cli.close) self.assertEqual(self.cli.getsockname()[1], self.source_port) # The port number being used is sufficient to show that the bind() # call happened. testTimeoutDefault = _justAccept def _testTimeoutDefault(self): # passing no explicit timeout uses socket's global default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(42) try: self.cli = socket.create_connection((HOST, self.port)) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), 42) testTimeoutNone = _justAccept def _testTimeoutNone(self): # None timeout means the same as sock.settimeout(None) self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: self.cli = socket.create_connection((HOST, self.port), timeout=None) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), None) testTimeoutValueNamed = _justAccept def _testTimeoutValueNamed(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.gettimeout(), 30) testTimeoutValueNonamed = _justAccept def _testTimeoutValueNonamed(self): self.cli = socket.create_connection((HOST, self.port), 30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.gettimeout(), 30) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send(b"done!") testOutsideTimeout = testInsideTimeout def _testInsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port)) data = sock.recv(5) self.assertEqual(data, b"done!") def _testOutsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port), timeout=1) self.assertRaises(socket.timeout, lambda: sock.recv(5)) class TCPTimeoutTest(SocketTCPTest): def testTCPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (TCP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of error (TCP)") except OSError: ok = True except: self.fail("caught unexpected exception (TCP)") if not ok: self.fail("accept() returned success when we did not expect it") @unittest.skipUnless(hasattr(signal, 'alarm'), 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass def alarm_handler(signal, frame): raise Alarm old_alarm = signal.signal(signal.SIGALRM, alarm_handler) try: signal.alarm(2) # POSIX allows alarm to be up to 1 second early try: foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of Alarm") except Alarm: pass except: self.fail("caught other exception instead of Alarm:" " %s(%s):\n%s" % (sys.exc_info()[:2] + (traceback.format_exc(),))) else: self.fail("nothing caught") finally: signal.alarm(0) # shut off alarm except Alarm: self.fail("got Alarm in wrong place") finally: # no alarm can be pending. Safe to restore old handler. signal.signal(signal.SIGALRM, old_alarm) class UDPTimeoutTest(SocketUDPTest): def testUDPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.recv(1024) self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (UDP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.recv(1024) except socket.timeout: self.fail("caught timeout instead of error (UDP)") except OSError: ok = True except: self.fail("caught unexpected exception (UDP)") if not ok: self.fail("recv() returned success when we did not expect it") class TestExceptions(unittest.TestCase): def testExceptionTree(self): self.assertTrue(issubclass(OSError, Exception)) self.assertTrue(issubclass(socket.herror, OSError)) self.assertTrue(issubclass(socket.gaierror, OSError)) self.assertTrue(issubclass(socket.timeout, OSError)) @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 def testLinuxAbstractNamespace(self): address = b"\x00python-test-hello\x00\xff" with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1: s1.bind(address) s1.listen() with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s2: s2.connect(s1.getsockname()) with s1.accept()[0] as s3: self.assertEqual(s1.getsockname(), address) self.assertEqual(s2.getpeername(), address) def testMaxName(self): address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1) with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: s.bind(address) self.assertEqual(s.getsockname(), address) def testNameOverflow(self): address = "\x00" + "h" * self.UNIX_PATH_MAX with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: self.assertRaises(OSError, s.bind, address) def testStrName(self): # Check that an abstract name can be passed as a string. s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: s.bind("\x00python\x00test\x00") self.assertEqual(s.getsockname(), b"\x00python\x00test\x00") finally: s.close() def testBytearrayName(self): # Check that an abstract name can be passed as a bytearray. with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: s.bind(bytearray(b"\x00python\x00test\x00")) self.assertEqual(s.getsockname(), b"\x00python\x00test\x00") @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'test needs socket.AF_UNIX') class TestUnixDomain(unittest.TestCase): def setUp(self): self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) def tearDown(self): self.sock.close() def encoded(self, path): # Return the given path encoded in the file system encoding, # or skip the test if this is not possible. try: return os.fsencode(path) except UnicodeEncodeError: self.skipTest( "Pathname {0!a} cannot be represented in file " "system encoding {1!r}".format( path, sys.getfilesystemencoding())) def bind(self, sock, path): # Bind the socket try: sock.bind(path) except OSError as e: if str(e) == "AF_UNIX path too long": self.skipTest( "Pathname {0!a} is too long to serve as an AF_UNIX path" .format(path)) else: raise def testStrAddr(self): # Test binding to and retrieving a normal string pathname. path = os.path.abspath(support.TESTFN) self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testBytesAddr(self): # Test binding to a bytes pathname. path = os.path.abspath(support.TESTFN) self.bind(self.sock, self.encoded(path)) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testSurrogateescapeBind(self): # Test binding to a valid non-ASCII pathname, with the # non-ASCII bytes supplied using surrogateescape encoding. path = os.path.abspath(support.TESTFN_UNICODE) b = self.encoded(path) self.bind(self.sock, b.decode("ascii", "surrogateescape")) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testUnencodableAddr(self): # Test binding to a pathname that cannot be encoded in the # file system encoding. if support.TESTFN_UNENCODABLE is None: self.skipTest("No unencodable filename available") path = os.path.abspath(support.TESTFN_UNENCODABLE) self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) @unittest.skipUnless(thread, 'Threading required for this test.') class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). """ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecvIntoArray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvIntoArray(self): buf = bytes(MSG) self.serv_conn.send(buf) def testRecvIntoBytearray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoBytearray = _testRecvIntoArray def testRecvIntoMemoryview(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoMemoryview = _testRecvIntoArray def testRecvFromIntoArray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFromIntoArray(self): buf = bytes(MSG) self.serv_conn.send(buf) def testRecvFromIntoBytearray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoBytearray = _testRecvFromIntoArray def testRecvFromIntoMemoryview(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoMemoryview = _testRecvFromIntoArray def testRecvFromIntoSmallBuffer(self): # See issue #20246. buf = bytearray(8) self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) def _testRecvFromIntoSmallBuffer(self): self.serv_conn.send(MSG) def testRecvFromIntoEmptyBuffer(self): buf = bytearray() self.cli_conn.recvfrom_into(buf) self.cli_conn.recvfrom_into(buf, 0) _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray TIPC_STYPE = 2000 TIPC_LOWER = 200 TIPC_UPPER = 210 def isTipcAvailable(): """Check if the TIPC module is loaded The TIPC module is not loaded automatically on Ubuntu and probably other Linux distros. """ if not hasattr(socket, "AF_TIPC"): return False if not os.path.isfile("/proc/modules"): return False with open("/proc/modules") as f: for line in f: if line.startswith("tipc "): return True return False @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCTest(unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) self.addCleanup(srv.close) self.addCleanup(cli.close) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) srv.bind(srvaddr) sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0) cli.sendto(MSG, sendaddr) msg, recvaddr = srv.recvfrom(1024) self.assertEqual(cli.getsockname(), recvaddr) self.assertEqual(msg, MSG) @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCThreadableTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) def setUp(self): self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.addCleanup(self.srv.close) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) self.srv.bind(srvaddr) self.srv.listen() self.serverExplicitReady() self.conn, self.connaddr = self.srv.accept() self.addCleanup(self.conn.close) def clientSetUp(self): # The is a hittable race between serverExplicitReady() and the # accept() call; sleep a little while to avoid it, otherwise # we could get an exception time.sleep(0.1) self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.addCleanup(self.cli.close) addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0) self.cli.connect(addr) self.cliaddr = self.cli.getsockname() def testStream(self): msg = self.conn.recv(1024) self.assertEqual(msg, MSG) self.assertEqual(self.cliaddr, self.connaddr) def _testStream(self): self.cli.send(MSG) self.cli.close() @unittest.skipUnless(thread, 'Threading required for this test.') class ContextManagersTest(ThreadedTCPSocketTest): def _testSocketClass(self): # base test with socket.socket() as sock: self.assertFalse(sock._closed) self.assertTrue(sock._closed) # close inside with block with socket.socket() as sock: sock.close() self.assertTrue(sock._closed) # exception inside with block with socket.socket() as sock: self.assertRaises(OSError, sock.sendall, b'foo') self.assertTrue(sock._closed) def testCreateConnectionBase(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) data = conn.recv(1024) conn.sendall(data) def _testCreateConnectionBase(self): address = self.serv.getsockname() with socket.create_connection(address) as sock: self.assertFalse(sock._closed) sock.sendall(b'foo') self.assertEqual(sock.recv(1024), b'foo') self.assertTrue(sock._closed) def testCreateConnectionClose(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) data = conn.recv(1024) conn.sendall(data) def _testCreateConnectionClose(self): address = self.serv.getsockname() with socket.create_connection(address) as sock: sock.close() self.assertTrue(sock._closed) self.assertRaises(OSError, sock.sendall, b'foo') class InheritanceTest(unittest.TestCase): @unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"), "SOCK_CLOEXEC not defined") @support.requires_linux_version(2, 6, 28) def test_SOCK_CLOEXEC(self): with socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s: self.assertTrue(s.type & socket.SOCK_CLOEXEC) self.assertFalse(s.get_inheritable()) def test_default_inheritable(self): sock = socket.socket() with sock: self.assertEqual(sock.get_inheritable(), False) def test_dup(self): sock = socket.socket() with sock: newsock = sock.dup() sock.close() with newsock: self.assertEqual(newsock.get_inheritable(), False) def test_set_inheritable(self): sock = socket.socket() with sock: sock.set_inheritable(True) self.assertEqual(sock.get_inheritable(), True) sock.set_inheritable(False) self.assertEqual(sock.get_inheritable(), False) @unittest.skipIf(fcntl is None, "need fcntl") def test_get_inheritable_cloexec(self): sock = socket.socket() with sock: fd = sock.fileno() self.assertEqual(sock.get_inheritable(), False) # clear FD_CLOEXEC flag flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags &= ~fcntl.FD_CLOEXEC fcntl.fcntl(fd, fcntl.F_SETFD, flags) self.assertEqual(sock.get_inheritable(), True) @unittest.skipIf(fcntl is None, "need fcntl") def test_set_inheritable_cloexec(self): sock = socket.socket() with sock: fd = sock.fileno() self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC, fcntl.FD_CLOEXEC) sock.set_inheritable(True) self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC, 0) @unittest.skipUnless(hasattr(socket, "socketpair"), "need socket.socketpair()") def test_socketpair(self): s1, s2 = socket.socketpair() self.addCleanup(s1.close) self.addCleanup(s2.close) self.assertEqual(s1.get_inheritable(), False) self.assertEqual(s2.get_inheritable(), False) @unittest.skipUnless(hasattr(socket, "SOCK_NONBLOCK"), "SOCK_NONBLOCK not defined") class NonblockConstantTest(unittest.TestCase): def checkNonblock(self, s, nonblock=True, timeout=0.0): if nonblock: self.assertTrue(s.type & socket.SOCK_NONBLOCK) self.assertEqual(s.gettimeout(), timeout) else: self.assertFalse(s.type & socket.SOCK_NONBLOCK) self.assertEqual(s.gettimeout(), None) @support.requires_linux_version(2, 6, 28) def test_SOCK_NONBLOCK(self): # a lot of it seems silly and redundant, but I wanted to test that # changing back and forth worked ok with socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_NONBLOCK) as s: self.checkNonblock(s) s.setblocking(1) self.checkNonblock(s, False) s.setblocking(0) self.checkNonblock(s) s.settimeout(None) self.checkNonblock(s, False) s.settimeout(2.0) self.checkNonblock(s, timeout=2.0) s.setblocking(1) self.checkNonblock(s, False) # defaulttimeout t = socket.getdefaulttimeout() socket.setdefaulttimeout(0.0) with socket.socket() as s: self.checkNonblock(s) socket.setdefaulttimeout(None) with socket.socket() as s: self.checkNonblock(s, False) socket.setdefaulttimeout(2.0) with socket.socket() as s: self.checkNonblock(s, timeout=2.0) socket.setdefaulttimeout(None) with socket.socket() as s: self.checkNonblock(s, False) socket.setdefaulttimeout(t) @unittest.skipUnless(os.name == "nt", "Windows specific") @unittest.skipUnless(multiprocessing, "need multiprocessing") class TestSocketSharing(SocketTCPTest): # This must be classmethod and not staticmethod or multiprocessing # won't be able to bootstrap it. @classmethod def remoteProcessServer(cls, q): # Recreate socket from shared data sdata = q.get() message = q.get() s = socket.fromshare(sdata) s2, c = s.accept() # Send the message s2.sendall(message) s2.close() s.close() def testShare(self): # Transfer the listening server socket to another process # and service it from there. # Create process: q = multiprocessing.Queue() p = multiprocessing.Process(target=self.remoteProcessServer, args=(q,)) p.start() # Get the shared socket data data = self.serv.share(p.pid) # Pass the shared socket to the other process addr = self.serv.getsockname() self.serv.close() q.put(data) # The data that the server will send us message = b"slapmahfro" q.put(message) # Connect s = socket.create_connection(addr) # listen for the data m = [] while True: data = s.recv(100) if not data: break m.append(data) s.close() received = b"".join(m) self.assertEqual(received, message) p.join() def testShareLength(self): data = self.serv.share(os.getpid()) self.assertRaises(ValueError, socket.fromshare, data[:-1]) self.assertRaises(ValueError, socket.fromshare, data+b"foo") def compareSockets(self, org, other): # socket sharing is expected to work only for blocking socket # since the internal python timout value isn't transfered. self.assertEqual(org.gettimeout(), None) self.assertEqual(org.gettimeout(), other.gettimeout()) self.assertEqual(org.family, other.family) self.assertEqual(org.type, other.type) # If the user specified "0" for proto, then # internally windows will have picked the correct value. # Python introspection on the socket however will still return # 0. For the shared socket, the python value is recreated # from the actual value, so it may not compare correctly. if org.proto != 0: self.assertEqual(org.proto, other.proto) def testShareLocal(self): data = self.serv.share(os.getpid()) s = socket.fromshare(data) try: self.compareSockets(self.serv, s) finally: s.close() def testTypes(self): families = [socket.AF_INET, socket.AF_INET6] types = [socket.SOCK_STREAM, socket.SOCK_DGRAM] for f in families: for t in types: try: source = socket.socket(f, t) except OSError: continue # This combination is not supported try: data = source.share(os.getpid()) shared = socket.fromshare(data) try: self.compareSockets(source, shared) finally: shared.close() finally: source.close() @unittest.skipUnless(thread, 'Threading required for this test.') class SendfileUsingSendTest(ThreadedTCPSocketTest): """ Test the send() implementation of socket.sendfile(). """ FILESIZE = (10 * 1024 * 1024) # 10MB BUFSIZE = 8192 FILEDATA = b"" TIMEOUT = 2 @classmethod def setUpClass(cls): def chunks(total, step): assert total >= step while total > step: yield step total -= step if total: yield total chunk = b"".join([random.choice(string.ascii_letters).encode() for i in range(cls.BUFSIZE)]) with open(support.TESTFN, 'wb') as f: for csize in chunks(cls.FILESIZE, cls.BUFSIZE): f.write(chunk) with open(support.TESTFN, 'rb') as f: cls.FILEDATA = f.read() assert len(cls.FILEDATA) == cls.FILESIZE @classmethod def tearDownClass(cls): support.unlink(support.TESTFN) def accept_conn(self): self.serv.settimeout(self.TIMEOUT) conn, addr = self.serv.accept() conn.settimeout(self.TIMEOUT) self.addCleanup(conn.close) return conn def recv_data(self, conn): received = [] while True: chunk = conn.recv(self.BUFSIZE) if not chunk: break received.append(chunk) return b''.join(received) def meth_from_sock(self, sock): # Depending on the mixin class being run return either send() # or sendfile() method implementation. return getattr(sock, "_sendfile_use_send") # regular file def _testRegularFile(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, self.FILESIZE) self.assertEqual(file.tell(), self.FILESIZE) def testRegularFile(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # non regular file def _testNonRegularFile(self): address = self.serv.getsockname() file = io.BytesIO(self.FILEDATA) with socket.create_connection(address) as sock, file as file: sent = sock.sendfile(file) self.assertEqual(sent, self.FILESIZE) self.assertEqual(file.tell(), self.FILESIZE) self.assertRaises(socket._GiveupOnSendfile, sock._sendfile_use_sendfile, file) def testNonRegularFile(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # empty file def _testEmptyFileSend(self): address = self.serv.getsockname() filename = support.TESTFN + "2" with open(filename, 'wb'): self.addCleanup(support.unlink, filename) file = open(filename, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, 0) self.assertEqual(file.tell(), 0) def testEmptyFileSend(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(data, b"") # offset def _testOffset(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file, offset=5000) self.assertEqual(sent, self.FILESIZE - 5000) self.assertEqual(file.tell(), self.FILESIZE) def testOffset(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE - 5000) self.assertEqual(data, self.FILEDATA[5000:]) # count def _testCount(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 5000007 meth = self.meth_from_sock(sock) sent = meth(file, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count) def testCount(self): count = 5000007 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[:count]) # count small def _testCountSmall(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 1 meth = self.meth_from_sock(sock) sent = meth(file, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count) def testCountSmall(self): count = 1 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[:count]) # count + offset def _testCountWithOffset(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 100007 meth = self.meth_from_sock(sock) sent = meth(file, offset=2007, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count + 2007) def testCountWithOffset(self): count = 100007 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[2007:count+2007]) # non blocking sockets are not supposed to work def _testNonBlocking(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: sock.setblocking(False) meth = self.meth_from_sock(sock) self.assertRaises(ValueError, meth, file) self.assertRaises(ValueError, sock.sendfile, file) def testNonBlocking(self): conn = self.accept_conn() if conn.recv(8192): self.fail('was not supposed to receive any data') # timeout (non-triggered) def _testWithTimeout(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, self.FILESIZE) def testWithTimeout(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # timeout (triggered) def _testWithTimeoutTriggeredSend(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=0.01) as sock, \ file as file: meth = self.meth_from_sock(sock) self.assertRaises(socket.timeout, meth, file) def testWithTimeoutTriggeredSend(self): conn = self.accept_conn() conn.recv(88192) # errors def _test_errors(self): pass def test_errors(self): with open(support.TESTFN, 'rb') as file: with socket.socket(type=socket.SOCK_DGRAM) as s: meth = self.meth_from_sock(s) self.assertRaisesRegex( ValueError, "SOCK_STREAM", meth, file) with open(support.TESTFN, 'rt') as file: with socket.socket() as s: meth = self.meth_from_sock(s) self.assertRaisesRegex( ValueError, "binary mode", meth, file) with open(support.TESTFN, 'rb') as file: with socket.socket() as s: meth = self.meth_from_sock(s) self.assertRaisesRegex(TypeError, "positive integer", meth, file, count='2') self.assertRaisesRegex(TypeError, "positive integer", meth, file, count=0.1) self.assertRaisesRegex(ValueError, "positive integer", meth, file, count=0) self.assertRaisesRegex(ValueError, "positive integer", meth, file, count=-1) @unittest.skipUnless(thread, 'Threading required for this test.') @unittest.skipUnless(hasattr(os, "sendfile"), 'os.sendfile() required for this test.') @unittest.skipUnless(hasattr(os, 'gevent_uses_sendfile'), 'gevent sockets do not support this') class SendfileUsingSendfileTest(SendfileUsingSendTest): """ Test the sendfile() implementation of socket.sendfile(). """ def meth_from_sock(self, sock): return getattr(sock, "_sendfile_use_sendfile") def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, UnicodeReadFileObjectClassTestCase, UnicodeWriteFileObjectClassTestCase, UnicodeReadWriteFileObjectClassTestCase, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ContextManagersTest, InheritanceTest, NonblockConstantTest ]) tests.append(BasicSocketPairTest) tests.append(TestUnixDomain) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) tests.extend([BasicCANTest, CANTest]) tests.extend([BasicRDSTest, RDSTest]) tests.extend([ CmsgMacroTests, SendmsgUDPTest, RecvmsgUDPTest, RecvmsgIntoUDPTest, SendmsgUDP6Test, RecvmsgUDP6Test, RecvmsgRFC3542AncillaryUDP6Test, RecvmsgIntoRFC3542AncillaryUDP6Test, RecvmsgIntoUDP6Test, SendmsgTCPTest, RecvmsgTCPTest, RecvmsgIntoTCPTest, SendmsgSCTPStreamTest, RecvmsgSCTPStreamTest, RecvmsgIntoSCTPStreamTest, SendmsgUnixStreamTest, RecvmsgUnixStreamTest, RecvmsgIntoUnixStreamTest, RecvmsgSCMRightsStreamTest, RecvmsgIntoSCMRightsStreamTest, # These are slow when setitimer() is not available InterruptedRecvTimeoutTest, InterruptedSendTimeoutTest, TestSocketSharing, SendfileUsingSendTest, SendfileUsingSendfileTest, ]) thread_info = support.threading_setup() support.run_unittest(*tests) support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/3.5/test_ssl.py0000644000076500000000000044656512666555342020302 0ustar jmaddenwheel00000000000000# Test the support for SSL and sockets import sys import unittest from test import support import socket import select import time import datetime import gc import os import errno import pprint import tempfile import urllib.request import traceback import asyncore import weakref import platform import functools ssl = support.import_module("ssl") PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) HOST = support.HOST def data_file(*name): return os.path.join(os.path.dirname(__file__), *name) # The custom key and certificate files used in test_ssl are generated # using Lib/test/make_ssl_certs.py. # Other certificates are simply fetched from the Internet servers they # are meant to authenticate. CERTFILE = data_file("keycert.pem") BYTES_CERTFILE = os.fsencode(CERTFILE) ONLYCERT = data_file("ssl_cert.pem") ONLYKEY = data_file("ssl_key.pem") BYTES_ONLYCERT = os.fsencode(ONLYCERT) BYTES_ONLYKEY = os.fsencode(ONLYKEY) CERTFILE_PROTECTED = data_file("keycert.passwd.pem") ONLYKEY_PROTECTED = data_file("ssl_key.passwd.pem") KEY_PASSWORD = "somepass" CAPATH = data_file("capath") BYTES_CAPATH = os.fsencode(CAPATH) CAFILE_NEURONIO = data_file("capath", "4e1295a3.0") CAFILE_CACERT = data_file("capath", "5ed36f99.0") # empty CRL CRLFILE = data_file("revocation.crl") # Two keys and certs signed by the same CA (for SNI tests) SIGNED_CERTFILE = data_file("keycert3.pem") SIGNED_CERTFILE2 = data_file("keycert4.pem") SIGNING_CA = data_file("pycacert.pem") REMOTE_HOST = "self-signed.pythontest.net" REMOTE_ROOT_CERT = data_file("selfsigned_pythontestdotnet.pem") EMPTYCERT = data_file("nullcert.pem") BADCERT = data_file("badcert.pem") NONEXISTINGCERT = data_file("XXXnonexisting.pem") BADKEY = data_file("badkey.pem") NOKIACERT = data_file("nokia.pem") NULLBYTECERT = data_file("nullbytecert.pem") DHFILE = data_file("dh1024.pem") BYTES_DHFILE = os.fsencode(DHFILE) def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) if support.verbose: sys.stdout.write(prefix + exc_format) def can_clear_options(): # 0.9.8m or higher return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15) def no_sslv2_implies_sslv3_hello(): # 0.9.7h or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15) def have_verify_flags(): # 0.9.8 or higher return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 0, 15) def utc_offset(): #NOTE: ignore issues like #1647654 # local time = utc time + utc offset if time.daylight and time.localtime().tm_isdst > 0: return -time.altzone # seconds return -time.timezone def asn1time(cert_time): # Some versions of OpenSSL ignore seconds, see #18207 # 0.9.8.i if ssl._OPENSSL_API_VERSION == (0, 9, 8, 9, 15): fmt = "%b %d %H:%M:%S %Y GMT" dt = datetime.datetime.strptime(cert_time, fmt) dt = dt.replace(second=0) cert_time = dt.strftime(fmt) # %d adds leading zero but ASN1_TIME_print() uses leading space if cert_time[4] == "0": cert_time = cert_time[:4] + " " + cert_time[5:] return cert_time # Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2 def skip_if_broken_ubuntu_ssl(func): if hasattr(ssl, 'PROTOCOL_SSLv2'): @functools.wraps(func) def f(*args, **kwargs): try: ssl.SSLContext(ssl.PROTOCOL_SSLv2) except ssl.SSLError: if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and platform.linux_distribution() == ('debian', 'squeeze/sid', '')): raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour") return func(*args, **kwargs) return f else: return func needs_sni = unittest.skipUnless(ssl.HAS_SNI, "SNI support needed for this test") class BasicSocketTests(unittest.TestCase): def test_constants(self): ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED ssl.OP_CIPHER_SERVER_PREFERENCE ssl.OP_SINGLE_DH_USE if ssl.HAS_ECDH: ssl.OP_SINGLE_ECDH_USE if ssl.OPENSSL_VERSION_INFO >= (1, 0): ssl.OP_NO_COMPRESSION self.assertIn(ssl.HAS_SNI, {True, False}) self.assertIn(ssl.HAS_ECDH, {True, False}) def test_str_for_enums(self): # Make sure that the PROTOCOL_* constants have enum-like string # reprs. proto = ssl.PROTOCOL_SSLv23 self.assertEqual(str(proto), '_SSLMethod.PROTOCOL_SSLv23') ctx = ssl.SSLContext(proto) self.assertIs(ctx.protocol, proto) def test_random(self): v = ssl.RAND_status() if support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) data, is_cryptographic = ssl.RAND_pseudo_bytes(16) self.assertEqual(len(data), 16) self.assertEqual(is_cryptographic, v == 1) if v: data = ssl.RAND_bytes(16) self.assertEqual(len(data), 16) else: self.assertRaises(ssl.SSLError, ssl.RAND_bytes, 16) # negative num is invalid self.assertRaises(ValueError, ssl.RAND_bytes, -5) self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5) if hasattr(ssl, 'RAND_egd'): self.assertRaises(TypeError, ssl.RAND_egd, 1) self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) ssl.RAND_add("this is a random string", 75.0) ssl.RAND_add(b"this is a random bytes object", 75.0) ssl.RAND_add(bytearray(b"this is a random bytearray object"), 75.0) @unittest.skipUnless(os.name == 'posix', 'requires posix') def test_random_fork(self): status = ssl.RAND_status() if not status: self.fail("OpenSSL's PRNG has insufficient randomness") rfd, wfd = os.pipe() pid = os.fork() if pid == 0: try: os.close(rfd) child_random = ssl.RAND_pseudo_bytes(16)[0] self.assertEqual(len(child_random), 16) os.write(wfd, child_random) os.close(wfd) except BaseException: os._exit(1) else: os._exit(0) else: os.close(wfd) self.addCleanup(os.close, rfd) _, status = os.waitpid(pid, 0) self.assertEqual(status, 0) child_random = os.read(rfd, 16) self.assertEqual(len(child_random), 16) parent_random = ssl.RAND_pseudo_bytes(16)[0] self.assertEqual(len(parent_random), 16) self.assertNotEqual(child_random, parent_random) def test_parse_cert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['issuer'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) # Note the next three asserts will fail if the keys are regenerated self.assertEqual(p['notAfter'], asn1time('Oct 5 23:01:56 2020 GMT')) self.assertEqual(p['notBefore'], asn1time('Oct 8 23:01:56 2010 GMT')) self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') self.assertEqual(p['subject'], ((('countryName', 'XY'),), (('localityName', 'Castle Anthrax'),), (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) # Issue #13034: the subjectAltName in some certificates # (notably projects.developer.nokia.com:443) wasn't parsed p = ssl._ssl._test_decode_cert(NOKIACERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subjectAltName'], (('DNS', 'projects.developer.nokia.com'), ('DNS', 'projects.forum.nokia.com')) ) # extra OCSP and AIA fields self.assertEqual(p['OCSP'], ('http://ocsp.verisign.com',)) self.assertEqual(p['caIssuers'], ('http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cer',)) self.assertEqual(p['crlDistributionPoints'], ('http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl',)) def test_parse_cert_CVE_2013_4238(self): p = ssl._ssl._test_decode_cert(NULLBYTECERT) if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") subject = ((('countryName', 'US'),), (('stateOrProvinceName', 'Oregon'),), (('localityName', 'Beaverton'),), (('organizationName', 'Python Software Foundation'),), (('organizationalUnitName', 'Python Core Development'),), (('commonName', 'null.python.org\x00example.org'),), (('emailAddress', 'python-dev@python.org'),)) self.assertEqual(p['subject'], subject) self.assertEqual(p['issuer'], subject) if ssl._OPENSSL_API_VERSION >= (0, 9, 8): san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '2001:DB8:0:0:0:0:0:1\n')) else: # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), ('IP Address', '192.0.2.1'), ('IP Address', '')) self.assertEqual(p['subjectAltName'], san) def test_DER_to_PEM(self): with open(CAFILE_CACERT, 'r') as f: pem = f.read() d1 = ssl.PEM_cert_to_DER_cert(pem) p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) self.assertEqual(d1, d2) if not p2.startswith(ssl.PEM_HEADER + '\n'): self.fail("DER-to-PEM didn't include correct header:\n%r\n" % p2) if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'): self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2) def test_openssl_version(self): n = ssl.OPENSSL_VERSION_NUMBER t = ssl.OPENSSL_VERSION_INFO s = ssl.OPENSSL_VERSION self.assertIsInstance(n, int) self.assertIsInstance(t, tuple) self.assertIsInstance(s, str) # Some sanity checks follow # >= 0.9 self.assertGreaterEqual(n, 0x900000) # < 3.0 self.assertLess(n, 0x30000000) major, minor, fix, patch, status = t self.assertGreaterEqual(major, 0) self.assertLess(major, 3) self.assertGreaterEqual(minor, 0) self.assertLess(minor, 256) self.assertGreaterEqual(fix, 0) self.assertLess(fix, 256) self.assertGreaterEqual(patch, 0) self.assertLessEqual(patch, 63) self.assertGreaterEqual(status, 0) self.assertLessEqual(status, 15) # Version string as returned by {Open,Libre}SSL, the format might change if "LibreSSL" in s: self.assertTrue(s.startswith("LibreSSL {:d}.{:d}".format(major, minor)), (s, t, hex(n))) else: self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), (s, t, hex(n))) @support.cpython_only def test_refcycle(self): # Issue #7943: an SSL object doesn't create reference cycles with # itself. s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) with support.check_warnings(("", ResourceWarning)): del ss self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # Methods on an unconnected SSLSocket propagate the original # OSError raise by the underlying socket object. s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s) as ss: self.assertRaises(OSError, ss.recv, 1) self.assertRaises(OSError, ss.recv_into, bytearray(b'x')) self.assertRaises(OSError, ss.recvfrom, 1) self.assertRaises(OSError, ss.recvfrom_into, bytearray(b'x'), 1) self.assertRaises(OSError, ss.send, b'x') self.assertRaises(OSError, ss.sendto, b'x', ('0.0.0.0', 0)) def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the # original socket should be retained. for timeout in (None, 0.0, 5.0): s = socket.socket(socket.AF_INET) s.settimeout(timeout) with ssl.wrap_socket(s) as ss: self.assertEqual(timeout, ss.gettimeout()) def test_errors(self): sock = socket.socket() self.assertRaisesRegex(ValueError, "certfile must be specified", ssl.wrap_socket, sock, keyfile=CERTFILE) self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True) self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True, certfile="") with ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) as s: self.assertRaisesRegex(ValueError, "can't connect in server-side mode", s.connect, (HOST, 8080)) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=CERTFILE, keyfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=NONEXISTINGCERT, keyfile=NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) def bad_cert_test(self, certfile): """Check that trying to use the given client certificate fails""" certfile = os.path.join(os.path.dirname(__file__) or os.curdir, certfile) sock = socket.socket() self.addCleanup(sock.close) with self.assertRaises(ssl.SSLError): ssl.wrap_socket(sock, certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) def test_empty_cert(self): """Wrapping with an empty cert file""" self.bad_cert_test("nullcert.pem") def test_malformed_cert(self): """Wrapping with a badly formatted certificate (syntax error)""" self.bad_cert_test("badcert.pem") def test_malformed_key(self): """Wrapping with a badly formatted key (syntax error)""" self.bad_cert_test("badkey.pem") def test_match_hostname(self): def ok(cert, hostname): ssl.match_hostname(cert, hostname) def fail(cert, hostname): self.assertRaises(ssl.CertificateError, ssl.match_hostname, cert, hostname) # -- Hostname matching -- cert = {'subject': ((('commonName', 'example.com'),),)} ok(cert, 'example.com') ok(cert, 'ExAmple.cOm') fail(cert, 'www.example.com') fail(cert, '.example.com') fail(cert, 'example.org') fail(cert, 'exampleXcom') cert = {'subject': ((('commonName', '*.a.com'),),)} ok(cert, 'foo.a.com') fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') # only match one left-most wildcard cert = {'subject': ((('commonName', 'f*.com'),),)} ok(cert, 'foo.com') ok(cert, 'f.com') fail(cert, 'bar.com') fail(cert, 'foo.a.com') fail(cert, 'bar.foo.com') # NULL bytes are bad, CVE-2013-4073 cert = {'subject': ((('commonName', 'null.python.org\x00example.org'),),)} ok(cert, 'null.python.org\x00example.org') # or raise an error? fail(cert, 'example.org') fail(cert, 'null.python.org') # error cases with wildcards cert = {'subject': ((('commonName', '*.*.a.com'),),)} fail(cert, 'bar.foo.a.com') fail(cert, 'a.com') fail(cert, 'Xa.com') fail(cert, '.a.com') cert = {'subject': ((('commonName', 'a.*.com'),),)} fail(cert, 'a.foo.com') fail(cert, 'a..com') fail(cert, 'a.com') # wildcard doesn't match IDNA prefix 'xn--' idna = 'püthon.python.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, idna) cert = {'subject': ((('commonName', 'x*.python.org'),),)} fail(cert, idna) cert = {'subject': ((('commonName', 'xn--p*.python.org'),),)} fail(cert, idna) # wildcard in first fragment and IDNA A-labels in sequent fragments # are supported. idna = 'www*.pythön.org'.encode("idna").decode("ascii") cert = {'subject': ((('commonName', idna),),)} ok(cert, 'www.pythön.org'.encode("idna").decode("ascii")) ok(cert, 'www1.pythön.org'.encode("idna").decode("ascii")) fail(cert, 'ftp.pythön.org'.encode("idna").decode("ascii")) fail(cert, 'pythön.org'.encode("idna").decode("ascii")) # Slightly fake real-world example cert = {'notAfter': 'Jun 26 21:41:46 2011 GMT', 'subject': ((('commonName', 'linuxfrz.org'),),), 'subjectAltName': (('DNS', 'linuxfr.org'), ('DNS', 'linuxfr.com'), ('othername', ''))} ok(cert, 'linuxfr.org') ok(cert, 'linuxfr.com') # Not a "DNS" entry fail(cert, '') # When there is a subjectAltName, commonName isn't used fail(cert, 'linuxfrz.org') # A pristine real-world example cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),), (('commonName', 'mail.google.com'),))} ok(cert, 'mail.google.com') fail(cert, 'gmail.com') # Only commonName is considered fail(cert, 'California') # -- IPv4 matching -- cert = {'subject': ((('commonName', 'example.com'),),), 'subjectAltName': (('DNS', 'example.com'), ('IP Address', '10.11.12.13'), ('IP Address', '14.15.16.17'))} ok(cert, '10.11.12.13') ok(cert, '14.15.16.17') fail(cert, '14.15.16.18') fail(cert, 'example.net') # -- IPv6 matching -- cert = {'subject': ((('commonName', 'example.com'),),), 'subjectAltName': (('DNS', 'example.com'), ('IP Address', '2001:0:0:0:0:0:0:CAFE\n'), ('IP Address', '2003:0:0:0:0:0:0:BABA\n'))} ok(cert, '2001::cafe') ok(cert, '2003::baba') fail(cert, '2003::bebe') fail(cert, 'example.net') # -- Miscellaneous -- # Neither commonName nor subjectAltName cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),))} fail(cert, 'mail.google.com') # No DNS entry in subjectAltName but a commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('commonName', 'mail.google.com'),)), 'subjectAltName': (('othername', 'blabla'), )} ok(cert, 'mail.google.com') # No DNS entry subjectAltName and no commonName cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ((('countryName', 'US'),), (('stateOrProvinceName', 'California'),), (('localityName', 'Mountain View'),), (('organizationName', 'Google Inc'),)), 'subjectAltName': (('othername', 'blabla'),)} fail(cert, 'google.com') # Empty cert / no cert self.assertRaises(ValueError, ssl.match_hostname, None, 'example.com') self.assertRaises(ValueError, ssl.match_hostname, {}, 'example.com') # Issue #17980: avoid denials of service by refusing more than one # wildcard per fragment. cert = {'subject': ((('commonName', 'a*b.com'),),)} ok(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b.co*'),),)} fail(cert, 'axxb.com') cert = {'subject': ((('commonName', 'a*b*.com'),),)} with self.assertRaises(ssl.CertificateError) as cm: ssl.match_hostname(cert, 'axxbxxc.com') self.assertIn("too many wildcards", str(cm.exception)) def test_server_side(self): # server_hostname doesn't work for server sockets ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with socket.socket() as sock: self.assertRaises(ValueError, ctx.wrap_socket, sock, True, server_hostname="some.hostname") def test_unknown_channel_binding(self): # should raise ValueError for unknown type s = socket.socket(socket.AF_INET) s.bind(('127.0.0.1', 0)) s.listen() c = socket.socket(socket.AF_INET) c.connect(s.getsockname()) with ssl.wrap_socket(c, do_handshake_on_connect=False) as ss: with self.assertRaises(ValueError): ss.get_channel_binding("unknown-type") s.close() @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): # unconnected should return None for known type s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) # the same for server-side s = socket.socket(socket.AF_INET) with ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) as ss: self.assertIsNone(ss.get_channel_binding("tls-unique")) def test_dealloc_warn(self): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) r = repr(ss) with self.assertWarns(ResourceWarning) as cm: ss = None support.gc_collect() self.assertIn(r, str(cm.warning.args[0])) def test_get_default_verify_paths(self): paths = ssl.get_default_verify_paths() self.assertEqual(len(paths), 6) self.assertIsInstance(paths, ssl.DefaultVerifyPaths) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE paths = ssl.get_default_verify_paths() self.assertEqual(paths.cafile, CERTFILE) self.assertEqual(paths.capath, CAPATH) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_certificates(self): self.assertTrue(ssl.enum_certificates("CA")) self.assertTrue(ssl.enum_certificates("ROOT")) self.assertRaises(TypeError, ssl.enum_certificates) self.assertRaises(WindowsError, ssl.enum_certificates, "") trust_oids = set() for storename in ("CA", "ROOT"): store = ssl.enum_certificates(storename) self.assertIsInstance(store, list) for element in store: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 3) cert, enc, trust = element self.assertIsInstance(cert, bytes) self.assertIn(enc, {"x509_asn", "pkcs_7_asn"}) self.assertIsInstance(trust, (set, bool)) if isinstance(trust, set): trust_oids.update(trust) serverAuth = "1.3.6.1.5.5.7.3.1" self.assertIn(serverAuth, trust_oids) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_enum_crls(self): self.assertTrue(ssl.enum_crls("CA")) self.assertRaises(TypeError, ssl.enum_crls) self.assertRaises(WindowsError, ssl.enum_crls, "") crls = ssl.enum_crls("CA") self.assertIsInstance(crls, list) for element in crls: self.assertIsInstance(element, tuple) self.assertEqual(len(element), 2) self.assertIsInstance(element[0], bytes) self.assertIn(element[1], {"x509_asn", "pkcs_7_asn"}) def test_asn1object(self): expected = (129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertEqual(val, expected) self.assertEqual(val.nid, 129) self.assertEqual(val.shortname, 'serverAuth') self.assertEqual(val.longname, 'TLS Web Server Authentication') self.assertEqual(val.oid, '1.3.6.1.5.5.7.3.1') self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object, 'serverAuth') val = ssl._ASN1Object.fromnid(129) self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertRaises(ValueError, ssl._ASN1Object.fromnid, -1) with self.assertRaisesRegex(ValueError, "unknown NID 100000"): ssl._ASN1Object.fromnid(100000) for i in range(1000): try: obj = ssl._ASN1Object.fromnid(i) except ValueError: pass else: self.assertIsInstance(obj.nid, int) self.assertIsInstance(obj.shortname, str) self.assertIsInstance(obj.longname, str) self.assertIsInstance(obj.oid, (str, type(None))) val = ssl._ASN1Object.fromname('TLS Web Server Authentication') self.assertEqual(val, expected) self.assertIsInstance(val, ssl._ASN1Object) self.assertEqual(ssl._ASN1Object.fromname('serverAuth'), expected) self.assertEqual(ssl._ASN1Object.fromname('1.3.6.1.5.5.7.3.1'), expected) with self.assertRaisesRegex(ValueError, "unknown object 'serverauth'"): ssl._ASN1Object.fromname('serverauth') def test_purpose_enum(self): val = ssl._ASN1Object('1.3.6.1.5.5.7.3.1') self.assertIsInstance(ssl.Purpose.SERVER_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.SERVER_AUTH, val) self.assertEqual(ssl.Purpose.SERVER_AUTH.nid, 129) self.assertEqual(ssl.Purpose.SERVER_AUTH.shortname, 'serverAuth') self.assertEqual(ssl.Purpose.SERVER_AUTH.oid, '1.3.6.1.5.5.7.3.1') val = ssl._ASN1Object('1.3.6.1.5.5.7.3.2') self.assertIsInstance(ssl.Purpose.CLIENT_AUTH, ssl._ASN1Object) self.assertEqual(ssl.Purpose.CLIENT_AUTH, val) self.assertEqual(ssl.Purpose.CLIENT_AUTH.nid, 130) self.assertEqual(ssl.Purpose.CLIENT_AUTH.shortname, 'clientAuth') self.assertEqual(ssl.Purpose.CLIENT_AUTH.oid, '1.3.6.1.5.5.7.3.2') def test_unsupported_dtls(self): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) with self.assertRaises(NotImplementedError) as cx: ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE) self.assertEqual(str(cx.exception), "only stream sockets are supported") ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with self.assertRaises(NotImplementedError) as cx: ctx.wrap_socket(s) self.assertEqual(str(cx.exception), "only stream sockets are supported") def cert_time_ok(self, timestring, timestamp): self.assertEqual(ssl.cert_time_to_seconds(timestring), timestamp) def cert_time_fail(self, timestring): with self.assertRaises(ValueError): ssl.cert_time_to_seconds(timestring) @unittest.skipUnless(utc_offset(), 'local time needs to be different from UTC') def test_cert_time_to_seconds_timezone(self): # Issue #19940: ssl.cert_time_to_seconds() returns wrong # results if local timezone is not UTC self.cert_time_ok("May 9 00:00:00 2007 GMT", 1178668800.0) self.cert_time_ok("Jan 5 09:34:43 2018 GMT", 1515144883.0) def test_cert_time_to_seconds(self): timestring = "Jan 5 09:34:43 2018 GMT" ts = 1515144883.0 self.cert_time_ok(timestring, ts) # accept keyword parameter, assert its name self.assertEqual(ssl.cert_time_to_seconds(cert_time=timestring), ts) # accept both %e and %d (space or zero generated by strftime) self.cert_time_ok("Jan 05 09:34:43 2018 GMT", ts) # case-insensitive self.cert_time_ok("JaN 5 09:34:43 2018 GmT", ts) self.cert_time_fail("Jan 5 09:34 2018 GMT") # no seconds self.cert_time_fail("Jan 5 09:34:43 2018") # no GMT self.cert_time_fail("Jan 5 09:34:43 2018 UTC") # not GMT timezone self.cert_time_fail("Jan 35 09:34:43 2018 GMT") # invalid day self.cert_time_fail("Jon 5 09:34:43 2018 GMT") # invalid month self.cert_time_fail("Jan 5 24:00:00 2018 GMT") # invalid hour self.cert_time_fail("Jan 5 09:60:43 2018 GMT") # invalid minute newyear_ts = 1230768000.0 # leap seconds self.cert_time_ok("Dec 31 23:59:60 2008 GMT", newyear_ts) # same timestamp self.cert_time_ok("Jan 1 00:00:00 2009 GMT", newyear_ts) self.cert_time_ok("Jan 5 09:34:59 2018 GMT", 1515144899) # allow 60th second (even if it is not a leap second) self.cert_time_ok("Jan 5 09:34:60 2018 GMT", 1515144900) # allow 2nd leap second for compatibility with time.strptime() self.cert_time_ok("Jan 5 09:34:61 2018 GMT", 1515144901) self.cert_time_fail("Jan 5 09:34:62 2018 GMT") # invalid seconds # no special treatement for the special value: # 99991231235959Z (rfc 5280) self.cert_time_ok("Dec 31 23:59:59 9999 GMT", 253402300799.0) @support.run_with_locale('LC_ALL', '') def test_cert_time_to_seconds_locale(self): # `cert_time_to_seconds()` should be locale independent def local_february_name(): return time.strftime('%b', (1, 2, 3, 4, 5, 6, 0, 0, 0)) if local_february_name().lower() == 'feb': self.skipTest("locale-specific month name needs to be " "different from C locale") # locale-independent self.cert_time_ok("Feb 9 00:00:00 2007 GMT", 1170979200.0) self.cert_time_fail(local_february_name() + " 9 00:00:00 2007 GMT") class ContextTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_constructor(self): for protocol in PROTOCOLS: ssl.SSLContext(protocol) self.assertRaises(TypeError, ssl.SSLContext) self.assertRaises(ValueError, ssl.SSLContext, -1) self.assertRaises(ValueError, ssl.SSLContext, 42) @skip_if_broken_ubuntu_ssl def test_protocol(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.protocol, proto) def test_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") @skip_if_broken_ubuntu_ssl def test_options(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3, ctx.options) ctx.options |= ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1, ctx.options) if can_clear_options(): ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1 self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3, ctx.options) ctx.options = 0 self.assertEqual(0, ctx.options) else: with self.assertRaises(ValueError): ctx.options = 0 def test_verify_mode(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Default value self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) ctx.verify_mode = ssl.CERT_OPTIONAL self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL) ctx.verify_mode = ssl.CERT_REQUIRED self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) ctx.verify_mode = ssl.CERT_NONE self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) with self.assertRaises(TypeError): ctx.verify_mode = None with self.assertRaises(ValueError): ctx.verify_mode = 42 @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_verify_flags(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # default value tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT | tf) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF) ctx.verify_flags = ssl.VERIFY_CRL_CHECK_CHAIN self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_CHAIN) ctx.verify_flags = ssl.VERIFY_DEFAULT self.assertEqual(ctx.verify_flags, ssl.VERIFY_DEFAULT) # supports any value ctx.verify_flags = ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT self.assertEqual(ctx.verify_flags, ssl.VERIFY_CRL_CHECK_LEAF | ssl.VERIFY_X509_STRICT) with self.assertRaises(TypeError): ctx.verify_flags = None def test_load_cert_chain(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Combined key and cert in a single file ctx.load_cert_chain(CERTFILE, keyfile=None) ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE) self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE) with self.assertRaises(OSError) as cm: ctx.load_cert_chain(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(BADCERT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(EMPTYCERT) # Separate key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_cert_chain(ONLYCERT, ONLYKEY) ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY) ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYCERT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(ONLYKEY) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT) # Mismatching key and cert ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"): ctx.load_cert_chain(CAFILE_CACERT, ONLYKEY) # Password protected key and cert ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD) ctx.load_cert_chain(CERTFILE_PROTECTED, password=KEY_PASSWORD.encode()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=bytearray(KEY_PASSWORD.encode())) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, KEY_PASSWORD.encode()) ctx.load_cert_chain(ONLYCERT, ONLYKEY_PROTECTED, bytearray(KEY_PASSWORD.encode())) with self.assertRaisesRegex(TypeError, "should be a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=True) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password="badpass") with self.assertRaisesRegex(ValueError, "cannot be longer"): # openssl has a fixed limit on the password buffer. # PEM_BUFSIZE is generally set to 1kb. # Return a string larger than this. ctx.load_cert_chain(CERTFILE_PROTECTED, password=b'a' * 102400) # Password callback def getpass_unicode(): return KEY_PASSWORD def getpass_bytes(): return KEY_PASSWORD.encode() def getpass_bytearray(): return bytearray(KEY_PASSWORD.encode()) def getpass_badpass(): return "badpass" def getpass_huge(): return b'a' * (1024 * 1024) def getpass_bad_type(): return 9 def getpass_exception(): raise Exception('getpass error') class GetPassCallable: def __call__(self): return KEY_PASSWORD def getpass(self): return KEY_PASSWORD ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_unicode) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytes) ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bytearray) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable()) ctx.load_cert_chain(CERTFILE_PROTECTED, password=GetPassCallable().getpass) with self.assertRaises(ssl.SSLError): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_badpass) with self.assertRaisesRegex(ValueError, "cannot be longer"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_huge) with self.assertRaisesRegex(TypeError, "must return a string"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_bad_type) with self.assertRaisesRegex(Exception, "getpass error"): ctx.load_cert_chain(CERTFILE_PROTECTED, password=getpass_exception) # Make sure the password function isn't called if it isn't needed ctx.load_cert_chain(CERTFILE, password=getpass_exception) def test_load_verify_locations(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(CERTFILE) ctx.load_verify_locations(cafile=CERTFILE, capath=None) ctx.load_verify_locations(BYTES_CERTFILE) ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None) self.assertRaises(TypeError, ctx.load_verify_locations) self.assertRaises(TypeError, ctx.load_verify_locations, None, None, None) with self.assertRaises(OSError) as cm: ctx.load_verify_locations(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaisesRegex(ssl.SSLError, "PEM lib"): ctx.load_verify_locations(BADCERT) ctx.load_verify_locations(CERTFILE, CAPATH) ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH) # Issue #10989: crash if the second argument type is invalid self.assertRaises(TypeError, ctx.load_verify_locations, None, True) def test_load_verify_cadata(self): # test cadata with open(CAFILE_CACERT) as f: cacert_pem = f.read() cacert_der = ssl.PEM_cert_to_DER_cert(cacert_pem) with open(CAFILE_NEURONIO) as f: neuronio_pem = f.read() neuronio_der = ssl.PEM_cert_to_DER_cert(neuronio_pem) # test PEM ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 0) ctx.load_verify_locations(cadata=cacert_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 1) ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=neuronio_pem) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = "\n".join((cacert_pem, neuronio_pem)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # with junk around the certs ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = ["head", cacert_pem, "other", neuronio_pem, "again", neuronio_pem, "tail"] ctx.load_verify_locations(cadata="\n".join(combined)) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # test DER ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_verify_locations(cadata=cacert_der) ctx.load_verify_locations(cadata=neuronio_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # cert already in hash table ctx.load_verify_locations(cadata=cacert_der) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # combined ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) combined = b"".join((cacert_der, neuronio_der)) ctx.load_verify_locations(cadata=combined) self.assertEqual(ctx.cert_store_stats()["x509_ca"], 2) # error cases ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_verify_locations, cadata=object) with self.assertRaisesRegex(ssl.SSLError, "no start line"): ctx.load_verify_locations(cadata="broken") with self.assertRaisesRegex(ssl.SSLError, "not enough data"): ctx.load_verify_locations(cadata=b"broken") def test_load_dh_params(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_dh_params(DHFILE) if os.name != 'nt': ctx.load_dh_params(BYTES_DHFILE) self.assertRaises(TypeError, ctx.load_dh_params) self.assertRaises(TypeError, ctx.load_dh_params, None) with self.assertRaises(FileNotFoundError) as cm: ctx.load_dh_params(NONEXISTINGCERT) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) @skip_if_broken_ubuntu_ssl def test_session_stats(self): for proto in PROTOCOLS: ctx = ssl.SSLContext(proto) self.assertEqual(ctx.session_stats(), { 'number': 0, 'connect': 0, 'connect_good': 0, 'connect_renegotiate': 0, 'accept': 0, 'accept_good': 0, 'accept_renegotiate': 0, 'hits': 0, 'misses': 0, 'timeouts': 0, 'cache_full': 0, }) def test_set_default_verify_paths(self): # There's not much we can do to test that it acts as expected, # so just check it doesn't crash or raise an exception. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_default_verify_paths() @unittest.skipUnless(ssl.HAS_ECDH, "ECDH disabled on this OpenSSL build") def test_set_ecdh_curve(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ecdh_curve("prime256v1") ctx.set_ecdh_curve(b"prime256v1") self.assertRaises(TypeError, ctx.set_ecdh_curve) self.assertRaises(TypeError, ctx.set_ecdh_curve, None) self.assertRaises(ValueError, ctx.set_ecdh_curve, "foo") self.assertRaises(ValueError, ctx.set_ecdh_curve, b"foo") @needs_sni def test_sni_callback(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # set_servername_callback expects a callable, or None self.assertRaises(TypeError, ctx.set_servername_callback) self.assertRaises(TypeError, ctx.set_servername_callback, 4) self.assertRaises(TypeError, ctx.set_servername_callback, "") self.assertRaises(TypeError, ctx.set_servername_callback, ctx) def dummycallback(sock, servername, ctx): pass ctx.set_servername_callback(None) ctx.set_servername_callback(dummycallback) @needs_sni def test_sni_callback_refcycle(self): # Reference cycles through the servername callback are detected # and cleared. ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) def dummycallback(sock, servername, ctx, cycle=ctx): pass ctx.set_servername_callback(dummycallback) wr = weakref.ref(ctx) del ctx, dummycallback gc.collect() self.assertIs(wr(), None) def test_cert_store_stats(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_cert_chain(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 0}) ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 0, 'crl': 0, 'x509': 1}) ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.cert_store_stats(), {'x509_ca': 1, 'crl': 0, 'x509': 2}) def test_get_ca_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.get_ca_certs(), []) # CERTFILE is not flagged as X509v3 Basic Constraints: CA:TRUE ctx.load_verify_locations(CERTFILE) self.assertEqual(ctx.get_ca_certs(), []) # but CAFILE_CACERT is a CA cert ctx.load_verify_locations(CAFILE_CACERT) self.assertEqual(ctx.get_ca_certs(), [{'issuer': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'notAfter': asn1time('Mar 29 12:29:49 2033 GMT'), 'notBefore': asn1time('Mar 30 12:29:49 2003 GMT'), 'serialNumber': '00', 'crlDistributionPoints': ('https://www.cacert.org/revoke.crl',), 'subject': ((('organizationName', 'Root CA'),), (('organizationalUnitName', 'http://www.cacert.org'),), (('commonName', 'CA Cert Signing Authority'),), (('emailAddress', 'support@cacert.org'),)), 'version': 3}]) with open(CAFILE_CACERT) as f: pem = f.read() der = ssl.PEM_cert_to_DER_cert(pem) self.assertEqual(ctx.get_ca_certs(True), [der]) def test_load_default_certs(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.SERVER_AUTH) ctx.load_default_certs() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs(ssl.Purpose.CLIENT_AUTH) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(TypeError, ctx.load_default_certs, None) self.assertRaises(TypeError, ctx.load_default_certs, 'SERVER_AUTH') @unittest.skipIf(sys.platform == "win32", "not-Windows specific") def test_load_default_certs_env(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() self.assertEqual(ctx.cert_store_stats(), {"crl": 0, "x509": 1, "x509_ca": 0}) @unittest.skipUnless(sys.platform == "win32", "Windows specific") def test_load_default_certs_env_windows(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.load_default_certs() stats = ctx.cert_store_stats() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with support.EnvironmentVarGuard() as env: env["SSL_CERT_DIR"] = CAPATH env["SSL_CERT_FILE"] = CERTFILE ctx.load_default_certs() stats["x509"] += 1 self.assertEqual(ctx.cert_store_stats(), stats) def test_create_default_context(self): ctx = ssl.create_default_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) with open(SIGNING_CA) as f: cadata = f.read() ctx = ssl.create_default_context(cafile=SIGNING_CA, capath=CAPATH, cadata=cadata) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) self.assertEqual( ctx.options & getattr(ssl, "OP_NO_COMPRESSION", 0), getattr(ssl, "OP_NO_COMPRESSION", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_DH_USE", 0), getattr(ssl, "OP_SINGLE_DH_USE", 0), ) self.assertEqual( ctx.options & getattr(ssl, "OP_SINGLE_ECDH_USE", 0), getattr(ssl, "OP_SINGLE_ECDH_USE", 0), ) def test__create_stdlib_context(self): ctx = ssl._create_stdlib_context() self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertFalse(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1, cert_reqs=ssl.CERT_REQUIRED, check_hostname=True) self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1) self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) self.assertTrue(ctx.check_hostname) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) ctx = ssl._create_stdlib_context(purpose=ssl.Purpose.CLIENT_AUTH) self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23) self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2) def test_check_hostname(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertFalse(ctx.check_hostname) # Requires CERT_REQUIRED or CERT_OPTIONAL with self.assertRaises(ValueError): ctx.check_hostname = True ctx.verify_mode = ssl.CERT_REQUIRED self.assertFalse(ctx.check_hostname) ctx.check_hostname = True self.assertTrue(ctx.check_hostname) ctx.verify_mode = ssl.CERT_OPTIONAL ctx.check_hostname = True self.assertTrue(ctx.check_hostname) # Cannot set CERT_NONE with check_hostname enabled with self.assertRaises(ValueError): ctx.verify_mode = ssl.CERT_NONE ctx.check_hostname = False self.assertFalse(ctx.check_hostname) class SSLErrorTests(unittest.TestCase): def test_str(self): # The str() of a SSLError doesn't include the errno e = ssl.SSLError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) # Same for a subclass e = ssl.SSLZeroReturnError(1, "foo") self.assertEqual(str(e), "foo") self.assertEqual(e.errno, 1) def test_lib_reason(self): # Test the library and reason attributes ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with self.assertRaises(ssl.SSLError) as cm: ctx.load_dh_params(CERTFILE) self.assertEqual(cm.exception.library, 'PEM') self.assertEqual(cm.exception.reason, 'NO_START_LINE') s = str(cm.exception) self.assertTrue(s.startswith("[PEM: NO_START_LINE] no start line"), s) def test_subclass(self): # Check that the appropriate SSLError subclass is raised # (this only tests one of them) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with socket.socket() as s: s.bind(("127.0.0.1", 0)) s.listen() c = socket.socket() c.connect(s.getsockname()) c.setblocking(False) with ctx.wrap_socket(c, False, do_handshake_on_connect=False) as c: with self.assertRaises(ssl.SSLWantReadError) as cm: c.do_handshake() s = str(cm.exception) self.assertTrue(s.startswith("The operation did not complete (read)"), s) # For compatibility self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ) class MemoryBIOTests(unittest.TestCase): def test_read_write(self): bio = ssl.MemoryBIO() bio.write(b'foo') self.assertEqual(bio.read(), b'foo') self.assertEqual(bio.read(), b'') bio.write(b'foo') bio.write(b'bar') self.assertEqual(bio.read(), b'foobar') self.assertEqual(bio.read(), b'') bio.write(b'baz') self.assertEqual(bio.read(2), b'ba') self.assertEqual(bio.read(1), b'z') self.assertEqual(bio.read(1), b'') def test_eof(self): bio = ssl.MemoryBIO() self.assertFalse(bio.eof) self.assertEqual(bio.read(), b'') self.assertFalse(bio.eof) bio.write(b'foo') self.assertFalse(bio.eof) bio.write_eof() self.assertFalse(bio.eof) self.assertEqual(bio.read(2), b'fo') self.assertFalse(bio.eof) self.assertEqual(bio.read(1), b'o') self.assertTrue(bio.eof) self.assertEqual(bio.read(), b'') self.assertTrue(bio.eof) def test_pending(self): bio = ssl.MemoryBIO() self.assertEqual(bio.pending, 0) bio.write(b'foo') self.assertEqual(bio.pending, 3) for i in range(3): bio.read(1) self.assertEqual(bio.pending, 3-i-1) for i in range(3): bio.write(b'x') self.assertEqual(bio.pending, i+1) bio.read() self.assertEqual(bio.pending, 0) def test_buffer_types(self): bio = ssl.MemoryBIO() bio.write(b'foo') self.assertEqual(bio.read(), b'foo') bio.write(bytearray(b'bar')) self.assertEqual(bio.read(), b'bar') bio.write(memoryview(b'baz')) self.assertEqual(bio.read(), b'baz') def test_error_types(self): bio = ssl.MemoryBIO() self.assertRaises(TypeError, bio.write, 'foo') self.assertRaises(TypeError, bio.write, None) self.assertRaises(TypeError, bio.write, True) self.assertRaises(TypeError, bio.write, 1) class NetworkedTests(unittest.TestCase): def test_connect(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) try: s.connect((REMOTE_HOST, 443)) self.assertEqual({}, s.getpeercert()) finally: s.close() # this should fail because we have no verification certs s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED) self.assertRaisesRegex(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # this should succeed because we specify the root cert s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: s.connect((REMOTE_HOST, 443)) self.assertTrue(s.getpeercert()) finally: s.close() def test_connect_ex(self): # Issue #11326: check connect_ex() implementation with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: self.assertEqual(0, s.connect_ex((REMOTE_HOST, 443))) self.assertTrue(s.getpeercert()) finally: s.close() def test_non_blocking_connect_ex(self): # Issue #11326: non-blocking connect_ex() should allow handshake # to proceed after the socket gets ready. with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.setblocking(False) rc = s.connect_ex((REMOTE_HOST, 443)) # EWOULDBLOCK under Windows, EINPROGRESS elsewhere self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK)) # Wait for connect to finish select.select([], [s], [], 5.0) # Non-blocking handshake while True: try: s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], [], 5.0) except ssl.SSLWantWriteError: select.select([], [s], [], 5.0) # SSL established self.assertTrue(s.getpeercert()) finally: s.close() def test_timeout_connect_ex(self): # Issue #12065: on a timeout, connect_ex() should return the original # errno (mimicking the behaviour of non-SSL sockets). with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT, do_handshake_on_connect=False) try: s.settimeout(0.0000001) rc = s.connect_ex((REMOTE_HOST, 443)) if rc == 0: self.skipTest("REMOTE_HOST responded too quickly") self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) finally: s.close() def test_connect_ex_error(self): with support.transient_internet(REMOTE_HOST): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED, ca_certs=REMOTE_ROOT_CERT) try: rc = s.connect_ex((REMOTE_HOST, 444)) # Issue #19919: Windows machines or VMs hosted on Windows # machines sometimes return EWOULDBLOCK. errors = ( errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.ETIMEDOUT, errno.EWOULDBLOCK, ) self.assertIn(rc, errors) finally: s.close() def test_connect_with_context(self): with support.transient_internet(REMOTE_HOST): # Same as test_connect, but with a separately created context ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: self.assertEqual({}, s.getpeercert()) finally: s.close() # Same with a server hostname s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname=REMOTE_HOST) s.connect((REMOTE_HOST, 443)) s.close() # This should fail because we have no verification certs ctx.verify_mode = ssl.CERT_REQUIRED s = ctx.wrap_socket(socket.socket(socket.AF_INET)) self.assertRaisesRegex(ssl.SSLError, "certificate verify failed", s.connect, (REMOTE_HOST, 443)) s.close() # This should succeed because we specify the root cert ctx.load_verify_locations(REMOTE_ROOT_CERT) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_capath(self): # Verify server certificates using the `capath` argument # NOTE: the subject hashing algorithm has been changed between # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must # contain both versions of each certificate (same content, different # filename) for this test to be portable across OpenSSL releases. with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() # Same with a bytes `capath` argument ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=BYTES_CAPATH) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() def test_connect_cadata(self): with open(REMOTE_ROOT_CERT) as f: pem = f.read() der = ssl.PEM_cert_to_DER_cert(pem) with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=pem) with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) # same with DER ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(cadata=der) with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: s.connect((REMOTE_HOST, 443)) cert = s.getpeercert() self.assertTrue(cert) @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't # delay closing the underlying "real socket" (here tested with its # file descriptor, hence skipping the test under Windows). with support.transient_internet(REMOTE_HOST): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) ss.connect((REMOTE_HOST, 443)) fd = ss.fileno() f = ss.makefile() f.close() # The fd is still open os.read(fd, 0) # Closing the SSL socket should close the fd too ss.close() gc.collect() with self.assertRaises(OSError) as e: os.read(fd, 0) self.assertEqual(e.exception.errno, errno.EBADF) def test_non_blocking_handshake(self): with support.transient_internet(REMOTE_HOST): s = socket.socket(socket.AF_INET) s.connect((REMOTE_HOST, 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLWantReadError: select.select([s], [], []) except ssl.SSLWantWriteError: select.select([], [s], []) s.close() if support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) def test_get_server_certificate(self): def _test_get_server_certificate(host, port, cert=None): with support.transient_internet(host): pem = ssl.get_server_certificate((host, port)) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) try: pem = ssl.get_server_certificate((host, port), ca_certs=CERTFILE) except ssl.SSLError as x: #should fail if support.verbose: sys.stdout.write("%s\n" % x) else: self.fail("Got server certificate %s for %s:%s!" % (pem, host, port)) pem = ssl.get_server_certificate((host, port), ca_certs=cert) if not pem: self.fail("No server certificate on %s:%s!" % (host, port)) if support.verbose: sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem)) _test_get_server_certificate(REMOTE_HOST, 443, REMOTE_ROOT_CERT) if support.IPV6_ENABLED: _test_get_server_certificate('ipv6.google.com', 443) def test_ciphers(self): remote = (REMOTE_HOST, 443) with support.transient_internet(remote[0]): with ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s: s.connect(remote) with ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s: s.connect(remote) # Error checking can happen at instantiation or when connecting with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): with socket.socket(socket.AF_INET) as sock: s = ssl.wrap_socket(sock, cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx") s.connect(remote) def test_algorithms(self): # Issue #8484: all algorithms should be available when verifying a # certificate. # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) # sha256.tbs-internet.com needs SNI to use the correct certificate if not ssl.HAS_SNI: self.skipTest("SNI needed for this test") # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host) remote = ("sha256.tbs-internet.com", 443) sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") with support.transient_internet("sha256.tbs-internet.com"): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(sha256_cert) s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname="sha256.tbs-internet.com") try: s.connect(remote) if support.verbose: sys.stdout.write("\nCipher with %r is %r\n" % (remote, s.cipher())) sys.stdout.write("Certificate is:\n%s\n" % pprint.pformat(s.getpeercert())) finally: s.close() def test_get_ca_certs_capath(self): # capath certs are loaded on request with support.transient_internet(REMOTE_HOST): ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(capath=CAPATH) self.assertEqual(ctx.get_ca_certs(), []) s = ctx.wrap_socket(socket.socket(socket.AF_INET)) s.connect((REMOTE_HOST, 443)) try: cert = s.getpeercert() self.assertTrue(cert) finally: s.close() self.assertEqual(len(ctx.get_ca_certs()), 1) @needs_sni def test_context_setget(self): # Check that the context of a connected socket can be replaced. with support.transient_internet(REMOTE_HOST): ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23) s = socket.socket(socket.AF_INET) with ctx1.wrap_socket(s) as ss: ss.connect((REMOTE_HOST, 443)) self.assertIs(ss.context, ctx1) self.assertIs(ss._sslobj.context, ctx1) ss.context = ctx2 self.assertIs(ss.context, ctx2) self.assertIs(ss._sslobj.context, ctx2) class NetworkedBIOTests(unittest.TestCase): def ssl_io_loop(self, sock, incoming, outgoing, func, *args, **kwargs): # A simple IO loop. Call func(*args) depending on the error we get # (WANT_READ or WANT_WRITE) move data between the socket and the BIOs. timeout = kwargs.get('timeout', 10) count = 0 while True: errno = None count += 1 try: ret = func(*args) except ssl.SSLError as e: if e.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): raise errno = e.errno # Get any data from the outgoing BIO irrespective of any error, and # send it to the socket. buf = outgoing.read() sock.sendall(buf) # If there's no error, we're done. For WANT_READ, we need to get # data from the socket and put it in the incoming BIO. if errno is None: break elif errno == ssl.SSL_ERROR_WANT_READ: buf = sock.recv(32768) if buf: incoming.write(buf) else: incoming.write_eof() if support.verbose: sys.stdout.write("Needed %d calls to complete %s().\n" % (count, func.__name__)) return ret def test_handshake(self): with support.transient_internet(REMOTE_HOST): sock = socket.socket(socket.AF_INET) sock.connect((REMOTE_HOST, 443)) incoming = ssl.MemoryBIO() outgoing = ssl.MemoryBIO() ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_REQUIRED ctx.load_verify_locations(REMOTE_ROOT_CERT) ctx.check_hostname = True sslobj = ctx.wrap_bio(incoming, outgoing, False, REMOTE_HOST) self.assertIs(sslobj._sslobj.owner, sslobj) self.assertIsNone(sslobj.cipher()) self.assertIsNone(sslobj.shared_ciphers()) self.assertRaises(ValueError, sslobj.getpeercert) if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES: self.assertIsNone(sslobj.get_channel_binding('tls-unique')) self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake) self.assertTrue(sslobj.cipher()) self.assertIsNone(sslobj.shared_ciphers()) self.assertTrue(sslobj.getpeercert()) if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES: self.assertTrue(sslobj.get_channel_binding('tls-unique')) try: self.ssl_io_loop(sock, incoming, outgoing, sslobj.unwrap) except ssl.SSLSyscallError: # self-signed.pythontest.net probably shuts down the TCP # connection without sending a secure shutdown message, and # this is reported as SSL_ERROR_SYSCALL pass self.assertRaises(ssl.SSLError, sslobj.write, b'foo') sock.close() def test_read_write_data(self): with support.transient_internet(REMOTE_HOST): sock = socket.socket(socket.AF_INET) sock.connect((REMOTE_HOST, 443)) incoming = ssl.MemoryBIO() outgoing = ssl.MemoryBIO() ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx.verify_mode = ssl.CERT_NONE sslobj = ctx.wrap_bio(incoming, outgoing, False) self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake) req = b'GET / HTTP/1.0\r\n\r\n' self.ssl_io_loop(sock, incoming, outgoing, sslobj.write, req) buf = self.ssl_io_loop(sock, incoming, outgoing, sslobj.read, 1024) self.assertEqual(buf[:5], b'HTTP/') self.ssl_io_loop(sock, incoming, outgoing, sslobj.unwrap) sock.close() try: import threading except ImportError: _have_threads = False else: _have_threads = True from test.ssl_servers import make_https_server class ThreadedEchoServer(threading.Thread): class ConnectionHandler(threading.Thread): """A mildly complicated class, because we want it to work both with and without the SSL wrapper around the socket connection, so that we can test the STARTTLS functionality.""" def __init__(self, server, connsock, addr): self.server = server self.running = False self.sock = connsock self.addr = addr self.sock.setblocking(1) self.sslconn = None threading.Thread.__init__(self) self.daemon = True def wrap_conn(self): try: self.sslconn = self.server.context.wrap_socket( self.sock, server_side=True) self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol()) self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol()) except (ssl.SSLError, ConnectionResetError) as e: # We treat ConnectionResetError as though it were an # SSLError - OpenSSL on Ubuntu abruptly closes the # connection when asked to use an unsupported protocol. # # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n") self.running = False self.server.stop() self.close() return False else: self.server.shared_ciphers.append(self.sslconn.shared_ciphers()) if self.server.context.verify_mode == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") sys.stdout.write(" server: selected protocol is now " + str(self.sslconn.selected_npn_protocol()) + "\n") return True def read(self): if self.sslconn: return self.sslconn.read() else: return self.sock.recv(1024) def write(self, bytes): if self.sslconn: return self.sslconn.write(bytes) else: return self.sock.send(bytes) def close(self): if self.sslconn: self.sslconn.close() else: self.sock.close() def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif (self.server.starttls_server and stripped == b'STARTTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write(b"OK\n") if not self.wrap_conn(): return elif (self.server.starttls_server and self.sslconn and stripped == b'ENDTLS'): if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read ENDTLS from client, sending OK...\n") self.write(b"OK\n") self.sock = self.sslconn.unwrap() self.sslconn = None if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: connection is now unencrypted...\n") elif stripped == b'CB tls-unique': if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read CB tls-unique from client, sending our CB data...\n") data = self.sslconn.get_channel_binding("tls-unique") self.write(repr(data).encode("us-ascii") + b"\n") else: if (support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n" % (msg, ctype, msg.lower(), ctype)) self.write(msg.lower()) except OSError: if self.server.chatty: handle_error("Test server failure:\n") self.close() self.running = False # normally, we'd just stop here, but for the test # harness, we want to stop the server self.server.stop() def __init__(self, certificate=None, ssl_version=None, certreqs=None, cacerts=None, chatty=True, connectionchatty=False, starttls_server=False, npn_protocols=None, alpn_protocols=None, ciphers=None, context=None): if context: self.context = context else: self.context = ssl.SSLContext(ssl_version if ssl_version is not None else ssl.PROTOCOL_TLSv1) self.context.verify_mode = (certreqs if certreqs is not None else ssl.CERT_NONE) if cacerts: self.context.load_verify_locations(cacerts) if certificate: self.context.load_cert_chain(certificate) if npn_protocols: self.context.set_npn_protocols(npn_protocols) if alpn_protocols: self.context.set_alpn_protocols(alpn_protocols) if ciphers: self.context.set_ciphers(ciphers) self.chatty = chatty self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() self.port = support.bind_port(self.sock) self.flag = None self.active = False self.selected_npn_protocols = [] self.selected_alpn_protocols = [] self.shared_ciphers = [] self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): self.stop() self.join() def start(self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.sock.settimeout(0.05) self.sock.listen() self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + repr(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn, connaddr) handler.start() handler.join() except socket.timeout: pass except KeyboardInterrupt: self.stop() self.sock.close() def stop(self): self.active = False class AsyncoreEchoServer(threading.Thread): # this one's based on asyncore.dispatcher class EchoServer (asyncore.dispatcher): class ConnectionHandler (asyncore.dispatcher_with_send): def __init__(self, conn, certfile): self.socket = ssl.wrap_socket(conn, server_side=True, certfile=certfile, do_handshake_on_connect=False) asyncore.dispatcher_with_send.__init__(self, self.socket) self._ssl_accepting = True self._do_ssl_handshake() def readable(self): if isinstance(self.socket, ssl.SSLSocket): while self.socket.pending() > 0: self.handle_read_event() return True def _do_ssl_handshake(self): try: self.socket.do_handshake() except (ssl.SSLWantReadError, ssl.SSLWantWriteError): return except ssl.SSLEOFError: return self.handle_close() except ssl.SSLError: raise except OSError as err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def handle_read(self): if self._ssl_accepting: self._do_ssl_handshake() else: data = self.recv(1024) if support.verbose: sys.stdout.write(" server: read %s from client\n" % repr(data)) if not data: self.close() else: self.send(data.lower()) def handle_close(self): self.close() if support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): raise def __init__(self, certfile): self.certfile = certfile sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(sock, '') asyncore.dispatcher.__init__(self, sock) self.listen(5) def handle_accepted(self, sock_obj, addr): if support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) def handle_error(self): raise def __init__(self, certfile): self.flag = None self.active = False self.server = self.EchoServer(certfile) self.port = self.server.port threading.Thread.__init__(self) self.daemon = True def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) def __enter__(self): self.start(threading.Event()) self.flag.wait() return self def __exit__(self, *args): if support.verbose: sys.stdout.write(" cleanup: stopping server.\n") self.stop() if support.verbose: sys.stdout.write(" cleanup: joining server thread.\n") self.join() if support.verbose: sys.stdout.write(" cleanup: successfully joined.\n") def start (self, flag=None): self.flag = flag threading.Thread.start(self) def run(self): self.active = True if self.flag: self.flag.set() while self.active: try: asyncore.loop(1) except: pass def stop(self): self.active = False self.server.close() def server_params_test(client_context, server_context, indata=b"FOO\n", chatty=True, connectionchatty=False, sni_name=None): """ Launch a server, connect a client to it and try various reads and writes. """ stats = {} server = ThreadedEchoServer(context=server_context, chatty=chatty, connectionchatty=False) with server: with client_context.wrap_socket(socket.socket(), server_hostname=sni_name) as s: s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(arg) outdata = s.read() if connectionchatty: if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): raise AssertionError( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if connectionchatty: if support.verbose: sys.stdout.write(" client: closing connection.\n") stats.update({ 'compression': s.compression(), 'cipher': s.cipher(), 'peercert': s.getpeercert(), 'client_alpn_protocol': s.selected_alpn_protocol(), 'client_npn_protocol': s.selected_npn_protocol(), 'version': s.version(), }) s.close() stats['server_alpn_protocols'] = server.selected_alpn_protocols stats['server_npn_protocols'] = server.selected_npn_protocols stats['server_shared_ciphers'] = server.shared_ciphers return stats def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None, server_options=0, client_options=0): """ Try to SSL-connect using *client_protocol* to *server_protocol*. If *expect_success* is true, assert that the connection succeeds, if it's false, assert that the connection fails. Also, if *expect_success* is a string, assert that it is the protocol version actually used by the connection. """ if certsreqs is None: certsreqs = ssl.CERT_NONE certtype = { ssl.CERT_NONE: "CERT_NONE", ssl.CERT_OPTIONAL: "CERT_OPTIONAL", ssl.CERT_REQUIRED: "CERT_REQUIRED", }[certsreqs] if support.verbose: formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol), certtype)) client_context = ssl.SSLContext(client_protocol) client_context.options |= client_options server_context = ssl.SSLContext(server_protocol) server_context.options |= server_options # NOTE: we must enable "ALL" ciphers on the client, otherwise an # SSLv23 client will send an SSLv3 hello (rather than SSLv2) # starting from OpenSSL 1.0.0 (see issue #8322). if client_context.protocol == ssl.PROTOCOL_SSLv23: client_context.set_ciphers("ALL") for ctx in (client_context, server_context): ctx.verify_mode = certsreqs ctx.load_cert_chain(CERTFILE) ctx.load_verify_locations(CERTFILE) try: stats = server_params_test(client_context, server_context, chatty=False, connectionchatty=False) # Protocol mismatch can result in either an SSLError, or a # "Connection reset by peer" error. except ssl.SSLError: if expect_success: raise except OSError as e: if expect_success or e.errno != errno.ECONNRESET: raise else: if not expect_success: raise AssertionError( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) elif (expect_success is not True and expect_success != stats['version']): raise AssertionError("version mismatch: expected %r, got %r" % (expect_success, stats['version'])) class ThreadedTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl def test_echo(self): """Basic test of an SSL client connecting to a server""" if support.verbose: sys.stdout.write("\n") for protocol in PROTOCOLS: with self.subTest(protocol=ssl._PROTOCOL_NAMES[protocol]): context = ssl.SSLContext(protocol) context.load_cert_chain(CERTFILE) server_params_test(context, context, chatty=True, connectionchatty=True) def test_getpeercert(self): if support.verbose: sys.stdout.write("\n") context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket(), do_handshake_on_connect=False) s.connect((HOST, server.port)) # getpeercert() raise ValueError while the handshake isn't # done. with self.assertRaises(ValueError): s.getpeercert() s.do_handshake() cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() if support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: self.fail("No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): self.fail( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") self.assertIn('notBefore', cert) self.assertIn('notAfter', cert) before = ssl.cert_time_to_seconds(cert['notBefore']) after = ssl.cert_time_to_seconds(cert['notAfter']) self.assertLess(before, after) s.close() @unittest.skipUnless(have_verify_flags(), "verify_flags need OpenSSL > 0.9.8") def test_crl_check(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(SIGNING_CA) tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0) self.assertEqual(context.verify_flags, ssl.VERIFY_DEFAULT | tf) # VERIFY_DEFAULT should pass server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # VERIFY_CRL_CHECK_LEAF without a loaded CRL file fails context.verify_flags |= ssl.VERIFY_CRL_CHECK_LEAF server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: with self.assertRaisesRegex(ssl.SSLError, "certificate verify failed"): s.connect((HOST, server.port)) # now load a CRL file. The CRL file is signed by the CA. context.load_verify_locations(CRLFILE) server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") def test_check_hostname(self): if support.verbose: sys.stdout.write("\n") server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED context.check_hostname = True context.load_verify_locations(SIGNING_CA) # correct hostname should verify server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket(), server_hostname="localhost") as s: s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") # incorrect hostname should raise an exception server = ThreadedEchoServer(context=server_context, chatty=True) with server: with context.wrap_socket(socket.socket(), server_hostname="invalid") as s: with self.assertRaisesRegex(ssl.CertificateError, "hostname 'invalid' doesn't match 'localhost'"): s.connect((HOST, server.port)) # missing server_hostname arg should cause an exception, too server = ThreadedEchoServer(context=server_context, chatty=True) with server: with socket.socket() as s: with self.assertRaisesRegex(ValueError, "check_hostname requires server_hostname"): context.wrap_socket(s) def test_wrong_cert(self): """Connecting when the server rejects the client's certificate Launch a server with CERT_REQUIRED, and check that trying to connect to it with a wrong client certificate fails. """ certfile = os.path.join(os.path.dirname(__file__) or os.curdir, "wrongcert.pem") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False, connectionchatty=False) with server, \ socket.socket() as sock, \ ssl.wrap_socket(sock, certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) as s: try: # Expect either an SSL error about the server rejecting # the connection, or a low-level connection reset (which # sometimes happens on Windows) s.connect((HOST, server.port)) except ssl.SSLError as e: if support.verbose: sys.stdout.write("\nSSLError is %r\n" % e) except OSError as e: if e.errno != errno.ECONNRESET: raise if support.verbose: sys.stdout.write("\nsocket.error is %r\n" % e) else: self.fail("Use of invalid cert should have failed!") def test_rude_shutdown(self): """A brutal shutdown of an SSL server should raise an OSError in the client when attempting handshake. """ listener_ready = threading.Event() listener_gone = threading.Event() s = socket.socket() port = support.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, # and sets Event `listener_gone` to let the main thread know # the socket is gone. def listener(): s.listen() listener_ready.set() newsock, addr = s.accept() newsock.close() s.close() listener_gone.set() def connector(): listener_ready.wait() with socket.socket() as c: c.connect((HOST, port)) listener_gone.wait() try: ssl_sock = ssl.wrap_socket(c) except OSError: pass else: self.fail('connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) t.start() try: connector() finally: t.join() @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv2'), "OpenSSL is compiled without SSLv2 support") def test_protocol_sslv2(self): """Connecting to an SSLv2 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) # SSLv23 client with specific SSL options if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl def test_protocol_sslv23(self): """Connecting to an SSLv23 server with various client options""" if support.verbose: sys.stdout.write("\n") if hasattr(ssl, 'PROTOCOL_SSLv2'): try: try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except OSError as x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1') if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED) # Server with specific SSL options if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, server_options=ssl.OP_NO_SSLv3) # Will choose TLSv1 try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False, server_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv3'), "OpenSSL is compiled without SSLv3 support") def test_protocol_sslv3(self): """Connecting to an SSLv3 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3') try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv3) try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_SSLv2) @skip_if_broken_ubuntu_ssl def test_protocol_tlsv1(self): """Connecting to a TLSv1 server with various client options""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1') try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_1"), "TLS version 1.1 not supported.") def test_protocol_tlsv1_1(self): """Connecting to a TLSv1.1 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1') if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_1) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1') try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False) @skip_if_broken_ubuntu_ssl @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_2"), "TLS version 1.2 not supported.") def test_protocol_tlsv1_2(self): """Connecting to a TLSv1.2 server with various client options. Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n") try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2', server_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2, client_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2,) if hasattr(ssl, 'PROTOCOL_SSLv2'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv2, False) if hasattr(ssl, 'PROTOCOL_SSLv3'): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_2) try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2') try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_2, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, False) try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_2, False) def test_starttls(self): """Switching from clear text to encrypted and back again.""" msgs = (b"msg 1", b"MSG 2", b"STARTTLS", b"MSG 3", b"msg 4", b"ENDTLS", b"msg 5", b"msg 6") server = ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, starttls_server=True, chatty=True, connectionchatty=True) wrapped = False with server: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) if support.verbose: sys.stdout.write("\n") for indata in msgs: if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) if wrapped: conn.write(indata) outdata = conn.read() else: s.send(indata) outdata = s.recv(1024) msg = outdata.strip().lower() if indata == b"STARTTLS" and msg.startswith(b"ok"): # STARTTLS ok, switch to secure mode if support.verbose: sys.stdout.write( " client: read %r from server, starting TLS...\n" % msg) conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) wrapped = True elif indata == b"ENDTLS" and msg.startswith(b"ok"): # ENDTLS ok, switch back to clear text if support.verbose: sys.stdout.write( " client: read %r from server, ending TLS...\n" % msg) s = conn.unwrap() wrapped = False else: if support.verbose: sys.stdout.write( " client: read %r from server\n" % msg) if support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write(b"over\n") else: s.send(b"over\n") if wrapped: conn.close() else: s.close() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" server = make_https_server(self, certfile=CERTFILE) # try to connect if support.verbose: sys.stdout.write('\n') with open(CERTFILE, 'rb') as f: d1 = f.read() d2 = '' # now fetch the same data from the HTTPS server url = 'https://localhost:%d/%s' % ( server.port, os.path.split(CERTFILE)[1]) context = ssl.create_default_context(cafile=CERTFILE) f = urllib.request.urlopen(url, context=context) try: dlen = f.info().get("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) if support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) finally: f.close() self.assertEqual(d1, d2) def test_asyncore_server(self): """Check the example asyncore integration.""" indata = "TEST MESSAGE of mixed case\n" if support.verbose: sys.stdout.write("\n") indata = b"FOO\n" server = AsyncoreEchoServer(CERTFILE) with server: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if support.verbose: sys.stdout.write( " client: sending %r...\n" % indata) s.write(indata) outdata = s.read() if support.verbose: sys.stdout.write(" client: read %r\n" % outdata) if outdata != indata.lower(): self.fail( "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" % (outdata[:20], len(outdata), indata[:20].lower(), len(indata))) s.write(b"over\n") if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() if support.verbose: sys.stdout.write(" client: connection closed.\n") def test_recv_send(self): """Test recv(), send() and friends.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray(b"\0"*100) count = s.recv_into(b) return b[:count] def _recvfrom_into(): b = bytearray(b"\0"*100) count, addr = s.recvfrom_into(b) return b[:count] # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]), ('sendall', s.sendall, True, []), ] recv_methods = [ ('recv', s.recv, True, []), ('recvfrom', s.recvfrom, False, ["some.address"]), ('recv_into', _recv_into, True, []), ('recvfrom_into', _recvfrom_into, False, []), ] data_prefix = "PREFIX_" for meth_name, send_meth, expect_success, args in send_methods: indata = (data_prefix + meth_name).encode('ascii') try: send_meth(indata, *args) outdata = s.read() if outdata != indata.lower(): self.fail( "While sending with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to send with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) for meth_name, recv_meth, expect_success, args in recv_methods: indata = (data_prefix + meth_name).encode('ascii') try: s.send(indata) outdata = recv_meth(*args) if outdata != indata.lower(): self.fail( "While receiving with <<{name:s}>> bad data " "<<{outdata:r}>> ({nout:d}) received; " "expected <<{indata:r}>> ({nin:d})\n".format( name=meth_name, outdata=outdata[:20], nout=len(outdata), indata=indata[:20], nin=len(indata) ) ) except ValueError as e: if expect_success: self.fail( "Failed to receive with method <<{name:s}>>; " "expected to succeed.\n".format(name=meth_name) ) if not str(e).startswith(meth_name): self.fail( "Method <<{name:s}>> failed with unexpected " "exception message: {exp:s}\n".format( name=meth_name, exp=e ) ) # consume data s.read() # Make sure sendmsg et al are disallowed to avoid # inadvertent disclosure of data and/or corruption # of the encrypted data stream self.assertRaises(NotImplementedError, s.sendmsg, [b"data"]) self.assertRaises(NotImplementedError, s.recvmsg, 100) self.assertRaises(NotImplementedError, s.recvmsg_into, bytearray(100)) s.write(b"over\n") s.close() def test_nonblocking_send(self): server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) s.setblocking(False) # If we keep sending data, at some point the buffers # will be full and the call will block buf = bytearray(8192) def fill_buffer(): while True: s.send(buf) self.assertRaises((ssl.SSLWantWriteError, ssl.SSLWantReadError), fill_buffer) # Now read all the output and discard it s.setblocking(True) s.close() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) started = threading.Event() finish = False def serve(): server.listen() started.set() conns = [] while not finish: r, w, e = select.select([server], [], [], 0.1) if server in r: # Let the socket hang around rather than having # it closed by garbage collection. conns.append(server.accept()[0]) for sock in conns: sock.close() t = threading.Thread(target=serve) t.start() started.wait() try: try: c = socket.socket(socket.AF_INET) c.settimeout(0.2) c.connect((host, port)) # Will attempt handshake and time out self.assertRaisesRegex(socket.timeout, "timed out", ssl.wrap_socket, c) finally: c.close() try: c = socket.socket(socket.AF_INET) c = ssl.wrap_socket(c) c.settimeout(0.2) # Will attempt handshake and time out self.assertRaisesRegex(socket.timeout, "timed out", c.connect, (host, port)) finally: c.close() finally: finish = True t.join() server.close() def test_server_accept(self): # Issue #16357: accept() on a SSLSocket created through # SSLContext.wrap_socket(). context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = socket.socket(socket.AF_INET) host = "127.0.0.1" port = support.bind_port(server) server = context.wrap_socket(server, server_side=True) evt = threading.Event() remote = None peer = None def serve(): nonlocal remote, peer server.listen() # Block on the accept and wait on the connection to close. evt.set() remote, peer = server.accept() remote.recv(1) t = threading.Thread(target=serve) t.start() # Client wait until server setup and perform a connect. evt.wait() client = context.wrap_socket(socket.socket()) client.connect((host, port)) client_addr = client.getsockname() client.close() t.join() remote.close() server.close() # Sanity checks. self.assertIsInstance(remote, ssl.SSLSocket) self.assertEqual(peer, client_addr) def test_getpeercert_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with context.wrap_socket(socket.socket()) as sock: with self.assertRaises(OSError) as cm: sock.getpeercert() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_do_handshake_enotconn(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) with context.wrap_socket(socket.socket()) as sock: with self.assertRaises(OSError) as cm: sock.do_handshake() self.assertEqual(cm.exception.errno, errno.ENOTCONN) def test_default_ciphers(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) try: # Force a set of weak ciphers on our client context context.set_ciphers("DES") except ssl.SSLError: self.skipTest("no DES cipher available") with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: with context.wrap_socket(socket.socket()) as s: with self.assertRaises(OSError): s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0])) def test_version_basic(self): """ Basic tests for SSLSocket.version(). More tests are done in the test_protocol_*() methods. """ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_TLSv1, chatty=False) as server: with context.wrap_socket(socket.socket()) as s: self.assertIs(s.version(), None) s.connect((HOST, server.port)) self.assertEqual(s.version(), "TLSv1") self.assertIs(s.version(), None) @unittest.skipUnless(ssl.HAS_ECDH, "test requires ECDH-enabled OpenSSL") def test_default_ecdh_curve(self): # Issue #21015: elliptic curve-based Diffie Hellman key exchange # should be enabled by default on SSL contexts. context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.load_cert_chain(CERTFILE) # Prior to OpenSSL 1.0.0, ECDH ciphers have to be enabled # explicitly using the 'ECCdraft' cipher alias. Otherwise, # our default cipher list should prefer ECDH-based ciphers # automatically. if ssl.OPENSSL_VERSION_INFO < (1, 0, 0): context.set_ciphers("ECCdraft:ECDH") with ThreadedEchoServer(context=context) as server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) self.assertIn("ECDH", s.cipher()[0]) @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): """Test tls-unique channel binding.""" if support.verbose: sys.stdout.write("\n") server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1, cacerts=CERTFILE, chatty=True, connectionchatty=False) with server: s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) # get the data cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got channel binding data: {0!r}\n" .format(cb_data)) # check if it is sane self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 # and compare with the peers version s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(cb_data).encode("us-ascii")) s.close() # now, again s = ssl.wrap_socket(socket.socket(), server_side=False, certfile=CERTFILE, ca_certs=CERTFILE, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) new_cb_data = s.get_channel_binding("tls-unique") if support.verbose: sys.stdout.write(" got another channel binding data: {0!r}\n" .format(new_cb_data)) # is it really unique self.assertNotEqual(cb_data, new_cb_data) self.assertIsNotNone(cb_data) self.assertEqual(len(cb_data), 12) # True for TLSv1 s.write(b"CB tls-unique\n") peer_data_repr = s.read().strip() self.assertEqual(peer_data_repr, repr(new_cb_data).encode("us-ascii")) s.close() def test_compression(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) if support.verbose: sys.stdout.write(" got compression: {!r}\n".format(stats['compression'])) self.assertIn(stats['compression'], { None, 'ZLIB', 'RLE' }) @unittest.skipUnless(hasattr(ssl, 'OP_NO_COMPRESSION'), "ssl.OP_NO_COMPRESSION needed for this test") def test_compression_disabled(self): context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.options |= ssl.OP_NO_COMPRESSION stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['compression'], None) def test_dh_params(self): # Check we can get a connection with ephemeral Diffie-Hellman context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) context.load_dh_params(DHFILE) context.set_ciphers("kEDH") stats = server_params_test(context, context, chatty=True, connectionchatty=True) cipher = stats["cipher"][0] parts = cipher.split("-") if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts: self.fail("Non-DH cipher: " + cipher[0]) def test_selected_alpn_protocol(self): # selected_alpn_protocol() is None unless ALPN is used. context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['client_alpn_protocol'], None) @unittest.skipUnless(ssl.HAS_ALPN, "ALPN support required") def test_selected_alpn_protocol_if_server_uses_alpn(self): # selected_alpn_protocol() is None unless ALPN is used by the client. client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_verify_locations(CERTFILE) server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_alpn_protocols(['foo', 'bar']) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) self.assertIs(stats['client_alpn_protocol'], None) @unittest.skipUnless(ssl.HAS_ALPN, "ALPN support needed for this test") def test_alpn_protocols(self): server_protocols = ['foo', 'bar', 'milkshake'] protocol_tests = [ (['foo', 'bar'], 'foo'), (['bar', 'foo'], 'foo'), (['milkshake'], 'milkshake'), (['http/3.0', 'http/4.0'], None) ] for client_protocols, expected in protocol_tests: server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_alpn_protocols(server_protocols) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_alpn_protocols(client_protocols) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) msg = "failed trying %s (s) and %s (c).\n" \ "was expecting %s, but got %%s from the %%s" \ % (str(server_protocols), str(client_protocols), str(expected)) client_result = stats['client_alpn_protocol'] self.assertEqual(client_result, expected, msg % (client_result, "client")) server_result = stats['server_alpn_protocols'][-1] \ if len(stats['server_alpn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) def test_selected_npn_protocol(self): # selected_npn_protocol() is None unless NPN is used context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.load_cert_chain(CERTFILE) stats = server_params_test(context, context, chatty=True, connectionchatty=True) self.assertIs(stats['client_npn_protocol'], None) @unittest.skipUnless(ssl.HAS_NPN, "NPN support needed for this test") def test_npn_protocols(self): server_protocols = ['http/1.1', 'spdy/2'] protocol_tests = [ (['http/1.1', 'spdy/2'], 'http/1.1'), (['spdy/2', 'http/1.1'], 'http/1.1'), (['spdy/2', 'test'], 'spdy/2'), (['abc', 'def'], 'abc') ] for client_protocols, expected in protocol_tests: server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(CERTFILE) server_context.set_npn_protocols(server_protocols) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_npn_protocols(client_protocols) stats = server_params_test(client_context, server_context, chatty=True, connectionchatty=True) msg = "failed trying %s (s) and %s (c).\n" \ "was expecting %s, but got %%s from the %%s" \ % (str(server_protocols), str(client_protocols), str(expected)) client_result = stats['client_npn_protocol'] self.assertEqual(client_result, expected, msg % (client_result, "client")) server_result = stats['server_npn_protocols'][-1] \ if len(stats['server_npn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) def sni_contexts(self): server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) other_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) other_context.load_cert_chain(SIGNED_CERTFILE2) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.verify_mode = ssl.CERT_REQUIRED client_context.load_verify_locations(SIGNING_CA) return server_context, other_context, client_context def check_common_name(self, stats, name): cert = stats['peercert'] self.assertIn((('commonName', name),), cert['subject']) @needs_sni def test_sni_callback(self): calls = [] server_context, other_context, client_context = self.sni_contexts() def servername_cb(ssl_sock, server_name, initial_context): calls.append((server_name, initial_context)) if server_name is not None: ssl_sock.context = other_context server_context.set_servername_callback(servername_cb) stats = server_params_test(client_context, server_context, chatty=True, sni_name='supermessage') # The hostname was fetched properly, and the certificate was # changed for the connection. self.assertEqual(calls, [("supermessage", server_context)]) # CERTFILE4 was selected self.check_common_name(stats, 'fakehostname') calls = [] # The callback is called with server_name=None stats = server_params_test(client_context, server_context, chatty=True, sni_name=None) self.assertEqual(calls, [(None, server_context)]) self.check_common_name(stats, 'localhost') # Check disabling the callback calls = [] server_context.set_servername_callback(None) stats = server_params_test(client_context, server_context, chatty=True, sni_name='notfunny') # Certificate didn't change self.check_common_name(stats, 'localhost') self.assertEqual(calls, []) @needs_sni def test_sni_callback_alert(self): # Returning a TLS alert is reflected to the connecting client server_context, other_context, client_context = self.sni_contexts() def cb_returning_alert(ssl_sock, server_name, initial_context): return ssl.ALERT_DESCRIPTION_ACCESS_DENIED server_context.set_servername_callback(cb_returning_alert) with self.assertRaises(ssl.SSLError) as cm: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED') @needs_sni def test_sni_callback_raising(self): # Raising fails the connection with a TLS handshake failure alert. server_context, other_context, client_context = self.sni_contexts() def cb_raising(ssl_sock, server_name, initial_context): 1/0 server_context.set_servername_callback(cb_raising) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'SSLV3_ALERT_HANDSHAKE_FAILURE') self.assertIn("ZeroDivisionError", stderr.getvalue()) @needs_sni def test_sni_callback_wrong_return_type(self): # Returning the wrong return type terminates the TLS connection # with an internal error alert. server_context, other_context, client_context = self.sni_contexts() def cb_wrong_return_type(ssl_sock, server_name, initial_context): return "foo" server_context.set_servername_callback(cb_wrong_return_type) with self.assertRaises(ssl.SSLError) as cm, \ support.captured_stderr() as stderr: stats = server_params_test(client_context, server_context, chatty=False, sni_name='supermessage') self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_INTERNAL_ERROR') self.assertIn("TypeError", stderr.getvalue()) def test_shared_ciphers(self): server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) server_context.load_cert_chain(SIGNED_CERTFILE) client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.verify_mode = ssl.CERT_REQUIRED client_context.load_verify_locations(SIGNING_CA) client_context.set_ciphers("RC4") server_context.set_ciphers("AES:RC4") stats = server_params_test(client_context, server_context) ciphers = stats['server_shared_ciphers'][0] self.assertGreater(len(ciphers), 0) for name, tls_version, bits in ciphers: self.assertIn("RC4", name.split("-")) def test_read_write_after_close_raises_valuerror(self): context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: s = context.wrap_socket(socket.socket()) s.connect((HOST, server.port)) s.close() self.assertRaises(ValueError, s.read, 1024) self.assertRaises(ValueError, s.write, b'hello') def test_sendfile(self): TEST_DATA = b"x" * 512 with open(support.TESTFN, 'wb') as f: f.write(TEST_DATA) self.addCleanup(support.unlink, support.TESTFN) context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) context.verify_mode = ssl.CERT_REQUIRED context.load_verify_locations(CERTFILE) context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: with context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) with open(support.TESTFN, 'rb') as file: s.sendfile(file) self.assertEqual(s.recv(1024), TEST_DATA) def test_main(verbose=False): if support.verbose: import warnings plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } with warnings.catch_warnings(): warnings.filterwarnings( 'ignore', 'dist\(\) and linux_distribution\(\) ' 'functions are deprecated .*', PendingDeprecationWarning, ) for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicSocketTests, SSLErrorTests, MemoryBIOTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) tests.append(NetworkedBIOTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/3.5/test_subprocess.py0000644000076500000000000033360212666555342021654 0ustar jmaddenwheel00000000000000import unittest from test.support import script_helper from test import support import subprocess import sys import signal import io import locale import os import errno import tempfile import time import re import selectors import sysconfig import warnings import select import shutil import gc import textwrap try: import threading except ImportError: threading = None mswindows = (sys.platform == "win32") # # Depends on the following external programs: Python # if mswindows: SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), ' 'os.O_BINARY);') else: SETBINARY = '' try: mkstemp = tempfile.mkstemp except AttributeError: # tempfile.mkstemp is not available def mkstemp(): """Replacement for mkstemp, calling mktemp.""" fname = tempfile.mktemp() return os.open(fname, os.O_RDWR|os.O_CREAT), fname class BaseTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). support.reap_children() def tearDown(self): for inst in subprocess._active: inst.wait() subprocess._cleanup() self.assertFalse(subprocess._active, "subprocess._active not empty") def assertStderrEqual(self, stderr, expected, msg=None): # In a debug build, stuff like "[6580 refs]" is printed to stderr at # shutdown time. That frustrates tests trying to check stderr produced # from a spawned Python process. actual = support.strip_python_stderr(stderr) # strip_python_stderr also strips whitespace, so we do too. expected = expected.strip() self.assertEqual(actual, expected, msg) class PopenTestException(Exception): pass class PopenExecuteChildRaises(subprocess.Popen): """Popen subclass for testing cleanup of subprocess.PIPE filehandles when _execute_child fails. """ def _execute_child(self, *args, **kwargs): raise PopenTestException("Forced Exception for Test") class ProcessTestCase(BaseTestCase): def test_io_buffered_by_default(self): p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: self.assertIsInstance(p.stdin, io.BufferedIOBase) self.assertIsInstance(p.stdout, io.BufferedIOBase) self.assertIsInstance(p.stderr, io.BufferedIOBase) finally: p.stdin.close() p.stdout.close() p.stderr.close() p.wait() def test_io_unbuffered_works(self): p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) try: self.assertIsInstance(p.stdin, io.RawIOBase) self.assertIsInstance(p.stdout, io.RawIOBase) self.assertIsInstance(p.stderr, io.RawIOBase) finally: p.stdin.close() p.stdout.close() p.stderr.close() p.wait() def test_call_seq(self): # call() function with sequence argument rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) def test_call_timeout(self): # call() function with timeout argument; we want to test that the child # process gets killed when the timeout expires. If the child isn't # killed, this call will deadlock since subprocess.call waits for the # child. self.assertRaises(subprocess.TimeoutExpired, subprocess.call, [sys.executable, "-c", "while True: pass"], timeout=0.1) def test_check_call_zero(self): # check_call() function with zero return code rc = subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(0)"]) self.assertEqual(rc, 0) def test_check_call_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_call([sys.executable, "-c", "import sys; sys.exit(47)"]) self.assertEqual(c.exception.returncode, 47) def test_check_output(self): # check_output() function with zero return code output = subprocess.check_output( [sys.executable, "-c", "print('BDFL')"]) self.assertIn(b'BDFL', output) def test_check_output_nonzero(self): # check_call() function with non-zero return code with self.assertRaises(subprocess.CalledProcessError) as c: subprocess.check_output( [sys.executable, "-c", "import sys; sys.exit(5)"]) self.assertEqual(c.exception.returncode, 5) def test_check_output_stderr(self): # check_output() function stderr redirected to stdout output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"], stderr=subprocess.STDOUT) self.assertIn(b'BDFL', output) def test_check_output_stdin_arg(self): # check_output() can be called with stdin set to a file tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stdout.write(sys.stdin.read().upper())"], stdin=tf) self.assertIn(b'PEAR', output) def test_check_output_input_arg(self): # check_output() can be called with input set to a string output = subprocess.check_output( [sys.executable, "-c", "import sys; sys.stdout.write(sys.stdin.read().upper())"], input=b'pear') self.assertIn(b'PEAR', output) def test_check_output_stdout_arg(self): # check_output() refuses to accept 'stdout' argument with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print('will not be run')"], stdout=sys.stdout) self.fail("Expected ValueError when stdout arg supplied.") self.assertIn('stdout', c.exception.args[0]) def test_check_output_stdin_with_input_arg(self): # check_output() refuses to accept 'stdin' with 'input' tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) with self.assertRaises(ValueError) as c: output = subprocess.check_output( [sys.executable, "-c", "print('will not be run')"], stdin=tf, input=b'hare') self.fail("Expected ValueError when stdin and input args supplied.") self.assertIn('stdin', c.exception.args[0]) self.assertIn('input', c.exception.args[0]) def test_check_output_timeout(self): # check_output() function with timeout arg with self.assertRaises(subprocess.TimeoutExpired) as c: output = subprocess.check_output( [sys.executable, "-c", "import sys, time\n" "sys.stdout.write('BDFL')\n" "sys.stdout.flush()\n" "time.sleep(3600)"], # Some heavily loaded buildbots (sparc Debian 3.x) require # this much time to start and print. timeout=3) self.fail("Expected TimeoutExpired.") self.assertEqual(c.exception.output, b'BDFL') def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() newenv["FRUIT"] = "banana" rc = subprocess.call([sys.executable, "-c", 'import sys, os;' 'sys.exit(os.getenv("FRUIT")=="banana")'], env=newenv) self.assertEqual(rc, 1) def test_invalid_args(self): # Popen() called with invalid arguments should raise TypeError # but Popen.__del__ should not complain (issue #12085) with support.captured_stderr() as s: self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1) argcount = subprocess.Popen.__init__.__code__.co_argcount too_many_args = [0] * (argcount + 1) self.assertRaises(TypeError, subprocess.Popen, *too_many_args) self.assertEqual(s.getvalue(), '') def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print("banana")'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) p.wait() self.assertEqual(p.stdin, None) def test_stdout_none(self): # .stdout is None when not redirected, and the child's stdout will # be inherited from the parent. In order to test this we run a # subprocess in a subprocess: # this_test # \-- subprocess created by this test (parent) # \-- subprocess created by the parent subprocess (child) # The parent doesn't specify stdout, so the child will use the # parent's stdout. This test checks that the message printed by the # child goes to the parent stdout. The parent also checks that the # child's stdout is None. See #11963. code = ('import sys; from subprocess import Popen, PIPE;' 'p = Popen([sys.executable, "-c", "print(\'test_stdout_none\')"],' ' stdin=PIPE, stderr=PIPE);' 'p.wait(); assert p.stdout is None;') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), b'test_stdout_none') def test_stderr_none(self): # .stderr is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print("banana")'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stdin.close) p.wait() self.assertEqual(p.stderr, None) def _assert_python(self, pre_args, **kwargs): # We include sys.exit() to prevent the test runner from hanging # whenever python is found. args = pre_args + ["import sys; sys.exit(47)"] p = subprocess.Popen(args, **kwargs) p.wait() self.assertEqual(47, p.returncode) def test_executable(self): # Check that the executable argument works. # # On Unix (non-Mac and non-Windows), Python looks at args[0] to # determine where its standard library is, so we need the directory # of args[0] to be valid for the Popen() call to Python to succeed. # See also issue #16170 and issue #7774. doesnotexist = os.path.join(os.path.dirname(sys.executable), "doesnotexist") self._assert_python([doesnotexist, "-c"], executable=sys.executable) def test_executable_takes_precedence(self): # Check that the executable argument takes precedence over args[0]. # # Verify first that the call succeeds without the executable arg. pre_args = [sys.executable, "-c"] self._assert_python(pre_args) self.assertRaises(FileNotFoundError, self._assert_python, pre_args, executable="doesnotexist") @unittest.skipIf(mswindows, "executable argument replaces shell") def test_executable_replaces_shell(self): # Check that the executable argument replaces the default shell # when shell=True. self._assert_python([], executable=sys.executable, shell=True) # For use in the test_cwd* tests below. def _normalize_cwd(self, cwd): # Normalize an expected cwd (for Tru64 support). # We can't use os.path.realpath since it doesn't expand Tru64 {memb} # strings. See bug #1063571. with support.change_cwd(cwd): return os.getcwd() # For use in the test_cwd* tests below. def _split_python_path(self): # Return normalized (python_dir, python_base). python_path = os.path.realpath(sys.executable) return os.path.split(python_path) # For use in the test_cwd* tests below. def _assert_cwd(self, expected_cwd, python_arg, **kwargs): # Invoke Python via Popen, and assert that (1) the call succeeds, # and that (2) the current working directory of the child process # matches *expected_cwd*. p = subprocess.Popen([python_arg, "-c", "import os, sys; " "sys.stdout.write(os.getcwd()); " "sys.exit(47)"], stdout=subprocess.PIPE, **kwargs) self.addCleanup(p.stdout.close) p.wait() self.assertEqual(47, p.returncode) normcase = os.path.normcase self.assertEqual(normcase(expected_cwd), normcase(p.stdout.read().decode("utf-8"))) def test_cwd(self): # Check that cwd changes the cwd for the child process. temp_dir = tempfile.gettempdir() temp_dir = self._normalize_cwd(temp_dir) self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir) @unittest.skipIf(mswindows, "pending resolution of issue #15533") def test_cwd_with_relative_arg(self): # Check that Popen looks for args[0] relative to cwd if args[0] # is relative. python_dir, python_base = self._split_python_path() rel_python = os.path.join(os.curdir, python_base) with support.temp_cwd('test_cwd_with_relative_arg', quiet=True) as wrong_dir: # gevent: use distinct name, avoid Travis CI failure # Before calling with the correct cwd, confirm that the call fails # without cwd and with the wrong cwd. self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python]) self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python], cwd=wrong_dir) python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, rel_python, cwd=python_dir) @unittest.skipIf(mswindows, "pending resolution of issue #15533") def test_cwd_with_relative_executable(self): # Check that Popen looks for executable relative to cwd if executable # is relative (and that executable takes precedence over args[0]). python_dir, python_base = self._split_python_path() rel_python = os.path.join(os.curdir, python_base) doesntexist = "somethingyoudonthave" with support.temp_cwd('test_cwd_with_relative_executable', quiet=True) as wrong_dir: # gevent: use distinct name, avoid Travis CI failure # Before calling with the correct cwd, confirm that the call fails # without cwd and with the wrong cwd. self.assertRaises(FileNotFoundError, subprocess.Popen, [doesntexist], executable=rel_python) self.assertRaises(FileNotFoundError, subprocess.Popen, [doesntexist], executable=rel_python, cwd=wrong_dir) python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, doesntexist, executable=rel_python, cwd=python_dir) def test_cwd_with_absolute_arg(self): # Check that Popen can find the executable when the cwd is wrong # if args[0] is an absolute path. python_dir, python_base = self._split_python_path() abs_python = os.path.join(python_dir, python_base) rel_python = os.path.join(os.curdir, python_base) with support.temp_dir() as wrong_dir: # Before calling with an absolute path, confirm that using a # relative path fails. self.assertRaises(FileNotFoundError, subprocess.Popen, [rel_python], cwd=wrong_dir) wrong_dir = self._normalize_cwd(wrong_dir) self._assert_cwd(wrong_dir, abs_python, cwd=wrong_dir) @unittest.skipIf(sys.base_prefix != sys.prefix, 'Test is not venv-compatible') def test_executable_with_cwd(self): python_dir, python_base = self._split_python_path() python_dir = self._normalize_cwd(python_dir) self._assert_cwd(python_dir, "somethingyoudonthave", executable=sys.executable, cwd=python_dir) @unittest.skipIf(sys.base_prefix != sys.prefix, 'Test is not venv-compatible') @unittest.skipIf(sysconfig.is_python_build(), "need an installed Python. See #7774") def test_executable_without_cwd(self): # For a normal installation, it should work without 'cwd' # argument. For test runs in the build directory, see #7774. self._assert_cwd(os.getcwd(), "somethingyoudonthave", executable=sys.executable) def test_stdin_pipe(self): # stdin redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.stdin.write(b"pear") p.stdin.close() p.wait() self.assertEqual(p.returncode, 1) def test_stdin_filedes(self): # stdin is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() os.write(d, b"pear") os.lseek(d, 0, 0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=d) p.wait() self.assertEqual(p.returncode, 1) def test_stdin_fileobj(self): # stdin is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b"pear") tf.seek(0) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.exit(sys.stdin.read() == "pear")'], stdin=tf) p.wait() self.assertEqual(p.returncode, 1) def test_stdout_pipe(self): # stdout redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), b"orange") def test_stdout_filedes(self): # stdout is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), b"orange") def test_stdout_fileobj(self): # stdout is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), b"orange") def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.addCleanup(p.stderr.close) self.assertStderrEqual(p.stderr.read(), b"strawberry") def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() self.addCleanup(tf.close) d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertStderrEqual(os.read(d, 1024), b"strawberry") def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), b"strawberry") def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.addCleanup(p.stdout.close) self.assertStderrEqual(p.stdout.read(), b"appleorange") def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() self.addCleanup(tf.close) p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) self.assertStderrEqual(tf.read(), b"appleorange") def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). # To avoid printing the text on stdout, we do something similar to # test_stdout_none (see above). The parent subprocess calls the child # subprocess passing stdout=1, and this test uses stdout=PIPE in # order to capture and check the output of the parent. See #11963. code = ('import sys, subprocess; ' 'rc = subprocess.call([sys.executable, "-c", ' ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), ' 'b\'test with stdout=1\'))"], stdout=1); ' 'assert rc == 18') p = subprocess.Popen([sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) out, err = p.communicate() self.assertEqual(p.returncode, 0, err) self.assertEqual(out.rstrip(), b'test with stdout=1') def test_stdout_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'for i in range(10240):' 'print("x" * 1024)'], stdout=subprocess.DEVNULL) p.wait() self.assertEqual(p.stdout, None) def test_stderr_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'import sys\n' 'for i in range(10240):' 'sys.stderr.write("x" * 1024)'], stderr=subprocess.DEVNULL) p.wait() self.assertEqual(p.stderr, None) def test_stdin_devnull(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdin.read(1)'], stdin=subprocess.DEVNULL) p.wait() self.assertEqual(p.stdin, None) def test_env(self): newenv = os.environ.copy() newenv["FRUIT"] = "orange" with subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, env=newenv) as p: stdout, stderr = p.communicate() self.assertEqual(stdout, b"orange") # Windows requires at least the SYSTEMROOT environment variable to start # Python @unittest.skipIf(sys.platform == 'win32', 'cannot test an empty env on Windows') @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') is not None, 'the python library cannot be loaded ' 'with an empty environment') def test_empty_env(self): with subprocess.Popen([sys.executable, "-c", 'import os; ' 'print(list(os.environ.keys()))'], stdout=subprocess.PIPE, env={}) as p: stdout, stderr = p.communicate() self.assertIn(stdout.strip(), (b"[]", # Mac OS X adds __CF_USER_TEXT_ENCODING variable to an empty # environment b"['__CF_USER_TEXT_ENCODING']")) def test_communicate_stdin(self): p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.exit(sys.stdin.read() == "pear")'], stdin=subprocess.PIPE) p.communicate(b"pear") self.assertEqual(p.returncode, 1) def test_communicate_stdout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("pineapple")'], stdout=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, b"pineapple") self.assertEqual(stderr, None) def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertStderrEqual(stderr, b"pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) (stdout, stderr) = p.communicate(b"banana") self.assertEqual(stdout, b"banana") self.assertStderrEqual(stderr, b"pineapple") def test_communicate_timeout(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os,time;' 'sys.stderr.write("pineapple\\n");' 'time.sleep(1);' 'sys.stderr.write("pear\\n");' 'sys.stdout.write(sys.stdin.read())'], universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.assertRaises(subprocess.TimeoutExpired, p.communicate, "banana", timeout=0.3) # Make sure we can keep waiting for it, and that we get the whole output # after it completes. (stdout, stderr) = p.communicate() self.assertEqual(stdout, "banana") self.assertStderrEqual(stderr.encode(), b"pineapple\npear\n") def test_communicate_timeout_large_ouput(self): # Test an expiring timeout while the child is outputting lots of data. p = subprocess.Popen([sys.executable, "-c", 'import sys,os,time;' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));' 'time.sleep(0.2);' 'sys.stdout.write("a" * (64 * 1024));'], stdout=subprocess.PIPE) self.assertRaises(subprocess.TimeoutExpired, p.communicate, timeout=0.4) (stdout, _) = p.communicate() self.assertEqual(len(stdout), 4 * 64 * 1024) # Test for the fd leak reported in http://bugs.python.org/issue2791. def test_communicate_pipe_fd_leak(self): for stdin_pipe in (False, True): for stdout_pipe in (False, True): for stderr_pipe in (False, True): options = {} if stdin_pipe: options['stdin'] = subprocess.PIPE if stdout_pipe: options['stdout'] = subprocess.PIPE if stderr_pipe: options['stderr'] = subprocess.PIPE if not options: continue p = subprocess.Popen((sys.executable, "-c", "pass"), **options) p.communicate() if p.stdin is not None: self.assertTrue(p.stdin.closed) if p.stdout is not None: self.assertTrue(p.stdout.closed) if p.stderr is not None: self.assertTrue(p.stderr.closed) def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(47)"]) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, None) def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. x, y = os.pipe() os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' 'sys.stderr.write("x" * %d);' 'sys.stdout.write(sys.stdin.read())' % support.PIPE_MAX_SIZE], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) string_to_write = b"a" * support.PIPE_MAX_SIZE (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.stdin.write(b"banana") (stdout, stderr) = p.communicate(b"split") self.assertEqual(stdout, b"bananasplit") self.assertStderrEqual(stderr, b"") def test_universal_newlines(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'buf = sys.stdout.buffer;' 'buf.write(sys.stdin.readline().encode());' 'buf.flush();' 'buf.write(b"line2\\n");' 'buf.flush();' 'buf.write(sys.stdin.read().encode());' 'buf.flush();' 'buf.write(b"line4\\n");' 'buf.flush();' 'buf.write(b"line5\\r\\n");' 'buf.flush();' 'buf.write(b"line6\\r");' 'buf.flush();' 'buf.write(b"\\nline7");' 'buf.flush();' 'buf.write(b"\\nline8");'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=1) p.stdin.write("line1\n") p.stdin.flush() self.assertEqual(p.stdout.readline(), "line1\n") p.stdin.write("line3\n") p.stdin.close() self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.readline(), "line2\n") self.assertEqual(p.stdout.read(6), "line3\n") self.assertEqual(p.stdout.read(), "line4\nline5\nline6\nline7\nline8") def test_universal_newlines_communicate(self): # universal newlines through communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'buf = sys.stdout.buffer;' 'buf.write(b"line2\\n");' 'buf.flush();' 'buf.write(b"line4\\n");' 'buf.flush();' 'buf.write(b"line5\\r\\n");' 'buf.flush();' 'buf.write(b"line6\\r");' 'buf.flush();' 'buf.write(b"\\nline7");' 'buf.flush();' 'buf.write(b"\\nline8");'], stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=1) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate() self.assertEqual(stdout, "line2\nline4\nline5\nline6\nline7\nline8") def test_universal_newlines_communicate_stdin(self): # universal newlines through communicate(), with only stdin p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + textwrap.dedent(''' s = sys.stdin.readline() assert s == "line1\\n", repr(s) s = sys.stdin.read() assert s == "line3\\n", repr(s) ''')], stdin=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate("line1\nline3\n") self.assertEqual(p.returncode, 0) def test_universal_newlines_communicate_input_none(self): # Test communicate(input=None) with universal newlines. # # We set stdout to PIPE because, as of this writing, a different # code path is tested when the number of pipes is zero or one. p = subprocess.Popen([sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) p.communicate() self.assertEqual(p.returncode, 0) def test_universal_newlines_communicate_stdin_stdout_stderr(self): # universal newlines through communicate(), with stdin, stdout, stderr p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + textwrap.dedent(''' s = sys.stdin.buffer.readline() sys.stdout.buffer.write(s) sys.stdout.buffer.write(b"line2\\r") sys.stderr.buffer.write(b"eline2\\n") s = sys.stdin.buffer.read() sys.stdout.buffer.write(s) sys.stdout.buffer.write(b"line4\\n") sys.stdout.buffer.write(b"line5\\r\\n") sys.stderr.buffer.write(b"eline6\\r") sys.stderr.buffer.write(b"eline7\\r\\nz") ''')], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate("line1\nline3\n") self.assertEqual(p.returncode, 0) self.assertEqual("line1\nline2\nline3\nline4\nline5\n", stdout) # Python debug build push something like "[42442 refs]\n" # to stderr at exit of subprocess. # Don't use assertStderrEqual because it strips CR and LF from output. self.assertTrue(stderr.startswith("eline2\neline6\neline7\n")) def test_universal_newlines_communicate_encodings(self): # Check that universal newlines mode works for various encodings, # in particular for encodings in the UTF-16 and UTF-32 families. # See issue #15595. # # UTF-16 and UTF-32-BE are sufficient to check both with BOM and # without, and UTF-16 and UTF-32. import _bootlocale for encoding in ['utf-16', 'utf-32-be']: old_getpreferredencoding = _bootlocale.getpreferredencoding # Indirectly via io.TextIOWrapper, Popen() defaults to # locale.getpreferredencoding(False) and earlier in Python 3.2 to # locale.getpreferredencoding(). def getpreferredencoding(do_setlocale=True): return encoding code = ("import sys; " r"sys.stdout.buffer.write('1\r\n2\r3\n4'.encode('%s'))" % encoding) args = [sys.executable, '-c', code] try: _bootlocale.getpreferredencoding = getpreferredencoding # We set stdin to be non-None because, as of this writing, # a different code path is used when the number of pipes is # zero or one. popen = subprocess.Popen(args, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = popen.communicate(input='') finally: _bootlocale.getpreferredencoding = old_getpreferredencoding self.assertEqual(stdout, '1\n2\n3\n4') def test_no_leaking(self): # Make sure we leak no resources if not mswindows: max_handles = 1026 # too much for most UNIX systems else: max_handles = 2050 # too much for (at least some) Windows setups handles = [] tmpdir = tempfile.mkdtemp() try: for i in range(max_handles): try: tmpfile = os.path.join(tmpdir, support.TESTFN) handles.append(os.open(tmpfile, os.O_WRONLY|os.O_CREAT)) except OSError as e: if e.errno != errno.EMFILE: raise break else: self.skipTest("failed to reach the file descriptor limit " "(tried %d)" % max_handles) # Close a couple of them (should be enough for a subprocess) for i in range(10): os.close(handles.pop()) # Loop creating some subprocesses. If one of them leaks some fds, # the next loop iteration will fail by reaching the max fd limit. for i in range(15): p = subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate(b"lime")[0] self.assertEqual(data, b"lime") finally: for h in handles: os.close(h) shutil.rmtree(tmpdir) def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), '"a b c" d e') self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']), 'ab\\"c \\ d') self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']), 'ab\\"c " \\\\" d') self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']), 'a\\\\\\b "de fg" h') self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']), 'a\\\\\\"b c d') self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']), '"a\\\\b c" d e') self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']), '"a\\\\b\\ c" d e') self.assertEqual(subprocess.list2cmdline(['ab', '']), 'ab ""') def test_poll(self): p = subprocess.Popen([sys.executable, "-c", "import os; os.read(0, 1)"], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) self.assertIsNone(p.poll()) os.write(p.stdin.fileno(), b'A') p.wait() # Subsequent invocations should just return the returncode self.assertEqual(p.poll(), 0) def test_wait(self): p = subprocess.Popen([sys.executable, "-c", "pass"]) self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) def test_wait_timeout(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(0.3)"]) with self.assertRaises(subprocess.TimeoutExpired) as c: p.wait(timeout=0.0001) self.assertIn("0.0001", str(c.exception)) # For coverage of __str__. # Some heavily loaded buildbots (sparc Debian 3.x) require this much # time to start. self.assertEqual(p.wait(timeout=3), 0) def test_invalid_bufsize(self): # an invalid type of the bufsize argument should raise # TypeError. with self.assertRaises(TypeError): subprocess.Popen([sys.executable, "-c", "pass"], "orange") def test_bufsize_is_none(self): # bufsize=None should be the same as bufsize=0. p = subprocess.Popen([sys.executable, "-c", "pass"], None) self.assertEqual(p.wait(), 0) # Again with keyword arg p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) self.assertEqual(p.wait(), 0) def _test_bufsize_equal_one(self, line, expected, universal_newlines): # subprocess may deadlock with bufsize=1, see issue #21332 with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write(sys.stdin.readline());" "sys.stdout.flush()"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=1, universal_newlines=universal_newlines) as p: p.stdin.write(line) # expect that it flushes the line in text mode os.close(p.stdin.fileno()) # close it without flushing the buffer read_line = p.stdout.readline() try: p.stdin.close() except OSError: pass p.stdin = None self.assertEqual(p.returncode, 0) self.assertEqual(read_line, expected) def test_bufsize_equal_one_text_mode(self): # line is flushed in text mode with bufsize=1. # we should get the full line in return line = "line\n" self._test_bufsize_equal_one(line, line, universal_newlines=True) def test_bufsize_equal_one_binary_mode(self): # line is not flushed in binary mode with bufsize=1. # we should get empty response line = b'line' + os.linesep.encode() # assume ascii-based locale self._test_bufsize_equal_one(line, b'', universal_newlines=False) def test_leaking_fds_on_error(self): # see bug #5179: Popen leaks file descriptors to PIPEs if # the child fails to execute; this will eventually exhaust # the maximum number of open fds. 1024 seems a very common # value for that limit, but Windows has 2048, so we loop # 1024 times (each call leaked two fds). for i in range(1024): with self.assertRaises(OSError) as c: subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # ignore errors that indicate the command was not found if c.exception.errno not in (errno.ENOENT, errno.EACCES): raise c.exception @unittest.skipIf(threading is None, "threading required") def test_double_close_on_error(self): # Issue #18851 fds = [] def open_fds(): for i in range(20): fds.extend(os.pipe()) time.sleep(0.001) t = threading.Thread(target=open_fds) t.start() try: with self.assertRaises(EnvironmentError): subprocess.Popen(['nonexisting_i_hope'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: t.join() exc = None for fd in fds: # If a double close occurred, some of those fds will # already have been closed by mistake, and os.close() # here will raise. try: os.close(fd) except OSError as e: exc = e if exc is not None: raise exc @unittest.skipIf(threading is None, "threading required") def test_threadsafe_wait(self): """Issue21291: Popen.wait() needs to be threadsafe for returncode.""" proc = subprocess.Popen([sys.executable, '-c', 'import time; time.sleep(12)']) self.assertEqual(proc.returncode, None) results = [] def kill_proc_timer_thread(): results.append(('thread-start-poll-result', proc.poll())) # terminate it from the thread and wait for the result. proc.kill() proc.wait() results.append(('thread-after-kill-and-wait', proc.returncode)) # this wait should be a no-op given the above. proc.wait() results.append(('thread-after-second-wait', proc.returncode)) # This is a timing sensitive test, the failure mode is # triggered when both the main thread and this thread are in # the wait() call at once. The delay here is to allow the # main thread to most likely be blocked in its wait() call. t = threading.Timer(0.2, kill_proc_timer_thread) t.start() if mswindows: expected_errorcode = 1 else: # Should be -9 because of the proc.kill() from the thread. expected_errorcode = -9 # Wait for the process to finish; the thread should kill it # long before it finishes on its own. Supplying a timeout # triggers a different code path for better coverage. proc.wait(timeout=20) self.assertEqual(proc.returncode, expected_errorcode, msg="unexpected result in wait from main thread") # This should be a no-op with no change in returncode. proc.wait() self.assertEqual(proc.returncode, expected_errorcode, msg="unexpected result in second main wait.") t.join() # Ensure that all of the thread results are as expected. # When a race condition occurs in wait(), the returncode could # be set by the wrong thread that doesn't actually have it # leading to an incorrect value. self.assertEqual([('thread-start-poll-result', None), ('thread-after-kill-and-wait', expected_errorcode), ('thread-after-second-wait', expected_errorcode)], results) def test_issue8780(self): # Ensure that stdout is inherited from the parent # if stdout=PIPE is not used code = ';'.join(( 'import subprocess, sys', 'retcode = subprocess.call(' "[sys.executable, '-c', 'print(\"Hello World!\")'])", 'assert retcode == 0')) output = subprocess.check_output([sys.executable, '-c', code]) self.assertTrue(output.startswith(b'Hello World!'), ascii(output)) def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released ifhandle, ifname = mkstemp() ofhandle, ofname = mkstemp() efhandle, efname = mkstemp() try: subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle, stderr=efhandle) except OSError: os.close(ifhandle) os.remove(ifname) os.close(ofhandle) os.remove(ofname) os.close(efhandle) os.remove(efname) self.assertFalse(os.path.exists(ifname)) self.assertFalse(os.path.exists(ofname)) self.assertFalse(os.path.exists(efname)) def test_communicate_epipe(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) p.communicate(b"x" * 2**20) def test_communicate_epipe_only_stdin(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen([sys.executable, "-c", 'pass'], stdin=subprocess.PIPE) self.addCleanup(p.stdin.close) p.wait() p.communicate(b"x" * 2**20) @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), "Requires signal.SIGUSR1") @unittest.skipUnless(hasattr(os, 'kill'), "Requires os.kill") @unittest.skipUnless(hasattr(os, 'getppid'), "Requires os.getppid") def test_communicate_eintr(self): # Issue #12493: communicate() should handle EINTR def handler(signum, frame): pass old_handler = signal.signal(signal.SIGUSR1, handler) self.addCleanup(signal.signal, signal.SIGUSR1, old_handler) args = [sys.executable, "-c", 'import os, signal;' 'os.kill(os.getppid(), signal.SIGUSR1)'] for stream in ('stdout', 'stderr'): kw = {stream: subprocess.PIPE} with subprocess.Popen(args, **kw) as process: # communicate() will be interrupted by SIGUSR1 process.communicate() # This test is Linux-ish specific for simplicity to at least have # some coverage. It is not a platform specific bug. @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), "Linux specific") def test_failed_child_execute_fd_leak(self): """Test for the fork() failure fd leak reported in issue16327.""" fd_directory = '/proc/%d/fd' % os.getpid() fds_before_popen = os.listdir(fd_directory) with self.assertRaises(PopenTestException): PopenExecuteChildRaises( [sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # NOTE: This test doesn't verify that the real _execute_child # does not close the file descriptors itself on the way out # during an exception. Code inspection has confirmed that. fds_after_exception = os.listdir(fd_directory) self.assertEqual(fds_before_popen, fds_after_exception) class RunFuncTestCase(BaseTestCase): def run_python(self, code, **kwargs): """Run Python code in a subprocess using subprocess.run""" argv = [sys.executable, "-c", code] return subprocess.run(argv, **kwargs) def test_returncode(self): # call() function with sequence argument cp = self.run_python("import sys; sys.exit(47)") self.assertEqual(cp.returncode, 47) with self.assertRaises(subprocess.CalledProcessError): cp.check_returncode() def test_check(self): with self.assertRaises(subprocess.CalledProcessError) as c: self.run_python("import sys; sys.exit(47)", check=True) self.assertEqual(c.exception.returncode, 47) def test_check_zero(self): # check_returncode shouldn't raise when returncode is zero cp = self.run_python("import sys; sys.exit(0)", check=True) self.assertEqual(cp.returncode, 0) def test_timeout(self): # run() function with timeout argument; we want to test that the child # process gets killed when the timeout expires. If the child isn't # killed, this call will deadlock since subprocess.run waits for the # child. with self.assertRaises(subprocess.TimeoutExpired): self.run_python("while True: pass", timeout=0.0001) def test_capture_stdout(self): # capture stdout with zero return code cp = self.run_python("print('BDFL')", stdout=subprocess.PIPE) self.assertIn(b'BDFL', cp.stdout) def test_capture_stderr(self): cp = self.run_python("import sys; sys.stderr.write('BDFL')", stderr=subprocess.PIPE) self.assertIn(b'BDFL', cp.stderr) def test_check_output_stdin_arg(self): # run() can be called with stdin set to a file tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) cp = self.run_python( "import sys; sys.stdout.write(sys.stdin.read().upper())", stdin=tf, stdout=subprocess.PIPE) self.assertIn(b'PEAR', cp.stdout) def test_check_output_input_arg(self): # check_output() can be called with input set to a string cp = self.run_python( "import sys; sys.stdout.write(sys.stdin.read().upper())", input=b'pear', stdout=subprocess.PIPE) self.assertIn(b'PEAR', cp.stdout) def test_check_output_stdin_with_input_arg(self): # run() refuses to accept 'stdin' with 'input' tf = tempfile.TemporaryFile() self.addCleanup(tf.close) tf.write(b'pear') tf.seek(0) with self.assertRaises(ValueError, msg="Expected ValueError when stdin and input args supplied.") as c: output = self.run_python("print('will not be run')", stdin=tf, input=b'hare') self.assertIn('stdin', c.exception.args[0]) self.assertIn('input', c.exception.args[0]) def test_check_output_timeout(self): with self.assertRaises(subprocess.TimeoutExpired) as c: cp = self.run_python(( "import sys, time\n" "sys.stdout.write('BDFL')\n" "sys.stdout.flush()\n" "time.sleep(3600)"), # Some heavily loaded buildbots (sparc Debian 3.x) require # this much time to start and print. timeout=3, stdout=subprocess.PIPE) self.assertEqual(c.exception.output, b'BDFL') # output is aliased to stdout self.assertEqual(c.exception.stdout, b'BDFL') def test_run_kwargs(self): newenv = os.environ.copy() newenv["FRUIT"] = "banana" cp = self.run_python(('import sys, os;' 'sys.exit(33 if os.getenv("FRUIT")=="banana" else 31)'), env=newenv) self.assertEqual(cp.returncode, 33) @unittest.skipIf(mswindows, "POSIX specific tests") class POSIXProcessTestCase(BaseTestCase): def setUp(self): super().setUp() self._nonexistent_dir = "/_this/pa.th/does/not/exist" def _get_chdir_exception(self): try: os.chdir(self._nonexistent_dir) except OSError as e: # This avoids hard coding the errno value or the OS perror() # string and instead capture the exception that we want to see # below for comparison. desired_exception = e desired_exception.strerror += ': ' + repr(self._nonexistent_dir) else: self.fail("chdir to nonexistant directory %s succeeded." % self._nonexistent_dir) return desired_exception def test_exception_cwd(self): """Test error in the child raised in the parent for a bad cwd.""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([sys.executable, "-c", ""], cwd=self._nonexistent_dir) except OSError as e: # Test that the child process chdir failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_exception_bad_executable(self): """Test error in the child raised in the parent for a bad executable.""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([sys.executable, "-c", ""], executable=self._nonexistent_dir) except OSError as e: # Test that the child process exec failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_exception_bad_args_0(self): """Test error in the child raised in the parent for a bad args[0].""" desired_exception = self._get_chdir_exception() try: p = subprocess.Popen([self._nonexistent_dir, "-c", ""]) except OSError as e: # Test that the child process exec failure actually makes # it up to the parent process as the correct exception. self.assertEqual(desired_exception.errno, e.errno) self.assertEqual(desired_exception.strerror, e.strerror) else: self.fail("Expected OSError: %s" % desired_exception) def test_restore_signals(self): # Code coverage for both values of restore_signals to make sure it # at least does not blow up. # A test for behavior would be complex. Contributions welcome. subprocess.call([sys.executable, "-c", ""], restore_signals=True) subprocess.call([sys.executable, "-c", ""], restore_signals=False) def test_start_new_session(self): # For code coverage of calling setsid(). We don't care if we get an # EPERM error from it depending on the test execution environment, that # still indicates that it was called. try: output = subprocess.check_output( [sys.executable, "-c", "import os; print(os.getpgid(os.getpid()))"], start_new_session=True) except OSError as e: if e.errno != errno.EPERM: raise else: parent_pgid = os.getpgid(os.getpid()) child_pgid = int(output) self.assertNotEqual(parent_pgid, child_pgid) def test_run_abort(self): # returncode handles signal termination with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import os; os.abort()']) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT) def test_preexec(self): # DISCLAIMER: Setting environment variables is *not* a good use # of a preexec_fn. This is merely a test. p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stdout.write(os.getenv("FRUIT"))'], stdout=subprocess.PIPE, preexec_fn=lambda: os.putenv("FRUIT", "apple")) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), b"apple") def test_preexec_exception(self): def raise_it(): raise ValueError("What if two swallows carried a coconut?") try: p = subprocess.Popen([sys.executable, "-c", ""], preexec_fn=raise_it) except subprocess.SubprocessError as e: self.assertTrue( subprocess._posixsubprocess, "Expected a ValueError from the preexec_fn") except ValueError as e: self.assertIn("coconut", e.args[0]) else: self.fail("Exception raised by preexec_fn did not make it " "to the parent process.") class _TestExecuteChildPopen(subprocess.Popen): """Used to test behavior at the end of _execute_child.""" def __init__(self, testcase, *args, **kwargs): self._testcase = testcase subprocess.Popen.__init__(self, *args, **kwargs) def _execute_child(self, *args, **kwargs): try: subprocess.Popen._execute_child(self, *args, **kwargs) finally: # Open a bunch of file descriptors and verify that # none of them are the same as the ones the Popen # instance is using for stdin/stdout/stderr. devzero_fds = [os.open("/dev/zero", os.O_RDONLY) for _ in range(8)] try: for fd in devzero_fds: self._testcase.assertNotIn( fd, (self.stdin.fileno(), self.stdout.fileno(), self.stderr.fileno()), msg="At least one fd was closed early.") finally: for fd in devzero_fds: os.close(fd) @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") def test_preexec_errpipe_does_not_double_close_pipes(self): """Issue16140: Don't double close pipes on preexec error.""" def raise_it(): raise subprocess.SubprocessError( "force the _execute_child() errpipe_data path.") with self.assertRaises(subprocess.SubprocessError): self._TestExecuteChildPopen( self, [sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=raise_it) def test_preexec_gc_module_failure(self): # This tests the code that disables garbage collection if the child # process will execute any Python. def raise_runtime_error(): raise RuntimeError("this shouldn't escape") enabled = gc.isenabled() orig_gc_disable = gc.disable orig_gc_isenabled = gc.isenabled try: gc.disable() self.assertFalse(gc.isenabled()) subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) self.assertFalse(gc.isenabled(), "Popen enabled gc when it shouldn't.") gc.enable() self.assertTrue(gc.isenabled()) subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) self.assertTrue(gc.isenabled(), "Popen left gc disabled.") gc.disable = raise_runtime_error self.assertRaises(RuntimeError, subprocess.Popen, [sys.executable, '-c', ''], preexec_fn=lambda: None) del gc.isenabled # force an AttributeError self.assertRaises(AttributeError, subprocess.Popen, [sys.executable, '-c', ''], preexec_fn=lambda: None) finally: gc.disable = orig_gc_disable gc.isenabled = orig_gc_isenabled if not enabled: gc.disable() def test_args_string(self): # args is a string fd, fname = mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.chmod(fname, 0o700) p = subprocess.Popen(fname) p.wait() os.remove(fname) self.assertEqual(p.returncode, 47) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], startupinfo=47) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], creationflags=47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen(["echo $FRUIT"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple") def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "apple" p = subprocess.Popen("echo $FRUIT", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple") def test_call_string(self): # call() function with string argument on UNIX fd, fname = mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % sys.executable) os.chmod(fname, 0o700) rc = subprocess.call(fname) os.remove(fname) self.assertEqual(rc, 47) def test_specific_shell(self): # Issue #9265: Incorrect name passed as arg[0]. shells = [] for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']: for name in ['bash', 'ksh']: sh = os.path.join(prefix, name) if os.path.isfile(sh): shells.append(sh) if not shells: # Will probably work for any shell but csh. self.skipTest("bash or ksh required for this test") sh = '/bin/sh' if os.path.isfile(sh) and not os.path.islink(sh): # Test will fail if /bin/sh is a symlink to csh. shells.append(sh) for sh in shells: p = subprocess.Popen("echo $0", executable=sh, shell=True, stdout=subprocess.PIPE) self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii')) def _kill_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. # Also set the SIGINT handler to the default to make sure it's not # being ignored (some tests rely on that.) old_handler = signal.signal(signal.SIGINT, signal.default_int_handler) try: p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) finally: signal.signal(signal.SIGINT, old_handler) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) return p @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() """], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) p.communicate() def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() self.assertIn(b'KeyboardInterrupt', stderr) self.assertNotEqual(p.wait(), 0) def test_kill(self): p = self._kill_process('kill') _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') self.assertEqual(p.wait(), -signal.SIGKILL) def test_terminate(self): p = self._kill_process('terminate') _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') self.assertEqual(p.wait(), -signal.SIGTERM) def test_send_signal_dead(self): # Sending a signal to a dead process self._kill_dead_process('send_signal', signal.SIGINT) def test_kill_dead(self): # Killing a dead process self._kill_dead_process('kill') def test_terminate_dead(self): # Terminating a dead process self._kill_dead_process('terminate') def _save_fds(self, save_fds): fds = [] for fd in save_fds: inheritable = os.get_inheritable(fd) saved = os.dup(fd) fds.append((fd, saved, inheritable)) return fds def _restore_fds(self, fds): for fd, saved, inheritable in fds: os.dup2(saved, fd, inheritable=inheritable) os.close(saved) def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed stdin = 0 saved_fds = self._save_fds(fds) for fd, saved, inheritable in saved_fds: if fd == 0: stdin = saved break try: for fd in fds: os.close(fd) out, err = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple");' 'sys.stdout.flush();' 'sys.stderr.write("orange")'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() err = support.strip_python_stderr(err) self.assertEqual((out, err), (b'apple', b'orange')) finally: self._restore_fds(saved_fds) def test_close_fd_0(self): self.check_close_std_fds([0]) def test_close_fd_1(self): self.check_close_std_fds([1]) def test_close_fd_2(self): self.check_close_std_fds([2]) def test_close_fds_0_1(self): self.check_close_std_fds([0, 1]) def test_close_fds_0_2(self): self.check_close_std_fds([0, 2]) def test_close_fds_1_2(self): self.check_close_std_fds([1, 2]) def test_close_fds_0_1_2(self): # Issue #10806: test that subprocess pipes still work properly with # all standard fds closed. self.check_close_std_fds([0, 1, 2]) def test_small_errpipe_write_fd(self): """Issue #15798: Popen should work when stdio fds are available.""" new_stdin = os.dup(0) new_stdout = os.dup(1) try: os.close(0) os.close(1) # Side test: if errpipe_write fails to have its CLOEXEC # flag set this should cause the parent to think the exec # failed. Extremely unlikely: everyone supports CLOEXEC. subprocess.Popen([ sys.executable, "-c", "print('AssertionError:0:CLOEXEC failure.')"]).wait() finally: # Restore original stdin and stdout os.dup2(new_stdin, 0) os.dup2(new_stdout, 1) os.close(new_stdin) os.close(new_stdout) def test_remapping_std_fds(self): # open up some temporary files temps = [mkstemp() for i in range(3)] try: temp_fds = [fd for fd, fname in temps] # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # write some data to what will become stdin, and rewind os.write(temp_fds[1], b"STDIN") os.lseek(temp_fds[1], 0, 0) # move the standard file descriptors out of the way saved_fds = self._save_fds(range(3)) try: # duplicate the file objects over the standard fd's for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # now use those files in the "wrong" order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=temp_fds[1], stdout=temp_fds[2], stderr=temp_fds[0]) p.wait() finally: self._restore_fds(saved_fds) for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(temp_fds[2], 1024) err = support.strip_python_stderr(os.read(temp_fds[0], 1024)) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) def check_swap_fds(self, stdin_no, stdout_no, stderr_no): # open up some temporary files temps = [mkstemp() for i in range(3)] temp_fds = [fd for fd, fname in temps] try: # unlink the files -- we won't need to reopen them for fd, fname in temps: os.unlink(fname) # save a copy of the standard file descriptors saved_fds = self._save_fds(range(3)) try: # duplicate the temp files over the standard fd's 0, 1, 2 for fd, temp_fd in enumerate(temp_fds): os.dup2(temp_fd, fd) # write some data to what will become stdin, and rewind os.write(stdin_no, b"STDIN") os.lseek(stdin_no, 0, 0) # now use those files in the given order, so that subprocess # has to rearrange them in the child p = subprocess.Popen([sys.executable, "-c", 'import sys; got = sys.stdin.read();' 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'], stdin=stdin_no, stdout=stdout_no, stderr=stderr_no) p.wait() for fd in temp_fds: os.lseek(fd, 0, 0) out = os.read(stdout_no, 1024) err = support.strip_python_stderr(os.read(stderr_no, 1024)) finally: self._restore_fds(saved_fds) self.assertEqual(out, b"got STDIN") self.assertEqual(err, b"err") finally: for fd in temp_fds: os.close(fd) # When duping fds, if there arises a situation where one of the fds is # either 0, 1 or 2, it is possible that it is overwritten (#12607). # This tests all combinations of this. def test_swap_fds(self): self.check_swap_fds(0, 1, 2) self.check_swap_fds(0, 2, 1) self.check_swap_fds(1, 0, 2) self.check_swap_fds(1, 2, 0) self.check_swap_fds(2, 0, 1) self.check_swap_fds(2, 1, 0) def test_surrogates_error_message(self): def prepare(): raise ValueError("surrogate:\uDCff") try: subprocess.call( [sys.executable, "-c", "pass"], preexec_fn=prepare) except ValueError as err: # Pure Python implementations keeps the message self.assertIsNone(subprocess._posixsubprocess) self.assertEqual(str(err), "surrogate:\uDCff") except subprocess.SubprocessError as err: # _posixsubprocess uses a default message self.assertIsNotNone(subprocess._posixsubprocess) self.assertEqual(str(err), "Exception occurred in preexec_fn.") else: self.fail("Expected ValueError or subprocess.SubprocessError") def test_undecodable_env(self): for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')): encoded_value = value.encode("ascii", "surrogateescape") # test str with surrogates script = "import os; print(ascii(os.getenv(%s)))" % repr(key) env = os.environ.copy() env[key] = value # Use C locale to get ASCII for the locale encoding to force # surrogate-escaping of \xFF in the child process; otherwise it can # be decoded as-is if the default locale is latin-1. env['LC_ALL'] = 'C' if sys.platform.startswith("aix"): # On AIX, the C locale uses the Latin1 encoding decoded_value = encoded_value.decode("latin1", "surrogateescape") else: # On other UNIXes, the C locale uses the ASCII encoding decoded_value = value stdout = subprocess.check_output( [sys.executable, "-c", script], env=env) stdout = stdout.rstrip(b'\n\r') self.assertEqual(stdout.decode('ascii'), ascii(decoded_value)) # test bytes key = key.encode("ascii", "surrogateescape") script = "import os; print(ascii(os.getenvb(%s)))" % repr(key) env = os.environ.copy() env[key] = encoded_value stdout = subprocess.check_output( [sys.executable, "-c", script], env=env) stdout = stdout.rstrip(b'\n\r') self.assertEqual(stdout.decode('ascii'), ascii(encoded_value)) def test_bytes_program(self): abs_program = os.fsencode(sys.executable) path, program = os.path.split(sys.executable) program = os.fsencode(program) # absolute bytes path exitcode = subprocess.call([abs_program, "-c", "pass"]) self.assertEqual(exitcode, 0) # absolute bytes path as a string cmd = b"'" + abs_program + b"' -c pass" exitcode = subprocess.call(cmd, shell=True) self.assertEqual(exitcode, 0) # bytes program, unicode PATH env = os.environ.copy() env["PATH"] = path exitcode = subprocess.call([program, "-c", "pass"], env=env) self.assertEqual(exitcode, 0) # bytes program, bytes PATH envb = os.environb.copy() envb[b"PATH"] = os.fsencode(path) exitcode = subprocess.call([program, "-c", "pass"], env=envb) self.assertEqual(exitcode, 0) def test_pipe_cloexec(self): sleeper = support.findfile("input_reader.py", subdir="subprocessdata") fd_status = support.findfile("fd_status.py", subdir="subprocessdata") p1 = subprocess.Popen([sys.executable, sleeper], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) self.addCleanup(p1.communicate, b'') p2 = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=False) output, error = p2.communicate() result_fds = set(map(int, output.split(b','))) unwanted_fds = set([p1.stdin.fileno(), p1.stdout.fileno(), p1.stderr.fileno()]) self.assertFalse(result_fds & unwanted_fds, "Expected no fds from %r to be open in child, " "found %r" % (unwanted_fds, result_fds & unwanted_fds)) def test_pipe_cloexec_real_tools(self): qcat = support.findfile("qcat.py", subdir="subprocessdata") qgrep = support.findfile("qgrep.py", subdir="subprocessdata") subdata = b'zxcvbn' data = subdata * 4 + b'\n' p1 = subprocess.Popen([sys.executable, qcat], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=False) p2 = subprocess.Popen([sys.executable, qgrep, subdata], stdin=p1.stdout, stdout=subprocess.PIPE, close_fds=False) self.addCleanup(p1.wait) self.addCleanup(p2.wait) def kill_p1(): try: p1.terminate() except ProcessLookupError: pass def kill_p2(): try: p2.terminate() except ProcessLookupError: pass self.addCleanup(kill_p1) self.addCleanup(kill_p2) p1.stdin.write(data) p1.stdin.close() readfiles, ignored1, ignored2 = select.select([p2.stdout], [], [], 10) self.assertTrue(readfiles, "The child hung") self.assertEqual(p2.stdout.read(), data) p1.stdout.close() p2.stdout.close() def test_close_fds(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") fds = os.pipe() self.addCleanup(os.close, fds[0]) self.addCleanup(os.close, fds[1]) open_fds = set(fds) # add a bunch more fds for _ in range(9): fd = os.open(os.devnull, os.O_RDONLY) self.addCleanup(os.close, fd) open_fds.add(fd) for fd in open_fds: os.set_inheritable(fd, True) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=False) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertEqual(remaining_fds & open_fds, open_fds, "Some fds were closed") p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertFalse(remaining_fds & open_fds, "Some fds were left open") self.assertIn(1, remaining_fds, "Subprocess failed") # Keep some of the fd's we opened open in the subprocess. # This tests _posixsubprocess.c's proper handling of fds_to_keep. fds_to_keep = set(open_fds.pop() for _ in range(8)) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, pass_fds=()) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertFalse(remaining_fds & fds_to_keep & open_fds, "Some fds not in pass_fds were left open") self.assertIn(1, remaining_fds, "Subprocess failed") @unittest.skipIf(sys.platform.startswith("freebsd") and os.stat("/dev").st_dev == os.stat("/dev/fd").st_dev, "Requires fdescfs mounted on /dev/fd on FreeBSD.") def test_close_fds_when_max_fd_is_lowered(self): """Confirm that issue21618 is fixed (may fail under valgrind).""" fd_status = support.findfile("fd_status.py", subdir="subprocessdata") # This launches the meat of the test in a child process to # avoid messing with the larger unittest processes maximum # number of file descriptors. # This process launches: # +--> Process that lowers its RLIMIT_NOFILE aftr setting up # a bunch of high open fds above the new lower rlimit. # Those are reported via stdout before launching a new # process with close_fds=False to run the actual test: # +--> The TEST: This one launches a fd_status.py # subprocess with close_fds=True so we can find out if # any of the fds above the lowered rlimit are still open. p = subprocess.Popen([sys.executable, '-c', textwrap.dedent( ''' import os, resource, subprocess, sys, textwrap open_fds = set() # Add a bunch more fds to pass down. for _ in range(40): fd = os.open(os.devnull, os.O_RDONLY) open_fds.add(fd) # Leave a two pairs of low ones available for use by the # internal child error pipe and the stdout pipe. # We also leave 10 more open as some Python buildbots run into # "too many open files" errors during the test if we do not. for fd in sorted(open_fds)[:14]: os.close(fd) open_fds.remove(fd) for fd in open_fds: #self.addCleanup(os.close, fd) os.set_inheritable(fd, True) max_fd_open = max(open_fds) # Communicate the open_fds to the parent unittest.TestCase process. print(','.join(map(str, sorted(open_fds)))) sys.stdout.flush() rlim_cur, rlim_max = resource.getrlimit(resource.RLIMIT_NOFILE) try: # 29 is lower than the highest fds we are leaving open. resource.setrlimit(resource.RLIMIT_NOFILE, (29, rlim_max)) # Launch a new Python interpreter with our low fd rlim_cur that # inherits open fds above that limit. It then uses subprocess # with close_fds=True to get a report of open fds in the child. # An explicit list of fds to check is passed to fd_status.py as # letting fd_status rely on its default logic would miss the # fds above rlim_cur as it normally only checks up to that limit. subprocess.Popen( [sys.executable, '-c', textwrap.dedent(""" import subprocess, sys subprocess.Popen([sys.executable, %r] + [str(x) for x in range({max_fd})], close_fds=True).wait() """.format(max_fd=max_fd_open+1))], close_fds=False).wait() finally: resource.setrlimit(resource.RLIMIT_NOFILE, (rlim_cur, rlim_max)) ''' % fd_status)], stdout=subprocess.PIPE) output, unused_stderr = p.communicate() output_lines = output.splitlines() self.assertEqual(len(output_lines), 2, msg="expected exactly two lines of output:\n%r" % output) opened_fds = set(map(int, output_lines[0].strip().split(b','))) remaining_fds = set(map(int, output_lines[1].strip().split(b','))) self.assertFalse(remaining_fds & opened_fds, msg="Some fds were left open.") # Mac OS X Tiger (10.4) has a kernel bug: sometimes, the file # descriptor of a pipe closed in the parent process is valid in the # child process according to fstat(), but the mode of the file # descriptor is invalid, and read or write raise an error. @support.requires_mac_ver(10, 5) def test_pass_fds(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") open_fds = set() for x in range(5): fds = os.pipe() self.addCleanup(os.close, fds[0]) self.addCleanup(os.close, fds[1]) os.set_inheritable(fds[0], True) os.set_inheritable(fds[1], True) open_fds.update(fds) for fd in open_fds: p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, pass_fds=(fd, )) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) to_be_closed = open_fds - {fd} self.assertIn(fd, remaining_fds, "fd to be passed not passed") self.assertFalse(remaining_fds & to_be_closed, "fd to be closed passed") # pass_fds overrides close_fds with a warning. with self.assertWarns(RuntimeWarning) as context: self.assertFalse(subprocess.call( [sys.executable, "-c", "import sys; sys.exit(0)"], close_fds=False, pass_fds=(fd, ))) self.assertIn('overriding close_fds', str(context.warning)) def test_pass_fds_inheritable(self): script = support.findfile("fd_status.py", subdir="subprocessdata") inheritable, non_inheritable = os.pipe() self.addCleanup(os.close, inheritable) self.addCleanup(os.close, non_inheritable) os.set_inheritable(inheritable, True) os.set_inheritable(non_inheritable, False) pass_fds = (inheritable, non_inheritable) args = [sys.executable, script] args += list(map(str, pass_fds)) p = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True, pass_fds=pass_fds) output, ignored = p.communicate() fds = set(map(int, output.split(b','))) # the inheritable file descriptor must be inherited, so its inheritable # flag must be set in the child process after fork() and before exec() self.assertEqual(fds, set(pass_fds), "output=%a" % output) # inheritable flag must not be changed in the parent process self.assertEqual(os.get_inheritable(inheritable), True) self.assertEqual(os.get_inheritable(non_inheritable), False) def test_stdout_stdin_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdout=inout, stdin=inout) p.wait() def test_stdout_stderr_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stdout=inout, stderr=inout) p.wait() def test_stderr_stdin_are_single_inout_fd(self): with io.open(os.devnull, "r+") as inout: p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"], stderr=inout, stdin=inout) p.wait() def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(0, p.returncode, "sigchild_ignore.py exited" " non-zero with this error:\n%s" % stderr.decode('utf-8')) def test_select_unbuffered(self): # Issue #11459: bufsize=0 should really set the pipes as # unbuffered (and therefore let select() work properly). select = support.import_module("select") p = subprocess.Popen([sys.executable, "-c", 'import sys;' 'sys.stdout.write("apple")'], stdout=subprocess.PIPE, bufsize=0) f = p.stdout self.addCleanup(f.close) try: self.assertEqual(f.read(4), b"appl") self.assertIn(f, select.select([f], [], [], 0.0)[0]) finally: p.wait() def test_zombie_fast_process_del(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, it wouldn't be added to subprocess._active, and would # remain a zombie. # spawn a Popen, and delete its reference before it exits p = subprocess.Popen([sys.executable, "-c", 'import sys, time;' 'time.sleep(0.2)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) def test_leak_fast_process_del_killed(self): # Issue #12650: on Unix, if Popen.__del__() was called before the # process exited, and the process got killed by a signal, it would never # be removed from subprocess._active, which triggered a FD and memory # leak. # spawn a Popen, delete its reference and kill it p = subprocess.Popen([sys.executable, "-c", 'import time;' 'time.sleep(3)'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) ident = id(p) pid = p.pid del p os.kill(pid, signal.SIGKILL) # check that p is in the active processes list self.assertIn(ident, [id(o) for o in subprocess._active]) # let some time for the process to exit, and create a new Popen: this # should trigger the wait() of p time.sleep(0.2) with self.assertRaises(OSError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass # p should have been wait()ed on, and removed from the _active list self.assertRaises(OSError, os.waitpid, pid, 0) self.assertNotIn(ident, [id(o) for o in subprocess._active]) def test_close_fds_after_preexec(self): fd_status = support.findfile("fd_status.py", subdir="subprocessdata") # this FD is used as dup2() target by preexec_fn, and should be closed # in the child process fd = os.dup(1) self.addCleanup(os.close, fd) p = subprocess.Popen([sys.executable, fd_status], stdout=subprocess.PIPE, close_fds=True, preexec_fn=lambda: os.dup2(1, fd)) output, ignored = p.communicate() remaining_fds = set(map(int, output.split(b','))) self.assertNotIn(fd, remaining_fds) @support.cpython_only def test_fork_exec(self): # Issue #22290: fork_exec() must not crash on memory allocation failure # or other errors import _posixsubprocess gc_enabled = gc.isenabled() try: # Use a preexec function and enable the garbage collector # to force fork_exec() to re-enable the garbage collector # on error. func = lambda: None gc.enable() executable_list = "exec" # error: must be a sequence for args, exe_list, cwd, env_list in ( (123, [b"exe"], None, [b"env"]), ([b"arg"], 123, None, [b"env"]), ([b"arg"], [b"exe"], 123, [b"env"]), ([b"arg"], [b"exe"], None, 123), ): with self.assertRaises(TypeError): _posixsubprocess.fork_exec( args, exe_list, True, [], cwd, env_list, -1, -1, -1, -1, 1, 2, 3, 4, True, True, func) finally: if not gc_enabled: gc.disable() @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_MAXIMIZE # Since Python is a console process, it won't be affected # by wShowWindow, but the argument should be silently # ignored subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) def test_creationflags(self): # creationflags argument CREATE_NEW_CONSOLE = 16 sys.stderr.write(" a DOS box should flash briefly ...\n") subprocess.call(sys.executable + ' -c "import time; time.sleep(0.25)"', creationflags=CREATE_NEW_CONSOLE) def test_invalid_args(self): # invalid arguments should raise ValueError self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) self.assertRaises(ValueError, subprocess.call, [sys.executable, "-c", "import sys; sys.exit(47)"], stdout=subprocess.PIPE, close_fds=True) def test_close_fds(self): # close file descriptors rc = subprocess.call([sys.executable, "-c", "import sys; sys.exit(47)"], close_fds=True) self.assertEqual(rc, 47) def test_shell_sequence(self): # Run command through the shell (sequence) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn(b"physalis", p.stdout.read()) def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) self.addCleanup(p.stdout.close) self.assertIn(b"physalis", p.stdout.read()) def test_call_string(self): # call() function with string argument on Windows rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) def _kill_process(self, method, *args): # Some win32 buildbot raises EOFError if stdin is inherited p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() time.sleep(30) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') returncode = p.wait() self.assertNotEqual(returncode, 0) def _kill_dead_process(self, method, *args): p = subprocess.Popen([sys.executable, "-c", """if 1: import sys, time sys.stdout.write('x\\n') sys.stdout.flush() sys.exit(42) """], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) self.addCleanup(p.stdin.close) # Wait for the interpreter to be completely initialized before # sending any signal. p.stdout.read(1) # The process should end after this time.sleep(1) # This shouldn't raise even though the child is now dead getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, b'') rc = p.wait() self.assertEqual(rc, 42) def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) def test_kill(self): self._kill_process('kill') def test_terminate(self): self._kill_process('terminate') def test_send_signal_dead(self): self._kill_dead_process('send_signal', signal.SIGTERM) def test_kill_dead(self): self._kill_dead_process('kill') def test_terminate_dead(self): self._kill_dead_process('terminate') class CommandTests(unittest.TestCase): def test_getoutput(self): self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy') self.assertEqual(subprocess.getstatusoutput('echo xyzzy'), (0, 'xyzzy')) # we use mkdtemp in the next line to create an empty directory # under our exclusive control; from that, we can invent a pathname # that we _know_ won't exist. This is guaranteed to fail. dir = None try: dir = tempfile.mkdtemp() name = os.path.join(dir, "foo") status, output = subprocess.getstatusoutput( ("type " if mswindows else "cat ") + name) self.assertNotEqual(status, 0) finally: if dir is not None: os.rmdir(dir) @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") class ProcessTestCaseNoPoll(ProcessTestCase): def setUp(self): self.orig_selector = subprocess._PopenSelector subprocess._PopenSelector = selectors.SelectSelector ProcessTestCase.setUp(self) def tearDown(self): subprocess._PopenSelector = self.orig_selector ProcessTestCase.tearDown(self) def test__all__(self): """Ensure that __all__ is populated properly.""" intentionally_excluded = set(("list2cmdline",)) exported = set(subprocess.__all__) possible_exports = set() import types for name, value in subprocess.__dict__.items(): if name.startswith('_'): continue if isinstance(value, (types.ModuleType,)): continue possible_exports.add(name) self.assertEqual(exported, possible_exports - intentionally_excluded) @unittest.skipUnless(mswindows, "Windows-specific tests") class CommandsWithSpaces (BaseTestCase): def setUp(self): super().setUp() f, fname = mkstemp(".py", "te st") self.fname = fname.lower () os.write(f, b"import sys;" b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))" ) os.close(f) def tearDown(self): os.remove(self.fname) super().tearDown() def with_spaces(self, *args, **kwargs): kwargs['stdout'] = subprocess.PIPE p = subprocess.Popen(*args, **kwargs) self.addCleanup(p.stdout.close) self.assertEqual( p.stdout.read ().decode("mbcs"), "2 [%r, 'ab cd']" % self.fname ) def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd"), shell=1) def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1) def test_noshell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname, "ab cd")) def test_noshell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([sys.executable, self.fname, "ab cd"]) class ContextManagerTests(BaseTestCase): def test_pipe(self): with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.stdout.write('stdout');" "sys.stderr.write('stderr');"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: self.assertEqual(proc.stdout.read(), b"stdout") self.assertStderrEqual(proc.stderr.read(), b"stderr") self.assertTrue(proc.stdout.closed) self.assertTrue(proc.stderr.closed) def test_returncode(self): with subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(100)"]) as proc: pass # __exit__ calls wait(), so the returncode should be set self.assertEqual(proc.returncode, 100) def test_communicate_stdin(self): with subprocess.Popen([sys.executable, "-c", "import sys;" "sys.exit(sys.stdin.read() == 'context')"], stdin=subprocess.PIPE) as proc: proc.communicate(b"context") self.assertEqual(proc.returncode, 1) def test_invalid_args(self): with self.assertRaises(FileNotFoundError) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: pass def test_broken_pipe_cleanup(self): """Broken pipe error should not prevent wait() (Issue 21619)""" proc = subprocess.Popen([sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, bufsize=support.PIPE_MAX_SIZE*2) proc = proc.__enter__() # Prepare to send enough data to overflow any OS pipe buffering and # guarantee a broken pipe error. Data is held in BufferedWriter # buffer until closed. proc.stdin.write(b'x' * support.PIPE_MAX_SIZE) self.assertIsNone(proc.returncode) # EPIPE expected under POSIX; EINVAL under Windows self.assertRaises(OSError, proc.__exit__, None, None, None) self.assertEqual(proc.returncode, 0) self.assertTrue(proc.stdin.closed) def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, CommandTests, ProcessTestCaseNoPoll, CommandsWithSpaces, ContextManagerTests, RunFuncTestCase, ) support.run_unittest(*unit_tests) support.reap_children() if __name__ == "__main__": unittest.main() gevent-1.1.0/greentest/3.5/test_threading.py0000644000076500000000000011475512666555342021437 0ustar jmaddenwheel00000000000000""" Tests for the threading module. """ import test.support from test.support import verbose, strip_python_stderr, import_module, cpython_only from test.support.script_helper import assert_python_ok, assert_python_failure import random import re import sys _thread = import_module('_thread') threading = import_module('threading') import time import unittest import weakref import os import subprocess from test import lock_tests # Between fork() and exec(), only async-safe functions are allowed (issues # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', 'hp-ux11') # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print('task %s will run for %.1f usec' % (self.name, delay * 1e6)) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print(self.nrunning.get(), 'tasks are running') self.testcase.assertTrue(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print('task', self.name, 'done') with self.mutex: self.nrunning.dec() self.testcase.assertTrue(self.nrunning.get() >= 0) if verbose: print('%s is finished. %d tasks are running' % (self.name, self.nrunning.get())) class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test.support.threading_setup() def tearDown(self): test.support.threading_cleanup(*self._threads) test.support.reap_children() class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) self.assertEqual(t.ident, None) self.assertTrue(re.match('', repr(t))) t.start() if verbose: print('waiting for all tasks to complete') for t in threads: t.join() self.assertTrue(not t.is_alive()) self.assertNotEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assertTrue(re.match('', repr(t))) if verbose: print('all tasks done') self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertFalse(threading.currentThread().ident is None) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] _thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print('with 256kB thread stack size...') try: threading.stack_size(262144) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print('with 1MB thread stack size...') try: threading.stack_size(0x100000) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = _thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assertIn(tid, threading._active) self.assertIsInstance(threading._active[tid], threading._DummyThread) del threading._active[tid] # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. def test_PyThreadState_SetAsyncExc(self): ctypes = import_module("ctypes") set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # First check it works when setting the exception from the same thread. tid = threading.get_ident() try: result = set_async_exc(ctypes.c_long(tid), exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: pass except AsyncExc: pass else: # This code is unreachable but it reflects the intent. If we wanted # to be smarter the above loop wouldn't be infinite. self.fail("AsyncExc not raised") try: self.assertEqual(result, 1) # one thread state modified except UnboundLocalError: # The exception was raised too quickly for us to get the result. pass # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = threading.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print(" started worker thread") # Try a thread id that doesn't make sense. if verbose: print(" trying nonsensical thread id") result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print(" waiting for worker thread to get started") ret = worker_started.wait() self.assertTrue(ret) if verbose: print(" verifying worker hasn't exited") self.assertTrue(not t.finished) if verbose: print(" attempting to raise asynch exception in worker") result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print(" waiting for worker to say it caught the exception") worker_saw_exception.wait(timeout=10) self.assertTrue(t.finished) if verbose: print(" all OK -- joining worker") if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise threading.ThreadError() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(threading.ThreadError, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. import_module("ctypes") rc, out, err = assert_python_failure("-c", """if 1: import ctypes, sys, time, _thread # This lock is used as a simple event variable. ready = _thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) _thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown assert_python_ok("-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print('program blocked; aborting') os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown rc, out, err = assert_python_ok("-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print("Woke up, sleep function is:", sleep) threading.Thread(target=child).start() raise SystemExit """) self.assertEqual(out.strip(), b"Woke up, sleep function is: ") self.assertEqual(err, b"") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getswitchinterval() try: for i in range(1, 100): sys.setswitchinterval(i * 0.0002) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertNotIn(t, l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setswitchinterval(old_interval) def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertIsNone(weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertIsNone(weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) def test_old_threading_api(self): # Just a quick sanity check to make sure the old method names are # still present t = threading.Thread() t.isDaemon() t.setDaemon(True) t.getName() t.setName("name") t.isAlive() e = threading.Event() e.isSet() threading.activeCount() def test_repr_daemon(self): t = threading.Thread() self.assertFalse('daemon' in repr(t)) t.daemon = True self.assertTrue('daemon' in repr(t)) def test_deamon_param(self): t = threading.Thread() self.assertFalse(t.daemon) t = threading.Thread(daemon=False) self.assertFalse(t.daemon) t = threading.Thread(daemon=True) self.assertTrue(t.daemon) @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') def test_dummy_thread_after_fork(self): # Issue #14308: a dummy thread in the active list doesn't mess up # the after-fork mechanism. code = """if 1: import _thread, threading, os, time def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() _thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: os.wait() """ _, out, err = assert_python_ok("-c", code) self.assertEqual(out, b'') self.assertEqual(err, b'') @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_is_alive_after_fork(self): # Try hard to trigger #18418: is_alive() could sometimes be True on # threads that vanished after a fork. old_interval = sys.getswitchinterval() self.addCleanup(sys.setswitchinterval, old_interval) # Make the bug more likely to manifest. sys.setswitchinterval(1e-6) for i in range(20): t = threading.Thread(target=lambda: None) t.start() self.addCleanup(t.join) pid = os.fork() if pid == 0: os._exit(1 if t.is_alive() else 0) else: pid, status = os.waitpid(pid, 0) self.assertEqual(0, status) def test_main_thread(self): main = threading.main_thread() self.assertEqual(main.name, 'MainThread') self.assertEqual(main.ident, threading.current_thread().ident) self.assertEqual(main.ident, threading.get_ident()) def f(): self.assertNotEqual(threading.main_thread().ident, threading.current_thread().ident) th = threading.Thread(target=f) th.start() th.join() @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork(self): code = """if 1: import os, threading pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) else: os.waitpid(pid, 0) """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "MainThread\nTrue\nTrue\n") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork_from_nonmain_thread(self): code = """if 1: import os, threading, sys def f(): pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) # stdout is fully buffered because not a tty, # we have to flush before exit. sys.stdout.flush() else: os.waitpid(pid, 0) th = threading.Thread(target=f) th.start() th.join() """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "Thread-1\nTrue\nTrue\n") def test_tstate_lock(self): # Test an implementation detail of Thread objects. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() time.sleep(0.01) # The tstate lock is None until the thread is started t = threading.Thread(target=f) self.assertIs(t._tstate_lock, None) t.start() started.acquire() self.assertTrue(t.is_alive()) # The tstate lock can't be acquired when the thread is running # (or suspended). tstate_lock = t._tstate_lock self.assertFalse(tstate_lock.acquire(timeout=0), False) finish.release() # When the thread ends, the state_lock can be successfully # acquired. self.assertTrue(tstate_lock.acquire(timeout=5), False) # But is_alive() is still True: we hold _tstate_lock now, which # prevents is_alive() from knowing the thread's end-of-life C code # is done. self.assertTrue(t.is_alive()) # Let is_alive() find out the C code is done. tstate_lock.release() self.assertFalse(t.is_alive()) # And verify the thread disposed of _tstate_lock. self.assertTrue(t._tstate_lock is None) def test_repr_stopped(self): # Verify that "stopped" shows up in repr(Thread) appropriately. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() t = threading.Thread(target=f) t.start() started.acquire() self.assertIn("started", repr(t)) finish.release() # "stopped" should appear in the repr in a reasonable amount of time. # Implementation detail: as of this writing, that's trivially true # if .join() is called, and almost trivially true if .is_alive() is # called. The detail we're testing here is that "stopped" shows up # "all on its own". LOOKING_FOR = "stopped" for i in range(500): if LOOKING_FOR in repr(t): break time.sleep(0.01) self.assertIn(LOOKING_FOR, repr(t)) # we waited at least 5 seconds def test_BoundedSemaphore_limit(self): # BoundedSemaphore should raise ValueError if released too often. for limit in range(1, 10): bs = threading.BoundedSemaphore(limit) threads = [threading.Thread(target=bs.acquire) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() threads = [threading.Thread(target=bs.release) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() self.assertRaises(ValueError, bs.release) @cpython_only def test_frame_tstate_tracing(self): # Issue #14432: Crash when a generator is created in a C thread that is # destroyed while the generator is still used. The issue was that a # generator contains a frame, and the frame kept a reference to the # Python state of the destroyed C thread. The crash occurs when a trace # function is setup. def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "generator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call import _testcapi _testcapi.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print('end of thread') # stdout is fully buffered because not a tty, we have to flush # before exit. sys.stdout.flush() \n""" + script rc, out, err = assert_python_ok("-c", script) data = out.decode().replace('\r', '') self.assertEqual(data, "end of main\nend of thread\n") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print('end of main') t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_4_daemon_threads(self): # Check that a daemon thread cannot crash the interpreter on shutdown # by manipulating internal structures that are being disposed of in # the main thread. script = """if True: import os import random import sys import time import threading thread_has_run = set() def random_io(): '''Loop for a while sleeping random tiny amounts and doing some I/O.''' while True: in_f = open(os.__file__, 'rb') stuff = in_f.read(200) null_f = open(os.devnull, 'wb') null_f.write(stuff) time.sleep(random.random() / 1995) null_f.close() in_f.close() thread_has_run.add(threading.current_thread()) def main(): count = 0 for _ in range(40): new_thread = threading.Thread(target=random_io) new_thread.daemon = True new_thread.start() count += 1 while len(thread_has_run) < count: time.sleep(0.001) # Trigger process shutdown sys.exit(0) main() """ rc, out, err = assert_python_ok('-c', script) self.assertFalse(err) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): # Issue #13817: fork() would deadlock in a multithreaded program with # the ad-hoc TLS implementation. def do_fork_and_wait(): # just fork a child process and wait it pid = os.fork() if pid > 0: os.waitpid(pid, 0) else: os._exit(0) # start a bunch of threads that will fork() child processes threads = [] for i in range(16): t = threading.Thread(target=do_fork_and_wait) threads.append(t) t.start() for t in threads: t.join() @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_clear_threads_states_after_fork(self): # Issue #17094: check that threads states are cleared after fork() # start a bunch of threads threads = [] for i in range(16): t = threading.Thread(target=lambda : time.sleep(0.3)) threads.append(t) t.start() pid = os.fork() if pid == 0: # check that threads states have been cleared if len(sys._current_frames()) == 1: os._exit(0) else: os._exit(1) else: _, status = os.waitpid(pid, 0) self.assertEqual(0, status) for t in threads: t.join() class SubinterpThreadingTests(BaseTestCase): def test_threads_join(self): # Non-daemon threads should be joined at subinterpreter shutdown # (issue #18808) r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") def test_threads_join_2(self): # Same as above, but a delay gets introduced after the thread's # Python code returned but before the thread state is deleted. # To achieve this, we register a thread-local object which sleeps # a bit when deallocated. r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time class Sleeper: def __del__(self): time.sleep(0.05) tls = threading.local() def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) tls.x = Sleeper() os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") @cpython_only def test_daemon_threads_fatal_error(self): subinterp_code = r"""if 1: import os import threading import time def f(): # Make sure the daemon thread is still running when # Py_EndInterpreter is called. time.sleep(10) threading.Thread(target=f, daemon=True).start() """ script = r"""if 1: import _testcapi _testcapi.run_in_subinterp(%r) """ % (subinterp_code,) with test.support.SuppressCrashReport(): rc, out, err = assert_python_failure("-c", script) self.assertIn("Fatal Python error: Py_EndInterpreter: " "not the last thread", err.decode()) class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) def test_releasing_unacquired_lock(self): lock = threading.Lock() self.assertRaises(RuntimeError, lock.release) @unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(), 'test macosx problem') def test_recursion_limit(self): # Issue 9670 # test that excessive recursion within a non-main thread causes # an exception rather than crashing the interpreter on platforms # like Mac OS X or FreeBSD which have small default stack sizes # for threads script = """if True: import threading def recurse(): return recurse() def outer(): try: recurse() except RecursionError: pass w = threading.Thread(target=outer) w.start() w.join() print('end of main thread') """ expected_output = "end of main thread\n" p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() data = stdout.decode().replace('\r', '') self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode()) self.assertEqual(data, expected_output) def test_print_exception(self): script = r"""if True: import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_1(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) sys.stderr = None running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_2(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 sys.stderr = None t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') self.assertNotIn("Unhandled exception", err.decode()) class TimerTests(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) self.callback_args = [] self.callback_event = threading.Event() def test_init_immutable_default_args(self): # Issue 17435: constructor defaults were mutable objects, they could be # mutated via the object attributes and affect other Timer objects. timer1 = threading.Timer(0.01, self._callback_spy) timer1.start() self.callback_event.wait() timer1.args.append("blah") timer1.kwargs["foo"] = "bar" self.callback_event.clear() timer2 = threading.Timer(0.01, self._callback_spy) timer2.start() self.callback_event.wait() self.assertEqual(len(self.callback_args), 2) self.assertEqual(self.callback_args, [((), {}), ((), {})]) def _callback_spy(self, *args, **kwargs): self.callback_args.append((args[:], kwargs.copy())) self.callback_event.set() class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) @unittest.skip("not on gevent") def test_locked_repr(self): pass @unittest.skip("not on gevent") def test_repr(self): pass class PyRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._PyRLock) @unittest.skipIf(threading._CRLock is None, 'RLock not implemented in C') class CRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._CRLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) @unittest.skip("not on gevent") def test_reset_internal_locks(self): pass class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) class BarrierTests(lock_tests.BarrierTests): barriertype = staticmethod(threading.Barrier) if __name__ == "__main__": unittest.main() gevent-1.1.0/greentest/3.5/version0000644000076500000000000000000612666555342017450 0ustar jmaddenwheel000000000000003.5.0 gevent-1.1.0/greentest/3.5/wrongcert.pem0000644000076500000000000000353012666555342020562 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw eSHj5jpC8iZKjCHBn+mAi4cQ514= -----END CERTIFICATE----- gevent-1.1.0/greentest/_blocks_at_top_level.py0000644000076500000000000000006012666555342022256 0ustar jmaddenwheel00000000000000from gevent import sleep sleep(0.01) x = "done" gevent-1.1.0/greentest/_import_import_patch.py0000644000076500000000000000003412666555342022330 0ustar jmaddenwheel00000000000000__import__('_import_patch') gevent-1.1.0/greentest/_import_patch.py0000644000076500000000000000005712666555342020743 0ustar jmaddenwheel00000000000000import gevent.monkey gevent.monkey.patch_all() gevent-1.1.0/greentest/_import_wait.py0000644000076500000000000000107212666555342020606 0ustar jmaddenwheel00000000000000# test__import_wait.py calls this via an import statement, # so all of this is happening with import locks held (especially on py2) import gevent def fn2(): return 2 # A blocking function doesn't raise LoopExit def fn(): return gevent.wait([gevent.spawn(fn2), gevent.spawn(fn2)]) gevent.spawn(fn).get() # Marshalling the traceback across greenlets doesn't # raise LoopExit def raise_name_error(): raise NameError("ThisIsExpected") try: gevent.spawn(raise_name_error).get() raise AssertionError("Should fail") except NameError as e: x = e gevent-1.1.0/greentest/_imports_at_top_level.py0000644000076500000000000000006712666555342022505 0ustar jmaddenwheel00000000000000# We simply import a stdlib module __import__('netrc') gevent-1.1.0/greentest/_imports_imports_at_top_level.py0000644000076500000000000000053112666555342024256 0ustar jmaddenwheel00000000000000import gevent # For reproducing #728: We spawn a greenlet at import time, # that itself wants to import, and wait on it at import time. # If we're the only greenlet running, and locks aren't granular # enough, this results in a LoopExit (and also a lock deadlock) def f(): __import__('_imports_at_top_level') g = gevent.spawn(f) g.get() gevent-1.1.0/greentest/badcert.pem0000644000076500000000000000361012666555342017646 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- Just bad cert data -----END CERTIFICATE----- gevent-1.1.0/greentest/badkey.pem0000644000076500000000000000416212666555342017504 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/bench_sendall.py0000644000076500000000000000141712666555342020675 0ustar jmaddenwheel00000000000000#! /usr/bin/env python from __future__ import print_function import time from gevent import socket from gevent.server import StreamServer def recvall(socket, addr): while socket.recv(4096): pass def main(): server = StreamServer(("127.0.0.1", 0), recvall) server.start() length = 50 * 0x100000 data = b"x" * length spent_total = 0 N = 10 conn = socket.create_connection((server.server_host, server.server_port)) for i in range(N): start = time.time() conn.sendall(data) spent = time.time() - start print("%.2f MB/s" % (length / spent / 0x100000)) spent_total += spent print("~ %.2f MB/s" % (length * N / spent_total / 0x100000)) server.stop() if __name__ == "__main__": main() gevent-1.1.0/greentest/bench_sleep0.py0000644000076500000000000000221612666555342020441 0ustar jmaddenwheel00000000000000"""Benchmarking sleep(0) performance.""" from __future__ import print_function import sys from time import time try: xrange except NameError: xrange = range def noop(p): pass N = 100000 ARG = 0 def test(sleep, arg): start = time() for _ in xrange(N): sleep(arg) return time() - start def bench_none(): test(noop) def bench_gevent(arg=0): import gevent from gevent import sleep delta = test(sleep, arg) print('gevent %s (%s): sleep(%r): %.1f microseconds' % (gevent.__version__, gevent.__file__, arg, delta * 1000000. / N)) def bench_eventlet(arg): try: import eventlet except ImportError as ex: sys.stderr.write('Failed to import eventlet: %s\n' % ex) return from eventlet.api import sleep delta = test(sleep, arg) print('eventlet %s (%s): sleep(%r): %.1f microseconds' % (eventlet.__version__, eventlet.__file__, arg, delta * 1000000. / N)) def main(): global N for arg in [0, -1, 0.00001]: bench_gevent(arg) bench_eventlet(arg) N = 1000 bench_gevent(0.001) bench_eventlet(0.001) if __name__ == '__main__': main() gevent-1.1.0/greentest/bench_spawn.py0000644000076500000000000001073212666555342020403 0ustar jmaddenwheel00000000000000"""Benchmarking spawn() performance. """ from __future__ import print_function import sys import os import random from time import time try: xrange except NameError: xrange = range N = 10000 counter = 0 def incr(sleep, **kwargs): global counter counter += 1 sleep(0) def noop(p): pass def test(spawn, sleep, kwargs): start = time() for _ in xrange(N): spawn(incr, sleep, **kwargs) delta = time() - start print('spawning: %.1f microseconds per greenlet' % (delta * 1000000.0 / N)) assert counter == 0, counter start = time() sleep(0) delta = time() - start assert counter == N, (counter, N) print('sleep(0): %.1f microseconds per greenlet' % (delta * 1000000.0 / N)) def bench_none(options): kwargs = options.kwargs start = time() for _ in xrange(N): incr(noop, **kwargs) delta = time() - start assert counter == N, (counter, N) print('%.2f microseconds' % (delta * 1000000.0 / N)) def bench_gevent(options): import gevent print('using gevent from %s' % gevent.__file__) from gevent import spawn, sleep test(spawn, sleep, options.kwargs) def bench_geventraw(options): import gevent print('using gevent from %s' % gevent.__file__) from gevent import sleep, spawn_raw test(spawn_raw, sleep, options.kwargs) def bench_geventpool(options): import gevent print('using gevent from %s' % gevent.__file__) from gevent import sleep from gevent.pool import Pool p = Pool() test(p.spawn, sleep, options.kwargs) start = time() p.join() delta = time() - start print('joining: %.1f microseconds per greenlet' % (delta * 1000000.0 / N)) def bench_eventlet(options): try: import eventlet except ImportError: if options.ignore_import_errors: return raise print('using eventlet from %s' % eventlet.__file__) from eventlet.api import spawn, sleep, use_hub if options.eventlet_hub is not None: use_hub(options.eventlet_hub) test(spawn, sleep, options.kwargs) def bench_eventlet1(options): try: import eventlet except ImportError: if options.ignore_import_errors: return raise print('using eventlet from %s' % eventlet.__file__) from eventlet.proc import spawn_greenlet as spawn from eventlet.api import sleep, use_hub if options.eventlet_hub: use_hub(options.eventlet_hub) if options.with_kwargs: print('eventlet.proc.spawn_greenlet does support kwargs') return test(spawn, sleep, options.kwargs) def bench_all(options): import time error = 0 names = all() random.shuffle(names) for func in names: cmd = '%s %s %s --ignore-import-errors' % (sys.executable, __file__, func) print(cmd) sys.stdout.flush() time.sleep(0.01) if os.system(cmd): error = 1 print('%s failed' % cmd) print('') for func in names: cmd = '%s %s --with-kwargs %s --ignore-import-errors' % (sys.executable, __file__, func) print(cmd) sys.stdout.flush() if os.system(cmd): error = 1 print('%s failed' % cmd) print('') if error: sys.exit(1) def all(): result = [x for x in globals() if x.startswith('bench_') and x != 'bench_all'] try: result.sort(key=lambda x: globals()[x].func_code.co_firstlineno) except AttributeError: result.sort(key=lambda x: globals()[x].__code__.co_firstlineno) result = [x.replace('bench_', '') for x in result] return result def all_functions(): return [globals()['bench_%s' % x] for x in all()] if __name__ == '__main__': USAGE = 'USAGE: python %s [--with-kwargs] [--eventlet-hub HUB] %s' % (sys.argv[0], '|'.join(all())) if not sys.argv[1:]: sys.exit(USAGE) import optparse parser = optparse.OptionParser() parser.add_option('--with-kwargs', default=False, action='store_true') parser.add_option('--eventlet-hub') parser.add_option('--ignore-import-errors', action='store_true') options, args = parser.parse_args() if options.with_kwargs: options.kwargs = {'foo': 1, 'bar': 'hello'} else: options.kwargs = {} if len(args) != 1: sys.exit(USAGE) if args[0] == 'all': bench_all(options) else: if args[0] not in all(): sys.exit(USAGE) function = globals()['bench_' + args[0]] function(options) gevent-1.1.0/greentest/coveragesite/0000755000076500000000000000000012666555433020220 5ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/coveragesite/sitecustomize.py0000644000076500000000000000037712666555342023507 0ustar jmaddenwheel00000000000000# When testrunner.py is invoked with --coverage, it puts this first # on the path as per http://coverage.readthedocs.org/en/coverage-4.0b3/subprocess.html. # Note that this disables other sitecustomize.py files. import coverage coverage.process_startup() gevent-1.1.0/greentest/getaddrinfo_module.py0000644000076500000000000000016412666555342021745 0ustar jmaddenwheel00000000000000import socket import gevent.socket as gevent_socket gevent_socket.getaddrinfo(u'gevent.org', None, socket.AF_INET) gevent-1.1.0/greentest/greentest.py0000644000076500000000000005704512666555342020124 0ustar jmaddenwheel00000000000000# Copyright (c) 2008-2009 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # package is named greentest, not test, so it won't be confused with test in stdlib import sys import types import unittest from unittest import TestCase as BaseTestCase import time import os from os.path import basename, splitext import gevent import gevent.core from patched_tests_setup import get_switch_expected from gevent.hub import _get_hub from functools import wraps import contextlib import gc import six try: from unittest.util import safe_repr except ImportError: # Py 2.6 _MAX_LENGTH = 80 def safe_repr(obj, short=False): try: result = repr(obj) except Exception: result = object.__repr__(obj) if not short or len(result) < _MAX_LENGTH: return result return result[:_MAX_LENGTH] + ' [truncated]...' PYPY = hasattr(sys, 'pypy_version_info') VERBOSE = sys.argv.count('-v') > 1 if '--debug-greentest' in sys.argv: sys.argv.remove('--debug-greentest') DEBUG = True else: DEBUG = False RUN_LEAKCHECKS = os.getenv('GEVENTTEST_LEAKCHECK') OPTIONAL_MODULES = ['resolver_ares'] # Generally, ignore the portions that are only implemented # on particular platforms; they generally contain partial # implementations completed in different modules. PLATFORM_SPECIFIC_SUFFIXES = ['2', '279', '3'] if sys.platform.startswith('win'): PLATFORM_SPECIFIC_SUFFIXES.append('posix') NON_APPLICABLE_SUFFIXES = [] if sys.version_info[0] == 3: # Python 3 NON_APPLICABLE_SUFFIXES.extend(('2', '279')) PY2 = False PY3 = True if sys.version_info[0] == 2: # Any python 2 PY3 = False PY2 = True NON_APPLICABLE_SUFFIXES.append('3') if (sys.version_info[1] < 7 or (sys.version_info[1] == 7 and sys.version_info[2] < 9)): # Python 2, < 2.7.9 NON_APPLICABLE_SUFFIXES.append('279') if sys.platform.startswith('win'): NON_APPLICABLE_SUFFIXES.append("posix") # This is intimately tied to FileObjectPosix NON_APPLICABLE_SUFFIXES.append("fileobject2") RUNNING_ON_TRAVIS = os.environ.get('TRAVIS') RUNNING_ON_APPVEYOR = os.environ.get('APPVEYOR') RUNNING_ON_CI = RUNNING_ON_TRAVIS or RUNNING_ON_APPVEYOR if RUNNING_ON_APPVEYOR: # See comments scattered around about timeouts and the timer # resolution available on appveyor (lots of jitter). this # seems worse with the 62-bit builds. # Note that we skip/adjust these tests only on AppVeyor, not # win32---we don't think there's gevent related problems but # environment related problems. These can be tested and debugged # separately on windows in a more stable environment. skipOnAppVeyor = unittest.skip # We can't exec corecext on appveyor if we haven't run setup.py in # 'develop' mode (i.e., we install) NON_APPLICABLE_SUFFIXES.append('corecext') else: def skipOnAppVeyor(reason): def dec(f): return f return dec class ExpectedException(Exception): """An exception whose traceback should be ignored""" def wrap_switch_count_check(method): @wraps(method) def wrapped(self, *args, **kwargs): initial_switch_count = getattr(_get_hub(), 'switch_count', None) self.switch_expected = getattr(self, 'switch_expected', True) if initial_switch_count is not None: fullname = getattr(self, 'fullname', None) if self.switch_expected == 'default' and fullname: self.switch_expected = get_switch_expected(fullname) result = method(self, *args, **kwargs) if initial_switch_count is not None and self.switch_expected is not None: switch_count = _get_hub().switch_count - initial_switch_count if self.switch_expected is True: assert switch_count >= 0 if not switch_count: raise AssertionError('%s did not switch' % fullname) elif self.switch_expected is False: if switch_count: raise AssertionError('%s switched but not expected to' % fullname) else: raise AssertionError('Invalid value for switch_expected: %r' % (self.switch_expected, )) return result return wrapped def wrap_timeout(timeout, method): if timeout is None: return method @wraps(method) def wrapped(self, *args, **kwargs): with gevent.Timeout(timeout, 'test timed out', ref=False): return method(self, *args, **kwargs) return wrapped def wrap_refcount(method): if not RUN_LEAKCHECKS: return method if getattr(method, 'ignore_leakcheck', False): return method # Some builtin things that we ignore IGNORED_TYPES = (tuple, dict, types.FrameType, types.TracebackType) def type_hist(): import collections d = collections.defaultdict(int) for x in gc.get_objects(): k = type(x) if k in IGNORED_TYPES: continue if k == gevent.core.callback and x.callback is None and x.args is None: # these represent callbacks that have been stopped, but # the event loop hasn't cycled around to run them. The only # known cause of this is killing greenlets before they get a chance # to run for the first time. continue d[k] += 1 return d def report_diff(a, b): diff_lines = [] for k, v in sorted(a.items(), key=lambda i: i[0].__name__): if b[k] != v: diff_lines.append("%s: %s != %s" % (k, v, b[k])) if not diff_lines: return None diff = '\n'.join(diff_lines) return diff @wraps(method) def wrapped(self, *args, **kwargs): gc.collect() gc.collect() gc.collect() deltas = [] d = None gc.disable() try: while True: # Grab current snapshot hist_before = type_hist() d = sum(hist_before.values()) self.setUp() method(self, *args, **kwargs) self.tearDown() # Grab post snapshot if 'urlparse' in sys.modules: sys.modules['urlparse'].clear_cache() if 'urllib.parse' in sys.modules: sys.modules['urllib.parse'].clear_cache() hist_after = type_hist() d = sum(hist_after.values()) - d deltas.append(d) # Reset and check for cycles gc.collect() if gc.garbage: raise AssertionError("Generated uncollectable garbage") # the following configurations are classified as "no leak" # [0, 0] # [x, 0, 0] # [... a, b, c, d] where a+b+c+d = 0 # # the following configurations are classified as "leak" # [... z, z, z] where z > 0 if deltas[-2:] == [0, 0] and len(deltas) in (2, 3): break elif deltas[-3:] == [0, 0, 0]: break elif len(deltas) >= 4 and sum(deltas[-4:]) == 0: break elif len(deltas) >= 3 and deltas[-1] > 0 and deltas[-1] == deltas[-2] and deltas[-2] == deltas[-3]: diff = report_diff(hist_before, hist_after) raise AssertionError('refcount increased by %r\n%s' % (deltas, diff)) # OK, we don't know for sure yet. Let's search for more if sum(deltas[-3:]) <= 0 or sum(deltas[-4:]) <= 0 or deltas[-4:].count(0) >= 2: # this is suspicious, so give a few more runs limit = 11 else: limit = 7 if len(deltas) >= limit: raise AssertionError('refcount increased by %r\n%s' % (deltas, report_diff(hist_before, hist_after))) finally: gc.enable() self.skipTearDown = True return wrapped def wrap_error_fatal(method): @wraps(method) def wrapped(self, *args, **kwargs): # XXX should also be able to do gevent.SYSTEM_ERROR = object # which is a global default to all hubs SYSTEM_ERROR = gevent.get_hub().SYSTEM_ERROR gevent.get_hub().SYSTEM_ERROR = object try: return method(self, *args, **kwargs) finally: gevent.get_hub().SYSTEM_ERROR = SYSTEM_ERROR return wrapped def wrap_restore_handle_error(method): @wraps(method) def wrapped(self, *args, **kwargs): old = gevent.get_hub().handle_error try: return method(self, *args, **kwargs) finally: gevent.get_hub().handle_error = old if self.peek_error()[0] is not None: gevent.getcurrent().throw(*self.peek_error()[1:]) return wrapped def _get_class_attr(classDict, bases, attr, default=AttributeError): NONE = object() value = classDict.get(attr, NONE) if value is not NONE: return value for base in bases: value = getattr(bases[0], attr, NONE) if value is not NONE: return value if default is AttributeError: raise AttributeError('Attribute %r not found\n%s\n%s\n' % (attr, classDict, bases)) return default class TestCaseMetaClass(type): # wrap each test method with # a) timeout check # b) fatal error check # c) restore the hub's error handler (see expect_one_error) # d) totalrefcount check def __new__(meta, classname, bases, classDict): timeout = classDict.get('__timeout__', 'NONE') if timeout == 'NONE': timeout = getattr(bases[0], '__timeout__', None) if RUN_LEAKCHECKS and timeout is not None: timeout *= 6 check_totalrefcount = _get_class_attr(classDict, bases, 'check_totalrefcount', True) error_fatal = _get_class_attr(classDict, bases, 'error_fatal', True) for key, value in classDict.items(): if key.startswith('test') and callable(value): classDict.pop(key) #value = wrap_switch_count_check(value) value = wrap_timeout(timeout, value) my_error_fatal = getattr(value, 'error_fatal', None) if my_error_fatal is None: my_error_fatal = error_fatal if my_error_fatal: value = wrap_error_fatal(value) value = wrap_restore_handle_error(value) if check_totalrefcount: value = wrap_refcount(value) classDict[key] = value return type.__new__(meta, classname, bases, classDict) class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})): # Travis is slow and overloaded; Appveyor used to be faster, but # as of Dec 2015 it's almost always slower and/or has much worse timer # resolution __timeout__ = 1 if not RUNNING_ON_CI else 5 switch_expected = 'default' error_fatal = True close_on_teardown = () def run(self, *args, **kwargs): if self.switch_expected == 'default': self.switch_expected = get_switch_expected(self.fullname) return BaseTestCase.run(self, *args, **kwargs) def tearDown(self): if getattr(self, 'skipTearDown', False): return if hasattr(self, 'cleanup'): self.cleanup() self._error = self._none for x in self.close_on_teardown: try: x.close() except Exception: pass try: del self.close_on_teardown except AttributeError: pass def _close_on_teardown(self, resource): if 'close_on_teardown' not in self.__dict__: self.close_on_teardown = [] self.close_on_teardown.append(resource) return resource @property def testname(self): return getattr(self, '_testMethodName', '') or getattr(self, '_TestCase__testMethodName') @property def testcasename(self): return self.__class__.__name__ + '.' + self.testname @property def modulename(self): return os.path.basename(sys.modules[self.__class__.__module__].__file__).rsplit('.', 1)[0] @property def fullname(self): return splitext(basename(self.modulename))[0] + '.' + self.testcasename _none = (None, None, None) _error = _none def expect_one_error(self): assert self._error == self._none, self._error self._old_handle_error = gevent.get_hub().handle_error gevent.get_hub().handle_error = self._store_error def _store_error(self, where, type, value, tb): del tb if self._error != self._none: gevent.get_hub().parent.throw(type, value) else: self._error = (where, type, value) def peek_error(self): return self._error def get_error(self): try: return self._error finally: self._error = self._none def assert_error(self, type=None, value=None, error=None): if error is None: error = self.get_error() if type is not None: assert issubclass(error[1], type), error if value is not None: if isinstance(value, str): assert str(error[2]) == value, error else: assert error[2] is value, error return error if RUNNING_ON_APPVEYOR: # appveyor timeouts are unreliable; seems to be very slow wakeups def assertTimeoutAlmostEqual(self, *args, **kwargs): return def assertTimeWithinRange(self, delay, min_time, max_time): return else: def assertTimeoutAlmostEqual(self, *args, **kwargs): self.assertAlmostEqual(*args, **kwargs) def assertTimeWithinRange(self, delay, min_time, max_time): self.assertLessEqual(delay, max_time) self.assertGreaterEqual(delay, min_time) if not hasattr(BaseTestCase, 'assertGreater'): # Compatibility with 2.6, backported from 2.7 longMessage = False def _formatMessage(self, msg, standardMsg): """Honour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert If longMessage is True: * Use the standard message * If an explicit message is provided, plus ' : ' and the explicit message """ if not self.longMessage: return msg or standardMsg if msg is None: return standardMsg try: # don't switch to '{}' formatting in Python 2.X # it changes the way unicode input is handled return '%s : %s' % (standardMsg, msg) except UnicodeDecodeError: return '%s : %s' % (safe_repr(standardMsg), safe_repr(msg)) def assertLess(self, a, b, msg=None): """Just like self.assertTrue(a < b), but with a nicer default message.""" if not a < b: standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b)) self.fail(self._formatMessage(msg, standardMsg)) def assertLessEqual(self, a, b, msg=None): """Just like self.assertTrue(a <= b), but with a nicer default message.""" if not a <= b: standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b)) self.fail(self._formatMessage(msg, standardMsg)) def assertGreater(self, a, b, msg=None): """Just like self.assertTrue(a > b), but with a nicer default message.""" if not a > b: standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b)) self.fail(self._formatMessage(msg, standardMsg)) def assertGreaterEqual(self, a, b, msg=None): """Just like self.assertTrue(a >= b), but with a nicer default message.""" if not a >= b: standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b)) self.fail(self._formatMessage(msg, standardMsg)) main = unittest.main _original_Hub = gevent.hub.Hub class CountingHub(_original_Hub): EXPECTED_TEST_ERROR = (ExpectedException,) switch_count = 0 def switch(self, *args): self.switch_count += 1 return _original_Hub.switch(self, *args) def handle_error(self, context, type, value, tb): if issubclass(type, self.EXPECTED_TEST_ERROR): # Don't print these to cut down on the noise in the test logs return return _original_Hub.handle_error(self, context, type, value, tb) gevent.hub.Hub = CountingHub class _DelayWaitMixin(object): _default_wait_timeout = 0.01 _default_delay_min_adj = 0.001 if not RUNNING_ON_APPVEYOR: _default_delay_max_adj = 0.11 else: # Timing resolution is extremely poor on Appveyor # and subject to jitter. _default_delay_max_adj = 0.98 def wait(self, timeout): raise NotImplementedError('override me in subclass') def _check_delay_bounds(self, timeout, delay, delay_min_adj=None, delay_max_adj=None): delay_min_adj = self._default_delay_min_adj if not delay_min_adj else delay_min_adj delay_max_adj = self._default_delay_max_adj if not delay_max_adj else delay_max_adj self.assertGreaterEqual(delay, timeout - delay_min_adj) self.assertLess(delay, timeout + delay_max_adj) def _wait_and_check(self, timeout=None): if timeout is None: timeout = self._default_wait_timeout # gevent.timer instances have a 'seconds' attribute, # otherwise it's the raw number seconds = getattr(timeout, 'seconds', timeout) start = time.time() try: result = self.wait(timeout) finally: self._check_delay_bounds(seconds, time.time() - start, self._default_delay_min_adj, self._default_delay_max_adj) return result def test_outer_timeout_is_not_lost(self): timeout = gevent.Timeout.start_new(0.001, ref=False) try: try: result = self.wait(timeout=1) except gevent.Timeout as ex: assert ex is timeout, (ex, timeout) else: raise AssertionError('must raise Timeout (returned %r)' % (result, )) finally: timeout.cancel() class GenericWaitTestCase(_DelayWaitMixin, TestCase): _default_wait_timeout = 0.2 _default_delay_min_adj = 0.1 if not RUNNING_ON_APPVEYOR: _default_delay_max_adj = 0.11 else: # Timing resolution is very poor on Appveyor _default_delay_max_adj = 0.9 def test_returns_none_after_timeout(self): result = self._wait_and_check() # join and wait simply return after timeout expires assert result is None, repr(result) class GenericGetTestCase(_DelayWaitMixin, TestCase): Timeout = gevent.Timeout def cleanup(self): pass def test_raises_timeout_number(self): self.assertRaises(self.Timeout, self._wait_and_check, timeout=0.01) # get raises Timeout after timeout expired self.cleanup() def test_raises_timeout_Timeout(self): timeout = gevent.Timeout(self._default_wait_timeout) try: self._wait_and_check(timeout=timeout) except gevent.Timeout as ex: assert ex is timeout, (ex, timeout) self.cleanup() def test_raises_timeout_Timeout_exc_customized(self): error = RuntimeError('expected error') timeout = gevent.Timeout(self._default_wait_timeout, exception=error) try: self._wait_and_check(timeout=timeout) except RuntimeError as ex: assert ex is error, (ex, error) self.cleanup() def walk_modules(basedir=None, modpath=None, include_so=False, recursive=False): if PYPY: include_so = False if basedir is None: basedir = os.path.dirname(gevent.__file__) if modpath is None: modpath = 'gevent.' else: if modpath is None: modpath = '' for fn in sorted(os.listdir(basedir)): path = os.path.join(basedir, fn) if os.path.isdir(path): if not recursive: continue pkg_init = os.path.join(path, '__init__.py') if os.path.exists(pkg_init): yield pkg_init, modpath + fn for p, m in walk_modules(path, modpath + fn + "."): yield p, m continue if fn.endswith('.py'): x = fn[:-3] if x.endswith('_d'): x = x[:-2] if x in ['__init__', 'core', 'ares', '_util', '_semaphore', 'corecffi', '_corecffi', '_corecffi_build']: continue if x in OPTIONAL_MODULES: try: six.exec_("import %s" % x, {}) except ImportError: continue yield path, modpath + x elif include_so and fn.endswith('.so'): if '.pypy-' in fn: continue if fn.endswith('_d.so'): yield path, modpath + fn[:-5] else: yield path, modpath + fn[:-3] def bind_and_listen(sock, address=('', 0), backlog=50, reuse_addr=True): from socket import SOL_SOCKET, SO_REUSEADDR, error if reuse_addr: try: sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, sock.getsockopt(SOL_SOCKET, SO_REUSEADDR) | 1) except error: pass sock.bind(address) sock.listen(backlog) def tcp_listener(address, backlog=50, reuse_addr=True): """A shortcut to create a TCP socket, bind it and put it into listening state.""" from gevent import socket sock = socket.socket() bind_and_listen(sock) return sock @contextlib.contextmanager def disabled_gc(): was_enabled = gc.isenabled() gc.disable() try: yield finally: if was_enabled: gc.enable() def get_number_open_files(): if os.path.exists('/proc/'): fd_directory = '/proc/%d/fd' % os.getpid() return len(os.listdir(fd_directory)) if PYPY: def getrefcount(*args): pass else: def getrefcount(*args): return sys.getrefcount(*args) gevent-1.1.0/greentest/https_svn_python_org_root.pem0000644000076500000000000000501112666555342023602 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD -----END CERTIFICATE----- gevent-1.1.0/greentest/keycert.pem0000644000076500000000000000352012666555342017710 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0 ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/ loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- gevent-1.1.0/greentest/lock_tests.py0000644000076500000000000003672512666555342020300 0ustar jmaddenwheel00000000000000""" Various tests for synchronization primitives. """ import sys import time try: from thread import start_new_thread, get_ident except ImportError: from _thread import start_new_thread, get_ident import threading import unittest try: from test import support except ImportError: from test import test_support as support def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() for _ in range(n): start_new_thread(task, ()) def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children() class BaseLockTests(BaseTestCase): """ Tests for both recursive and non-recursive locks. """ def locktype(self): raise NotImplementedError() def test_constructor(self): lock = self.locktype() del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) def test_with(self): lock = self.locktype() def f(): lock.acquire() lock.release() def _with(err=None): with lock: if err is not None: raise err _with() # Check the lock is unacquired Bunch(f, 1).wait_for_finished() self.assertRaises(TypeError, _with, TypeError) # Check the lock is unacquired Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. Bunch(f, 15).wait_for_finished() self.assertEqual(n, len(threading.enumerate())) class LockTests(BaseLockTests): """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def test_reacquire(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def test_different_thread(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() class RLockTests(BaseLockTests): """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_different_thread(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) class EventTests(BaseTestCase): """ Tests for Event objects. """ def eventtype(self): raise NotImplementedError() def test_is_set(self): evt = self.eventtype() self.assertFalse(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) def _check_notify(self, evt): # All threads get notified N = 5 results1 = [] results2 = [] def f(): evt.wait() results1.append(evt.is_set()) evt.wait() results2.append(evt.is_set()) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(results1), 0) evt.set() b.wait_for_finished() self.assertEqual(results1, [True] * N) self.assertEqual(results2, [True] * N) def test_notify(self): evt = self.eventtype() self._check_notify(evt) # Another time, after an explicit clear() evt.set() evt.clear() self._check_notify(evt) def test_timeout(self): evt = self.eventtype() results1 = [] results2 = [] N = 5 def f(): evt.wait(0.0) results1.append(evt.is_set()) t1 = time.time() evt.wait(0.2) r = evt.is_set() t2 = time.time() results2.append((r, t2 - t1)) Bunch(f, N).wait_for_finished() self.assertEqual(results1, [False] * N) for r, dt in results2: self.assertFalse(r) self.assertTrue(dt >= 0.2, dt) # The event is set results1 = [] results2 = [] evt.set() Bunch(f, N).wait_for_finished() self.assertEqual(results1, [True] * N) for r, dt in results2: self.assertTrue(r) class ConditionTests(BaseTestCase): """ Tests for condition variables. """ def condtype(self, *args): raise NotImplementedError() def test_acquire(self): cond = self.condtype() # Be default we have an RLock: the condition can be acquired multiple # times. cond.acquire() cond.acquire() cond.release() cond.release() lock = threading.Lock() cond = self.condtype(lock) cond.acquire() self.assertFalse(lock.acquire(False)) cond.release() self.assertTrue(lock.acquire(False)) self.assertFalse(cond.acquire(False)) lock.release() with cond: self.assertFalse(lock.acquire(False)) def test_unacquired_wait(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.wait) def test_unacquired_notify(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.notify) def _check_notify(self, cond): N = 5 results1 = [] results2 = [] phase_num = 0 def f(): cond.acquire() cond.wait() cond.release() results1.append(phase_num) cond.acquire() cond.wait() cond.release() results2.append(phase_num) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(results1, []) # Notify 3 threads at first cond.acquire() cond.notify(3) _wait() phase_num = 1 cond.release() while len(results1) < 3: _wait() self.assertEqual(results1, [1] * 3) self.assertEqual(results2, []) # Notify 5 threads: they might be in their first or second wait cond.acquire() cond.notify(5) _wait() phase_num = 2 cond.release() while len(results1) + len(results2) < 8: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3) # Notify all threads: they are all in their second wait cond.acquire() cond.notify_all() _wait() phase_num = 3 cond.release() while len(results2) < 5: _wait() self.assertEqual(results1, [1] * 3 + [2] * 2) self.assertEqual(results2, [2] * 3 + [3] * 2) b.wait_for_finished() def test_notify(self): cond = self.condtype() self._check_notify(cond) # A second time, to check internal state is still ok. self._check_notify(cond) def test_timeout(self): cond = self.condtype() results = [] N = 5 def f(): cond.acquire() t1 = time.time() cond.wait(0.2) t2 = time.time() cond.release() results.append(t2 - t1) Bunch(f, N).wait_for_finished() self.assertEqual(len(results), 5) for dt in results: self.assertTrue(dt >= 0.2, dt) class BaseSemaphoreTests(BaseTestCase): """ Common tests for {bounded, unbounded} semaphore objects. """ def semtype(self, *args): raise NotImplementedError() def test_constructor(self): self.assertRaises(ValueError, self.semtype, value = -1) # Py3 doesn't have sys.maxint self.assertRaises(ValueError, self.semtype, value = -getattr(sys, 'maxint', getattr(sys, 'maxsize', None))) def test_acquire(self): sem = self.semtype(1) sem.acquire() sem.release() sem = self.semtype(2) sem.acquire() sem.acquire() sem.release() sem.release() def test_acquire_destroy(self): sem = self.semtype() sem.acquire() del sem def test_acquire_contended(self): sem = self.semtype(7) sem.acquire() #N = 10 results1 = [] results2 = [] phase_num = 0 def f(): sem.acquire() results1.append(phase_num) sem.acquire() results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() while len(results1) + len(results2) < 6: _wait() self.assertEqual(results1 + results2, [0] * 6) phase_num = 1 for _ in range(7): sem.release() while len(results1) + len(results2) < 13: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7) phase_num = 2 for _ in range(6): sem.release() while len(results1) + len(results2) < 19: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7 + [2] * 6) # The semaphore is still locked self.assertFalse(sem.acquire(False)) # Final release, to let the last thread finish sem.release() b.wait_for_finished() def test_try_acquire(self): sem = self.semtype(2) self.assertTrue(sem.acquire(False)) self.assertTrue(sem.acquire(False)) self.assertFalse(sem.acquire(False)) sem.release() self.assertTrue(sem.acquire(False)) def test_try_acquire_contended(self): sem = self.semtype(4) sem.acquire() results = [] def f(): results.append(sem.acquire(False)) results.append(sem.acquire(False)) Bunch(f, 5).wait_for_finished() # There can be a thread switch between acquiring the semaphore and # appending the result, therefore results will not necessarily be # ordered. self.assertEqual(sorted(results), [False] * 7 + [True] * 3 ) def test_default_value(self): # The default initial value is 1. sem = self.semtype() sem.acquire() def f(): sem.acquire() sem.release() b = Bunch(f, 1) b.wait_for_started() _wait() self.assertFalse(b.finished) sem.release() b.wait_for_finished() def test_with(self): sem = self.semtype(2) def _with(err=None): with sem: self.assertTrue(sem.acquire(False)) sem.release() with sem: self.assertFalse(sem.acquire(False)) if err: raise err _with() self.assertTrue(sem.acquire(False)) sem.release() self.assertRaises(TypeError, _with, TypeError) self.assertTrue(sem.acquire(False)) sem.release() class SemaphoreTests(BaseSemaphoreTests): """ Tests for unbounded semaphores. """ def test_release_unacquired(self): # Unbounded releases are allowed and increment the semaphore's value sem = self.semtype(1) sem.release() sem.acquire() sem.acquire() sem.release() class BoundedSemaphoreTests(BaseSemaphoreTests): """ Tests for bounded semaphores. """ def test_release_unacquired(self): # Cannot go past the initial value sem = self.semtype() self.assertRaises(ValueError, sem.release) sem.acquire() sem.release() self.assertRaises(ValueError, sem.release) if __name__ == '__main__': print("This module contains no tests; it is used by other test cases like test_threading_2") gevent-1.1.0/greentest/monkey_test.py0000644000076500000000000000211612666555342020452 0ustar jmaddenwheel00000000000000import sys import os kwargs = {} if sys.argv[1] == '--Event': kwargs['Event'] = True del sys.argv[1] else: kwargs['Event'] = False test_filename = sys.argv[1] del sys.argv[1] print('Running with patch_all(%s): %s' % (','.join('%s=%r' % x for x in kwargs.items()), test_filename)) from gevent import monkey; monkey.patch_all(**kwargs) from patched_tests_setup import disable_tests_in_source try: from test import support except ImportError: from test import test_support as support support.is_resource_enabled = lambda *args: True del support.use_resources if sys.version_info[:2] <= (2, 6): support.TESTFN += '_%s' % os.getpid() __file__ = os.path.join(os.getcwd(), test_filename) test_name = os.path.splitext(test_filename)[0] if sys.version_info[0] >= 3: module_file = open(test_filename, encoding='utf-8') else: module_file = open(test_filename) with module_file: module_source = module_file.read() module_source = disable_tests_in_source(module_source, test_name) module_code = compile(module_source, test_filename, 'exec') exec(module_code, globals()) gevent-1.1.0/greentest/nullcert.pem0000644000076500000000000000000012666555342020060 0ustar jmaddenwheel00000000000000gevent-1.1.0/greentest/patched_tests_setup.py0000644000076500000000000003750712666555342022177 0ustar jmaddenwheel00000000000000from __future__ import print_function import sys import os import re # By default, test cases are expected to switch and emit warnings if there was none # If a test is found in this list, it's expected not to switch. no_switch_tests = '''test_patched_select.SelectTestCase.test_error_conditions test_patched_ftplib.*.test_all_errors test_patched_ftplib.*.test_getwelcome test_patched_ftplib.*.test_sanitize test_patched_ftplib.*.test_set_pasv #test_patched_ftplib.TestIPv6Environment.test_af test_patched_socket.TestExceptions.testExceptionTree test_patched_socket.Urllib2FileobjectTest.testClose test_patched_socket.TestLinuxAbstractNamespace.testLinuxAbstractNamespace test_patched_socket.TestLinuxAbstractNamespace.testMaxName test_patched_socket.TestLinuxAbstractNamespace.testNameOverflow test_patched_socket.FileObjectInterruptedTestCase.* test_patched_urllib.* test_patched_asyncore.HelperFunctionTests.* test_patched_httplib.BasicTest.* test_patched_httplib.HTTPSTimeoutTest.test_attributes test_patched_httplib.HeaderTests.* test_patched_httplib.OfflineTest.* test_patched_httplib.HTTPSTimeoutTest.test_host_port test_patched_httplib.SourceAddressTest.testHTTPSConnectionSourceAddress test_patched_select.SelectTestCase.test_error_conditions test_patched_smtplib.NonConnectingTests.* test_patched_urllib2net.OtherNetworkTests.* test_patched_wsgiref.* test_patched_subprocess.HelperFunctionTests.* ''' ignore_switch_tests = ''' test_patched_socket.GeneralModuleTests.* test_patched_httpservers.BaseHTTPRequestHandlerTestCase.* test_patched_queue.* test_patched_signal.SiginterruptTest.* test_patched_urllib2.* test_patched_ssl.* test_patched_signal.BasicSignalTests.* test_patched_threading_local.* test_patched_threading.* ''' def make_re(tests): tests = [x.strip().replace('\.', '\\.').replace('*', '.*?') for x in tests.split('\n') if x.strip()] tests = re.compile('^%s$' % '|'.join(tests)) return tests no_switch_tests = make_re(no_switch_tests) ignore_switch_tests = make_re(ignore_switch_tests) def get_switch_expected(fullname): """ >>> get_switch_expected('test_patched_select.SelectTestCase.test_error_conditions') False >>> get_switch_expected('test_patched_socket.GeneralModuleTests.testCrucialConstants') False >>> get_switch_expected('test_patched_socket.SomeOtherTest.testHello') True >>> get_switch_expected("test_patched_httplib.BasicTest.test_bad_status_repr") False """ if ignore_switch_tests.match(fullname) is not None: return None if no_switch_tests.match(fullname) is not None: return False return True disabled_tests = [ # The server side takes awhile to shut down 'test_httplib.HTTPSTest.test_local_bad_hostname', 'test_threading.ThreadTests.test_PyThreadState_SetAsyncExc', # uses some internal C API of threads not available when threads are emulated with greenlets 'test_threading.ThreadTests.test_join_nondaemon_on_shutdown', # asserts that repr(sleep) is '' 'test_urllib2net.TimeoutTest.test_ftp_no_timeout', 'test_urllib2net.TimeoutTest.test_ftp_timeout', 'test_urllib2net.TimeoutTest.test_http_no_timeout', 'test_urllib2net.TimeoutTest.test_http_timeout', # accesses _sock.gettimeout() which is always in non-blocking mode 'test_urllib2net.OtherNetworkTests.test_ftp', # too slow 'test_urllib2net.OtherNetworkTests.test_urlwithfrag', # fails dues to some changes on python.org 'test_urllib2net.OtherNetworkTests.test_sites_no_connection_close', # flaky 'test_socket.UDPTimeoutTest.testUDPTimeout', # has a bug which makes it fail with error: (107, 'Transport endpoint is not connected') # (it creates a TCP socket, not UDP) 'test_socket.GeneralModuleTests.testRefCountGetNameInfo', # fails with "socket.getnameinfo loses a reference" while the reference is only "lost" # because it is referenced by the traceback - any Python function would lose a reference like that. # the original getnameinfo does not "lose" it because it's in C. 'test_socket.NetworkConnectionNoServer.test_create_connection_timeout', # replaces socket.socket with MockSocket and then calls create_connection. # this unfortunately does not work with monkey patching, because gevent.socket.create_connection # is bound to gevent.socket.socket and updating socket.socket does not affect it. # this issues also manifests itself when not monkey patching DNS: http://code.google.com/p/gevent/issues/detail?id=54 # create_connection still uses gevent.socket.getaddrinfo while it should be using socket.getaddrinfo 'test_asyncore.BaseTestAPI.test_handle_expt', # sends some OOB data and expect it to be detected as such; gevent.select.select does not support that 'test_signal.WakeupSignalTests.test_wakeup_fd_early', # expects time.sleep() to return prematurely in case of a signal; # gevent.sleep() is better than that and does not get interrupted (unless signal handler raises an error) 'test_signal.WakeupSignalTests.test_wakeup_fd_during', # expects select.select() to raise select.error(EINTR'interrupted system call') # gevent.select.select() does not get interrupted (unless signal handler raises an error) # maybe it should? 'test_signal.SiginterruptTest.test_without_siginterrupt', 'test_signal.SiginterruptTest.test_siginterrupt_on', # these rely on os.read raising EINTR which never happens with gevent.os.read 'test_subprocess.test_leak_fast_process_del_killed', 'test_subprocess.test_zombie_fast_process_del', # relies on subprocess._active which we don't use 'test_ssl.ThreadedTests.test_default_ciphers', 'test_ssl.ThreadedTests.test_empty_cert', 'test_ssl.ThreadedTests.test_malformed_cert', 'test_ssl.ThreadedTests.test_malformed_key', 'test_ssl.NetworkedTests.test_non_blocking_connect_ex', # XXX needs investigating 'test_ssl.NetworkedTests.test_algorithms', # The host this wants to use, sha256.tbs-internet.com, is not resolvable # right now (2015-10-10), and we need to get Windows wheels # Relies on the repr of objects (Py3) 'test_ssl.BasicSocketTests.test_dealloc_warn', 'test_urllib2.HandlerTests.test_cookie_redirect', # this uses cookielib which we don't care about 'test_thread.ThreadRunningTests.test__count', 'test_thread.TestForkInThread.test_forkinthread', # XXX needs investigating 'test_subprocess.POSIXProcessTestCase.test_terminate_dead', 'test_subprocess.POSIXProcessTestCase.test_send_signal_dead', 'test_subprocess.POSIXProcessTestCase.test_kill_dead', # Don't exist in the test suite until 2.7.4+; with our monkey patch in place, # they fail because the process they're looking for has been allowed to exit. # Our monkey patch waits for the process with a watcher and so detects # the exit before the normal polling mechanism would 'test_subprocess.POSIXProcessTestCase.test_preexec_errpipe_does_not_double_close_pipes', # Does not exist in the test suite until 2.7.4+. Subclasses Popen, and overrides # _execute_child. But our version has a different parameter list than the # version that comes with PyPy/CPython, so fails with a TypeError. ] if 'thread' in os.getenv('GEVENT_FILE', ''): disabled_tests += [ 'test_subprocess.ProcessTestCase.test_double_close_on_error' # Fails with "OSError: 9 invalid file descriptor"; expect GC/lifetime issues ] if sys.version_info[:2] == (2, 6): disabled_tests += [ # SSLv2 May or may not be available depending on the build 'test_ssl.BasicTests.test_constants', ] if os.environ.get('TRAVIS') == 'true': # somehow these fail with "Permission denied" on travis disabled_tests += [ 'test_httpservers.CGIHTTPServerTestCase.test_post', 'test_httpservers.CGIHTTPServerTestCase.test_headers_and_content', 'test_httpservers.CGIHTTPServerTestCase.test_authorization', 'test_httpservers.SimpleHTTPServerTestCase.test_get' ] if sys.platform == 'darwin': disabled_tests += [ 'test_subprocess.POSIXProcessTestCase.test_run_abort', # causes Mac OS X to show "Python crashes" dialog box which is annoying ] if sys.platform.startswith('win'): disabled_tests += [ # Issue with Unix vs DOS newlines in the file vs from the server 'test_ssl.ThreadedTests.test_socketserver', ] if hasattr(sys, 'pypy_version_info'): disabled_tests += [ 'test_subprocess.ProcessTestCase.test_failed_child_execute_fd_leak', # Does not exist in the CPython test suite, tests for a specific bug # in PyPy's forking. Only runs on linux and is specific to the PyPy # implementation of subprocess (possibly explains the extra parameter to # _execut_child) ] import cffi if cffi.__version_info__ < (1, 2, 0): disabled_tests += [ 'test_signal.InterProcessSignalTests.test_main', # Fails to get the signal to the correct handler due to # https://bitbucket.org/cffi/cffi/issue/152/handling-errors-from-signal-handlers-in ] # Generic Python 3 if sys.version_info[0] == 3: disabled_tests += [ # Triggers the crash reporter 'test_threading.SubinterpThreadingTests.test_daemon_threads_fatal_error', # Relies on an implementation detail, Thread._tstate_lock 'test_threading.ThreadTests.test_tstate_lock', # Relies on an implementation detail (reprs); we have our own version 'test_threading.ThreadTests.test_various_ops', 'test_threading.ThreadTests.test_various_ops_large_stack', 'test_threading.ThreadTests.test_various_ops_small_stack', # Relies on Event having a _cond and an _reset_internal_locks() # XXX: These are commented out in the source code of test_threading because # this doesn't work. # 'lock_tests.EventTests.test_reset_internal_locks', # Python bug 13502. We may or may not suffer from this as its # basically a timing race condition. # XXX Same as above # 'lock_tests.EventTests.test_set_and_clear', ] if sys.version_info[:2] == (3, 4) and sys.version_info[:3] < (3, 4, 4): # Older versions have some issues with the SSL tests. Seen on Appveyor disabled_tests += [ 'test_ssl.ContextTests.test_options', 'test_ssl.ThreadedTests.test_protocol_sslv23', 'test_ssl.ThreadedTests.test_protocol_sslv3', 'test_httplib.HTTPSTest.test_networked', ] if sys.version_info[:2] >= (3, 4): disabled_tests += [ 'test_subprocess.ProcessTestCase.test_threadsafe_wait', # XXX: It seems that threading.Timer is not being greened properly, possibly # due to a similar issue to what gevent.threading documents for normal threads. # In any event, this test hangs forever 'test_subprocess.ProcessTestCase.test_io_buffered_by_default', 'test_subprocess.ProcessTestCase.test_io_unbuffered_works', # These tests want to assert on the type of the class that implements # `Popen.stdin`; we use a FileObject, but they expect different subclasses # from the `io` module 'test_subprocess.POSIXProcessTestCase.test_terminate_dead', 'test_subprocess.POSIXProcessTestCase.test_send_signal_dead', 'test_subprocess.POSIXProcessTestCase.test_kill_dead', # With our monkey patch in place, # they fail because the process they're looking for has been allowed to exit. # Our monkey patch waits for the process with a watcher and so detects # the exit before the normal polling mechanism would 'test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0', 'test_subprocess.POSIXProcessTestCase.test_exception_bad_executable', 'test_subprocess.POSIXProcessTestCase.test_exception_cwd', # These all want to inspect the string value of an exception raised # by the exec() call in the child. The _posixsubprocess module arranges # for better exception handling and printing than we do. 'test_subprocess.POSIXProcessTestCase.test_preexec_errpipe_does_not_double_close_pipes', # Subclasses Popen, and overrides _execute_child. Expects things to be done # in a particular order in an exception case, but we don't follow that # exact order 'test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd', # Python 3 fixed a bug if the stdio file descriptors were closed; # we still have that bug 'test_selectors.PollSelectorTestCase.test_above_fd_setsize', # This test attempts to open many many file descriptors and # poll on them, expecting them all to be ready at once. But # libev limits the number of events it will return at once. Specifically, # on linux with epoll, it returns a max of 64 (ev_epoll.c). ] if os.environ.get('TRAVIS') == 'true': disabled_tests += [ 'test_subprocess.ProcessTestCase.test_double_close_on_error', # This test is racy or OS-dependent. It passes locally (sufficiently fast machine) # but fails under Travis ] if sys.version_info[:2] >= (3, 5): disabled_tests += [ # XXX: Hangs 'test_ssl.ThreadedTests.test_nonblocking_send', 'test_ssl.ThreadedTests.test_socketserver', # XXX: Hangs (Linux only) 'test_socket.NonBlockingTCPTests.testInitNonBlocking', # We don't handle the Linux-only SOCK_NONBLOCK option 'test_socket.NonblockConstantTest.test_SOCK_NONBLOCK', # Tries to use multiprocessing which doesn't quite work in # monkey_test module (Windows only) 'test_socket.TestSocketSharing.testShare', # Windows-only: Sockets have a 'ioctl' method in Python 3 # implemented in the C code. This test tries to check # for the presence of the method in the class, which we don't # have because we don't inherit the C implementation. But # it should be found at runtime. 'test_socket.GeneralModuleTests.test_sock_ioctl', # Relies on implementation details 'test_socket.GeneralModuleTests.test_SocketType_is_socketobject', 'test_socket.GeneralModuleTests.test_dealloc_warn', 'test_socket.GeneralModuleTests.test_repr', 'test_socket.GeneralModuleTests.test_str_for_enums', 'test_socket.GeneralModuleTests.testGetaddrinfo', # Relies on the regex of the repr having the locked state (TODO: it'd be nice if # we did that). # XXX: These are commented out in the source code of test_threading because # this doesn't work. # 'lock_tests.LockTests.lest_locked_repr', # 'lock_tests.LockTests.lest_repr', ] if os.environ.get('GEVENT_RESOLVER') == 'ares': disabled_tests += [ # These raise different errors or can't resolve # the IP address correctly 'test_socket.GeneralModuleTests.test_host_resolution', 'test_socket.GeneralModuleTests.test_getnameinfo', ] # if 'signalfd' in os.environ.get('GEVENT_BACKEND', ''): # # tests that don't interact well with signalfd # disabled_tests.extend([ # 'test_signal.SiginterruptTest.test_siginterrupt_off', # 'test_socketserver.SocketServerTest.test_ForkingTCPServer', # 'test_socketserver.SocketServerTest.test_ForkingUDPServer', # 'test_socketserver.SocketServerTest.test_ForkingUnixStreamServer']) def disable_tests_in_source(source, name): my_disabled_tests = [x for x in disabled_tests if x.startswith(name + '.')] if not my_disabled_tests: return source for test in my_disabled_tests: # XXX ignoring TestCase class name testcase = test.split('.')[-1] source, n = re.subn(testcase, 'XXX' + testcase, source) print('Removed %s (%d)' % (testcase, n), file=sys.stderr) return source gevent-1.1.0/greentest/sha256.pem0000644000076500000000000000402112666555342017247 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy MTI1WjBLMQswCQYDVQQGEwJERTEXMBUGA1UEChMOc2Nob2tva2Vrcy5vcmcxIzAh BgkqhkiG9w0BCQEWFGhhbm5vQHNjaG9rb2tla3Mub3JnMIICIjANBgkqhkiG9w0B AQEFAAOCAg8AMIICCgKCAgEApJ4ODPwEooMW35dQPlBqdvcfkEvjhcsA7jmJfFqN e/1T34zT44X9+KnMBSG2InacbD7eyFgjfaENFsZ87YkEBDIFZ/SHotLJZORQ8PUj YoxPG4mjKN+yL2WthNcYbRyJreTbbDroNMuw6tkTSxeSXyYFQrKMCUfErVbZa/d5 RvfFVk+Au9dVUFhed/Stn5cv+a0ffvpyA7ygihm1kMFICbvPeI0846tmC2Ph7rM5 pYQyNBDOVpULODTk5Wu6jiiJJygvJWCZ1FdpsdBs5aKWHWdRhX++quGuflTTjH5d qaIka4op9H7XksYphTDXmV+qHnva5jbPogwutDQcVsGBQcJaLmQqhsQK13bf4khE iWJvfBLfHn8OOpY25ZwwuigJIwifNCxQeeT1FrLmyuYNhz2phPpzx065kqSUSR+A Iw8DPE6e65UqMDKqZnID3dQeiQaFrHEV+Ibo0U/tD0YSBw5p33TMh0Es33IBWMac m7x4hIFWdhl8W522u6qOrTswY3s8vB7blNWqMc9n7oWH8ybFf7EgKeDVtEN9AyBE 0WotXIEZWI+WvDbU1ACJXau9sQhYP/eerg7Zwr3iGUy4IQ5oUJibnjtcE+z8zmDN pE6YcMCLJyLjXiQ3iHG9mNXzw7wPnslTbEEEukrfSlHGgW8Dm+VrNyW0JUM1bntx vbMCAwEAAaOBrTCBqjAdBgNVHQ4EFgQUCedv7pDTuXtCxm4HTw9hUtrTvsowewYD VR0jBHQwcoAUCedv7pDTuXtCxm4HTw9hUtrTvsqhT6RNMEsxCzAJBgNVBAYTAkRF MRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYUaGFubm9A c2Nob2tva2Vrcy5vcmeCCQC55Z3+bs05CDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 DQEBCwUAA4ICAQBHKAxA7WA/MEFjet03K8ouzEOr6Jrk2fZOuRhoDZ+9gr4FtaJB P3Hh5D00kuSOvDnwsvCohxeNd1KTMAwVmVoH+NZkHERn3UXniUENlp18koI1ehlr CZbXbzzE9Te9BelliSFA63q0cq0yJN1x9GyabU34XkAouCAmOqfSpKNZWZHGBHPF bbYnZrHEMcsye6vKeTOcg1GqUHGrQM2WK0QaOwnCQv2RblI9VN+SeRoUJ44qTXdW TwIYStsIPesacNcAQTStnHgKqIPx4zCwdx5xo8zONbXJfocqwyFqiAofvb9dN1nW g1noVBcXB+oRBZW5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4 +A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw== -----END CERTIFICATE----- gevent-1.1.0/greentest/six.py0000644000076500000000000000164412666555342016721 0ustar jmaddenwheel00000000000000import sys PY3 = sys.version_info[0] >= 3 if PY3: advance_iterator = next else: def advance_iterator(it): return it.next() if PY3: import builtins exec_ = getattr(builtins, "exec") def reraise(tp, value, tb=None): if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value xrange = range string_types = str, text_type = str else: def exec_(code, globs=None, locs=None): """Execute code in a namespace.""" if globs is None: frame = sys._getframe(1) globs = frame.f_globals if locs is None: locs = frame.f_locals del frame elif locs is None: locs = globs exec("""exec code in globs, locs""") import __builtin__ as builtins xrange = builtins.xrange string_types = builtins.basestring, text_type = builtins.unicode gevent-1.1.0/greentest/test___example_servers.py0000644000076500000000000001024212666555342022651 0ustar jmaddenwheel00000000000000import sys #import time from unittest import main if sys.version_info[0] == 3: from urllib import request as urllib2 else: import urllib2 import util import socket import ssl class Test_wsgiserver(util.TestServer): server = 'wsgiserver.py' URL = 'http://127.0.0.1:8088' PORT = 8088 not_found_message = b'

    Not Found

    ' ssl_ctx = None _use_ssl = False def read(self, path='/'): url = self.URL + path try: if self.ssl_ctx is not None: response = urllib2.urlopen(url, None, 2, context=self.ssl_ctx) else: response = urllib2.urlopen(url, None, 2) except urllib2.HTTPError: response = sys.exc_info()[1] result = '%s %s' % (response.code, response.msg), response.read() # XXX: It looks like under PyPy this isn't directly closing the socket # when SSL is in use. It takes a GC cycle to make that true. response.close() return result def _test_hello(self): status, data = self.read('/') self.assertEqual(status, '200 OK') self.assertEqual(data, b"hello world") def _test_not_found(self): status, data = self.read('/xxx') self.assertEqual(status, '404 Not Found') self.assertEqual(data, self.not_found_message) def _do_test_a_blocking_client(self): # We spawn this in a separate server because if it's broken # the whole server hangs print("Checking blocking") with self.running_server(): # First, make sure we can talk to it. self._test_hello() # Now create a connection and only partway finish # the transaction sock = socket.create_connection(('127.0.0.1', self.PORT)) ssl_sock = None if self._use_ssl: ssl_sock = ssl.wrap_socket(sock) sock_file = ssl_sock.makefile(mode='rwb') else: sock_file = sock.makefile(mode='rwb') # write an incomplete request sock_file.write(b'GET /xxx HTTP/1.0\r\n') sock_file.flush() # Leave it open and not doing anything # while the other request runs to completion. # This demonstrates that a blocking client # doesn't hang the whole server self._test_hello() # now finish the original request sock_file.write(b'\r\n') sock_file.flush() line = sock_file.readline() self.assertEqual(line, b'HTTP/1.1 404 Not Found\r\n') sock.close() sock_file.close() if ssl_sock is not None: ssl_sock.close() def test_a_blocking_client(self): self._do_test_a_blocking_client() class Test_wsgiserver_ssl(Test_wsgiserver): server = 'wsgiserver_ssl.py' URL = 'https://127.0.0.1:8443' PORT = 8443 _use_ssl = True if hasattr(ssl, '_create_unverified_context'): # Disable verification for our self-signed cert # on Python >= 2.7.9 and 3.4 ssl_ctx = ssl._create_unverified_context() class Test_webproxy(Test_wsgiserver): server = 'webproxy.py' def _run_all_tests(self): status, data = self.read('/') self.assertEqual(status, '200 OK') assert b"gevent example" in data, repr(data) status, data = self.read('/http://www.google.com') self.assertEqual(status, '200 OK') assert b'google' in data.lower(), repr(data) def _do_test_a_blocking_client(self): # Not applicable return # class Test_webpy(Test_wsgiserver): # server = 'webpy.py' # not_found_message = 'not found' # # def _test_hello(self): # status, data = self.read('/') # self.assertEqual(status, '200 OK') # assert "Hello, world" in data, repr(data) # # def _test_long(self): # start = time.time() # status, data = self.read('/long') # delay = time.time() - start # assert 10 - 0.5 < delay < 10 + 0.5, delay # self.assertEqual(status, '200 OK') # self.assertEqual(data, 'Hello, 10 seconds later') if __name__ == '__main__': main() gevent-1.1.0/greentest/test___monkey_patching.py0000644000076500000000000000276512666555342022637 0ustar jmaddenwheel00000000000000import sys import os import glob import util import atexit # subprocess: include in subprocess tests TIMEOUT = 120 directory = '%s.%s' % sys.version_info[:2] if hasattr(sys, 'pypy_version_info'): directory += 'pypy' version = '%s.%s.%s' % sys.version_info[:3] def get_absolute_pythonpath(): paths = [os.path.abspath(p) for p in os.environ.get('PYTHONPATH', '').split(os.pathsep)] return os.pathsep.join(paths) def TESTRUNNER(tests=None): if not os.path.exists(directory): return with open(os.path.join(directory, 'version')) as f: preferred_version = f.read().strip() if preferred_version != version: util.log('WARNING: The tests in %s/ are from version %s and your Python is %s', directory, preferred_version, version) if not tests: tests = sorted(glob.glob('%s/test_*.py' % directory)) PYTHONPATH = (os.getcwd() + os.pathsep + get_absolute_pythonpath()).rstrip(':') tests = [os.path.basename(x) for x in tests] options = {'cwd': directory, 'timeout': TIMEOUT, 'setenv': {'PYTHONPATH': PYTHONPATH}} if tests: atexit.register(os.system, 'rm -f */@test*') for filename in tests: yield [sys.executable, '-u', '-m', 'monkey_test', filename], options.copy() yield [sys.executable, '-u', '-m', 'monkey_test', '--Event', filename], options.copy() def main(): import testrunner return testrunner.run_many(list(TESTRUNNER(sys.argv[1:]))) if __name__ == '__main__': main() gevent-1.1.0/greentest/test__all__.py0000644000076500000000000001762612666555342020371 0ustar jmaddenwheel00000000000000"""Check __all__, __implements__, __extensions__, __imports__ of the modules""" from __future__ import print_function import six import sys import unittest import types from greentest import walk_modules from greentest import PLATFORM_SPECIFIC_SUFFIXES MAPPING = { 'gevent.local': '_threading_local', 'gevent.socket': 'socket', 'gevent.select': 'select', 'gevent.ssl': 'ssl', 'gevent.thread': '_thread' if six.PY3 else 'thread', 'gevent.subprocess': 'subprocess', 'gevent.os': 'os', 'gevent.threading': 'threading', 'gevent.builtins': 'builtins' if six.PY3 else '__builtin__', 'gevent.signal': 'signal', } class ANY(object): def __contains__(self, item): return True ANY = ANY() NOT_IMPLEMENTED = { 'socket': ['CAPI'], 'thread': ['allocate', 'exit_thread', 'interrupt_main', 'start_new'], 'select': ANY, 'os': ANY, 'threading': ANY, 'builtins' if six.PY3 else '__builtin__': ANY, 'signal': ANY, } COULD_BE_MISSING = { 'socket': ['create_connection', 'RAND_add', 'RAND_egd', 'RAND_status'], 'subprocess': ['_posixsubprocess'], } NO_ALL = ['gevent.threading', 'gevent._util', 'gevent._socketcommon', 'gevent._fileobjectcommon', 'gevent._fileobjectposix', 'gevent._tblib', 'gevent._corecffi'] # A list of modules that may contain things that aren't actually, technically, # extensions, but that need to be in __extensions__ anyway due to the way, # for example, monkey patching, needs to work. EXTRA_EXTENSIONS = [] if sys.platform.startswith('win'): EXTRA_EXTENSIONS.append('gevent.signal') class Test(unittest.TestCase): def check_all(self): "Check that __all__ is present and does not contain invalid entries" if not hasattr(self.module, '__all__'): assert self.modname in NO_ALL return names = {} six.exec_("from %s import *" % self.modname, names) names.pop('__builtins__', None) self.assertEqual(sorted(names), sorted(self.module.__all__)) def check_all_formula(self): "Check __all__ = __implements__ + __extensions__ + __imported__" all_calculated = self.__implements__ + self.__imports__ + self.__extensions__ self.assertEqual(sorted(all_calculated), sorted(self.module.__all__)) def check_implements_presence_justified(self): "Check that __implements__ is present only if the module is modeled after a module from stdlib (like gevent.socket)." if self.__implements__ is not None and self.stdlib_module is None: raise AssertionError('%r has __implements__ but no stdlib counterpart' % self.modname) def set_stdlib_all(self): assert self.stdlib_module is not None self.stdlib_has_all = True self.stdlib_all = getattr(self.stdlib_module, '__all__', None) if self.stdlib_all is None: self.stdlib_has_all = False self.stdlib_all = dir(self.stdlib_module) self.stdlib_all = [name for name in self.stdlib_all if not name.startswith('_')] self.stdlib_all = [name for name in self.stdlib_all if not isinstance(getattr(self.stdlib_module, name), types.ModuleType)] def check_implements_subset_of_stdlib_all(self): "Check that __implements__ + __imports__ is a subset of the corresponding standard module __all__ or dir()" for name in self.__implements__ + self.__imports__: if name in self.stdlib_all: continue if name in COULD_BE_MISSING.get(self.stdlib_name, ()): continue if name in dir(self.stdlib_module): # like thread._local which is not in thread.__all__ continue raise AssertionError('%r is not found in %r.__all__ nor in dir(%r)' % (name, self.stdlib_module, self.stdlib_module)) def check_implements_actually_implements(self): """Check that the module actually implements the entries from __implements__""" for name in self.__implements__: item = getattr(self.module, name) try: stdlib_item = getattr(self.stdlib_module, name) assert item is not stdlib_item, (name, item, stdlib_item) except AttributeError: if name not in COULD_BE_MISSING.get(self.stdlib_name, []): raise def check_imports_actually_imports(self): """Check that the module actually imports the entries from __imports__""" for name in self.__imports__: item = getattr(self.module, name) stdlib_item = getattr(self.stdlib_module, name) assert item is stdlib_item, (name, item, stdlib_item) def check_extensions_actually_extend(self): """Check that the module actually defines new entries in __extensions__""" if self.modname in EXTRA_EXTENSIONS: return for name in self.__extensions__: if hasattr(self.stdlib_module, name): raise AssertionError("'%r' is not an extension, it is found in %r" % (name, self.stdlib_module)) def check_completeness(self): """Check that __all__ (or dir()) of the corresponsing stdlib is a subset of __all__ of this module""" missed = [] for name in self.stdlib_all: if name not in getattr(self.module, '__all__', []): missed.append(name) # handle stuff like ssl.socket and ssl.socket_error which have no reason to be in gevent.ssl.__all__ if not self.stdlib_has_all: for name in missed[:]: if hasattr(self.module, name): missed.remove(name) # remove known misses not_implemented = NOT_IMPLEMENTED.get(self.stdlib_name) if not_implemented is not None: result = [] for name in missed[:]: if name in not_implemented: print('IncompleteImplWarning: %s.%s' % (self.modname, name)) else: result.append(name) missed = result if missed: if self.stdlib_has_all: msg = '''The following items in %r.__all__ are missing from %r: %r''' % (self.stdlib_module, self.module, missed) else: msg = '''The following items in dir(%r) are missing from %r: %r''' % (self.stdlib_module, self.module, missed) raise AssertionError(msg) def _test(self, modname): for x in PLATFORM_SPECIFIC_SUFFIXES: if modname.endswith(x): return self.modname = modname six.exec_("import %s" % modname, {}) self.module = sys.modules[modname] self.check_all() self.__implements__ = getattr(self.module, '__implements__', None) self.__imports__ = getattr(self.module, '__imports__', []) self.__extensions__ = getattr(self.module, '__extensions__', []) self.stdlib_name = MAPPING.get(modname) self.stdlib_module = None if self.stdlib_name is not None: try: self.stdlib_module = __import__(self.stdlib_name) except ImportError: pass self.check_implements_presence_justified() if self.stdlib_module is None: return # use __all__ as __implements__ if self.__implements__ is None: self.__implements__ = sorted(self.module.__all__) self.set_stdlib_all() self.check_implements_subset_of_stdlib_all() self.check_implements_actually_implements() self.check_imports_actually_imports() self.check_extensions_actually_extend() self.check_completeness() for path, modname in walk_modules(include_so=True): modname = modname.replace('gevent.', '').split('.')[0] exec('''def test_%s(self): self._test("gevent.%s")''' % (modname, modname)) del path, modname if __name__ == "__main__": unittest.main() gevent-1.1.0/greentest/test__api.py0000644000076500000000000001024312666555342020060 0ustar jmaddenwheel00000000000000# Copyright (c) 2008 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import greentest import gevent from gevent import util, socket DELAY = 0.1 class Test(greentest.TestCase): @greentest.skipOnAppVeyor("Timing causes the state to often be [start,finished]") def test_killing_dormant(self): state = [] def test(): try: state.append('start') gevent.sleep(DELAY * 3.0) except: state.append('except') # catching GreenletExit pass state.append('finished') g = gevent.spawn(test) gevent.sleep(DELAY / 2) assert state == ['start'], state g.kill() # will not get there, unless switching is explicitly scheduled by kill self.assertEqual(state, ['start', 'except', 'finished']) def test_nested_with_timeout(self): def func(): return gevent.with_timeout(0.2, gevent.sleep, 2, timeout_value=1) self.assertRaises(gevent.Timeout, gevent.with_timeout, 0.1, func) def test_sleep_invalid_switch(self): p = gevent.spawn(util.wrap_errors(AssertionError, gevent.sleep), 2) gevent.sleep(0) # wait for p to start, because actual order of switching is reversed switcher = gevent.spawn(p.switch, None) result = p.get() assert isinstance(result, AssertionError), result assert 'Invalid switch' in str(result), repr(str(result)) switcher.kill() if hasattr(socket, 'socketpair'): def _test_wait_read_invalid_switch(self, sleep): sock1, sock2 = socket.socketpair() try: p = gevent.spawn(util.wrap_errors(AssertionError, socket.wait_read), sock1.fileno()) gevent.get_hub().loop.run_callback(switch_None, p) if sleep is not None: gevent.sleep(sleep) result = p.get() assert isinstance(result, AssertionError), result assert 'Invalid switch' in str(result), repr(str(result)) finally: sock1.close() sock2.close() def test_invalid_switch_None(self): self._test_wait_read_invalid_switch(None) def test_invalid_switch_0(self): self._test_wait_read_invalid_switch(0) def test_invalid_switch_1(self): self._test_wait_read_invalid_switch(0.001) # we don't test wait_write the same way, because socket is always ready to write def switch_None(g): g.switch(None) class TestTimers(greentest.TestCase): def test_timer_fired(self): lst = [1] def func(): gevent.spawn_later(0.01, lst.pop) gevent.sleep(0.02) gevent.spawn(func) assert lst == [1], lst gevent.sleep(0.03) assert lst == [], lst def test_spawn_is_not_cancelled(self): lst = [1] def func(): gevent.spawn(lst.pop) # exiting immediatelly, but self.lst.pop must be called gevent.spawn(func) gevent.sleep(0.01) assert lst == [], lst if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__api_timeout.py0000644000076500000000000001106412666555342021630 0ustar jmaddenwheel00000000000000# Copyright (c) 2008 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import sys import greentest import weakref import time import gc from gevent import sleep, Timeout DELAY = 0.04 class Error(Exception): pass class Test(greentest.TestCase): @greentest.skipOnAppVeyor("Timing is flaky, especially under Py 3.4/64-bit") def test_api(self): # Nothing happens if with-block finishes before the timeout expires t = Timeout(DELAY * 2) assert not t.pending, repr(t) with t: assert t.pending, repr(t) sleep(DELAY) # check if timer was actually cancelled assert not t.pending, repr(t) sleep(DELAY * 2) # An exception will be raised if it's not try: with Timeout(DELAY) as t: sleep(DELAY * 10) except Timeout as ex: assert ex is t, (ex, t) else: raise AssertionError('must raise Timeout') # You can customize the exception raised: try: with Timeout(DELAY, IOError("Operation takes way too long")): sleep(DELAY * 10) except IOError as ex: assert str(ex) == "Operation takes way too long", repr(ex) # Providing classes instead of values should be possible too: try: with Timeout(DELAY, ValueError): sleep(DELAY * 10) except ValueError: pass try: 1 / 0 except: try: with Timeout(DELAY, sys.exc_info()[0]): sleep(DELAY * 10) raise AssertionError('should not get there') raise AssertionError('should not get there') except ZeroDivisionError: pass else: raise AssertionError('should not get there') # It's possible to cancel the timer inside the block: with Timeout(DELAY) as timer: timer.cancel() sleep(DELAY * 2) # To silent the exception before exiting the block, pass False as second parameter. XDELAY = 0.1 start = time.time() with Timeout(XDELAY, False): sleep(XDELAY * 2) delta = (time.time() - start) self.assertTimeWithinRange(delta, 0, XDELAY * 2) # passing None as seconds disables the timer with Timeout(None): sleep(DELAY) sleep(DELAY) def test_ref(self): err = Error() err_ref = weakref.ref(err) with Timeout(DELAY * 2, err): sleep(DELAY) del err gc.collect() assert not err_ref(), repr(err_ref()) def test_nested_timeout(self): with Timeout(DELAY, False): with Timeout(DELAY * 10, False): sleep(DELAY * 3 * 20) raise AssertionError('should not get there') with Timeout(DELAY) as t1: with Timeout(DELAY * 20) as t2: try: sleep(DELAY * 30) except Timeout as ex: assert ex is t1, (ex, t1) assert not t1.pending, t1 assert t2.pending, t2 assert not t2.pending, t2 with Timeout(DELAY * 20) as t1: with Timeout(DELAY) as t2: try: sleep(DELAY * 30) except Timeout as ex: assert ex is t2, (ex, t2) assert t1.pending, t1 assert not t2.pending, t2 assert not t1.pending, t1 if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__ares_host_result.py0000644000076500000000000000136712666555342022703 0ustar jmaddenwheel00000000000000from __future__ import print_function import pickle import sys import greentest try: from gevent.ares import ares_host_result except ImportError as ex: print(ex) sys.exit(0) class TestPickle(greentest.TestCase): # Issue 104: ares.ares_host_result unpickleable def _test(self, protocol): r = ares_host_result('family', ('arg1', 'arg2', )) dumped = pickle.dumps(r, protocol) loaded = pickle.loads(dumped) assert r == loaded, (r, loaded) assert r.family == loaded.family, (r, loaded) for i in range(0, pickle.HIGHEST_PROTOCOL): def make_test(j): return lambda self: self._test(j) setattr(TestPickle, 'test' + str(i), make_test(i)) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__backdoor.py0000644000076500000000000000632112666555342021075 0ustar jmaddenwheel00000000000000import greentest import gevent from gevent import socket from gevent import backdoor from six import xrange def read_until(conn, postfix): read = b'' if isinstance(postfix, str) and str != bytes: postfix = postfix.encode('utf-8') while not read.endswith(postfix): result = conn.recv(1) if not result: raise AssertionError('Connection ended before %r. Data read:\n%r' % (postfix, read)) read += result if str != bytes: read = read.decode('utf-8') return read def create_connection(address): conn = socket.socket() conn.connect(address) return conn def readline(conn): f = conn.makefile() line = f.readline() f.close() return line class Test(greentest.TestCase): def test(self): server = backdoor.BackdoorServer(('127.0.0.1', 0)) server.start() def connect(): conn = create_connection(('127.0.0.1', server.server_port)) try: read_until(conn, '>>> ') conn.sendall(b'2+2\r\n') line = readline(conn) self.assertEqual(line.strip(), '4', repr(line)) finally: conn.close() try: jobs = [gevent.spawn(connect) for _ in xrange(10)] gevent.joinall(jobs, raise_error=True) finally: server.close() #self.assertEqual(conn.recv(1), '') def test_quit(self): server = backdoor.BackdoorServer(('127.0.0.1', 0)) server.start() try: conn = create_connection(('127.0.0.1', server.server_port)) read_until(conn, '>>> ') conn.sendall(b'quit()\r\n') line = readline(conn) self.assertEqual(line, '') finally: conn.close() server.stop() def test_sys_exit(self): server = backdoor.BackdoorServer(('127.0.0.1', 0)) server.start() try: conn = create_connection(('127.0.0.1', server.server_port)) read_until(conn, b'>>> ') conn.sendall(b'import sys; sys.exit(0)\r\n') line = readline(conn) self.assertEqual(line, '') finally: conn.close() server.stop() def test_banner(self): banner = "Welcome stranger!" # native string server = backdoor.BackdoorServer(('127.0.0.1', 0), banner=banner) server.start() try: conn = create_connection(('127.0.0.1', server.server_port)) response = read_until(conn, b'>>> ') self.assertEqual(response[:len(banner)], banner, response) conn.close() finally: server.stop() def test_builtins(self): server = backdoor.BackdoorServer(('127.0.0.1', 0)) server.start() try: conn = create_connection(('127.0.0.1', server.server_port)) read_until(conn, b'>>> ') conn.sendall(b'locals()["__builtins__"]\r\n') response = read_until(conn, '>>> ') self.assertTrue(len(response) < 300, msg="locals() unusable: %s..." % response) finally: conn.close() server.stop() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__core.py0000644000076500000000000000447112666555342020245 0ustar jmaddenwheel00000000000000import sys from greentest import TestCase, main from gevent import core class Test(TestCase): switch_expected = False __timeout__ = None def test_get_version(self): version = core.get_version() assert isinstance(version, str), repr(version) assert version, repr(version) header_version = core.get_header_version() assert isinstance(header_version, str), repr(header_version) assert header_version, repr(header_version) self.assertEqual(version, header_version) def test_flags_conversion(self): if sys.platform != 'win32': self.assertEqual(core.loop(2, default=False).backend_int, 2) self.assertEqual(core.loop('select', default=False).backend, 'select') self.assertEqual(core._flags_to_int(None), 0) self.assertEqual(core._flags_to_int(['kqueue', 'SELECT']), core.BACKEND_KQUEUE | core.BACKEND_SELECT) self.assertEqual(core._flags_to_list(core.BACKEND_PORT | core.BACKEND_POLL), ['port', 'poll']) self.assertRaises(ValueError, core.loop, ['port', 'blabla']) self.assertRaises(TypeError, core.loop, object()) def test_events_conversion(self): self.assertEqual(core._events_to_str(core.READ | core.WRITE), 'READ|WRITE') def test_EVENTS(self): self.assertEqual(str(core.EVENTS), 'gevent.core.EVENTS') self.assertEqual(repr(core.EVENTS), 'gevent.core.EVENTS') def test_io(self): if sys.platform == 'win32': Error = IOError win32 = True else: Error = ValueError win32 = False self.assertRaises(Error, core.loop().io, -1, 1) self.assertRaises(ValueError, core.loop().io, 1, core.TIMER) # Test we can set events and io before it's started if not win32: # We can't do this with arbitrary FDs on windows; # see libev_vfd.h io = core.loop().io(1, core.READ) io.fd = 2 self.assertEqual(io.fd, 2) io.events = core.WRITE self.assertEqual(core._events_to_str(io.events), 'WRITE|_IOFDSET') def test_timer(self): self.assertRaises(ValueError, core.loop().timer, 1, -1) def test_signal(self): self.assertRaises(ValueError, core.loop().signal, 1000) if __name__ == '__main__': main() gevent-1.1.0/greentest/test__core_async.py0000644000076500000000000000071512666555342021437 0ustar jmaddenwheel00000000000000from __future__ import print_function import gevent import gevent.core import time try: import thread except ImportError: import _thread as thread hub = gevent.get_hub() watcher = hub.loop.async() gevent.spawn_later(0.1, thread.start_new_thread, watcher.send, ()) start = time.time() with gevent.Timeout(1.0): # Large timeout for appveyor hub.wait(watcher) print('Watcher %r reacted after %.6f seconds' % (watcher, time.time() - start - 0.1)) gevent-1.1.0/greentest/test__core_callback.py0000644000076500000000000000072712666555342022061 0ustar jmaddenwheel00000000000000import gevent from gevent.hub import get_hub called = [] def f(): called.append(1) def main(): loop = get_hub().loop x = loop.run_callback(f) assert x, x gevent.sleep(0) assert called == [1], called assert not x, (x, bool(x)) x = loop.run_callback(f) assert x, x x.stop() assert not x, x gevent.sleep(0) assert called == [1], called assert not x, x if __name__ == '__main__': called[:] = [] main() gevent-1.1.0/greentest/test__core_fork.py0000644000076500000000000000252512666555342021264 0ustar jmaddenwheel00000000000000from __future__ import print_function import gevent.monkey; gevent.monkey.patch_all() import gevent import os import multiprocessing hub = gevent.get_hub() pid = os.getpid() newpid = None def on_fork(): global newpid newpid = os.getpid() fork_watcher = hub.loop.fork(ref=False) fork_watcher.start(on_fork) def run(q): # libev only calls fork callbacks at the beginning of # the loop; we use callbacks extensively so it takes *two* # calls to sleep (with a timer) to actually get wrapped # around to the beginning of the loop. gevent.sleep(0.01) gevent.sleep(0.01) q.put(newpid) def test(): # Use a thread to make us multi-threaded hub.threadpool.apply(lambda: None) # If the Queue is global, q.get() hangs on Windows; must pass as # an argument. q = multiprocessing.Queue() p = multiprocessing.Process(target=run, args=(q,)) p.start() p.join() p_val = q.get() assert p_val is not None, "The fork watcher didn't run" assert p_val != pid if __name__ == '__main__': # Must call for Windows to fork properly; the fork can't be in the top-level multiprocessing.freeze_support() # fork watchers weren't firing in multi-threading processes. # This test is designed to prove that they are. # However, it fails on Windows: The fork watcher never runs! test() gevent-1.1.0/greentest/test__core_loop_run.py0000644000076500000000000000116512666555342022157 0ustar jmaddenwheel00000000000000from __future__ import print_function import sys # Using a direct import of signal (deprecated). # We are also called from test__core_loop_run_sig_mod.py, # which has already done 'import gevent.signal' to be sure we work # when the module has been imported. from gevent import core, signal loop = core.loop() signal = signal(2, sys.stderr.write, 'INTERRUPT!') print('must exit immediatelly...') loop.run() # must exit immediatelly print('...and once more...') loop.run() # repeating does not fail print('..done') print('must exit after 0.5 seconds.') timer = loop.timer(0.5) timer.start(lambda: None) loop.run() del loop gevent-1.1.0/greentest/test__core_loop_run_sig_mod.py0000644000076500000000000000103712666555342023656 0ustar jmaddenwheel00000000000000import sys import gevent.signal assert gevent.signal # Get gevent.signal as a module, make sure our backwards compatibility kicks in import test__core_loop_run # this runs main tests, fails if signal() is not callable. assert test__core_loop_run # pyflakes from gevent.hub import signal as hub_signal from gevent import signal assert gevent.signal is hub_signal assert gevent.signal is signal assert hasattr(gevent.signal, 'signal') s = signal(2, sys.stderr.write, 'INTERRUPT') assert isinstance(s, signal) assert isinstance(s, hub_signal) gevent-1.1.0/greentest/test__core_stat.py0000644000076500000000000000605312666555342021276 0ustar jmaddenwheel00000000000000from __future__ import print_function import gevent import gevent.core import os import sys import time #pylint: disable=protected-access filename = 'tmp.test__core_stat.%s' % os.getpid() hub = gevent.get_hub() DELAY = 0.5 EV_USE_INOTIFY = getattr(gevent.core, 'EV_USE_INOTIFY', None) WIN = sys.platform.startswith('win') try: open(filename, 'wb', buffering=0).close() assert os.path.exists(filename), filename def write(): with open(filename, 'wb', buffering=0) as f: f.write(b'x') start = time.time() greenlet = gevent.spawn_later(DELAY, write) # If we don't specify an interval, we default to zero. # libev interprets that as meaning to use its default interval, # which is about 5 seconds. If we go below it's minimum check # threshold, it bumps it up to the minimum. watcher = hub.loop.stat(filename, interval=-1) assert watcher.path == filename, (watcher.path, filename) filenames = filename if isinstance(filename, bytes) else filename.encode('ascii') assert watcher._paths == filenames, (watcher._paths, filenames) assert watcher.interval == -1 def check_attr(name, none): # Deals with the complex behaviour of the 'attr' and 'prev' # attributes on Windows. This codifies it, rather than simply letting # the test fail, so we know exactly when and what changes it. try: x = getattr(watcher, name) except ImportError: if WIN: # the 'posix' module is not available pass else: raise else: if WIN: # The ImportError is only raised for the first time; # after that, the attribute starts returning None assert x is None, "Only None is supported on Windows" if none: assert x is None, x else: assert x is not None, x with gevent.Timeout(5 + DELAY + 0.5): hub.wait(watcher) reaction = time.time() - start - DELAY print('Watcher %s reacted after %.4f seconds (write)' % (watcher, reaction)) if reaction >= DELAY and EV_USE_INOTIFY: print('WARNING: inotify failed (write)') assert reaction >= 0.0, 'Watcher %s reacted too early (write): %.3fs' % (watcher, reaction) check_attr('attr', False) check_attr('prev', False) # The watcher interval changed after it started; -1 is illegal assert watcher.interval != -1 greenlet.join() gevent.spawn_later(DELAY, os.unlink, filename) start = time.time() with gevent.Timeout(5 + DELAY + 0.5): hub.wait(watcher) reaction = time.time() - start - DELAY print('Watcher %s reacted after %.4f seconds (unlink)' % (watcher, reaction)) if reaction >= DELAY and EV_USE_INOTIFY: print('WARNING: inotify failed (unlink)') assert reaction >= 0.0, 'Watcher %s reacted too early (unlink): %.3fs' % (watcher, reaction) check_attr('attr', True) check_attr('prev', False) finally: if os.path.exists(filename): os.unlink(filename) gevent-1.1.0/greentest/test__core_timer.py0000644000076500000000000000272212666555342021442 0ustar jmaddenwheel00000000000000from __future__ import print_function from gevent import core called = [] def f(x=None): called.append(1) if x is not None: x.stop() def main(): loop = core.loop(default=True) x = loop.timer(0.001) x.start(f) if hasattr(loop, '_keepaliveset'): assert x in loop._keepaliveset assert x.active, x.pending try: x.priority = 1 raise AssertionError('must not be able to change priority of active watcher') except AttributeError: pass loop.run() assert x.pending == 0, x.pending assert called == [1], called assert x.callback is None, x.callback assert x.args is None, x.args assert x.priority == 0, x x.priority = 1 assert x.priority == 1, x x.stop() if hasattr(loop, '_keepaliveset'): assert x not in loop._keepaliveset # Again works for a new timer x = loop.timer(0.001, repeat=1) x.again(f, x) if hasattr(loop, '_keepaliveset'): assert x in loop._keepaliveset assert x.args == (x,), x.args loop.run() assert called == [1, 1], called x.stop() if hasattr(loop, '_keepaliveset'): assert x not in loop._keepaliveset if __name__ == '__main__': import sys gettotalrefcount = getattr(sys, 'gettotalrefcount', None) called[:] = [] if gettotalrefcount is not None: print(gettotalrefcount()) main() called[:] = [] if gettotalrefcount is not None: print(gettotalrefcount()) gevent-1.1.0/greentest/test__core_watcher.py0000644000076500000000000000334112666555342021755 0ustar jmaddenwheel00000000000000import greentest from gevent import core class Test(greentest.TestCase): __timeout__ = None def test_types(self): loop = core.loop() lst = [] io = loop.timer(0.01) # test that cannot pass non-callable thing to start() self.assertRaises(TypeError, io.start, None) self.assertRaises(TypeError, io.start, 5) # test that cannot set 'callback' to non-callable thing later either io.start(lambda *args: lst.append(args)) self.assertEqual(io.args, ()) try: io.callback = False raise AssertionError('"io.callback = False" must raise TypeError') except TypeError: pass try: io.callback = 5 raise AssertionError('"io.callback = 5" must raise TypeError') except TypeError: pass # test that args can be changed later io.args = (1, 2, 3) # test that only tuple and None are accepted by 'args' attribute self.assertRaises(TypeError, setattr, io, 'args', 5) self.assertEqual(io.args, (1, 2, 3)) self.assertRaises(TypeError, setattr, io, 'args', [4, 5]) self.assertEqual(io.args, (1, 2, 3)) # None also works, means empty tuple # XXX why? io.args = None self.assertEqual(io.args, None) start = core.time() loop.run() took = core.time() - start self.assertEqual(lst, [()]) assert took < 1, took io.start(reset, io, lst) del io loop.run() self.assertEqual(lst, [(), 25]) def reset(watcher, lst): watcher.args = None watcher.callback = lambda: None lst.append(25) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__destroy.py0000644000076500000000000000217312666555342021003 0ustar jmaddenwheel00000000000000import gevent # Loop of initial Hub is default loop. hub = gevent.get_hub() assert hub.loop.default, hub # Save `gevent.core.loop` object for later comparison. initloop = hub.loop # Increase test complexity via threadpool creation. # Implicitly creates fork watcher connected to the current event loop. tp = hub.threadpool # Destroy hub. Does not destroy libev default loop if not explicitly told to. hub.destroy() # Create new hub. Must re-use existing libev default loop. hub = gevent.get_hub() assert hub.loop.default, hub # Ensure that loop object is identical to the initial one. assert hub.loop is initloop # Destroy hub including default loop. hub.destroy(destroy_loop=True) # Create new hub and explicitly request creation of a new default loop. hub = gevent.get_hub(default=True) assert hub.loop.default, hub # `gevent.core.loop` objects as well as libev loop pointers must differ. assert hub.loop is not initloop assert hub.loop.ptr != initloop.ptr # Destroy hub including default loop, create new hub with non-default loop. hub.destroy(destroy_loop=True) hub = gevent.get_hub() assert not hub.loop.default, hub hub.destroy() gevent-1.1.0/greentest/test__doctests.py0000644000076500000000000000551212666555342021142 0ustar jmaddenwheel00000000000000from __future__ import print_function import doctest import functools import os import re import sys import traceback import unittest import gevent from gevent import socket from greentest import walk_modules # Ignore tracebacks: ZeroDivisionError def myfunction(*args, **kwargs): pass class RENormalizingOutputChecker(doctest.OutputChecker): """ Pattern-normalizing output checker. Inspired by one used in zope.testing. """ def __init__(self, patterns): self.transformers = [functools.partial(re.sub, replacement) for re, replacement in patterns] def check_output(self, want, got, optionflags): if got == want: return True for transformer in self.transformers: want = transformer(want) got = transformer(got) return doctest.OutputChecker.check_output(self, want, got, optionflags) if __name__ == '__main__': cwd = os.getcwd() try: allowed_modules = sys.argv[1:] sys.path.append('.') base = os.path.dirname(gevent.__file__) print(base) os.chdir('..') globs = {'myfunction': myfunction, 'gevent': gevent, 'socket': socket} modules = set() def add_module(name, path): if allowed_modules and name not in allowed_modules: return modules.add((name, path)) for path, module in walk_modules(): add_module(module, path) add_module('setup', 'setup.py') if not modules: sys.exit('No modules found matching %s' % ' '.join(allowed_modules)) suite = unittest.TestSuite() checker = RENormalizingOutputChecker(( # Normalize subprocess.py: BSD ls is in the example, gnu ls outputs # 'cannot access' (re.compile('cannot access non_existent_file: No such file or directory'), 'non_existent_file: No such file or directory'), )) tests_count = 0 modules_count = 0 for m, path in sorted(modules): with open(path, 'rb') as f: contents = f.read() if re.search(br'^\s*>>> ', contents, re.M): try: s = doctest.DocTestSuite(m, extraglobs=globs, checker=checker) test_count = len(s._tests) # pylint: disable=W0212 print('%s (from %s): %s tests' % (m, path, test_count)) suite.addTest(s) modules_count += 1 tests_count += test_count except Exception: traceback.print_exc() sys.stderr.write('Failed to process %s\n\n' % path) print('Total: %s tests in %s modules' % (tests_count, modules_count)) runner = unittest.TextTestRunner(verbosity=2) runner.run(suite) finally: os.chdir(cwd) gevent-1.1.0/greentest/test__environ.py0000644000076500000000000000050712666555342020771 0ustar jmaddenwheel00000000000000import os import sys import gevent import subprocess if sys.argv[1:] == []: os.environ['GEVENT_BACKEND'] = 'select' popen = subprocess.Popen([sys.executable, 'test__environ.py', '1']) assert popen.wait() == 0, popen.poll() else: hub = gevent.get_hub() assert hub.loop.backend == 'select', hub.loop.backend gevent-1.1.0/greentest/test__event.py0000644000076500000000000001206212666555342020431 0ustar jmaddenwheel00000000000000import greentest import gevent from gevent.event import Event, AsyncResult from six import xrange DELAY = 0.01 class TestEventWait(greentest.GenericWaitTestCase): def wait(self, timeout): Event().wait(timeout=timeout) def test_cover(self): str(Event()) class TestWaitEvent(greentest.GenericWaitTestCase): def wait(self, timeout): gevent.wait([Event()], timeout=timeout) class TestAsyncResultWait(greentest.GenericWaitTestCase): def wait(self, timeout): AsyncResult().wait(timeout=timeout) class TestWaitAsyncResult(greentest.GenericWaitTestCase): def wait(self, timeout): gevent.wait([AsyncResult()], timeout=timeout) class TestAsyncResultGet(greentest.GenericGetTestCase): def wait(self, timeout): AsyncResult().get(timeout=timeout) class TestAsyncResult(greentest.TestCase): def test_link(self): ar = AsyncResult() self.assertRaises(TypeError, ar.rawlink, None) ar.unlink(None) # doesn't raise ar.unlink(None) # doesn't raise str(ar) # cover def test_set_exc(self): log = [] e = AsyncResult() self.assertEqual(e.exc_info, ()) self.assertEqual(e.exception, None) def waiter(): try: result = e.get() log.append(('received', result)) except Exception as ex: log.append(('catched', ex)) gevent.spawn(waiter) obj = Exception() e.set_exception(obj) gevent.sleep(0) assert log == [('catched', obj)], log def test_set(self): event1 = AsyncResult() event2 = AsyncResult() g = gevent.spawn_later(DELAY / 2.0, event1.set, 'hello event1') t = gevent.Timeout.start_new(0, ValueError('interrupted')) try: try: result = event1.get() except ValueError: X = object() result = gevent.with_timeout(DELAY, event2.get, timeout_value=X) assert result is X, 'Nobody sent anything to event2 yet it received %r' % (result, ) finally: t.cancel() g.kill() def test_nonblocking_get(self): ar = AsyncResult() self.assertRaises(gevent.Timeout, ar.get, block=False) self.assertRaises(gevent.Timeout, ar.get_nowait) class TestAsyncResultAsLinkTarget(greentest.TestCase): error_fatal = False def test_set(self): g = gevent.spawn(lambda: 1) s1, s2, s3 = AsyncResult(), AsyncResult(), AsyncResult() g.link(s1) g.link_value(s2) g.link_exception(s3) assert s1.get() == 1 assert s2.get() == 1 assert gevent.with_timeout(DELAY, s3.get, timeout_value=X) is X def test_set_exception(self): def func(): raise greentest.ExpectedException('TestAsyncResultAsLinkTarget.test_set_exception') g = gevent.spawn(func) s1, s2, s3 = AsyncResult(), AsyncResult(), AsyncResult() g.link(s1) g.link_value(s2) g.link_exception(s3) self.assertRaises(greentest.ExpectedException, s1.get) assert gevent.with_timeout(DELAY, s2.get, timeout_value=X) is X self.assertRaises(greentest.ExpectedException, s3.get) class TestEvent_SetThenClear(greentest.TestCase): N = 1 def test(self): e = Event() waiters = [gevent.spawn(e.wait) for i in range(self.N)] gevent.sleep(0.001) e.set() e.clear() for t in waiters: t.join() class TestEvent_SetThenClear100(TestEvent_SetThenClear): N = 100 class TestEvent_SetThenClear1000(TestEvent_SetThenClear): N = 1000 class TestWait(greentest.TestCase): N = 5 count = None timeout = 1 period = timeout / 100.0 def _sender(self, events, asyncs): while events or asyncs: gevent.sleep(self.period) if events: events.pop().set() gevent.sleep(self.period) if asyncs: asyncs.pop().set() @greentest.skipOnAppVeyor("Not all results have arrived sometimes due to timer issues") def test(self): events = [Event() for _ in xrange(self.N)] asyncs = [AsyncResult() for _ in xrange(self.N)] max_len = len(events) + len(asyncs) sender = gevent.spawn(self._sender, events, asyncs) results = gevent.wait(events + asyncs, count=self.count, timeout=self.timeout) if self.timeout is None: expected_len = max_len else: expected_len = min(max_len, self.timeout / self.period) if self.count is None: assert sender.ready() else: expected_len = min(self.count, expected_len) assert not sender.ready() sender.kill() self.assertEqual(expected_len, len(results), (expected_len, len(results), results)) class TestWait_notimeout(TestWait): timeout = None class TestWait_count1(TestWait): count = 1 class TestWait_count2(TestWait): count = 2 X = object() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__example_echoserver.py0000644000076500000000000000215112666555342023166 0ustar jmaddenwheel00000000000000from gevent.socket import create_connection, timeout import greentest import gevent import util class Test(util.TestServer): server = 'echoserver.py' def _run_all_tests(self): def test_client(message): if greentest.PY3: kwargs = {'buffering': 1} else: kwargs = {'bufsize': 1} kwargs['mode'] = 'rb' conn = create_connection(('127.0.0.1', 16000)) conn.settimeout(0.1 if not greentest.RUNNING_ON_APPVEYOR else 2.0) rfile = conn.makefile(**kwargs) welcome = rfile.readline() assert b'Welcome' in welcome, repr(welcome) conn.sendall(message) received = rfile.read(len(message)) self.assertEqual(received, message) self.assertRaises(timeout, conn.recv, 1) rfile.close() conn.close() client1 = gevent.spawn(test_client, b'hello\r\n') client2 = gevent.spawn(test_client, b'world\r\n') gevent.joinall([client1, client2], raise_error=True) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__example_portforwarder.py0000644000076500000000000000365612666555342023734 0ustar jmaddenwheel00000000000000from __future__ import print_function from gevent import monkey; monkey.patch_all(subprocess=True) import signal import sys import socket from time import sleep import gevent from gevent.server import StreamServer import util class Test(util.TestServer): server = 'portforwarder.py' args = ['127.0.0.1:10011', '127.0.0.1:10012'] if sys.platform.startswith('win'): from subprocess import CREATE_NEW_PROCESS_GROUP # Must be in a new process group to use CTRL_C_EVENT, otherwise # we get killed too start_kwargs = {'creationflags': CREATE_NEW_PROCESS_GROUP} def after(self): if sys.platform == 'win32': assert self.popen.poll() is not None else: self.assertEqual(self.popen.poll(), 0) def _run_all_tests(self): log = [] def handle(socket, address): while True: data = socket.recv(1024) print('got %r' % data) if not data: break log.append(data) server = StreamServer(self.args[1], handle) server.start() try: conn = socket.create_connection(('127.0.0.1', 10011)) conn.sendall(b'msg1') sleep(0.1) # On Windows, SIGTERM actually abruptly terminates the process; # it can't be caught. However, CTRL_C_EVENT results in a KeyboardInterrupt # being raised, so we can shut down properly. self.popen.send_signal(getattr(signal, 'CTRL_C_EVENT') if hasattr(signal, 'CTRL_C_EVENT') else signal.SIGTERM) sleep(0.1) conn.sendall(b'msg2') conn.close() with gevent.Timeout(2.1): self.popen.wait() finally: server.close() self.assertEqual([b'msg1', b'msg2'], log) if __name__ == '__main__': from unittest import main main() gevent-1.1.0/greentest/test__example_udp_client.py0000644000076500000000000000130612666555342023150 0ustar jmaddenwheel00000000000000from gevent import monkey; monkey.patch_all(subprocess=True) import sys from gevent.server import DatagramServer from unittest import TestCase, main from util import run class Test_udp_client(TestCase): def test(self): log = [] def handle(message, address): log.append(message) server.sendto(b'reply-from-server', address) server = DatagramServer('127.0.0.1:9000', handle) server.start() try: run([sys.executable, '-u', 'udp_client.py', 'Test_udp_client'], timeout=10, cwd='../examples/') finally: server.close() self.assertEqual(log, [b'Test_udp_client']) if __name__ == '__main__': main() gevent-1.1.0/greentest/test__example_udp_server.py0000644000076500000000000000066212666555342023204 0ustar jmaddenwheel00000000000000import socket from unittest import main import util class Test(util.TestServer): server = 'udp_server.py' def _run_all_tests(self): sock = socket.socket(type=socket.SOCK_DGRAM) sock.connect(('127.0.0.1', 9000)) sock.send(b'Test udp_server') data, address = sock.recvfrom(8192) self.assertEqual(data, b'Received 15 bytes') sock.close() if __name__ == '__main__': main() gevent-1.1.0/greentest/test__examples.py0000644000076500000000000000257112666555342021132 0ustar jmaddenwheel00000000000000import sys import os import glob import time import util cwd = '../examples/' ignore = ['wsgiserver.py', 'wsgiserver_ssl.py', 'webproxy.py', 'webpy.py', 'unixsocket_server.py', 'unixsocket_client.py', 'psycopg2_pool.py', 'geventsendfile.py'] ignore += [x[14:] for x in glob.glob('test__example_*.py')] default_time_range = (2, 4) time_ranges = { 'concurrent_download.py': (0, 30), 'processes.py': (0, 4)} def main(tests=None): if not tests: tests = set(os.path.basename(x) for x in glob.glob('../examples/*.py')) tests = sorted(tests) failed = [] for filename in tests: if filename in ignore: continue min_time, max_time = time_ranges.get(filename, default_time_range) start = time.time() if util.run([sys.executable, '-u', filename], timeout=max_time, cwd=cwd): failed.append(filename) else: took = time.time() - start if took < min_time: util.log('! Failed example %s: exited too quickly, after %.1fs (expected %.1fs)', filename, took, min_time) failed.append(filename) if failed: util.log('! Failed examples:\n! - %s', '\n! - '.join(failed)) sys.exit(1) if not tests: sys.exit('No tests.') if __name__ == '__main__': main() gevent-1.1.0/greentest/test__exc_info.py0000644000076500000000000000221312666555342021077 0ustar jmaddenwheel00000000000000import gevent import sys import greentest import six if not six.PY3: sys.exc_clear() class ExpectedError(Exception): pass expected_error = ExpectedError('expected exception in hello') def hello(): assert sys.exc_info() == (None, None, None), sys.exc_info() raise expected_error def hello2(): try: hello() except ExpectedError: pass error = Exception('hello') class Test(greentest.TestCase): def test1(self): try: raise error except: self.expect_one_error() g = gevent.spawn(hello) g.join() self.assert_error(ExpectedError, expected_error) if not isinstance(g.exception, ExpectedError): raise g.exception try: raise except Exception: ex = sys.exc_info()[1] assert ex is error, (ex, error) def test2(self): timer = gevent.get_hub().loop.timer(0) timer.start(hello2) gevent.sleep(0.1) assert sys.exc_info() == (None, None, None), sys.exc_info() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__execmodules.py0000644000076500000000000000133612666555342021627 0ustar jmaddenwheel00000000000000from greentest import walk_modules, BaseTestCase, main, NON_APPLICABLE_SUFFIXES import six class TestExec(BaseTestCase): pass def make_exec_test(path, module): def test(self): #sys.stderr.write('%s %s\n' % (module, path)) with open(path, 'rb') as f: src = f.read() six.exec_(src, {'__file__': path}) name = "test_" + module.replace(".", "_") test.__name__ = name setattr(TestExec, name, test) for path, module in walk_modules(): ignored = False for x in NON_APPLICABLE_SUFFIXES: if module.endswith(x): ignored = True break if ignored: continue make_exec_test(path, module) if __name__ == '__main__': main() gevent-1.1.0/greentest/test__fileobject.py0000644000076500000000000000740212666555342021420 0ustar jmaddenwheel00000000000000from __future__ import print_function import os import sys import tempfile import gc import greentest import gevent from gevent.fileobject import FileObject, FileObjectThread PYPY = hasattr(sys, 'pypy_version_info') class Test(greentest.TestCase): def _test_del(self, **kwargs): pipe = os.pipe() try: self._do_test_del(pipe, **kwargs) finally: for f in pipe: try: os.close(f) except (IOError, OSError): pass def _do_test_del(self, pipe, **kwargs): r, w = pipe s = FileObject(w, 'wb', **kwargs) ts = type(s) s.write(b'x') try: s.flush() except IOError: # Sometimes seen on Windows/AppVeyor print("Failed flushing fileobject", repr(s), file=sys.stderr) import traceback traceback.print_exc() del s # Deliberately getting ResourceWarning with FileObject(Thread) under Py3 gc.collect() # PyPy if kwargs.get("close", True): try: os.close(w) except (OSError, IOError): pass # expected, because FileObject already closed it else: raise AssertionError('os.close(%r) must not succeed on %r' % (w, ts)) else: os.close(w) fobj = FileObject(r, 'rb') self.assertEqual(fobj.read(), b'x') fobj.close() def test_del(self): # Close should be true by default self._test_del() def test_del_close(self): self._test_del(close=True) if FileObject is not FileObjectThread: # FileObjectThread uses os.fdopen() when passed a file-descriptor, which returns # an object with a destructor that can't be bypassed, so we can't even # create one that way def test_del_noclose(self): self._test_del(close=False) else: def test_del_noclose(self): try: self._test_del(close=False) self.fail("Shouldn't be able to create a FileObjectThread with close=False") except TypeError as e: self.assertEqual(str(e), 'FileObjectThread does not support close=False') def test_newlines(self): r, w = os.pipe() lines = [b'line1\n', b'line2\r', b'line3\r\n', b'line4\r\nline5', b'\nline6'] g = gevent.spawn(writer, FileObject(w, 'wb'), lines) try: fobj = FileObject(r, 'rU') result = fobj.read() fobj.close() self.assertEqual('line1\nline2\nline3\nline4\nline5\nline6', result) finally: g.kill() def test_seek(self): fileno, path = tempfile.mkstemp() s = b'a' * 1024 os.write(fileno, b'B' * 15) os.write(fileno, s) os.close(fileno) try: with open(path, 'rb') as f: f.seek(15) native_data = f.read(1024) with open(path, 'rb') as f_raw: f = FileObject(f_raw, 'rb') if hasattr(f, 'seekable'): # Py3 self.assertTrue(f.seekable()) f.seek(15) self.assertEqual(15, f.tell()) fileobj_data = f.read(1024) self.assertEqual(native_data, s) self.assertEqual(native_data, fileobj_data) finally: os.remove(path) def test_close_pipe(self): # Issue #190, 203 r, w = os.pipe() x = FileObject(r) y = FileObject(w, 'w') x.close() y.close() def writer(fobj, line): for character in line: fobj.write(character) fobj.flush() fobj.close() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__getaddrinfo_import.py0000644000076500000000000000051612666555342023171 0ustar jmaddenwheel00000000000000# a deadlock is possible if we import a module that runs Gevent's getaddrinfo # with a unicode hostname, which starts Python's getaddrinfo on a thread, which # attempts to import encodings.idna but blocks on the import lock. verify # that Gevent avoids this deadlock. import getaddrinfo_module del getaddrinfo_module # fix pyflakes gevent-1.1.0/greentest/test__greenio.py0000644000076500000000000001020612666555342020736 0ustar jmaddenwheel00000000000000# Copyright (c) 2006-2007, Linden Research, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from greentest import TestCase, main, tcp_listener import gevent from gevent import socket import sys PYPY = hasattr(sys, 'pypy_version_info') PY3 = sys.version_info[0] >= 3 def _write_to_closed(f, s): try: r = f.write(s) except ValueError: assert PY3 else: assert r is None, r class TestGreenIo(TestCase): def test_close_with_makefile(self): def accept_close_early(listener): # verify that the makefile and the socket are truly independent # by closing the socket prior to using the made file try: conn, addr = listener.accept() fd = conn.makefile(mode='wb') conn.close() fd.write(b'hello\n') fd.close() _write_to_closed(fd, b'a') self.assertRaises(socket.error, conn.send, b'b') finally: listener.close() def accept_close_late(listener): # verify that the makefile and the socket are truly independent # by closing the made file and then sending a character try: conn, addr = listener.accept() fd = conn.makefile(mode='wb') fd.write(b'hello') fd.close() conn.send(b'\n') conn.close() _write_to_closed(fd, b'a') self.assertRaises(socket.error, conn.send, b'b') finally: listener.close() def did_it_work(server): client = socket.create_connection(('127.0.0.1', server.getsockname()[1])) fd = client.makefile(mode='rb') client.close() assert fd.readline() == b'hello\n' assert fd.read() == b'' fd.close() server = tcp_listener(('0.0.0.0', 0)) server_greenlet = gevent.spawn(accept_close_early, server) did_it_work(server) server_greenlet.kill() server = tcp_listener(('0.0.0.0', 0)) server_greenlet = gevent.spawn(accept_close_late, server) did_it_work(server) server_greenlet.kill() def test_del_closes_socket(self): if PYPY: return timer = gevent.Timeout.start_new(0.5) def accept_once(listener): # delete/overwrite the original conn # object, only keeping the file object around # closing the file object should close everything try: conn, addr = listener.accept() conn = conn.makefile(mode='wb') conn.write(b'hello\n') conn.close() _write_to_closed(conn, b'a') finally: listener.close() server = tcp_listener(('0.0.0.0', 0)) gevent.spawn(accept_once, server) client = socket.create_connection(('127.0.0.1', server.getsockname()[1])) fd = client.makefile() client.close() assert fd.read() == 'hello\n' assert fd.read() == '' timer.cancel() if __name__ == '__main__': main() gevent-1.1.0/greentest/test__greenlet.py0000644000076500000000000004772212666555342021130 0ustar jmaddenwheel00000000000000# Copyright (c) 2008-2009 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import sys import greentest import gevent import re from gevent import sleep, with_timeout, getcurrent from gevent import greenlet from gevent.event import AsyncResult from gevent.queue import Queue, Channel DELAY = 0.01 greentest.TestCase.error_fatal = False class ExpectedError(greentest.ExpectedException): pass class TestLink(greentest.TestCase): def assertRaises(self, err, func, *args, **kwargs): try: result = func(*args, **kwargs) except: ex = sys.exc_info()[1] if ex is err: return if isinstance(ex, err): return raise raise AssertionError('%s not raised, returned %r' % (err, result)) def test_link_to_asyncresult(self): p = gevent.spawn(lambda: 100) event = AsyncResult() p.link(event) self.assertEqual(event.get(), 100) for i in range(3): event2 = AsyncResult() p.link(event2) self.assertEqual(event2.get(), 100) def test_link_to_asyncresult_exception(self): err = ExpectedError('test_link_to_asyncresult_exception') p = gevent.spawn(lambda: getcurrent().throw(err)) event = AsyncResult() p.link(event) self.assertRaises(err, event.get) for i in range(3): event2 = AsyncResult() p.link(event2) self.assertRaises(err, event2.get) def test_link_to_queue(self): p = gevent.spawn(lambda: 100) q = Queue() p.link(q.put) self.assertEqual(q.get().get(), 100) for i in range(3): p.link(q.put) self.assertEqual(q.get().get(), 100) def test_link_to_channel(self): p1 = gevent.spawn(lambda: 101) p2 = gevent.spawn(lambda: 102) p3 = gevent.spawn(lambda: 103) q = Channel() p1.link(q.put) p2.link(q.put) p3.link(q.put) results = [q.get().get(), q.get().get(), q.get().get()] assert sorted(results) == [101, 102, 103], results class TestUnlink(greentest.TestCase): switch_expected = False def _test_func(self, p, link): link(dummy_test_func) assert len(p._links) == 1, p._links p.unlink(dummy_test_func) assert not p._links, p._links link(self.setUp) assert len(p._links) == 1, p._links p.unlink(self.setUp) assert not p._links, p._links p.kill() def test_func_link(self): p = gevent.spawn(dummy_test_func) self._test_func(p, p.link) def test_func_link_value(self): p = gevent.spawn(dummy_test_func) self._test_func(p, p.link_value) def test_func_link_exception(self): p = gevent.spawn(dummy_test_func) self._test_func(p, p.link_exception) class LinksTestCase(greentest.TestCase): def link(self, p, listener=None): getattr(p, self.link_method)(listener) def set_links(self, p): event = AsyncResult() self.link(p, event) queue = Queue(1) self.link(p, queue.put) callback_flag = ['initial'] self.link(p, lambda *args: callback_flag.remove('initial')) for _ in range(10): self.link(p, AsyncResult()) self.link(p, Queue(1).put) return event, queue, callback_flag def set_links_timeout(self, link): # stuff that won't be touched event = AsyncResult() link(event) queue = Channel() link(queue.put) return event, queue def check_timed_out(self, event, queue): assert with_timeout(DELAY, event.get, timeout_value=X) is X, repr(event.get()) assert with_timeout(DELAY, queue.get, timeout_value=X) is X, queue.get() def return25(): return 25 def sleep0(): return sleep(0) class TestReturn_link(LinksTestCase): link_method = 'link' def cleanup(self): while self.p._links: self.p._links.pop() def test_return(self): self.p = gevent.spawn(return25) for _ in range(3): self._test_return(self.p, 25, sleep0) self.p.kill() def _test_return(self, p, result, action): event, queue, callback_flag = self.set_links(p) # stuff that will time out because there's no unhandled exception: xxxxx = self.set_links_timeout(p.link_exception) sleep(DELAY * 2) assert not p, p self.assertEqual(event.get(), result) self.assertEqual(queue.get().get(), result) sleep(DELAY) assert not callback_flag, callback_flag self.check_timed_out(*xxxxx) def _test_kill(self, p): event, queue, callback_flag = self.set_links(p) xxxxx = self.set_links_timeout(p.link_exception) p.kill() sleep(DELAY) assert not p, p assert isinstance(event.get(), greenlet.GreenletExit), event.get() assert isinstance(queue.get().get(), greenlet.GreenletExit), queue.get().get() sleep(DELAY) assert not callback_flag, callback_flag self.check_timed_out(*xxxxx) def test_kill(self): p = self.p = gevent.spawn(sleep, DELAY) for _ in range(3): self._test_kill(p) class TestReturn_link_value(TestReturn_link): link_method = 'link_value' class TestRaise_link(LinksTestCase): link_method = 'link' def _test_raise(self, p): event, queue, callback_flag = self.set_links(p) xxxxx = self.set_links_timeout(p.link_value) sleep(DELAY) assert not p, p self.assertRaises(ExpectedError, event.get) self.assertEqual(queue.get(), p) sleep(DELAY) assert not callback_flag, callback_flag self.check_timed_out(*xxxxx) def test_raise(self): p = self.p = gevent.spawn(lambda: getcurrent().throw(ExpectedError('test_raise'))) for _ in range(3): self._test_raise(p) class TestRaise_link_exception(TestRaise_link): link_method = 'link_exception' class TestStuff(greentest.TestCase): def test_wait_noerrors(self): x = gevent.spawn(lambda: 1) y = gevent.spawn(lambda: 2) z = gevent.spawn(lambda: 3) gevent.joinall([x, y, z], raise_error=True) self.assertEqual([x.value, y.value, z.value], [1, 2, 3]) e = AsyncResult() x.link(e) self.assertEqual(e.get(), 1) x.unlink(e) e = AsyncResult() x.link(e) self.assertEqual(e.get(), 1) def test_wait_error(self): def x(): sleep(DELAY) return 1 x = gevent.spawn(x) y = gevent.spawn(lambda: getcurrent().throw(ExpectedError('test_wait_error'))) self.assertRaises(ExpectedError, gevent.joinall, [x, y], raise_error=True) self.assertRaises(ExpectedError, gevent.joinall, [y], raise_error=True) x.join() test_wait_error.ignore_leakcheck = True def test_joinall_exception_order(self): # if there're several exceptions raised, the earliest one must be raised by joinall def first(): sleep(0.1) raise ExpectedError('first') a = gevent.spawn(first) b = gevent.spawn(lambda: getcurrent().throw(ExpectedError('second'))) try: gevent.joinall([a, b], raise_error=True) except ExpectedError as ex: assert 'second' in str(ex), repr(str(ex)) gevent.joinall([a, b]) test_joinall_exception_order.ignore_leakcheck = True def test_joinall_count_raise_error(self): # When joinall is asked not to raise an error, the 'count' param still # works. def raises_but_ignored(): raise ExpectedError("count") def sleep_forever(): while True: sleep(0.1) sleeper = gevent.spawn(sleep_forever) raiser = gevent.spawn(raises_but_ignored) gevent.joinall([sleeper, raiser], raise_error=False, count=1) assert_ready(raiser) assert_not_ready(sleeper) # Clean up our mess sleeper.kill() assert_ready(sleeper) def test_multiple_listeners_error(self): # if there was an error while calling a callback # it should not prevent the other listeners from being called # also, all of the errors should be logged, check the output # manually that they are p = gevent.spawn(lambda: 5) results = [] def listener1(*args): results.append(10) raise ExpectedError('listener1') def listener2(*args): results.append(20) raise ExpectedError('listener2') def listener3(*args): raise ExpectedError('listener3') p.link(listener1) p.link(listener2) p.link(listener3) sleep(DELAY * 10) assert results in [[10, 20], [20, 10]], results p = gevent.spawn(lambda: getcurrent().throw(ExpectedError('test_multiple_listeners_error'))) results = [] p.link(listener1) p.link(listener2) p.link(listener3) sleep(DELAY * 10) assert results in [[10, 20], [20, 10]], results class Results(object): def __init__(self): self.results = [] def listener1(self, p): p.unlink(self.listener2) self.results.append(5) raise ExpectedError('listener1') def listener2(self, p): p.unlink(self.listener1) self.results.append(5) raise ExpectedError('listener2') def listener3(self, p): raise ExpectedError('listener3') def _test_multiple_listeners_error_unlink(self, p, link): # notification must not happen after unlink even # though notification process has been already started results = self.Results() link(results.listener1) link(results.listener2) link(results.listener3) sleep(DELAY * 10) assert results.results == [5], results.results def test_multiple_listeners_error_unlink_Greenlet_link(self): p = gevent.spawn(lambda: 5) self._test_multiple_listeners_error_unlink(p, p.link) p.kill() def test_multiple_listeners_error_unlink_Greenlet_rawlink(self): p = gevent.spawn(lambda: 5) self._test_multiple_listeners_error_unlink(p, p.rawlink) def test_multiple_listeners_error_unlink_AsyncResult_rawlink(self): e = AsyncResult() gevent.spawn(e.set, 6) self._test_multiple_listeners_error_unlink(e, e.rawlink) def test_killing_unlinked(self): e = AsyncResult() def func(): try: raise ExpectedError('test_killing_unlinked') except: e.set_exception(sys.exc_info()[1]) gevent.sleep(0) sleep(DELAY) def dummy_test_func(*args): pass class A(object): def method(self): pass hexobj = re.compile('-?0x[0123456789abcdef]+L?', re.I) class TestStr(greentest.TestCase): def test_function(self): g = gevent.Greenlet.spawn(dummy_test_func) self.assertEqual(hexobj.sub('X', str(g)), '') assert_not_ready(g) g.join() assert_ready(g) self.assertEqual(hexobj.sub('X', str(g)), '') def test_method(self): g = gevent.Greenlet.spawn(A().method) str_g = hexobj.sub('X', str(g)) str_g = str_g.replace(__name__, 'module') self.assertEqual(str_g, '>>') assert_not_ready(g) g.join() assert_ready(g) str_g = hexobj.sub('X', str(g)) str_g = str_g.replace(__name__, 'module') self.assertEqual(str_g, '>>') class TestJoin(greentest.GenericWaitTestCase): def wait(self, timeout): g = gevent.spawn(gevent.sleep, 10) try: return g.join(timeout=timeout) finally: g.kill() class TestGet(greentest.GenericGetTestCase): def wait(self, timeout): g = gevent.spawn(gevent.sleep, 10) try: return g.get(timeout=timeout) finally: g.kill() class TestJoinAll0(greentest.GenericWaitTestCase): g = gevent.Greenlet() def wait(self, timeout): gevent.joinall([self.g], timeout=timeout) class TestJoinAll(greentest.GenericWaitTestCase): def wait(self, timeout): g = gevent.spawn(gevent.sleep, 10) try: gevent.joinall([g], timeout=timeout) finally: g.kill() class TestBasic(greentest.TestCase): def test_spawn_non_callable(self): self.assertRaises(TypeError, gevent.spawn, 1) self.assertRaises(TypeError, gevent.spawn_raw, 1) # Not passing the run argument, just the seconds argument self.assertRaises(TypeError, gevent.spawn_later, 1) # Passing both, but not implemented self.assertRaises(TypeError, gevent.spawn_later, 1, 1) def test_spawn_raw_kwargs(self): value = [] def f(*args, **kwargs): value.append(args) value.append(kwargs) g = gevent.spawn_raw(f, 1, name='value') gevent.sleep(0.01) assert not g self.assertEqual(value[0], (1,)) self.assertEqual(value[1], {'name': 'value'}) def test_simple_exit(self): link_test = [] def func(delay, return_value=4): gevent.sleep(delay) return return_value g = gevent.Greenlet(func, 0.01, return_value=5) g.rawlink(link_test.append) # use rawlink to avoid timing issues on Appveyor (not always successful) assert not g, bool(g) assert not g.dead assert not g.started assert not g.ready() assert not g.successful() assert g.value is None assert g.exception is None g.start() assert g # changed assert not g.dead assert g.started # changed assert not g.ready() assert not g.successful() assert g.value is None assert g.exception is None gevent.sleep(0.001) assert g assert not g.dead assert g.started assert not g.ready() assert not g.successful() assert g.value is None assert g.exception is None assert not link_test gevent.sleep(0.02) assert not g assert g.dead assert not g.started assert g.ready() assert g.successful() assert g.value == 5 assert g.exception is None # not changed assert link_test == [g] or greentest.RUNNING_ON_APPVEYOR, link_test # changed def test_error_exit(self): link_test = [] def func(delay, return_value=4): gevent.sleep(delay) error = ExpectedError('test_error_exit') error.myattr = return_value raise error g = gevent.Greenlet(func, 0.001, return_value=5) # use rawlink to avoid timing issues on Appveyor (not always successful) g.rawlink(link_test.append) g.start() gevent.sleep(0.1) assert not g assert g.dead assert not g.started assert g.ready() assert not g.successful() assert g.value is None # not changed assert g.exception.myattr == 5 assert link_test == [g] or greentest.RUNNING_ON_APPVEYOR, link_test def _assertKilled(self, g): assert not g assert g.dead assert not g.started assert g.ready() assert g.successful(), (repr(g), g.value, g.exception) assert isinstance(g.value, gevent.GreenletExit), (repr(g), g.value, g.exception) assert g.exception is None def assertKilled(self, g): self._assertKilled(g) gevent.sleep(0.01) self._assertKilled(g) def _test_kill(self, g, block): g.kill(block=block) if not block: gevent.sleep(0.01) self.assertKilled(g) # kill second time must not hurt g.kill(block=block) self.assertKilled(g) def _test_kill_not_started(self, block): link_test = [] result = [] g = gevent.Greenlet(lambda: result.append(1)) g.link(lambda x: link_test.append(x)) self._test_kill(g, block=block) assert not result assert link_test == [g] def test_kill_not_started_block(self): self._test_kill_not_started(block=True) def test_kill_not_started_noblock(self): self._test_kill_not_started(block=False) def _test_kill_just_started(self, block): result = [] link_test = [] g = gevent.Greenlet(lambda: result.append(1)) g.link(lambda x: link_test.append(x)) g.start() self._test_kill(g, block=block) assert not result, result assert link_test == [g] def test_kill_just_started_block(self): self._test_kill_just_started(block=True) def test_kill_just_started_noblock(self): self._test_kill_just_started(block=False) def _test_kill_just_started_later(self, block): result = [] link_test = [] g = gevent.Greenlet(lambda: result.append(1)) g.link(lambda x: link_test.append(x)) g.start_later(1) self._test_kill(g, block=block) assert not result def test_kill_just_started_later_block(self): self._test_kill_just_started_later(block=True) def test_kill_just_started_later_noblock(self): self._test_kill_just_started_later(block=False) def _test_kill_running(self, block): link_test = [] g = gevent.spawn(gevent.sleep, 10) g.link(lambda x: link_test.append(x)) self._test_kill(g, block=block) gevent.sleep(0.01) assert link_test == [g] def test_kill_running_block(self): self._test_kill_running(block=True) def test_kill_running_noblock(self): self._test_kill_running(block=False) class TestStart(greentest.TestCase): def test(self): g = gevent.spawn(gevent.sleep, 0.01) assert g.started assert not g.dead g.start() assert g.started assert not g.dead g.join() assert not g.started assert g.dead g.start() assert not g.started assert g.dead def assert_ready(g): assert g.dead, g assert g.ready(), g assert not bool(g), g def assert_not_ready(g): assert not g.dead, g assert not g.ready(), g class TestRef(greentest.TestCase): def test_init(self): self.switch_expected = False # in python-dbg mode this will check that Greenlet() does not create any circular refs gevent.Greenlet() def test_kill_scheduled(self): gevent.spawn(gevent.sleep, 10).kill() def test_kill_started(self): g = gevent.spawn(gevent.sleep, 10) try: gevent.sleep(0.001) finally: g.kill() X = object() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__GreenletExit.py0000644000076500000000000000017712666555342021713 0ustar jmaddenwheel00000000000000from gevent import GreenletExit assert issubclass(GreenletExit, BaseException) assert not issubclass(GreenletExit, Exception) gevent-1.1.0/greentest/test__greenletset.py0000644000076500000000000001007512666555342021633 0ustar jmaddenwheel00000000000000import time import greentest import gevent from gevent import pool from gevent.timeout import Timeout DELAY = 0.1 class SpecialError(Exception): pass class Undead(object): def __init__(self): self.shot_count = 0 def __call__(self): while True: try: gevent.sleep(1) except SpecialError: break except: self.shot_count += 1 class Test(greentest.TestCase): def test_basic(self): DELAY = 0.05 if not greentest.RUNNING_ON_APPVEYOR else 0.1 s = pool.Group() s.spawn(gevent.sleep, DELAY) assert len(s) == 1, s s.spawn(gevent.sleep, DELAY * 2.) assert len(s) == 2, s gevent.sleep(DELAY * 3. / 2.) assert len(s) == 1, s gevent.sleep(DELAY) assert not s, s def test_waitall(self): s = pool.Group() s.spawn(gevent.sleep, DELAY) s.spawn(gevent.sleep, DELAY * 2) assert len(s) == 2, s start = time.time() s.join(raise_error=True) delta = time.time() - start assert not s, s assert len(s) == 0, s self.assertTimeWithinRange(delta, DELAY * 1.9, DELAY * 2.5) def test_kill_block(self): s = pool.Group() s.spawn(gevent.sleep, DELAY) s.spawn(gevent.sleep, DELAY * 2) assert len(s) == 2, s start = time.time() s.kill() assert not s, s assert len(s) == 0, s delta = time.time() - start assert delta < DELAY * 0.8, delta def test_kill_noblock(self): s = pool.Group() s.spawn(gevent.sleep, DELAY) s.spawn(gevent.sleep, DELAY * 2) assert len(s) == 2, s s.kill(block=False) assert len(s) == 2, s gevent.sleep(0.0001) assert len(s) == 0, s assert not s, s def test_kill_fires_once(self): u1 = Undead() u2 = Undead() p1 = gevent.spawn(u1) p2 = gevent.spawn(u2) def check(count1, count2): assert p1, p1 assert p2, p2 assert not p1.dead, p1 assert not p2.dead, p2 self.assertEqual(u1.shot_count, count1) self.assertEqual(u2.shot_count, count2) gevent.sleep(0.01) s = pool.Group([p1, p2]) assert len(s) == 2, s check(0, 0) s.killone(p1, block=False) check(0, 0) gevent.sleep(0) check(1, 0) s.killone(p1) check(1, 0) s.killone(p1) check(1, 0) s.kill(block=False) s.kill(block=False) s.kill(block=False) check(1, 0) gevent.sleep(DELAY) check(1, 1) X = object() kill_result = gevent.with_timeout(DELAY, s.kill, block=True, timeout_value=X) assert kill_result is X, repr(kill_result) assert len(s) == 2, s check(1, 1) p1.kill(SpecialError) p2.kill(SpecialError) def test_killall_subclass(self): p1 = GreenletSubclass.spawn(lambda: 1 / 0) p2 = GreenletSubclass.spawn(lambda: gevent.sleep(10)) s = pool.Group([p1, p2]) s.kill() def test_killall_iterable_argument_non_block(self): p1 = GreenletSubclass.spawn(lambda: gevent.sleep(0.5)) p2 = GreenletSubclass.spawn(lambda: gevent.sleep(0.5)) s = set() s.add(p1) s.add(p2) gevent.killall(s, block=False) gevent.sleep(0.5) for g in s: assert g.dead def test_killall_iterable_argument_timeout(self): def f(): try: gevent.sleep(1.5) except: gevent.sleep(1) p1 = GreenletSubclass.spawn(f) p2 = GreenletSubclass.spawn(f) s = set() s.add(p1) s.add(p2) try: gevent.killall(s, timeout=0.5) except Timeout: for g in s: assert not g.dead else: self.fail("Should raise timeout") class GreenletSubclass(gevent.Greenlet): pass if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__greenness.py0000644000076500000000000000472612666555342021311 0ustar jmaddenwheel00000000000000# Copyright (c) 2008 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """Test than modules in gevent.green package are indeed green. To do that spawn a green server and then access it using a green socket. If either operation blocked the whole script would block and timeout. """ import greentest from gevent import monkey monkey.patch_all() try: import urllib2 except ImportError: from urllib import request as urllib2 try: import BaseHTTPServer except ImportError: from http import server as BaseHTTPServer import gevent class TestGreenness(greentest.TestCase): check_totalrefcount = False def serve(self): self.httpd.handle_request() self.httpd.request_count += 1 def test_urllib2(self): server_address = ('', 0) BaseHTTPServer.BaseHTTPRequestHandler.protocol_version = "HTTP/1.0" self.httpd = BaseHTTPServer.HTTPServer(server_address, BaseHTTPServer.BaseHTTPRequestHandler) self.httpd.request_count = 0 server = gevent.spawn(self.serve) port = self.httpd.socket.getsockname()[1] try: urllib2.urlopen('http://127.0.0.1:%s' % port) assert False, 'should not get there' except urllib2.HTTPError as ex: assert ex.code == 501, repr(ex) server.get(0.01) self.assertEqual(self.httpd.request_count, 1) self.httpd.server_close() self.httpd = None if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__hub.py0000644000076500000000000000717312666555342020075 0ustar jmaddenwheel00000000000000# Copyright (c) 2009 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import greentest import time import re import gevent from gevent import socket from gevent.hub import Waiter, get_hub DELAY = 0.1 class TestCloseSocketWhilePolling(greentest.TestCase): def test(self): try: sock = socket.socket() get_hub().loop.timer(0, sock.close) sock.connect(('python.org', 81)) except Exception: gevent.sleep(0) else: assert False, 'expected an error here' class TestExceptionInMainloop(greentest.TestCase): def test_sleep(self): # even if there was an error in the mainloop, the hub should continue to work start = time.time() gevent.sleep(DELAY) delay = time.time() - start assert delay >= DELAY * 0.9, 'sleep returned after %s seconds (was scheduled for %s)' % (delay, DELAY) error = greentest.ExpectedException('TestExceptionInMainloop.test_sleep/fail') def fail(): raise error t = get_hub().loop.timer(0.001) t.start(fail) self.expect_one_error() start = time.time() gevent.sleep(DELAY) delay = time.time() - start self.assert_error(value=error) assert delay >= DELAY * 0.9, 'sleep returned after %s seconds (was scheduled for %s)' % (delay, DELAY) class TestSleep(greentest.GenericWaitTestCase): def wait(self, timeout): gevent.sleep(timeout) def test_simple(self): gevent.sleep(0) class TestWaiterGet(greentest.GenericWaitTestCase): def setUp(self): super(TestWaiterGet, self).setUp() self.waiter = Waiter() def wait(self, timeout): evt = get_hub().loop.timer(timeout) evt.start(self.waiter.switch) try: return self.waiter.get() finally: evt.stop() class TestWaiter(greentest.TestCase): def test(self): waiter = Waiter() self.assertEqual(str(waiter), '') waiter.switch(25) self.assertEqual(str(waiter), '') self.assertEqual(waiter.get(), 25) waiter = Waiter() waiter.throw(ZeroDivisionError) assert re.match('^ midtime: p.send_signal(signal_to_send) midtime = endtime + 1 # only once time.sleep(0.1) else: # Kill unresponsive child and exit with error 1 sys.stderr.write(__file__) sys.stderr.write(": Failed to wait for child\n") p.terminate() p.wait() sys.exit(1) # If we get here, it's because we caused the process to exit; it # didn't hang. Under Windows, however, we have to use CTRL_BREAK_EVENT, # which has an arbitrary returncode depending on versions (so does CTRL_C_EVENT # on Python 2). We still # count this as success. sys.exit(p.returncode if not WIN else 0) gevent-1.1.0/greentest/test__joinall.py0000644000076500000000000000015712666555342020742 0ustar jmaddenwheel00000000000000import gevent def func(): pass a = gevent.spawn(func) b = gevent.spawn(func) gevent.joinall([a, b, a]) gevent-1.1.0/greentest/test__local.py0000644000076500000000000000567512666555342020416 0ustar jmaddenwheel00000000000000import greentest from copy import copy # Comment the line below to see that the standard thread.local is working correct from gevent import monkey; monkey.patch_all() from threading import local class A(local): __slots__ = ['initialized', 'obj'] path = '' def __init__(self, obj): if not hasattr(self, 'initialized'): self.obj = obj self.path = '' class Obj(object): pass # These next two classes have to be global to avoid the leakchecks deleted_sentinels = [] created_sentinels = [] class Sentinel(object): def __del__(self): deleted_sentinels.append(id(self)) class MyLocal(local): def __init__(self): local.__init__(self) self.sentinel = Sentinel() created_sentinels.append(id(self.sentinel)) class GeventLocalTestCase(greentest.TestCase): def test_copy(self): a = A(Obj()) a.path = '123' a.obj.echo = 'test' b = copy(a) """ Copy makes a shallow copy. Meaning that the attribute path has to be independent in the original and the copied object because the value is a string, but the attribute obj should be just reference to the instance of the class Obj """ self.assertEqual(a.path, b.path, 'The values in the two objects must be equal') self.assertEqual(a.obj, b.obj, 'The values must be equal') b.path = '321' self.assertNotEqual(a.path, b.path, 'The values in the two objects must be different') a.obj.echo = "works" self.assertEqual(a.obj, b.obj, 'The values must be equal') def test_objects(self): """ Test which failed in the eventlet?! """ a = A({}) a.path = '123' b = A({'one': 2}) b.path = '123' self.assertEqual(a.path, b.path, 'The values in the two objects must be equal') b.path = '321' self.assertNotEqual(a.path, b.path, 'The values in the two objects must be different') def test_locals_collected_when_greenlet_dead_but_still_referenced(self): # https://github.com/gevent/gevent/issues/387 import gevent my_local = MyLocal() my_local.sentinel = None if greentest.PYPY: import gc gc.collect() del created_sentinels[:] del deleted_sentinels[:] def demonstrate_my_local(): # Get the important parts getattr(my_local, 'sentinel') # Create and reference greenlets greenlets = [gevent.spawn(demonstrate_my_local) for _ in range(5)] gevent.sleep() self.assertEqual(len(created_sentinels), len(greenlets)) for g in greenlets: assert g.dead gevent.sleep() # let the callbacks run if greentest.PYPY: gc.collect() # The sentinels should be gone too self.assertEqual(len(deleted_sentinels), len(greenlets)) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__loop_callback.py0000644000076500000000000000024112666555342022071 0ustar jmaddenwheel00000000000000from gevent.core import loop count = 0 def incr(): global count count += 1 loop = loop() loop.run_callback(incr) loop.run() assert count == 1, count gevent-1.1.0/greentest/test__makefile_ref.py0000644000076500000000000003556412666555342021735 0ustar jmaddenwheel00000000000000import os from gevent import monkey; monkey.patch_all() import re import socket import ssl import threading import unittest import errno dirname = os.path.dirname(os.path.abspath(__file__)) certfile = os.path.join(dirname, '2.7/keycert.pem') pid = os.getpid() import sys PY3 = sys.version_info[0] >= 3 fd_types = int if PY3: long = int fd_types = (int, long) WIN = sys.platform.startswith("win") try: import psutil except ImportError: psutil = None # Linux/OS X/BSD platforms can implement this by calling out to lsof tmpname = '/tmp/test__makefile_ref.lsof.%s' % pid lsof_command = 'lsof -p %s > %s' % (pid, tmpname) def get_open_files(): if os.system(lsof_command): raise OSError('lsof failed') with open(tmpname) as fobj: data = fobj.read().strip() results = {} for line in data.split('\n'): line = line.strip() if not line: continue split = re.split(r'\s+', line) command, pid, user, fd = split[:4] if fd[:-1].isdigit() and not fd[-1].isdigit(): fd = int(fd[:-1]) if fd in results: params = (fd, line, split, results.get(fd), data) raise AssertionError('error when parsing lsof output: duplicate fd=%r\nline=%r\nsplit=%r\nprevious=%r\ndata:\n%s' % params) results[fd] = line if not results: raise AssertionError('failed to parse lsof:\n%s' % (data, )) results['data'] = data return results else: # If psutil is available (it is cross-platform) use that. # It is *much* faster than shelling out to lsof each time # (Running 14 tests takes 3.964s with lsof and 0.046 with psutil) # However, it still doesn't completely solve the issue on Windows: fds are reported # as -1 there, so we can't fully check those. # XXX: Note: installing psutil on the travis linux vm caused failures. process = psutil.Process() def get_open_files(): results = dict() results['data'] = process.open_files() + process.connections('all') for x in results['data']: results[x.fd] = x return results class Test(unittest.TestCase): extra_allowed_open_states = () def tearDown(self): self.extra_allowed_open_states = () unittest.TestCase.tearDown(self) def assert_raises_EBADF(self, func): try: result = func() except (socket.error, OSError) as ex: # Windows/Py3 raises "OSError: [WinError 10038]" if ex.args[0] == errno.EBADF: return if WIN and ex.args[0] == 10038: return raise raise AssertionError('NOT RAISED EBADF: %r() returned %r' % (func, result)) def assert_fd_open(self, fileno): assert isinstance(fileno, fd_types) open_files = get_open_files() if fileno not in open_files: raise AssertionError('%r is not open:\n%s' % (fileno, open_files['data'])) def assert_fd_closed(self, fileno): assert isinstance(fileno, fd_types), repr(fileno) assert fileno > 0, fileno open_files = get_open_files() if fileno in open_files: raise AssertionError('%r is not closed:\n%s' % (fileno, open_files['data'])) def _assert_sock_open(self, sock): # requires the psutil output open_files = get_open_files() sockname = sock.getsockname() for x in open_files['data']: if x.laddr == sockname: assert x.status in (psutil.CONN_LISTEN, psutil.CONN_ESTABLISHED) + self.extra_allowed_open_states, x.status return raise AssertionError("%r is not open:\n%s" % (sock, open_files['data'])) def assert_open(self, sock, *rest): if isinstance(sock, fd_types): if not WIN: self.assert_fd_open(sock) else: fileno = sock.fileno() assert isinstance(fileno, fd_types), fileno sockname = sock.getsockname() assert isinstance(sockname, tuple), sockname if not WIN: self.assert_fd_open(fileno) else: self._assert_sock_open(sock) if rest: self.assert_open(rest[0], *rest[1:]) def assert_closed(self, sock, *rest): if isinstance(sock, fd_types): self.assert_fd_closed(sock) else: # Under Python3, the socket module returns -1 for a fileno # of a closed socket; under Py2 it raises if PY3: self.assertEqual(sock.fileno(), -1) else: self.assert_raises_EBADF(sock.fileno) self.assert_raises_EBADF(sock.getsockname) self.assert_raises_EBADF(sock.accept) if rest: self.assert_closed(rest[0], *rest[1:]) def make_open_socket(self): s = socket.socket() s.bind(('127.0.0.1', 0)) if WIN: # Windows doesn't show as open until this s.listen(1) self.assert_open(s, s.fileno()) return s class TestSocket(Test): def test_simple_close(self): s = self.make_open_socket() fileno = s.fileno() s.close() self.assert_closed(s, fileno) def test_makefile1(self): s = self.make_open_socket() fileno = s.fileno() f = s.makefile() self.assert_open(s, fileno) s.close() # Under python 2, this closes socket wrapper object but not the file descriptor; # under python 3, both stay open if PY3: self.assert_open(s, fileno) else: self.assert_closed(s) self.assert_open(fileno) f.close() self.assert_closed(s) self.assert_closed(fileno) def test_makefile2(self): s = self.make_open_socket() fileno = s.fileno() self.assert_open(s, fileno) f = s.makefile() self.assert_open(s) self.assert_open(s, fileno) f.close() # closing fileobject does not close the socket self.assert_open(s, fileno) s.close() self.assert_closed(s, fileno) def test_server_simple(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() fileno = client_socket.fileno() self.assert_open(client_socket, fileno) client_socket.close() self.assert_closed(client_socket) finally: t.join() listener.close() def test_server_makefile1(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() fileno = client_socket.fileno() f = client_socket.makefile() self.assert_open(client_socket, fileno) client_socket.close() # Under python 2, this closes socket wrapper object but not the file descriptor; # under python 3, both stay open if PY3: self.assert_open(client_socket, fileno) else: self.assert_closed(client_socket) self.assert_open(fileno) f.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() def test_server_makefile2(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() fileno = client_socket.fileno() f = client_socket.makefile() self.assert_open(client_socket, fileno) # closing fileobject does not close the socket f.close() self.assert_open(client_socket, fileno) client_socket.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() class TestSSL(Test): def test_simple_close(self): s = self.make_open_socket() fileno = s.fileno() s = ssl.wrap_socket(s) fileno = s.fileno() self.assert_open(s, fileno) s.close() self.assert_closed(s, fileno) def test_makefile1(self): s = self.make_open_socket() fileno = s.fileno() s = ssl.wrap_socket(s) fileno = s.fileno() self.assert_open(s, fileno) f = s.makefile() self.assert_open(s, fileno) s.close() self.assert_open(s, fileno) f.close() self.assert_closed(s, fileno) def test_makefile2(self): s = self.make_open_socket() fileno = s.fileno() s = ssl.wrap_socket(s) fileno = s.fileno() self.assert_open(s, fileno) f = s.makefile() self.assert_open(s, fileno) f.close() # closing fileobject does not close the socket self.assert_open(s, fileno) s.close() self.assert_closed(s, fileno) def test_server_simple(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) ssl.wrap_socket(connector) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() client_socket = ssl.wrap_socket(client_socket, keyfile=certfile, certfile=certfile, server_side=True) fileno = client_socket.fileno() self.assert_open(client_socket, fileno) client_socket.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() def test_server_makefile1(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) ssl.wrap_socket(connector) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() client_socket = ssl.wrap_socket(client_socket, keyfile=certfile, certfile=certfile, server_side=True) fileno = client_socket.fileno() self.assert_open(client_socket, fileno) f = client_socket.makefile() self.assert_open(client_socket, fileno) client_socket.close() self.assert_open(client_socket, fileno) f.close() self.assert_closed(client_socket, fileno) finally: t.join() connector.close() def test_server_makefile2(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) ssl.wrap_socket(connector) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() client_socket = ssl.wrap_socket(client_socket, keyfile=certfile, certfile=certfile, server_side=True) fileno = client_socket.fileno() self.assert_open(client_socket, fileno) f = client_socket.makefile() self.assert_open(client_socket, fileno) # Closing fileobject does not close SSLObject f.close() self.assert_open(client_socket, fileno) client_socket.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() connector.close() def test_serverssl_makefile1(self): listener = socket.socket() fileno = listener.fileno() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) listener = ssl.wrap_socket(listener, keyfile=certfile, certfile=certfile) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) ssl.wrap_socket(connector) t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() fileno = client_socket.fileno() self.assert_open(client_socket, fileno) f = client_socket.makefile() self.assert_open(client_socket, fileno) client_socket.close() self.assert_open(client_socket, fileno) f.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() connector.close() def test_serverssl_makefile2(self): listener = socket.socket() listener.bind(('127.0.0.1', 0)) port = listener.getsockname()[1] listener.listen(1) listener = ssl.wrap_socket(listener, keyfile=certfile, certfile=certfile) connector = socket.socket() def connect(): connector.connect(('127.0.0.1', port)) s = ssl.wrap_socket(connector) s.sendall(b'test_serverssl_makefile2') s.close() connector.close() t = threading.Thread(target=connect) t.start() try: client_socket, _addr = listener.accept() fileno = client_socket.fileno() self.assert_open(client_socket, fileno) f = client_socket.makefile() self.assert_open(client_socket, fileno) self.assertEqual(f.read(), 'test_serverssl_makefile2') self.assertEqual(f.read(), '') f.close() if WIN and psutil: # Hmm? self.extra_allowed_open_states = (psutil.CONN_CLOSE_WAIT,) self.assert_open(client_socket, fileno) client_socket.close() self.assert_closed(client_socket, fileno) finally: t.join() listener.close() if __name__ == '__main__': unittest.main() gevent-1.1.0/greentest/test__memleak.py0000644000076500000000000000221712666555342020724 0ustar jmaddenwheel00000000000000import sys from greentest import TestCase, main import gevent from gevent.timeout import Timeout class TestQueue(TestCase): def test(self): result = '' try: Timeout.start_new(0.01) gevent.sleep(1) raise AssertionError('must raise Timeout') except KeyboardInterrupt: raise except: pass result += '%s ' % sys.gettotalrefcount() try: Timeout.start_new(0.01) gevent.sleep(1) raise AssertionError('must raise Timeout') except KeyboardInterrupt: raise except: pass result += '%s ' % sys.gettotalrefcount() try: Timeout.start_new(0.01) gevent.sleep(1) raise AssertionError('must raise Timeout') except KeyboardInterrupt: raise except: pass result += '%s' % sys.gettotalrefcount() a, b, c = result.split() assert b == c, 'total refcount mismatch: %s' % result if not hasattr(sys, 'gettotalrefcount'): del TestQueue if __name__ == '__main__': main() gevent-1.1.0/greentest/test__monkey.py0000644000076500000000000000472312666555342020617 0ustar jmaddenwheel00000000000000from gevent import monkey monkey.patch_all() import sys import time assert 'built-in' not in repr(time.sleep), repr(time.sleep) try: import thread except ImportError: import _thread as thread import threading assert 'built-in' not in repr(thread.start_new_thread), repr(thread.start_new_thread) assert 'built-in' not in repr(threading._start_new_thread), repr(threading._start_new_thread) if sys.version_info[0] == 2: assert 'built-in' not in repr(threading._sleep), repr(threading._sleep) import socket from gevent import socket as gevent_socket assert socket.create_connection is gevent_socket.create_connection import os import types for name in ('fork', 'forkpty'): if hasattr(os, name): attr = getattr(os, name) assert 'built-in' not in repr(attr), repr(attr) assert not isinstance(attr, types.BuiltinFunctionType), repr(attr) assert isinstance(attr, types.FunctionType), repr(attr) assert monkey.saved assert not monkey.is_object_patched('threading', 'Event') monkey.patch_thread(Event=True) assert monkey.is_object_patched('threading', 'Event') for modname in monkey.saved: assert monkey.is_module_patched(modname) for objname in monkey.saved[modname]: assert monkey.is_object_patched(modname, objname) orig_saved = {} for k, v in monkey.saved.items(): orig_saved[k] = v.copy() import warnings with warnings.catch_warnings(record=True) as issued_warnings: # Patch again, triggering two warnings, on for os=False/signal=True, # one for repeated monkey-patching. monkey.patch_all(os=False) assert len(issued_warnings) == 2, len(issued_warnings) assert 'SIGCHLD' in str(issued_warnings[-1].message), issued_warnings[-1] assert 'more than once' in str(issued_warnings[0].message), issued_warnings[0] # Patching with the exact same argument doesn't issue a second warning. # in fact, it doesn't do anything del issued_warnings[:] monkey.patch_all(os=False) orig_saved['_gevent_saved_patch_all'] = monkey.saved['_gevent_saved_patch_all'] assert len(issued_warnings) == 0, len(issued_warnings) # Make sure that re-patching did not change the monkey.saved # attribute, overwriting the original functions. assert orig_saved == monkey.saved, (orig_saved, monkey.saved) # Make sure some problematic attributes stayed correct. # NOTE: This was only a problem if threading was not previously imported. for k, v in monkey.saved['threading'].items(): assert 'gevent' not in str(v), (k, v) gevent-1.1.0/greentest/test__monkey_builtins_future.py0000644000076500000000000000101112666555342024105 0ustar jmaddenwheel00000000000000# Under Python 2, if the `future` module is installed, we get # a `builtins` module, which mimics the `builtins` module from # Python 3, but does not have the __import__ and some other functions. # Make sure we can still run in that case. import sys try: # fake out a "broken" builtins module import builtins except ImportError: class builtins(object): pass sys.modules['builtins'] = builtins() if not hasattr(builtins, '__import__'): import gevent.monkey gevent.monkey.patch_builtins() gevent-1.1.0/greentest/test__monkey_hub_in_thread.py0000644000076500000000000000101012666555342023454 0ustar jmaddenwheel00000000000000from gevent.monkey import patch_all patch_all(thread=False) from threading import Thread import time # The first time we init the hub is in the native # thread with time.sleep(), needing multiple # threads at the same time. Note: this is very timing # dependent. # See #687 def func(): time.sleep() def main(): threads = [] for _ in range(3): th = Thread(target=func) th.start() threads.append(th) for th in threads: th.join() if __name__ == '__main__': main() gevent-1.1.0/greentest/test__monkey_logging.py0000644000076500000000000000215212666555342022317 0ustar jmaddenwheel00000000000000# If the logging module is imported *before* monkey patching, # the existing handlers are correctly monkey patched to use gevent locks import logging logging.basicConfig() import threading import sys PY2 = sys.version_info[0] == 2 def _inner_lock(lock): # The inner attribute changed between 2 and 3 attr = getattr(lock, '_block' if not PY2 else '_RLock__block', None) return attr def checkLocks(kind, ignore_none=True): handlers = logging._handlerList assert len(handlers) > 0 for weakref in handlers: # In py26, these are actual handlers, not weakrefs handler = weakref() if callable(weakref) else weakref attr = _inner_lock(handler.lock) if attr is None and ignore_none: continue assert isinstance(attr, kind), (handler.lock, attr, kind) attr = _inner_lock(logging._lock) if attr is None and ignore_none: return assert isinstance(attr, kind) checkLocks(type(threading._allocate_lock())) import gevent.monkey gevent.monkey.patch_all() import gevent.lock checkLocks(type(gevent.thread.allocate_lock()), ignore_none=False) gevent-1.1.0/greentest/test__monkey_multiple_imports.py0000644000076500000000000000045012666555342024300 0ustar jmaddenwheel00000000000000# https://github.com/gevent/gevent/issues/615 # Under Python 3, with its use of importlib, # if the monkey patch is done when the importlib import lock is held # (e.g., during recursive imports) we could fail to release the lock. # This is surprisingly common. __import__('_import_import_patch') gevent-1.1.0/greentest/test__monkey_sigchld.py0000644000076500000000000000406712666555342022315 0ustar jmaddenwheel00000000000000import errno import os import sys #os.environ['GEVENT_NOWAITPID'] = 'True' import gevent import gevent.monkey gevent.monkey.patch_all() pid = None awaiting_child = [] def handle_sigchld(*args): # Make sure we can do a blocking operation gevent.sleep() # Signal completion awaiting_child.pop() # Raise an ignored error raise TypeError("This should be ignored but printed") import signal if hasattr(signal, 'SIGCHLD'): assert signal.getsignal(signal.SIGCHLD) == signal.SIG_DFL signal.signal(signal.SIGCHLD, handle_sigchld) handler = signal.getsignal(signal.SIGCHLD) assert signal.getsignal(signal.SIGCHLD) is handle_sigchld, handler if hasattr(os, 'forkpty'): def forkpty(): # For printing in errors return os.forkpty()[0] funcs = (os.fork, forkpty) else: funcs = (os.fork,) for func in funcs: awaiting_child = [True] pid = func() if not pid: # child gevent.sleep(0.3) sys.exit(0) else: timeout = gevent.Timeout(1) try: while awaiting_child: gevent.sleep(0.01) # We should now be able to waitpid() for an arbitrary child wpid, status = os.waitpid(-1, os.WNOHANG) if wpid != pid: raise AssertionError("Failed to wait on a child pid forked with a function", wpid, pid, func) # And a second call should raise ECHILD try: wpid, status = os.waitpid(-1, os.WNOHANG) raise AssertionError("Should not be able to wait again") except OSError as e: assert e.errno == errno.ECHILD except gevent.Timeout as t: if timeout is not t: raise raise AssertionError("Failed to wait using", func) finally: timeout.cancel() sys.exit(0) else: print("No SIGCHLD, not testing") gevent-1.1.0/greentest/test__monkey_sigchld_2.py0000644000076500000000000000253312666555342022532 0ustar jmaddenwheel00000000000000# Mimics what gunicorn workers do: monkey patch in the child process # and try to reset signal handlers to SIG_DFL. # NOTE: This breaks again when gevent.subprocess is used, or any child # watcher. import os import sys import signal def handle(*args): if not pid: # We only do this is the child so our # parent's waitpid can get the status. # This is the opposite of gunicorn. os.waitpid(-1, os.WNOHANG) # The signal watcher must be installed *before* monkey patching if hasattr(signal, 'SIGCHLD'): signal.signal(signal.SIGCHLD, handle) pid = os.fork() if pid: # parent try: _, stat = os.waitpid(pid, 0) except OSError: # Interrupted system call _, stat = os.waitpid(pid, 0) assert stat == 0, stat else: import gevent.monkey gevent.monkey.patch_all() signal.signal(signal.SIGCHLD, signal.SIG_DFL) # Under Python 2, os.popen() directly uses the popen call, and # popen's file uses the pclose() system call to # wait for the child. If it's already waited on, # it raises the same exception. # Python 3 uses the subprocess module directly which doesn't # have this problem. f = os.popen('true') f.close() sys.exit(0) else: print("No SIGCHLD, not testing") gevent-1.1.0/greentest/test__nondefaultloop.py0000644000076500000000000000027512666555342022344 0ustar jmaddenwheel00000000000000# test for issue #210 from gevent import core from util import alarm alarm(1) log = [] loop = core.loop(default=False) loop.run_callback(log.append, 1) loop.run() assert log == [1], log gevent-1.1.0/greentest/test__order.py0000644000076500000000000000210412666555342020417 0ustar jmaddenwheel00000000000000import gevent import greentest from six import xrange class appender(object): def __init__(self, lst, item): self.lst = lst self.item = item def __call__(self, *args): self.lst.append(self.item) class Test(greentest.TestCase): count = 2 def test_greenlet_link(self): lst = [] # test that links are executed in the same order as they were added g = gevent.spawn(lst.append, 0) for i in xrange(1, self.count): g.link(appender(lst, i)) g.join() self.assertEqual(lst, list(range(self.count))) class Test3(Test): count = 3 class Test4(Test): count = 4 class TestM(Test): count = 1000 class TestSleep0(greentest.TestCase): def test(self): lst = [] gevent.spawn(sleep0, lst, '1') gevent.spawn(sleep0, lst, '2') gevent.wait() self.assertEqual(' '.join(lst), '1A 2A 1B 2B') def sleep0(lst, param): lst.append(param + 'A') gevent.sleep(0) lst.append(param + 'B') if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__os.py0000644000076500000000000000445512666555342017740 0ustar jmaddenwheel00000000000000import sys import six from os import pipe from gevent import os from greentest import TestCase, main from gevent import Greenlet, joinall try: import fcntl except ImportError: fcntl = None try: import errno except ImportError: errno = None class TestOS_tp(TestCase): __timeout__ = 5 def pipe(self): return pipe() def read(self, *args): return os.tp_read(*args) def write(self, *args): return os.tp_write(*args) def _test_if_pipe_blocks(self, buffer_class): r, w = self.pipe() # set nbytes such that for sure it is > maximum pipe buffer nbytes = 1000000 block = b'x' * 4096 buf = buffer_class(block) # Lack of "nonlocal" keyword in Python 2.x: bytesread = [0] byteswritten = [0] def produce(): while byteswritten[0] != nbytes: bytesleft = nbytes - byteswritten[0] byteswritten[0] += self.write(w, buf[:min(bytesleft, 4096)]) def consume(): while bytesread[0] != nbytes: bytesleft = nbytes - bytesread[0] bytesread[0] += len(self.read(r, min(bytesleft, 4096))) producer = Greenlet(produce) producer.start() consumer = Greenlet(consume) consumer.start_later(1) # If patching was not succesful, the producer will have filled # the pipe before the consumer starts, and would block the entire # process. Therefore the next line would never finish. joinall([producer, consumer]) assert bytesread[0] == nbytes assert bytesread[0] == byteswritten[0] if sys.version_info[0] < 3: def test_if_pipe_blocks_buffer(self): self._test_if_pipe_blocks(six.builtins.buffer) if sys.version_info[:2] >= (2, 7): def test_if_pipe_blocks_memoryview(self): self._test_if_pipe_blocks(six.builtins.memoryview) if hasattr(os, 'make_nonblocking'): class TestOS_nb(TestOS_tp): def pipe(self): r, w = pipe() os.make_nonblocking(r) os.make_nonblocking(w) return r, w def read(self, *args): return os.nb_read(*args) def write(self, *args): return os.nb_write(*args) if __name__ == '__main__': main() gevent-1.1.0/greentest/test__pool.py0000644000076500000000000003574612666555342020277 0ustar jmaddenwheel00000000000000from time import time import gevent from gevent import pool from gevent.event import Event from gevent.queue import Queue import greentest import random from greentest import ExpectedException import six import unittest class TestCoroutinePool(unittest.TestCase): klass = pool.Pool def test_apply_async(self): done = Event() def some_work(x): done.set() pool = self.klass(2) pool.apply_async(some_work, ('x', )) done.wait() def test_apply(self): value = 'return value' def some_work(): return value pool = self.klass(2) result = pool.apply(some_work) self.assertEqual(value, result) def test_apply_raises(self): pool = self.klass(1) def raiser(): raise ExpectedException() try: pool.apply(raiser) except ExpectedException: pass else: self.fail("Should have raised ExpectedException") # Don't let the metaclass automatically force any error # that reaches the hub from a spawned greenlet to become # fatal; that defeats the point of the test. test_apply_raises.error_fatal = False def test_multiple_coros(self): evt = Event() results = [] def producer(): gevent.sleep(0.001) results.append('prod') evt.set() def consumer(): results.append('cons1') evt.wait() results.append('cons2') pool = self.klass(2) done = pool.spawn(consumer) pool.apply_async(producer) done.get() self.assertEqual(['cons1', 'prod', 'cons2'], results) def dont_test_timer_cancel(self): timer_fired = [] def fire_timer(): timer_fired.append(True) def some_work(): gevent.timer(0, fire_timer) pool = self.klass(2) pool.apply(some_work) gevent.sleep(0) self.assertEqual(timer_fired, []) def test_reentrant(self): pool = self.klass(1) result = pool.apply(pool.apply, (lambda a: a + 1, (5, ))) self.assertEqual(result, 6) evt = Event() pool.apply_async(evt.set) evt.wait() def test_stderr_raising(self): if greentest.PYPY: # Does not work on PyPy return # testing that really egregious errors in the error handling code # (that prints tracebacks to stderr) don't cause the pool to lose # any members import sys pool = self.klass(size=1) # we're going to do this by causing the traceback.print_exc in # safe_apply to raise an exception and thus exit _main_loop normal_err = sys.stderr try: sys.stderr = FakeFile() waiter = pool.spawn(crash) with gevent.Timeout(2): self.assertRaises(RuntimeError, waiter.get) # the pool should have something free at this point since the # waiter returned # pool.Pool change: if an exception is raised during execution of a link, # the rest of the links are scheduled to be executed on the next hub iteration # this introduces a delay in updating pool.sem which makes pool.free_count() report 0 # therefore, sleep: gevent.sleep(0) self.assertEqual(pool.free_count(), 1) # shouldn't block when trying to get t = gevent.Timeout.start_new(0.1) try: pool.apply(gevent.sleep, (0, )) finally: t.cancel() finally: sys.stderr = normal_err pool.join() def crash(*args, **kw): raise RuntimeError("Whoa") class FakeFile(object): def write(*args): raise RuntimeError('Whaaa') class PoolBasicTests(greentest.TestCase): klass = pool.Pool def test_execute_async(self): p = self.klass(size=2) self.assertEqual(p.free_count(), 2) r = [] first = p.spawn(r.append, 1) self.assertEqual(p.free_count(), 1) first.get() self.assertEqual(r, [1]) gevent.sleep(0) self.assertEqual(p.free_count(), 2) #Once the pool is exhausted, calling an execute forces a yield. p.apply_async(r.append, (2, )) self.assertEqual(1, p.free_count()) self.assertEqual(r, [1]) p.apply_async(r.append, (3, )) self.assertEqual(0, p.free_count()) self.assertEqual(r, [1]) p.apply_async(r.append, (4, )) self.assertEqual(r, [1]) gevent.sleep(0.01) self.assertEqual(sorted(r), [1, 2, 3, 4]) def test_discard(self): p = self.klass(size=1) first = p.spawn(gevent.sleep, 1000) p.discard(first) first.kill() assert not first, first self.assertEqual(len(p), 0) self.assertEqual(p._semaphore.counter, 1) def test_add_method(self): p = self.klass(size=1) first = gevent.spawn(gevent.sleep, 1000) try: second = gevent.spawn(gevent.sleep, 1000) try: self.assertEqual(p.free_count(), 1) self.assertEqual(len(p), 0) p.add(first) timeout = gevent.Timeout(0.1) timeout.start() try: p.add(second) except gevent.Timeout: pass else: raise AssertionError('Expected timeout') finally: timeout.cancel() self.assertEqual(p.free_count(), 0) self.assertEqual(len(p), 1) finally: second.kill() finally: first.kill() def test_apply(self): p = self.klass() result = p.apply(lambda a: ('foo', a), (1, )) self.assertEqual(result, ('foo', 1)) def test_init_error(self): self.switch_expected = False self.assertRaises(ValueError, self.klass, -1) # # tests from standard library test/test_multiprocessing.py class TimingWrapper(object): def __init__(self, func): self.func = func self.elapsed = None def __call__(self, *args, **kwds): t = time() try: return self.func(*args, **kwds) finally: self.elapsed = time() - t def sqr(x, wait=0.0): gevent.sleep(wait) return x * x def squared(x): return x * x def sqr_random_sleep(x): gevent.sleep(random.random() * 0.1) return x * x def final_sleep(): for i in range(3): yield i gevent.sleep(0.2) TIMEOUT1, TIMEOUT2, TIMEOUT3 = 0.082, 0.035, 0.14 class TestPool(greentest.TestCase): __timeout__ = 5 if not greentest.RUNNING_ON_APPVEYOR else 20 size = 1 def setUp(self): greentest.TestCase.setUp(self) self.pool = pool.Pool(self.size) def cleanup(self): self.pool.join() def test_apply(self): papply = self.pool.apply self.assertEqual(papply(sqr, (5,)), 25) self.assertEqual(papply(sqr, (), {'x': 3}), 9) def test_map(self): pmap = self.pool.map self.assertEqual(pmap(sqr, range(10)), list(map(squared, range(10)))) self.assertEqual(pmap(sqr, range(100)), list(map(squared, range(100)))) def test_async(self): res = self.pool.apply_async(sqr, (7, TIMEOUT1,)) get = TimingWrapper(res.get) self.assertEqual(get(), 49) self.assertTimeoutAlmostEqual(get.elapsed, TIMEOUT1, 1) def test_async_callback(self): result = [] res = self.pool.apply_async(sqr, (7, TIMEOUT1,), callback=lambda x: result.append(x)) get = TimingWrapper(res.get) self.assertEqual(get(), 49) self.assertTimeoutAlmostEqual(get.elapsed, TIMEOUT1, 1) gevent.sleep(0) # let's the callback run assert result == [49], result def test_async_timeout(self): res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 0.2)) get = TimingWrapper(res.get) self.assertRaises(gevent.Timeout, get, timeout=TIMEOUT2) self.assertTimeoutAlmostEqual(get.elapsed, TIMEOUT2, 1) self.pool.join() def test_imap(self): it = self.pool.imap(sqr, range(10)) self.assertEqual(list(it), list(map(squared, range(10)))) it = self.pool.imap(sqr, range(10)) for i in range(10): self.assertEqual(six.advance_iterator(it), i * i) self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) it = self.pool.imap(sqr, range(1000)) for i in range(1000): self.assertEqual(six.advance_iterator(it), i * i) self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) def test_imap_random(self): it = self.pool.imap(sqr_random_sleep, range(10)) self.assertEqual(list(it), list(map(squared, range(10)))) def test_imap_unordered(self): it = self.pool.imap_unordered(sqr, range(1000)) self.assertEqual(sorted(it), list(map(squared, range(1000)))) it = self.pool.imap_unordered(sqr, range(1000)) self.assertEqual(sorted(it), list(map(squared, range(1000)))) def test_imap_unordered_random(self): it = self.pool.imap_unordered(sqr_random_sleep, range(10)) self.assertEqual(sorted(it), list(map(squared, range(10)))) def test_empty(self): it = self.pool.imap_unordered(sqr, []) self.assertEqual(list(it), []) it = self.pool.imap(sqr, []) self.assertEqual(list(it), []) self.assertEqual(self.pool.map(sqr, []), []) def test_terminate(self): result = self.pool.map_async(gevent.sleep, [0.1] * ((self.size or 10) * 2)) gevent.sleep(0.1) kill = TimingWrapper(self.pool.kill) kill() assert kill.elapsed < 0.5, kill.elapsed result.join() def sleep(self, x): gevent.sleep(float(x) / 10.) return str(x) def test_imap_unordered_sleep(self): # testing that imap_unordered returns items in competion order result = list(self.pool.imap_unordered(self.sleep, [10, 1, 2])) if self.pool.size == 1: expected = ['10', '1', '2'] else: expected = ['1', '2', '10'] self.assertEqual(result, expected) # https://github.com/gevent/gevent/issues/423 def test_imap_no_stop(self): q = Queue() q.put(123) gevent.spawn_later(0.1, q.put, StopIteration) result = list(self.pool.imap(lambda _: _, q)) self.assertEqual(result, [123]) def test_imap_unordered_no_stop(self): q = Queue() q.put(1234) gevent.spawn_later(0.1, q.put, StopIteration) result = list(self.pool.imap_unordered(lambda _: _, q)) self.assertEqual(result, [1234]) # same issue, but different test: https://github.com/gevent/gevent/issues/311 def test_imap_final_sleep(self): result = list(self.pool.imap(sqr, final_sleep())) self.assertEqual(result, [0, 1, 4]) def test_imap_unordered_final_sleep(self): result = list(self.pool.imap_unordered(sqr, final_sleep())) self.assertEqual(result, [0, 1, 4]) # Issue 638 def test_imap_unordered_bounded_queue(self): iterable = list(range(100)) running = [0] def short_running_func(i, j): running[0] += 1 return i # Send two iterables to make sure varargs and kwargs are handled # correctly for meth in self.pool.imap_unordered, self.pool.imap: running[0] = 0 mapping = meth(short_running_func, iterable, iterable, maxsize=1) # Simulate a long running reader. No matter how many workers # we have, we will never have a queue more than size 1 def reader(): result = [] for i, x in enumerate(mapping): self.assertTrue(running[0] <= i + 2, running[0]) result.append(x) gevent.sleep(0.01) self.assertTrue(len(mapping.queue) <= 2, len(mapping.queue)) return result l = reader() self.assertEqual(sorted(l), iterable) class TestPool2(TestPool): size = 2 class TestPool3(TestPool): size = 3 class TestPool10(TestPool): size = 10 class TestPoolUnlimit(TestPool): size = None class TestPool0(greentest.TestCase): size = 0 def test_wait_full(self): p = pool.Pool(size=0) self.assertEqual(0, p.free_count()) self.assertTrue(p.full()) self.assertEqual(0, p.wait_available(timeout=0.01)) class TestJoinSleep(greentest.GenericWaitTestCase): def wait(self, timeout): p = pool.Pool() g = p.spawn(gevent.sleep, 10) try: p.join(timeout=timeout) finally: g.kill() class TestJoinSleep_raise_error(greentest.GenericWaitTestCase): def wait(self, timeout): p = pool.Pool() g = p.spawn(gevent.sleep, 10) try: p.join(timeout=timeout, raise_error=True) finally: g.kill() class TestJoinEmpty(greentest.TestCase): switch_expected = False def test(self): p = pool.Pool() p.join() class TestSpawn(greentest.TestCase): switch_expected = True def test(self): p = pool.Pool(1) self.assertEqual(len(p), 0) p.spawn(gevent.sleep, 0.1) self.assertEqual(len(p), 1) p.spawn(gevent.sleep, 0.1) # this spawn blocks until the old one finishes self.assertEqual(len(p), 1) gevent.sleep(0.19 if not greentest.RUNNING_ON_APPVEYOR else 0.5) self.assertEqual(len(p), 0) def error_iter(): yield 1 yield 2 raise ExpectedException class TestErrorInIterator(greentest.TestCase): error_fatal = False def test(self): p = pool.Pool(3) self.assertRaises(ExpectedException, p.map, lambda x: None, error_iter()) gevent.sleep(0.001) def test_unordered(self): p = pool.Pool(3) def unordered(): return list(p.imap_unordered(lambda x: None, error_iter())) self.assertRaises(ExpectedException, unordered) gevent.sleep(0.001) def divide_by(x): return 1.0 / x class TestErrorInHandler(greentest.TestCase): error_fatal = False def test_map(self): p = pool.Pool(3) self.assertRaises(ZeroDivisionError, p.map, divide_by, [1, 0, 2]) def test_imap(self): p = pool.Pool(1) it = p.imap(divide_by, [1, 0, 2]) self.assertEqual(next(it), 1.0) self.assertRaises(ZeroDivisionError, next, it) self.assertEqual(next(it), 0.5) self.assertRaises(StopIteration, next, it) def test_imap_unordered(self): p = pool.Pool(1) it = p.imap_unordered(divide_by, [1, 0, 2]) self.assertEqual(next(it), 1.0) self.assertRaises(ZeroDivisionError, next, it) self.assertEqual(next(it), 0.5) self.assertRaises(StopIteration, next, it) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__pywsgi.py0000644000076500000000000015104412666555342020636 0ustar jmaddenwheel00000000000000# Copyright (c) 2007, Linden Research, Inc. # Copyright (c) 2009-2010 gevent contributors # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from __future__ import print_function from gevent import monkey monkey.patch_all(thread=False) try: from urllib.parse import parse_qs except ImportError: # Python 2 from cgi import parse_qs import os import sys try: # On Python 2, we want the C-optimized version if # available; it has different corner-case behaviour than # the Python implementation, and it used by socket.makefile # by default. from cStringIO import StringIO except ImportError: from io import BytesIO as StringIO import weakref try: from wsgiref.validate import validator except ImportError: def validator(app): return app import greentest import gevent from gevent.hub import PY3, PYPY from gevent import socket from gevent import pywsgi from gevent.pywsgi import Input CONTENT_LENGTH = 'Content-Length' CONN_ABORTED_ERRORS = [] server_implements_chunked = True server_implements_pipeline = True server_implements_100continue = True DEBUG = '-v' in sys.argv try: from errno import WSAECONNABORTED CONN_ABORTED_ERRORS.append(WSAECONNABORTED) except ImportError: pass if greentest.PYPY or PY3: from errno import ECONNRESET CONN_ABORTED_ERRORS.append(ECONNRESET) REASONS = {200: 'OK', 500: 'Internal Server Error'} class ConnectionClosed(Exception): pass def read_headers(fd): response_line = fd.readline() if not response_line: raise ConnectionClosed response_line = response_line.decode('latin-1') headers = {} while True: line = fd.readline().strip() if not line: break line = line.decode('latin-1') try: key, value = line.split(': ', 1) except: print('Failed to split: %r' % (line, )) raise assert key.lower() not in [x.lower() for x in headers.keys()], 'Header %r:%r sent more than once: %r' % (key, value, headers) headers[key] = value return response_line, headers def iread_chunks(fd): while True: line = fd.readline() chunk_size = line.strip() try: chunk_size = int(chunk_size, 16) except: print('Failed to parse chunk size: %r' % line) raise if chunk_size == 0: crlf = fd.read(2) assert crlf == b'\r\n', repr(crlf) break data = fd.read(chunk_size) yield data crlf = fd.read(2) assert crlf == b'\r\n', repr(crlf) class Response(object): def __init__(self, status_line, headers): self.status_line = status_line self.headers = headers self.body = None self.chunks = False try: version, code, self.reason = status_line[:-2].split(' ', 2) self.code = int(code) HTTP, self.version = version.split('/') assert HTTP == 'HTTP', repr(HTTP) assert self.version in ('1.0', '1.1'), repr(self.version) except Exception: print('Error: %r' % status_line) raise def __iter__(self): yield self.status_line yield self.headers yield self.body def __str__(self): args = (self.__class__.__name__, self.status_line, self.headers, self.body, self.chunks) return '<%s status_line=%r headers=%r body=%r chunks=%r>' % args def assertCode(self, code): if hasattr(code, '__contains__'): assert self.code in code, 'Unexpected code: %r (expected %r)\n%s' % (self.code, code, self) else: assert self.code == code, 'Unexpected code: %r (expected %r)\n%s' % (self.code, code, self) def assertReason(self, reason): assert self.reason == reason, 'Unexpected reason: %r (expected %r)\n%s' % (self.reason, reason, self) def assertVersion(self, version): assert self.version == version, 'Unexpected version: %r (expected %r)\n%s' % (self.version, version, self) def assertHeader(self, header, value): real_value = self.headers.get(header, False) assert real_value == value, \ 'Unexpected header %r: %r (expected %r)\n%s' % (header, real_value, value, self) def assertBody(self, body): if isinstance(body, str) and PY3: body = body.encode("ascii") assert self.body == body, 'Unexpected body: %r (expected %r)\n%s' % (self.body, body, self) @classmethod def read(cls, fd, code=200, reason='default', version='1.1', body=None, chunks=None, content_length=None): _status_line, headers = read_headers(fd) self = cls(_status_line, headers) if code is not None: self.assertCode(code) if reason == 'default': reason = REASONS.get(code) if reason is not None: self.assertReason(reason) if version is not None: self.assertVersion(version) if self.code == 100: return self if content_length is not None: if isinstance(content_length, int): content_length = str(content_length) self.assertHeader('Content-Length', content_length) try: if 'chunked' in headers.get('Transfer-Encoding', ''): if CONTENT_LENGTH in headers: print("WARNING: server used chunked transfer-encoding despite having Content-Length header (libevent 1.x's bug)") self.chunks = list(iread_chunks(fd)) self.body = b''.join(self.chunks) elif CONTENT_LENGTH in headers: num = int(headers[CONTENT_LENGTH]) self.body = fd.read(num) else: self.body = fd.read() except: print('Response.read failed to read the body:\n%s' % self) import traceback; traceback.print_exc() raise if body is not None: self.assertBody(body) if chunks is not None: assert chunks == self.chunks, (chunks, self.chunks) return self read_http = Response.read if not PY3: # Under Python 3, socket.makefile does not use # socket._fileobject; instead it uses the io package. # We don't want to artificially interfere with that because # then we won't be testing the actual code that's in use. class DebugFileObject(object): def __init__(self, obj): self.obj = obj def read(self, *args): result = self.obj.read(*args) if DEBUG: print(repr(result)) return result def readline(self, *args): result = self.obj.readline(*args) if DEBUG: print(repr(result)) return result def __getattr__(self, item): assert item != 'obj' return getattr(self.obj, item) def makefile(self, mode='r', bufsize=-1): return DebugFileObject(socket._fileobject(self.dup(), mode, bufsize)) socket.socket.makefile = makefile class TestCase(greentest.TestCase): validator = staticmethod(validator) application = None def init_logger(self): import logging logger = logging.getLogger('gevent.pywsgi') return logger def init_server(self, application): logger = self.logger = self.init_logger() self.server = pywsgi.WSGIServer(('127.0.0.1', 0), application, log=logger, error_log=logger) def setUp(self): application = self.application if self.validator is not None: application = self.validator(application) self.init_server(application) self.server.start() self.port = self.server.server_port # We keep a list of sockets/files we need to close so we # don't get ResourceWarnings under Py3 self.connected = list() greentest.TestCase.setUp(self) def close_opened(self): for x in self.connected: x = x() if x is not None: x.close() self.connected = list() def tearDown(self): self.close_opened() greentest.TestCase.tearDown(self) timeout = gevent.Timeout.start_new(0.5) try: self.server.stop() finally: timeout.cancel() # XXX currently listening socket is kept open in gevent.wsgi def connect(self): conn = socket.create_connection(('127.0.0.1', self.port)) self.connected.append(weakref.ref(conn)) result = conn if PY3: conn_makefile = conn.makefile def makefile(*args, **kwargs): if 'bufsize' in kwargs: kwargs['buffering'] = kwargs.pop('bufsize') if 'mode' in kwargs: return conn_makefile(*args, **kwargs) # Under Python3, you can't read and write to the same # makefile() opened in (default) r, and r+ is not allowed kwargs['mode'] = 'rwb' rconn = conn_makefile(*args, **kwargs) _rconn_write = rconn.write def write(data): if isinstance(data, str): data = data.encode('ascii') return _rconn_write(data) rconn.write = write self.connected.append(weakref.ref(rconn)) return rconn class proxy(object): def __getattribute__(self, name): if name == 'makefile': return makefile return getattr(conn, name) result = proxy() return result def makefile(self): return self.connect().makefile(bufsize=1) def urlopen(self, *args, **kwargs): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') return read_http(fd, *args, **kwargs) class CommonTests(TestCase): def test_basic(self): fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') response = read_http(fd, body='hello world') if response.headers.get('Connection') == 'close' and not server_implements_pipeline: return fd.write('GET /notexist HTTP/1.1\r\nHost: localhost\r\n\r\n') read_http(fd, code=404, reason='Not Found', body='not found') fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') read_http(fd, body='hello world') fd.close() def test_pipeline(self): if not server_implements_pipeline: return fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n' + 'GET /notexist HTTP/1.1\r\nHost: localhost\r\n\r\n') read_http(fd, body='hello world') exception = AssertionError('HTTP pipelining not supported; the second request is thrown away') try: timeout = gevent.Timeout.start_new(0.5, exception=exception) try: read_http(fd, code=404, reason='Not Found', body='not found') fd.close() finally: timeout.cancel() except AssertionError as ex: if ex is not exception: raise def test_connection_close(self): fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') response = read_http(fd) if response.headers.get('Connection') == 'close' and not server_implements_pipeline: return fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') read_http(fd) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') try: result = fd.readline() assert not result, 'The remote side is expected to close the connection, but it send %r' % (result, ) except socket.error as ex: if ex.args[0] not in CONN_ABORTED_ERRORS: raise def SKIP_test_006_reject_long_urls(self): fd = self.makefile() path_parts = [] for ii in range(3000): path_parts.append('path') path = '/'.join(path_parts) request = 'GET /%s HTTP/1.0\r\nHost: localhost\r\n\r\n' % path fd.write(request) result = fd.readline() status = result.split(' ')[1] self.assertEqual(status, '414') fd.close() class TestNoChunks(CommonTests): # when returning a list of strings a shortcut is employed by the server: # it calculates the content-length and joins all the chunks before sending validator = None @staticmethod def application(env, start_response): path = env['PATH_INFO'] if path == '/': start_response('200 OK', [('Content-Type', 'text/plain')]) return [b'hello ', b'world'] else: start_response('404 Not Found', [('Content-Type', 'text/plain')]) return [b'not ', b'found'] def test(self): fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') response = read_http(fd, body='hello world') assert response.chunks is False, response.chunks response.assertHeader('Content-Length', '11') if not server_implements_pipeline: fd = self.makefile() fd.write('GET /not-found HTTP/1.1\r\nHost: localhost\r\n\r\n') response = read_http(fd, code=404, reason='Not Found', body='not found') assert response.chunks is False, response.chunks response.assertHeader('Content-Length', '9') class TestExplicitContentLength(TestNoChunks): # when returning a list of strings a shortcut is empoyed by the server - it caculates the content-length @staticmethod def application(env, start_response): path = env['PATH_INFO'] if path == '/': start_response('200 OK', [('Content-Type', 'text/plain'), ('Content-Length', '11')]) return [b'hello ', b'world'] else: start_response('404 Not Found', [('Content-Type', 'text/plain'), ('Content-Length', '9')]) return [b'not ', b'found'] class TestYield(CommonTests): @staticmethod def application(env, start_response): path = env['PATH_INFO'] if path == '/': start_response('200 OK', [('Content-Type', 'text/plain')]) yield b"hello world" else: start_response('404 Not Found', [('Content-Type', 'text/plain')]) yield b"not found" if sys.version_info[:2] >= (2, 6): class TestBytearray(CommonTests): validator = None @staticmethod def application(env, start_response): path = env['PATH_INFO'] if path == '/': start_response('200 OK', [('Content-Type', 'text/plain')]) return [bytearray(b"hello "), bytearray(b"world")] else: start_response('404 Not Found', [('Content-Type', 'text/plain')]) return [bytearray(b"not found")] class MultiLineHeader(TestCase): @staticmethod def application(env, start_response): assert "test.submit" in env["CONTENT_TYPE"] start_response('200 OK', [('Content-Type', 'text/plain')]) return [b"ok"] def test_multiline_116(self): """issue #116""" request = '\r\n'.join(( 'POST / HTTP/1.0', 'Host: localhost', 'Content-Type: multipart/related; boundary="====XXXX====";', ' type="text/xml";start="test.submit"', 'Content-Length: 0', '', '')) fd = self.makefile() fd.write(request) read_http(fd) class TestGetArg(TestCase): @staticmethod def application(env, start_response): body = env['wsgi.input'].read(3) if PY3: body = body.decode('ascii') a = parse_qs(body).get('a', [1])[0] start_response('200 OK', [('Content-Type', 'text/plain')]) return [('a is %s, body is %s' % (a, body)).encode('ascii')] def test_007_get_arg(self): # define a new handler that does a get_arg as well as a read_body fd = self.makefile() request = '\r\n'.join(( 'POST / HTTP/1.0', 'Host: localhost', 'Content-Length: 3', '', 'a=a')) fd.write(request) # send some junk after the actual request fd.write('01234567890123456789') read_http(fd, body='a is a, body is a=a') fd.close() class TestChunkedApp(TestCase): chunks = [b'this', b'is', b'chunked'] def body(self): return b''.join(self.chunks) def application(self, env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) for chunk in self.chunks: yield chunk def test_chunked_response(self): fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') response = read_http(fd, body=self.body(), chunks=None) if server_implements_chunked: response.assertHeader('Transfer-Encoding', 'chunked') self.assertEqual(response.chunks, self.chunks) else: response.assertHeader('Transfer-Encoding', False) response.assertHeader('Content-Length', str(len(self.body()))) self.assertEqual(response.chunks, False) def test_no_chunked_http_1_0(self): fd = self.makefile() fd.write('GET / HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n') response = read_http(fd) self.assertEqual(response.body, self.body()) self.assertEqual(response.headers.get('Transfer-Encoding'), None) content_length = response.headers.get('Content-Length') if content_length is not None: self.assertEqual(content_length, str(len(self.body()))) class TestBigChunks(TestChunkedApp): chunks = [b'a' * 8192] * 3 class TestChunkedPost(TestCase): @staticmethod def application(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) if env['PATH_INFO'] == '/a': data = env['wsgi.input'].read(6) return [data] elif env['PATH_INFO'] == '/b': lines = [x for x in iter(lambda: env['wsgi.input'].read(6), b'')] return lines elif env['PATH_INFO'] == '/c': return [x for x in iter(lambda: env['wsgi.input'].read(1), b'')] def test_014_chunked_post(self): fd = self.makefile() data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'2\r\noh\r\n4\r\n hai\r\n0\r\n\r\n') fd.write(data) read_http(fd, body='oh hai') self.close_opened() fd = self.makefile() fd.write(data.replace(b'/a', b'/b')) read_http(fd, body='oh hai') fd = self.makefile() fd.write(data.replace(b'/a', b'/c')) read_http(fd, body='oh hai') def test_229_incorrect_chunk_no_newline(self): # Giving both a Content-Length and a Transfer-Encoding, # TE is preferred. But if the chunking is bad from the client, # missing its terminating newline, # the server doesn't hang data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Content-Length: 12\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'{"hi": "ho"}') fd = self.makefile() fd.write(data) read_http(fd, code=400) def test_229_incorrect_chunk_non_hex(self): # Giving both a Content-Length and a Transfer-Encoding, # TE is preferred. But if the chunking is bad from the client, # the server doesn't hang data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Content-Length: 12\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'{"hi": "ho"}\r\n') fd = self.makefile() fd.write(data) read_http(fd, code=400) def test_229_correct_chunk_quoted_ext(self): data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'2;token="oh hi"\r\noh\r\n4\r\n hai\r\n0\r\n\r\n') fd = self.makefile() fd.write(data) read_http(fd, body='oh hai') def test_229_correct_chunk_token_ext(self): data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'2;token=oh_hi\r\noh\r\n4\r\n hai\r\n0\r\n\r\n') fd = self.makefile() fd.write(data) read_http(fd, body='oh hai') def test_229_incorrect_chunk_token_ext_too_long(self): data = (b'POST /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' b'Transfer-Encoding: chunked\r\n\r\n' b'2;token=oh_hi\r\noh\r\n4\r\n hai\r\n0\r\n\r\n') data = data.replace(b'oh_hi', b'_oh_hi' * 4000) fd = self.makefile() fd.write(data) read_http(fd, code=400) class TestUseWrite(TestCase): body = b'abcde' end = b'end' content_length = str(len(body + end)) def application(self, env, start_response): if env['PATH_INFO'] == '/explicit-content-length': write = start_response('200 OK', [('Content-Type', 'text/plain'), ('Content-Length', self.content_length)]) write(self.body) elif env['PATH_INFO'] == '/no-content-length': write = start_response('200 OK', [('Content-Type', 'text/plain')]) write(self.body) elif env['PATH_INFO'] == '/no-content-length-twice': write = start_response('200 OK', [('Content-Type', 'text/plain')]) write(self.body) write(self.body) else: raise Exception('Invalid url') return [self.end] def test_explicit_content_length(self): fd = self.makefile() fd.write('GET /explicit-content-length HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') response = read_http(fd, body=self.body + self.end) response.assertHeader('Content-Length', self.content_length) response.assertHeader('Transfer-Encoding', False) def test_no_content_length(self): fd = self.makefile() fd.write('GET /no-content-length HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') response = read_http(fd, body=self.body + self.end) if server_implements_chunked: response.assertHeader('Content-Length', False) response.assertHeader('Transfer-Encoding', 'chunked') else: response.assertHeader('Content-Length', self.content_length) def test_no_content_length_twice(self): fd = self.makefile() fd.write('GET /no-content-length-twice HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') response = read_http(fd, body=self.body + self.body + self.end) if server_implements_chunked: response.assertHeader('Content-Length', False) response.assertHeader('Transfer-Encoding', 'chunked') assert response.chunks == [self.body, self.body, self.end], response.chunks else: response.assertHeader('Content-Length', str(5 + 5 + 3)) class HttpsTestCase(TestCase): certfile = os.path.join(os.path.dirname(__file__), 'test_server.crt') keyfile = os.path.join(os.path.dirname(__file__), 'test_server.key') def init_server(self, application): self.server = pywsgi.WSGIServer(('127.0.0.1', 0), application, certfile=self.certfile, keyfile=self.keyfile) def urlopen(self, method='GET', post_body=None, **kwargs): import ssl sock = self.connect() sock = ssl.wrap_socket(sock) fd = sock.makefile(bufsize=1) fd.write('%s / HTTP/1.1\r\nHost: localhost\r\n' % method) if post_body is not None: fd.write('Content-Length: %s\r\n\r\n' % len(post_body)) fd.write(post_body) if kwargs.get('body') is None: kwargs['body'] = post_body else: fd.write('\r\n') fd.flush() return read_http(fd, **kwargs) def application(self, environ, start_response): assert environ['wsgi.url_scheme'] == 'https', environ['wsgi.url_scheme'] start_response('200 OK', [('Content-Type', 'text/plain')]) return [environ['wsgi.input'].read(10)] class TestHttps(HttpsTestCase): if hasattr(socket, 'ssl'): def test_012_ssl_server(self): result = self.urlopen(method="POST", post_body='abc') self.assertEquals(result.body, 'abc') def test_013_empty_return(self): result = self.urlopen() self.assertEquals(result.body, '') class TestInternational(TestCase): validator = None # wsgiref.validate.IteratorWrapper([]) does not have __len__ def application(self, environ, start_response): path_bytes = b'/\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82' if PY3: # Under PY3, the escapes were decoded as latin-1 path_bytes = path_bytes.decode('latin-1') self.assertEqual(environ['PATH_INFO'], path_bytes) self.assertEqual(environ['QUERY_STRING'], '%D0%B2%D0%BE%D0%BF%D1%80%D0%BE%D1%81=%D0%BE%D1%82%D0%B2%D0%B5%D1%82') start_response("200 PASSED", [('Content-Type', 'text/plain')]) return [] def test(self): sock = self.connect() sock.sendall(b'''GET /%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82?%D0%B2%D0%BE%D0%BF%D1%80%D0%BE%D1%81=%D0%BE%D1%82%D0%B2%D0%B5%D1%82 HTTP/1.1 Host: localhost Connection: close '''.replace(b'\n', b'\r\n')) read_http(sock.makefile(), reason='PASSED', chunks=False, body='', content_length=0) class TestNonLatin1HeaderFromApplication(TestCase): error_fatal = False # Allow sending the exception response, don't kill the greenlet validator = None # Don't validate the application, it's deliberately bad header = b'\xe1\xbd\x8a3' # bomb in utf-8 bytes should_error = PY3 # non-native string under Py3 def init_server(self, app): TestCase.init_server(self, app) self.errors = list() def application(self, environ, start_response): # We return a header that cannot be encoded in latin-1 try: start_response("200 PASSED", [('Content-Type', 'text/plain'), ('Custom-Header', self.header)]) except: self.errors.append(sys.exc_info()[:2]) raise return [] def test(self): sock = self.connect() sock.sendall(b'''GET / HTTP/1.1\r\n\r\n''') if self.should_error: read_http(sock.makefile(), code=500, reason='Internal Server Error') self.assertEqual(len(self.errors), 1) t, v = self.errors[0] self.assertTrue(isinstance(v, UnicodeError)) else: read_http(sock.makefile(), code=200, reason='PASSED') self.assertEqual(len(self.errors), 0) class TestNonLatin1UnicodeHeaderFromApplication(TestNonLatin1HeaderFromApplication): # Flip-flop of the superclass: Python 3 native string, Python 2 unicode object header = u"\u1f4a3" # bomb in unicode # Error both on py3 and py2. On py2, non-native string. On py3, native string # that cannot be encoded to latin-1 should_error = True class TestInputReadline(TestCase): # this test relies on the fact that readline() returns '' after it reached EOF # this behaviour is not mandated by WSGI spec, it's just happens that gevent.wsgi behaves like that # as such, this may change in the future validator = None def application(self, environ, start_response): input = environ['wsgi.input'] lines = [] while True: line = input.readline() if not line: break line = line.decode('ascii') if PY3 else line lines.append(repr(line) + ' ') start_response('200 hello', []) return [l.encode('ascii') for l in lines] if PY3 else lines def test(self): fd = self.makefile() content = 'hello\n\nworld\n123' fd.write('POST / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n' 'Content-Length: %s\r\n\r\n%s' % (len(content), content)) fd.flush() read_http(fd, reason='hello', body="'hello\\n' '\\n' 'world\\n' '123' ") class TestInputIter(TestInputReadline): def application(self, environ, start_response): input = environ['wsgi.input'] lines = [] for line in input: if not line: break line = line.decode('ascii') if PY3 else line lines.append(repr(line) + ' ') start_response('200 hello', []) return [l.encode('ascii') for l in lines] if PY3 else lines class TestInputReadlines(TestInputReadline): def application(self, environ, start_response): input = environ['wsgi.input'] lines = [l.decode('ascii') if PY3 else l for l in input.readlines()] lines = [repr(line) + ' ' for line in lines] start_response('200 hello', []) return [l.encode('ascii') for l in lines] if PY3 else lines class TestInputN(TestCase): # testing for this: # File "/home/denis/work/gevent/gevent/pywsgi.py", line 70, in _do_read # if length and length > self.content_length - self.position: # TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' validator = None def application(self, environ, start_response): environ['wsgi.input'].read(5) start_response('200 OK', []) return [] def test(self): self.urlopen() class TestError(TestCase): error = greentest.ExpectedException('TestError.application') error_fatal = False def application(self, env, start_response): raise self.error def test(self): self.expect_one_error() self.urlopen(code=500) self.assert_error(greentest.ExpectedException, self.error) class TestError_after_start_response(TestError): error = greentest.ExpectedException('TestError_after_start_response.application') def application(self, env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) raise self.error class TestEmptyYield(TestCase): @staticmethod def application(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield b"" yield b"" def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') if server_implements_chunked: chunks = [] else: chunks = False read_http(fd, body='', chunks=chunks) garbage = fd.read() self.assertEqual(garbage, b"", "got garbage: %r" % garbage) class TestFirstEmptyYield(TestCase): @staticmethod def application(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield b"" yield b"hello" def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') if server_implements_chunked: chunks = [b'hello'] else: chunks = False read_http(fd, body='hello', chunks=chunks) garbage = fd.read() self.assert_(garbage == b"", "got garbage: %r" % garbage) class TestEmptyYield304(TestCase): @staticmethod def application(env, start_response): start_response('304 Not modified', []) yield b"" yield b"" def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') read_http(fd, code=304, body='', chunks=False) garbage = fd.read() self.assertEqual(garbage, b"", "got garbage: %r" % garbage) class TestContentLength304(TestCase): validator = None def application(self, env, start_response): try: start_response('304 Not modified', [('Content-Length', '100')]) except AssertionError as ex: start_response('200 Raised', []) return ex.args else: raise AssertionError('start_response did not fail but it should') def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') body = "Invalid Content-Length for 304 response: '100' (must be absent or zero)" read_http(fd, code=200, reason='Raised', body=body, chunks=False) garbage = fd.read() self.assertEqual(garbage, b"", "got garbage: %r" % garbage) class TestBody304(TestCase): validator = None def application(self, env, start_response): start_response('304 Not modified', []) return [b'body'] def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') try: read_http(fd) except AssertionError as ex: self.assertEqual(str(ex), 'The 304 response must have no body') else: raise AssertionError('AssertionError must be raised') class TestWrite304(TestCase): validator = None def application(self, env, start_response): write = start_response('304 Not modified', []) self.error_raised = False try: write('body') except AssertionError: self.error_raised = True raise def test_err(self): fd = self.connect().makefile(bufsize=1) fd.write(b'GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') try: read_http(fd) except AssertionError as ex: self.assertEqual(str(ex), 'The 304 response must have no body') else: raise AssertionError('write() must raise') assert self.error_raised, 'write() must raise' class TestEmptyWrite(TestEmptyYield): @staticmethod def application(env, start_response): write = start_response('200 OK', [('Content-Type', 'text/plain')]) write(b"") write(b"") return [] class BadRequestTests(TestCase): validator = None # pywsgi checks content-length, but wsgi does not def application(self, env, start_response): assert env['CONTENT_LENGTH'] == self.content_length, (env['CONTENT_LENGTH'], self.content_length) start_response('200 OK', [('Content-Type', 'text/plain')]) return [b'hello'] def test_negative_content_length(self): self.content_length = '-100' fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nContent-Length: %s\r\n\r\n' % self.content_length) read_http(fd, code=(200, 400)) def test_illegal_content_length(self): self.content_length = 'abc' fd = self.connect().makefile(bufsize=1) fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nContent-Length: %s\r\n\r\n' % self.content_length) read_http(fd, code=(200, 400)) class ChunkedInputTests(TestCase): dirt = "" validator = None def application(self, env, start_response): input = env['wsgi.input'] response = [] pi = env["PATH_INFO"] if pi == "/short-read": d = input.read(10) response = [d] elif pi == "/lines": for x in input: response.append(x) elif pi == "/ping": input.read(1) response.append(b"pong") else: raise RuntimeError("bad path") start_response('200 OK', [('Content-Type', 'text/plain')]) return response def chunk_encode(self, chunks, dirt=None): if dirt is None: dirt = self.dirt return chunk_encode(chunks, dirt=dirt) def body(self, dirt=None): return self.chunk_encode(["this", " is ", "chunked", "\nline", " 2", "\n", "line3", ""], dirt=dirt) def ping(self, fd): fd.write("GET /ping HTTP/1.1\r\n\r\n") read_http(fd, body="pong") def ping_if_possible(self, fd): try: self.ping(fd) except ConnectionClosed: if server_implements_pipeline: raise fd = self.connect().makefile(bufsize=1) self.ping(fd) def test_short_read_with_content_length(self): body = self.body() req = b"POST /short-read HTTP/1.1\r\ntransfer-encoding: Chunked\r\nContent-Length:1000\r\n\r\n" + body conn = self.connect() fd = conn.makefile(bufsize=1) fd.write(req) read_http(fd, body="this is ch") self.ping_if_possible(fd) fd.close() conn.close() def test_short_read_with_zero_content_length(self): body = self.body() req = b"POST /short-read HTTP/1.1\r\ntransfer-encoding: Chunked\r\nContent-Length:0\r\n\r\n" + body #print("REQUEST:", repr(req)) fd = self.connect().makefile(bufsize=1) fd.write(req) read_http(fd, body="this is ch") self.ping_if_possible(fd) def test_short_read(self): body = self.body() req = b"POST /short-read HTTP/1.1\r\ntransfer-encoding: Chunked\r\n\r\n" + body fd = self.connect().makefile(bufsize=1) fd.write(req) read_http(fd, body="this is ch") self.ping_if_possible(fd) def test_dirt(self): body = self.body(dirt="; here is dirt\0bla") req = b"POST /ping HTTP/1.1\r\ntransfer-encoding: Chunked\r\n\r\n" + body fd = self.connect().makefile(bufsize=1) fd.write(req) try: read_http(fd, body="pong") except AssertionError as ex: if str(ex).startswith('Unexpected code: 400'): if not server_implements_chunked: print('ChunkedNotImplementedWarning') return raise self.ping_if_possible(fd) def test_chunked_readline(self): body = self.body() req = "POST /lines HTTP/1.1\r\nContent-Length: %s\r\ntransfer-encoding: Chunked\r\n\r\n" % (len(body)) req = req.encode('latin-1') req += body fd = self.connect().makefile(bufsize=1) fd.write(req) read_http(fd, body='this is chunked\nline 2\nline3') def test_close_before_finished(self): if server_implements_chunked: self.expect_one_error() body = b'4\r\nthi' req = b"POST /short-read HTTP/1.1\r\ntransfer-encoding: Chunked\r\n\r\n" + body sock = self.connect() fd = sock.makefile(bufsize=1, mode='wb') fd.write(req) fd.close() if PY3: # Python 3 keeps the socket open even though the only # makefile is gone; python 2 closed them both (because there were # no outstanding references to the socket). Closing is essential for the server # to get the message that the read will fail. It's better to be explicit # to avoid a ResourceWarning sock.close() else: # Under Py2 it still needs to go away, which was implicit before del sock gevent.sleep(0.01) # timing needed for cpython if server_implements_chunked: if greentest.PYPY: # XXX: Something is keeping the socket alive, # by which I mean, the close event is not propagating to the server # and waking up its recv() loop...we are stuck with the three bytes of # 'thi' in the buffer and trying to read the forth. No amount of tinkering # with the timing changes this...the only thing that does is running a # GC and letting some object get collected. Might this be a problem in real life? import gc gc.collect() gevent.sleep(0.01) self.assert_error(IOError, 'unexpected end of file while parsing chunked data') class Expect100ContinueTests(TestCase): validator = None def application(self, environ, start_response): content_length = int(environ['CONTENT_LENGTH']) if content_length > 1024: start_response('417 Expectation Failed', [('Content-Length', '7'), ('Content-Type', 'text/plain')]) return [b'failure'] else: # pywsgi did sent a "100 continue" for each read # see http://code.google.com/p/gevent/issues/detail?id=93 text = environ['wsgi.input'].read(1) text += environ['wsgi.input'].read(content_length - 1) start_response('200 OK', [('Content-Length', str(len(text))), ('Content-Type', 'text/plain')]) return [text] def test_continue(self): fd = self.connect().makefile(bufsize=1) fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 1025\r\nExpect: 100-continue\r\n\r\n') try: read_http(fd, code=417, body="failure") except AssertionError as ex: if str(ex).startswith('Unexpected code: 400'): if not server_implements_100continue: print('100ContinueNotImplementedWarning') return raise fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 7\r\nExpect: 100-continue\r\n\r\ntesting') read_http(fd, code=100) read_http(fd, body="testing") class MultipleCookieHeadersTest(TestCase): validator = None def application(self, environ, start_response): self.assertEqual(environ['HTTP_COOKIE'], 'name1="value1"; name2="value2"') self.assertEqual(environ['HTTP_COOKIE2'], 'nameA="valueA"; nameB="valueB"') start_response('200 OK', []) return [] def test(self): fd = self.connect().makefile(bufsize=1) fd.write('''GET / HTTP/1.1 Host: localhost Cookie: name1="value1" Cookie2: nameA="valueA" Cookie2: nameB="valueB" Cookie: name2="value2"\n\n'''.replace('\n', '\r\n')) read_http(fd) class TestLeakInput(TestCase): def application(self, environ, start_response): pi = environ["PATH_INFO"] self._leak_wsgi_input = environ["wsgi.input"] self._leak_environ = environ if pi == "/leak-frame": environ["_leak"] = sys._getframe(0) text = b"foobar" start_response('200 OK', [('Content-Length', str(len(text))), ('Content-Type', 'text/plain')]) return [text] def test_connection_close_leak_simple(self): fd = self.connect().makefile(bufsize=1) fd.write(b"GET / HTTP/1.0\r\nConnection: close\r\n\r\n") d = fd.read() assert d.startswith(b"HTTP/1.1 200 OK"), "bad response: %r" % d def test_connection_close_leak_frame(self): fd = self.connect().makefile(bufsize=1) fd.write(b"GET /leak-frame HTTP/1.0\r\nConnection: close\r\n\r\n") d = fd.read() assert d.startswith(b"HTTP/1.1 200 OK"), "bad response: %r" % d self._leak_environ.pop('_leak') class TestInvalidEnviron(TestCase): validator = None # check that WSGIServer does not insert any default values for CONTENT_LENGTH def application(self, environ, start_response): for key, value in environ.items(): if key in ('CONTENT_LENGTH', 'CONTENT_TYPE') or key.startswith('HTTP_'): if key != 'HTTP_HOST': raise AssertionError('Unexpected environment variable: %s=%r' % (key, value)) start_response('200 OK', []) return [] def test(self): fd = self.makefile() fd.write('GET / HTTP/1.0\r\nHost: localhost\r\n\r\n') read_http(fd) fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n') read_http(fd) class Handler(pywsgi.WSGIHandler): def read_requestline(self): data = self.rfile.read(7) if data[0] == b'<'[0]: try: data += self.rfile.read(15) if data.lower() == b'': self.socket.sendall(b'HELLO') else: self.log_error('Invalid request: %r', data) finally: self.socket.shutdown(socket.SHUT_WR) self.socket.close() self.socket = None else: return data + self.rfile.readline() class TestSubclass1(TestCase): validator = None def application(self, environ, start_response): start_response('200 OK', []) return [] def init_server(self, application): self.server = pywsgi.WSGIServer(('127.0.0.1', 0), application, handler_class=Handler) def test(self): fd = self.makefile() fd.write(b'\x00') fd.flush() # flush() is needed on PyPy, apparently it buffers slightly differently self.assertEqual(fd.read(), b'HELLO') fd = self.makefile() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n') fd.flush() read_http(fd) fd = self.makefile() fd.write('\x00') fd.flush() self.assertEqual(fd.read(), b'') class TestErrorAfterChunk(TestCase): validator = None @staticmethod def application(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield b"hello" raise greentest.ExpectedException('TestErrorAfterChunk') def test(self): fd = self.connect().makefile(bufsize=1) self.expect_one_error() fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n') self.assertRaises(ValueError, read_http, fd) self.assert_error(greentest.ExpectedException) def chunk_encode(chunks, dirt=None): if dirt is None: dirt = "" b = b"" for c in chunks: x = "%x%s\r\n%s\r\n" % (len(c), dirt, c) b += x.encode('ascii') return b class TestInputRaw(greentest.BaseTestCase): def make_input(self, data, content_length=None, chunked_input=False): if isinstance(data, list): data = chunk_encode(data) chunked_input = True elif isinstance(data, str) and PY3: data = data.encode("ascii") return Input(StringIO(data), content_length=content_length, chunked_input=chunked_input) if PY3: def assertEqual(self, data, expected, *args): if isinstance(expected, str): expected = expected.encode('ascii') super(TestInputRaw, self).assertEqual(data, expected, *args) def test_short_post(self): i = self.make_input("1", content_length=2) self.assertRaises(IOError, i.read) def test_short_post_read_with_length(self): i = self.make_input("1", content_length=2) self.assertRaises(IOError, i.read, 2) def test_short_post_readline(self): i = self.make_input("1", content_length=2) self.assertRaises(IOError, i.readline) def test_post(self): i = self.make_input("12", content_length=2) data = i.read() self.assertEqual(data, "12") def test_post_read_with_length(self): i = self.make_input("12", content_length=2) data = i.read(10) self.assertEqual(data, "12") def test_chunked(self): i = self.make_input(["1", "2", ""]) data = i.read() self.assertEqual(data, "12") def test_chunked_read_with_length(self): i = self.make_input(["1", "2", ""]) data = i.read(10) self.assertEqual(data, "12") def test_chunked_missing_chunk(self): i = self.make_input(["1", "2"]) self.assertRaises(IOError, i.read) def test_chunked_missing_chunk_read_with_length(self): i = self.make_input(["1", "2"]) self.assertRaises(IOError, i.read, 10) def test_chunked_missing_chunk_readline(self): i = self.make_input(["1", "2"]) self.assertRaises(IOError, i.readline) def test_chunked_short_chunk(self): i = self.make_input("2\r\n1", chunked_input=True) self.assertRaises(IOError, i.read) def test_chunked_short_chunk_read_with_length(self): i = self.make_input("2\r\n1", chunked_input=True) self.assertRaises(IOError, i.read, 2) def test_chunked_short_chunk_readline(self): i = self.make_input("2\r\n1", chunked_input=True) self.assertRaises(IOError, i.readline) def test_32bit_overflow(self): # https://github.com/gevent/gevent/issues/289 # Should not raise an OverflowError on Python 2 data = b'asdf\nghij\n' long_data = b'a' * (pywsgi.MAX_REQUEST_LINE + 10) long_data += b'\n' data = data + long_data partial_data = b'qjk\n' # Note terminating \n n = 25 * 1000000000 if hasattr(n, 'bit_length'): self.assertEqual(n.bit_length(), 35) if not PY3 and not PYPY: # Make sure we have the impl we think we do self.assertRaises(OverflowError, StringIO(data).readline, n) i = self.make_input(data, content_length=n) # No size hint, but we have too large a content_length to fit self.assertEqual(i.readline(), b'asdf\n') # Large size hint self.assertEqual(i.readline(n), b'ghij\n') self.assertEqual(i.readline(n), long_data) # Now again with the real content length, assuring we can't read past it i = self.make_input(data + partial_data, content_length=len(data) + 1) self.assertEqual(i.readline(), b'asdf\n') self.assertEqual(i.readline(n), b'ghij\n') self.assertEqual(i.readline(n), long_data) # Now we've reached content_length so we shouldn't be able to # read anymore except the one byte remaining self.assertEqual(i.readline(n), b'q') class Test414(TestCase): @staticmethod def application(env, start_response): raise AssertionError('should not get there') def test(self): fd = self.makefile() longline = 'x' * 20000 fd.write(('''GET /%s HTTP/1.0\r\nHello: world\r\n\r\n''' % longline).encode('latin-1')) read_http(fd, code=414) class TestLogging(TestCase): # Something that gets wrapped in a LoggingLogAdapter class Logger(object): accessed = None logged = None thing = None def log(self, level, msg): self.logged = (level, msg) def access(self, msg): self.accessed = msg def get_thing(self): return self.thing def init_logger(self): return self.Logger() @staticmethod def application(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) return [b'hello'] # Tests for issue #663 def test_proxy_methods_on_log(self): # An object that looks like a logger gets wrapped # with a proxy that self.assertTrue(isinstance(self.server.log, pywsgi.LoggingLogAdapter)) self.server.log.access("access") self.server.log.write("write") self.assertEqual(self.server.log.accessed, "access") self.assertEqual(self.server.log.logged, (20, "write")) def test_set_attributes(self): # Not defined by the wrapper, it goes to the logger self.server.log.thing = 42 self.assertEqual(self.server.log.get_thing(), 42) del self.server.log.thing self.assertEqual(self.server.log.get_thing(), None) def test_status_log(self): # Issue 664: Make sure we format the status line as a string self.urlopen() msg = self.server.log.logged[1] self.assertTrue('"GET / HTTP/1.1" 200 ' in msg, msg) # Issue 756: Make sure we don't throw a newline on the end self.assertTrue('\n' not in msg, msg) del CommonTests if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__queue.py0000644000076500000000000002643012666555342020440 0ustar jmaddenwheel00000000000000import greentest from greentest import TestCase, main, GenericGetTestCase import gevent from gevent.hub import get_hub, LoopExit from gevent import util from gevent import queue from gevent.queue import Empty, Full from gevent.event import AsyncResult class TestQueue(TestCase): def test_send_first(self): self.switch_expected = False q = queue.Queue() q.put('hi') self.assertEqual(q.peek(), 'hi') self.assertEqual(q.get(), 'hi') def test_peek_empty(self): q = queue.Queue() # No putters waiting, in the main loop: LoopExit self.assertRaises(LoopExit, q.peek) def waiter(q): self.assertRaises(Empty, q.peek, timeout=0.01) g = gevent.spawn(waiter, q) gevent.sleep(0.1) g.join() def test_peek_multi_greenlet(self): q = queue.Queue() g = gevent.spawn(q.peek) g.start() gevent.sleep(0) q.put(1) g.join() self.assertTrue(g.exception is None) self.assertEqual(q.peek(), 1) def test_send_last(self): q = queue.Queue() def waiter(q): with gevent.Timeout(0.1 if not greentest.RUNNING_ON_APPVEYOR else 0.5): self.assertEqual(q.get(), 'hi2') return "OK" p = gevent.spawn(waiter, q) gevent.sleep(0.01) q.put('hi2') gevent.sleep(0.01) assert p.get(timeout=0) == "OK" def test_max_size(self): q = queue.Queue(2) results = [] def putter(q): q.put('a') results.append('a') q.put('b') results.append('b') q.put('c') results.append('c') return "OK" p = gevent.spawn(putter, q) gevent.sleep(0) self.assertEqual(results, ['a', 'b']) self.assertEqual(q.get(), 'a') gevent.sleep(0) self.assertEqual(results, ['a', 'b', 'c']) self.assertEqual(q.get(), 'b') self.assertEqual(q.get(), 'c') assert p.get(timeout=0) == "OK" def test_zero_max_size(self): q = queue.Channel() def sender(evt, q): q.put('hi') evt.set('done') def receiver(evt, q): x = q.get() evt.set(x) e1 = AsyncResult() e2 = AsyncResult() p1 = gevent.spawn(sender, e1, q) gevent.sleep(0.001) self.assertTrue(not e1.ready()) p2 = gevent.spawn(receiver, e2, q) self.assertEqual(e2.get(), 'hi') self.assertEqual(e1.get(), 'done') with gevent.Timeout(0): gevent.joinall([p1, p2]) def test_multiple_waiters(self): # tests that multiple waiters get their results back q = queue.Queue() def waiter(q, evt): evt.set(q.get()) sendings = ['1', '2', '3', '4'] evts = [AsyncResult() for x in sendings] for i, x in enumerate(sendings): gevent.spawn(waiter, q, evts[i]) # XXX use waitall for them gevent.sleep(0.01) # get 'em all waiting results = set() def collect_pending_results(): for e in evts: with gevent.Timeout(0.001, False): x = e.get() results.add(x) return len(results) q.put(sendings[0]) self.assertEqual(collect_pending_results(), 1) q.put(sendings[1]) self.assertEqual(collect_pending_results(), 2) q.put(sendings[2]) q.put(sendings[3]) self.assertEqual(collect_pending_results(), 4) def test_waiters_that_cancel(self): q = queue.Queue() def do_receive(q, evt): with gevent.Timeout(0, RuntimeError()): try: result = q.get() evt.set(result) except RuntimeError: evt.set('timed out') evt = AsyncResult() gevent.spawn(do_receive, q, evt) self.assertEqual(evt.get(), 'timed out') q.put('hi') self.assertEqual(q.get(), 'hi') def test_senders_that_die(self): q = queue.Queue() def do_send(q): q.put('sent') gevent.spawn(do_send, q) self.assertEqual(q.get(), 'sent') def test_two_waiters_one_dies(self): def waiter(q, evt): evt.set(q.get()) def do_receive(q, evt): with gevent.Timeout(0, RuntimeError()): try: result = q.get() evt.set(result) except RuntimeError: evt.set('timed out') q = queue.Queue() dying_evt = AsyncResult() waiting_evt = AsyncResult() gevent.spawn(do_receive, q, dying_evt) gevent.spawn(waiter, q, waiting_evt) gevent.sleep(0.1) q.put('hi') self.assertEqual(dying_evt.get(), 'timed out') self.assertEqual(waiting_evt.get(), 'hi') def test_two_bogus_waiters(self): def do_receive(q, evt): with gevent.Timeout(0, RuntimeError()): try: result = q.get() evt.set(result) except RuntimeError: evt.set('timed out') q = queue.Queue() e1 = AsyncResult() e2 = AsyncResult() gevent.spawn(do_receive, q, e1) gevent.spawn(do_receive, q, e2) gevent.sleep(0.1) q.put('sent') self.assertEqual(e1.get(), 'timed out') self.assertEqual(e2.get(), 'timed out') self.assertEqual(q.get(), 'sent') class TestChannel(TestCase): def test_send(self): channel = queue.Channel() events = [] def another_greenlet(): events.append(channel.get()) events.append(channel.get()) g = gevent.spawn(another_greenlet) events.append('sending') channel.put('hello') events.append('sent hello') channel.put('world') events.append('sent world') self.assertEqual(['sending', 'hello', 'sent hello', 'world', 'sent world'], events) g.get() def test_wait(self): channel = queue.Channel() events = [] def another_greenlet(): events.append('sending hello') channel.put('hello') events.append('sending world') channel.put('world') events.append('sent world') g = gevent.spawn(another_greenlet) events.append('waiting') events.append(channel.get()) events.append(channel.get()) self.assertEqual(['waiting', 'sending hello', 'hello', 'sending world', 'world'], events) gevent.sleep(0) self.assertEqual(['waiting', 'sending hello', 'hello', 'sending world', 'world', 'sent world'], events) g.get() def test_task_done(self): channel = queue.JoinableQueue(0) X = object() gevent.spawn(channel.put, X) result = channel.get() assert result is X, (result, X) assert channel.unfinished_tasks == 1, channel.unfinished_tasks channel.task_done() assert channel.unfinished_tasks == 0, channel.unfinished_tasks class TestNoWait(TestCase): def test_put_nowait_simple(self): result = [] q = queue.Queue(1) def store_result(func, *args): result.append(func(*args)) run_callback = get_hub().loop.run_callback run_callback(store_result, util.wrap_errors(Full, q.put_nowait), 2) run_callback(store_result, util.wrap_errors(Full, q.put_nowait), 3) gevent.sleep(0) assert len(result) == 2, result assert result[0] is None, result assert isinstance(result[1], queue.Full), result def test_get_nowait_simple(self): result = [] q = queue.Queue(1) q.put(4) def store_result(func, *args): result.append(func(*args)) run_callback = get_hub().loop.run_callback run_callback(store_result, util.wrap_errors(Empty, q.get_nowait)) run_callback(store_result, util.wrap_errors(Empty, q.get_nowait)) gevent.sleep(0) assert len(result) == 2, result assert result[0] == 4, result assert isinstance(result[1], queue.Empty), result # get_nowait must work from the mainloop def test_get_nowait_unlock(self): result = [] q = queue.Queue(1) p = gevent.spawn(q.put, 5) def store_result(func, *args): result.append(func(*args)) assert q.empty(), q gevent.sleep(0) assert q.full(), q get_hub().loop.run_callback(store_result, q.get_nowait) gevent.sleep(0) assert q.empty(), q assert result == [5], result assert p.ready(), p assert p.dead, p assert q.empty(), q def test_get_nowait_unlock_channel(self): result = [] q = queue.Channel() p = gevent.spawn(q.put, 5) def store_result(func, *args): result.append(func(*args)) assert q.empty(), q assert q.full(), q gevent.sleep(0.001) assert q.empty(), q assert q.full(), q get_hub().loop.run_callback(store_result, q.get_nowait) gevent.sleep(0.001) assert q.empty(), q assert q.full(), q assert result == [5], result assert p.ready(), p assert p.dead, p assert q.empty(), q # put_nowait must work from the mainloop def test_put_nowait_unlock(self): result = [] q = queue.Queue() p = gevent.spawn(q.get) def store_result(func, *args): result.append(func(*args)) assert q.empty(), q assert not q.full(), q gevent.sleep(0.001) assert q.empty(), q assert not q.full(), q get_hub().loop.run_callback(store_result, q.put_nowait, 10) assert not p.ready(), p gevent.sleep(0.001) assert result == [None], result assert p.ready(), p assert not q.full(), q assert q.empty(), q class TestJoinEmpty(TestCase): def test_issue_45(self): """Test that join() exits immediatelly if not jobs were put into the queue""" self.switch_expected = False q = queue.JoinableQueue() q.join() def make_get_interrupt(queue_type): class TestGetInterrupt(GenericGetTestCase): Timeout = Empty def wait(self, timeout): return queue_type().get(timeout=timeout) TestGetInterrupt.__name__ += '_' + queue_type.__name__ return TestGetInterrupt for queue_type in [queue.Queue, queue.JoinableQueue, queue.LifoQueue, queue.PriorityQueue, queue.Channel]: klass = make_get_interrupt(queue_type) globals()[klass.__name__] = klass del klass, queue_type def make_put_interrupt(queue): class TestPutInterrupt(GenericGetTestCase): Timeout = Full def wait(self, timeout): while not queue.full(): queue.put(1) return queue.put(2, timeout=timeout) TestPutInterrupt.__name__ += '_' + queue.__class__.__name__ return TestPutInterrupt for obj in [queue.Queue(1), queue.JoinableQueue(1), queue.LifoQueue(1), queue.PriorityQueue(1), queue.Channel()]: klass = make_put_interrupt(obj) globals()[klass.__name__] = klass del klass, obj del GenericGetTestCase if __name__ == '__main__': main() gevent-1.1.0/greentest/test__real_greenlet.py0000644000076500000000000000072012666555342022116 0ustar jmaddenwheel00000000000000"""Testing that greenlet restores sys.exc_info. Passes with CPython + greenlet 0.4.0 Fails with PyPy 2.2.1 """ from __future__ import print_function import sys import greenlet print('Your greenlet version: %s' % (getattr(greenlet, '__version__', None), )) result = [] def func(): result.append(repr(sys.exc_info())) g = greenlet.greenlet(func) try: 1 / 0 except ZeroDivisionError: g.switch() assert result == ['(None, None, None)'], result gevent-1.1.0/greentest/test__refcount.py0000644000076500000000000001110512666555342021132 0ustar jmaddenwheel00000000000000# Copyright (c) 2008 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """This test checks that underlying socket instances (gevent.socket.socket._sock) are not leaked by the hub. """ from __future__ import print_function from _socket import socket import sys if sys.version_info[0] >= 3: # Python3 enforces that __weakref__ appears only once, # and not when a slotted class inherits from an unslotted class. # We mess around with the class MRO below and violate that rule # (because socket.socket defines __slots__ with __weakref__), # so import socket.socket before that can happen. __import__('socket') Socket = socket else: class Socket(socket): "Something we can have a weakref to" import _socket _socket.socket = Socket import greentest from gevent import monkey; monkey.patch_all() from pprint import pformat try: from thread import start_new_thread except ImportError: from _thread import start_new_thread from time import sleep import weakref import gc import socket socket._realsocket = Socket SOCKET_TIMEOUT = 0.1 def init_server(): s = socket.socket() s.settimeout(SOCKET_TIMEOUT) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('127.0.0.1', 0)) s.listen(5) return s def handle_request(s, raise_on_timeout): try: conn, address = s.accept() except socket.timeout: if raise_on_timeout: raise else: return #print('handle_request - accepted') res = conn.recv(100) assert res == b'hello', repr(res) #print('handle_request - recvd %r' % res) res = conn.send(b'bye') #print('handle_request - sent %r' % res) #print('handle_request - conn refcount: %s' % sys.getrefcount(conn)) #conn.close() def make_request(port): #print('make_request') s = socket.socket() s.connect(('127.0.0.1', port)) #print('make_request - connected') res = s.send(b'hello') #print('make_request - sent %s' % res) res = s.recv(100) assert res == b'bye', repr(res) #print('make_request - recvd %r' % res) #s.close() def run_interaction(run_client): s = init_server() start_new_thread(handle_request, (s, run_client)) if run_client: port = s.getsockname()[1] start_new_thread(make_request, (port, )) sleep(0.1 + SOCKET_TIMEOUT) #print(sys.getrefcount(s._sock)) #s.close() w = weakref.ref(s._sock) s.close() if greentest.RUNNING_ON_APPVEYOR: # The background thread may not have even had a chance to run # yet, sleep again to be sure it does. Otherwise there could be # strong refs to the socket still around. try: sleep(0.1 + SOCKET_TIMEOUT) except Exception: pass return w def run_and_check(run_client): w = run_interaction(run_client=run_client) if greentest.PYPY: # PyPy doesn't use a strict ref counting and must # run a gc, but the object should be gone gc.collect() if w(): print(pformat(gc.get_referrers(w()))) for x in gc.get_referrers(w()): print(pformat(x)) for y in gc.get_referrers(x): print('-', pformat(y)) raise AssertionError('server should be dead by now') @greentest.skipOnAppVeyor("Often fail with timeouts; not sure why") class Test(greentest.TestCase): def test_clean_exit(self): run_and_check(True) run_and_check(True) def test_timeout_exit(self): run_and_check(False) run_and_check(False) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__refcount_core.py0000644000076500000000000000067712666555342022156 0ustar jmaddenwheel00000000000000import weakref class Dummy: def __init__(self): __import__('gevent.core') try: assert weakref.ref(Dummy())() is None from gevent import socket assert weakref.ref(socket.socket())() is None except AssertionError: import sys if hasattr(sys, 'pypy_version_info'): # PyPy uses a non refcounted GC which may defer # the collection of the weakref, unlike CPython pass else: raise gevent-1.1.0/greentest/test__select.py0000644000076500000000000000275712666555342020601 0ustar jmaddenwheel00000000000000import six import sys import os from gevent import select, socket import greentest class TestSelect(greentest.GenericWaitTestCase): def wait(self, timeout): select.select([], [], [], timeout) if sys.platform != 'win32': class TestSelectRead(greentest.GenericWaitTestCase): def wait(self, timeout): r, w = os.pipe() try: select.select([r], [], [], timeout) finally: os.close(r) os.close(w) if hasattr(select, 'poll') and sys.platform != 'darwin': class TestPollRead(greentest.GenericWaitTestCase): def wait(self, timeout): r, w = os.pipe() try: poll = select.poll() poll.register(r) poll.poll(timeout * 1000) poll.unregister(r) finally: os.close(r) os.close(w) class TestSelectTypes(greentest.TestCase): def test_int(self): sock = socket.socket() select.select([int(sock.fileno())], [], [], 0.001) if hasattr(six.builtins, 'long'): def test_long(self): sock = socket.socket() select.select( [six.builtins.long(sock.fileno())], [], [], 0.001) def test_string(self): self.switch_expected = False self.assertRaises(TypeError, select.select, ['hello'], [], [], 0.001) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__semaphore.py0000644000076500000000000000371112666555342021274 0ustar jmaddenwheel00000000000000import greentest import gevent from gevent.lock import Semaphore from gevent.thread import allocate_lock import weakref try: from _thread import allocate_lock as std_allocate_lock except ImportError: # Py2 from thread import allocate_lock as std_allocate_lock class TestSemaphore(greentest.TestCase): # issue 39 def test_acquire_returns_false_after_timeout(self): s = Semaphore(value=0) result = s.acquire(timeout=0.01) assert result is False, repr(result) def test_release_twice(self): s = Semaphore() result = [] s.rawlink(lambda s: result.append('a')) s.release() s.rawlink(lambda s: result.append('b')) s.release() gevent.sleep(0.001) self.assertEqual(result, ['a', 'b']) def test_semaphore_weakref(self): s = Semaphore() r = weakref.ref(s) self.assertEqual(s, r()) def test_semaphore_in_class_with_del(self): # Issue #704. This used to crash the process # under PyPy through at least 4.0.1 if the Semaphore # was implemented with Cython. class X(object): def __init__(self): self.s = Semaphore() def __del__(self): self.s.acquire() X() import gc gc.collect() gc.collect() test_semaphore_in_class_with_del.ignore_leakcheck = True class TestLock(greentest.TestCase): def test_release_unheld_lock(self): std_lock = std_allocate_lock() g_lock = allocate_lock() try: std_lock.release() self.fail("Should have thrown an exception") except Exception as e: std_exc = e try: g_lock.release() self.fail("Should have thrown an exception") except Exception as e: g_exc = e self.assertTrue(isinstance(g_exc, type(std_exc)), (g_exc, std_exc)) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__server.py0000644000076500000000000003317312666555342020624 0ustar jmaddenwheel00000000000000from __future__ import print_function import greentest from gevent.hub import PY3 from gevent import socket import gevent from gevent.server import StreamServer import errno import os # Timeouts very flaky on appveyor _DEFAULT_SOCKET_TIMEOUT = 0.1 if not greentest.RUNNING_ON_APPVEYOR else 1.0 _DEFAULT_TEST_TIMEOUT = 5 if not greentest.RUNNING_ON_APPVEYOR else 10 class SimpleStreamServer(StreamServer): def handle(self, client_socket, address): fd = client_socket.makefile() try: request_line = fd.readline() if not request_line: return try: method, path, rest = request_line.split(' ', 3) except Exception: print('Failed to parse request line: %r' % (request_line, )) raise if path == '/ping': client_socket.sendall(b'HTTP/1.0 200 OK\r\n\r\nPONG') elif path in ['/long', '/short']: client_socket.sendall(b'hello') while True: data = client_socket.recv(1) if not data: break else: client_socket.sendall(b'HTTP/1.0 404 WTF?\r\n\r\n') finally: fd.close() class Settings: ServerClass = StreamServer ServerSubClass = SimpleStreamServer restartable = True close_socket_detected = True @staticmethod def assertAcceptedConnectionError(self): conn = self.makefile() result = conn.read() assert not result, repr(result) assert500 = assertAcceptedConnectionError @staticmethod def assert503(self): # regular reads timeout self.assert500() # attempt to send anything reset the connection try: self.send_request() except socket.error as ex: if ex.args[0] != errno.ECONNRESET: raise @staticmethod def assertPoolFull(self): self.assertRaises(socket.timeout, self.assertRequestSucceeded, timeout=0.01) class TestCase(greentest.TestCase): __timeout__ = _DEFAULT_TEST_TIMEOUT def cleanup(self): if getattr(self, 'server', None) is not None: self.server.stop() self.server = None def get_listener(self): sock = socket.socket() sock.bind(('127.0.0.1', 0)) sock.listen(5) return sock def makefile(self, timeout=_DEFAULT_SOCKET_TIMEOUT, bufsize=1): sock = socket.socket() try: sock.connect((self.server.server_host, self.server.server_port)) except: # avoid ResourceWarning under Py3 sock.close() raise if PY3: # Under Python3, you can't read and write to the same # makefile() opened in r, and r+ is not allowed kwargs = {'buffering': bufsize, 'mode': 'rwb'} else: kwargs = {'bufsize': bufsize} rconn = sock.makefile(**kwargs) if PY3: rconn._sock = sock rconn._sock.settimeout(timeout) sock.close() return rconn def send_request(self, url='/', timeout=_DEFAULT_SOCKET_TIMEOUT, bufsize=1): conn = self.makefile(timeout=timeout, bufsize=bufsize) conn.write(('GET %s HTTP/1.0\r\n\r\n' % url).encode('latin-1')) conn.flush() return conn def assertConnectionRefused(self): try: conn = self.makefile() try: raise AssertionError('Connection was not refused: %r' % (conn._sock, )) finally: conn.close() except socket.error as ex: if ex.args[0] not in (errno.ECONNREFUSED, errno.EADDRNOTAVAIL): raise def assert500(self): Settings.assert500(self) def assert503(self): Settings.assert503(self) def assertAcceptedConnectionError(self): Settings.assertAcceptedConnectionError(self) def assertPoolFull(self): Settings.assertPoolFull(self) def assertNotAccepted(self): conn = self.makefile() conn.write(b'GET / HTTP/1.0\r\n\r\n') conn.flush() result = '' try: while True: data = conn._sock.recv(1) if not data: break result += data except socket.timeout: assert not result, repr(result) return assert result.startswith('HTTP/1.0 500 Internal Server Error'), repr(result) conn.close() def assertRequestSucceeded(self, timeout=_DEFAULT_SOCKET_TIMEOUT): conn = self.makefile(timeout=timeout) conn.write(b'GET /ping HTTP/1.0\r\n\r\n') result = conn.read() conn.close() assert result.endswith(b'\r\n\r\nPONG'), repr(result) def start_server(self): self.server.start() self.assertRequestSucceeded() self.assertRequestSucceeded() def stop_server(self): self.server.stop() self.assertConnectionRefused() def report_netstat(self, msg): return print(msg) os.system('sudo netstat -anp | grep %s' % os.getpid()) print('^^^^^') def init_server(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() gevent.sleep(0.01) @property def socket(self): return self.server.socket def _test_invalid_callback(self): try: self.expect_one_error() self.server = self.ServerClass(('127.0.0.1', 0), lambda: None) self.server.start() self.assert500() self.assert_error(TypeError) finally: self.server.stop() # XXX: There's something unreachable (with a traceback?) # We need to clear it to make the leak checks work on Travis; # so far I can't reproduce it locally on OS X. import gc; gc.collect() def ServerClass(self, *args, **kwargs): kwargs.setdefault('spawn', self.get_spawn()) return Settings.ServerClass(*args, **kwargs) def ServerSubClass(self, *args, **kwargs): kwargs.setdefault('spawn', self.get_spawn()) return Settings.ServerSubClass(*args, **kwargs) class TestDefaultSpawn(TestCase): def get_spawn(self): return gevent.spawn def _test_server_start_stop(self, restartable): self.report_netstat('before start') self.start_server() self.report_netstat('after start') if restartable and Settings.restartable: self.server.stop_accepting() self.report_netstat('after stop_accepting') self.assertNotAccepted() self.server.start_accepting() self.report_netstat('after start_accepting') self.assertRequestSucceeded() self.stop_server() self.report_netstat('after stop') def test_backlog_is_not_accepted_for_socket(self): self.switch_expected = False self.assertRaises(TypeError, self.ServerClass, self.get_listener(), backlog=25, handle=False) def test_backlog_is_accepted_for_address(self): self.server = self.ServerSubClass(('127.0.0.1', 0), backlog=25) self.assertConnectionRefused() self._test_server_start_stop(restartable=False) def test_subclass_just_create(self): self.server = self.ServerSubClass(self.get_listener()) self.assertNotAccepted() def test_subclass_with_socket(self): self.server = self.ServerSubClass(self.get_listener()) # the connection won't be refused, because there exists a listening socket, but it won't be handled also self.assertNotAccepted() self._test_server_start_stop(restartable=True) def test_subclass_with_address(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.assertConnectionRefused() self._test_server_start_stop(restartable=True) def test_invalid_callback(self): self._test_invalid_callback() def _test_serve_forever(self): g = gevent.spawn(self.server.serve_forever) try: gevent.sleep(0.01) self.assertRequestSucceeded() self.server.stop() assert not self.server.started self.assertConnectionRefused() finally: g.kill() g.get() def test_serve_forever(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) assert not self.server.started self.assertConnectionRefused() self._test_serve_forever() def test_serve_forever_after_start(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.assertConnectionRefused() assert not self.server.started self.server.start() assert self.server.started self._test_serve_forever() def test_server_closes_client_sockets(self): self.server = self.ServerClass(('127.0.0.1', 0), lambda *args: []) self.server.start() conn = self.send_request() timeout = gevent.Timeout.start_new(1) # use assert500 below? try: try: result = conn.read() if result: assert result.startswith('HTTP/1.0 500 Internal Server Error'), repr(result) except socket.error as ex: if ex.args[0] == 10053: pass # "established connection was aborted by the software in your host machine" elif ex.args[0] == errno.ECONNRESET: pass else: raise finally: timeout.cancel() conn.close() self.stop_server() def init_server(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() gevent.sleep(0.01) @property def socket(self): return self.server.socket def test_error_in_spawn(self): self.init_server() assert self.server.started error = ExpectedError('test_error_in_spawn') self.server._spawn = lambda *args: gevent.getcurrent().throw(error) self.expect_one_error() self.assertAcceptedConnectionError() self.assert_error(ExpectedError, error) return if Settings.restartable: assert not self.server.started else: assert self.server.started gevent.sleep(0.1) assert self.server.started def test_server_repr_when_handle_is_instancemethod(self): # PR 501 self.init_server() self.start_server() self.assertTrue('Server' in repr(self.server)) self.server.set_handle(self.server.handle) self.assertTrue('handle=' in repr(self.server), repr(self.server)) self.server.set_handle(self.test_server_repr_when_handle_is_instancemethod) self.assertTrue('test_server_repr_when_handle_is_instancemethod' in repr(self.server), repr(self.server)) def handle(): pass self.server.set_handle(handle) self.assertTrue('handle= 0: space = ' ' * space else: space = '' log(msg + space + time_ms) def run(function, *args): if DEBUG: log(format_call(function, args)) delta = time() result = _run(function, *args) delta = time() - delta if DEBUG: log_fresult(result, delta) return result, delta def log_call(result, time, function, *args): log(format_call(function, args)) log_fresult(result, time) def compare_relaxed(a, b): """ >>> compare_relaxed('2a00:1450:400f:801::1010', '2a00:1450:400f:800::1011') True >>> compare_relaxed('2a00:1450:400f:801::1010', '2aXX:1450:400f:900::1011') False >>> compare_relaxed('2a00:1450:4016:800::1013', '2a00:1450:4008:c01::93') True >>> compare_relaxed('2001:470::e852:4a38:9d7f:0', '2001:470:6d00:1c:1::d00') True >>> compare_relaxed('2001:470:4147:4943:6161:6161:2e74:6573', '2001:470::') True >>> compare_relaxed('2607:f8b0:6708:24af:1fd:700:60d4:4af', '2607:f8b0:2d00::f000:0') True >>> compare_relaxed('a.google.com', 'b.google.com') True >>> compare_relaxed('a.google.com', 'a.gevent.org') False """ # IPv6 address from different requests might be different a_segments = a.count(':') b_segments = b.count(':') if a_segments and b_segments: if a_segments == b_segments and a_segments in (4, 5, 6, 7): return True if a.rstrip(':').startswith(b.rstrip(':')) or b.rstrip(':').startswith(a.rstrip(':')): return True if a_segments >= 2 and b_segments >= 2 and a.split(':')[:2] == b.split(':')[:2]: return True return a.split('.', 1)[-1] == b.split('.', 1)[-1] def contains_5tuples(lst): for item in lst: if not (isinstance(item, tuple) and len(item) == 5): return False return True def relaxed_is_equal(a, b): """ >>> relaxed_is_equal([(10, 1, 6, '', ('2a00:1450:400f:801::1010', 80, 0, 0))], [(10, 1, 6, '', ('2a00:1450:400f:800::1011', 80, 0, 0))]) True >>> relaxed_is_equal([1, '2'], (1, '2')) False >>> relaxed_is_equal([1, '2'], [1, '2']) True >>> relaxed_is_equal(('wi-in-x93.1e100.net', 'http'), ('we-in-x68.1e100.net', 'http')) True """ if type(a) is not type(b): return False if a == b: return True if isinstance(a, six.string_types): return compare_relaxed(a, b) if len(a) != len(b): return False if contains_5tuples(a) and contains_5tuples(b): # getaddrinfo results a = sorted(a) b = sorted(b) return all(relaxed_is_equal(x, y) for (x, y) in zip(a, b)) def add(klass, hostname, name=None): call = callable(hostname) if name is None: if call: name = hostname.__name__ else: name = re.sub('[^\w]+', '_', repr(hostname)) assert name, repr(hostname) def test1(self): x = hostname() if call else hostname self._test('getaddrinfo', x, 'http') test1.__name__ = 'test_%s_getaddrinfo' % name setattr(klass, test1.__name__, test1) def test2(self): x = hostname() if call else hostname ipaddr = self._test('gethostbyname', x) if not isinstance(ipaddr, Exception): self._test('gethostbyaddr', ipaddr) test2.__name__ = 'test_%s_gethostbyname' % name setattr(klass, test2.__name__, test2) def test3(self): x = hostname() if call else hostname self._test('gethostbyname_ex', x) test3.__name__ = 'test_%s_gethostbyname_ex' % name setattr(klass, test3.__name__, test3) def test4(self): x = hostname() if call else hostname self._test('gethostbyaddr', x) test4.__name__ = 'test_%s_gethostbyaddr' % name setattr(klass, test4.__name__, test4) def test5(self): x = hostname() if call else hostname self._test('getnameinfo', (x, 80), 0) test5.__name__ = 'test_%s_getnameinfo' % name setattr(klass, test5.__name__, test5) class TestCase(greentest.TestCase): __timeout__ = 30 switch_expected = None def should_log_results(self, result1, result2): if isinstance(result1, BaseException) and isinstance(result2, BaseException): return type(result1) is not type(result2) return repr(result1) != repr(result2) def _test(self, func, *args): gevent_func = getattr(gevent_socket, func) real_func = getattr(socket, func) real_result, time_real = run(real_func, *args) gevent_result, time_gevent = run(gevent_func, *args) if not DEBUG and self.should_log_results(real_result, gevent_result): log('') log_call(real_result, time_real, real_func, *args) log_call(gevent_result, time_gevent, gevent_func, *args) self.assertEqualResults(real_result, gevent_result, func, args) if time_gevent > time_real + 0.01 and time_gevent > 0.02: msg = 'gevent:%s%s took %dms versus %dms stdlib' % (func, args, time_gevent * 1000.0, time_real * 1000.0) if time_gevent > time_real + 1: word = 'VERY' else: word = 'quite' log('\nWARNING: %s slow: %s', word, msg) return gevent_result def _normalize_result(self, result): return result def assertEqualResults(self, real_result, gevent_result, func, args): errors = (socket.gaierror, socket.herror, TypeError) if isinstance(real_result, errors) and isinstance(gevent_result, errors): if type(real_result) is not type(gevent_result): log('WARNING: error type mismatch: %r (gevent) != %r (stdlib)', gevent_result, real_result) return real_result = self._normalize_result(real_result) gevent_result = self._normalize_result(gevent_result) real_result_repr = repr(real_result) gevent_result_repr = repr(gevent_result) if real_result_repr == gevent_result_repr: return if relaxed_is_equal(gevent_result, real_result): return # From 2.7 on, assertEqual does a better job highlighting the results than we would # because it calls assertSequenceEqual, which highlights the exact # difference in the tuple msg = format_call(func, args) self.assertEqual((msg, gevent_result), (msg, real_result)) class TestTypeError(TestCase): pass add(TestTypeError, None) add(TestTypeError, 25) class TestHostname(TestCase): pass add(TestHostname, socket.gethostname) class TestLocalhost(TestCase): # certain tests in test_patched_socket.py only work if getaddrinfo('localhost') does not switch # (e.g. NetworkConnectionAttributesTest.testSourceAddress) pass #switch_expected = False add(TestLocalhost, 'localhost') add(TestLocalhost, 'ip6-localhost') class TestNonexistent(TestCase): pass add(TestNonexistent, 'nonexistentxxxyyy') class Test1234(TestCase): pass add(Test1234, '1.2.3.4') class Test127001(TestCase): pass add(Test127001, '127.0.0.1') class TestBroadcast(TestCase): switch_expected = False add(TestBroadcast, '') class TestEtcHosts(TestCase): pass try: etc_hosts = open('/etc/hosts').read() except IOError: etc_hosts = '' for ip, host in re.findall(r'^\s*(\d+\.\d+\.\d+\.\d+)\s+([^\s]+)', etc_hosts, re.M)[:10]: add(TestEtcHosts, host) add(TestEtcHosts, ip) del host, ip class TestGeventOrg(TestCase): HOSTNAME = 'www.gevent.org' # For this test to work correctly, it needs to resolve to # an address with a single A record; round-robin DNS and multiple A records # may mess it up (subsequent requests---and we always make two---may return # unequal results). We used to use gevent.org, but that now has multiple A records; # trying www.gevent.org which is a CNAME to readthedocs.org. add(TestGeventOrg, TestGeventOrg.HOSTNAME) class TestFamily(TestCase): @classmethod def getresult(cls): if not hasattr(cls, '_result'): cls._result = getattr(socket, 'getaddrinfo')(TestGeventOrg.HOSTNAME, None) return cls._result def assert_error(self, error, function, *args): try: result = function(*args) raise AssertionError('%s: Expected to raise %s, instead returned %r' % (function, error, result)) except Exception as ex: if isinstance(error, six.string_types): repr_error = error else: repr_error = repr(error) if type(ex) is not type(error): raise if repr(ex) == repr_error: return raise def test_inet(self): self.assertEqual(gevent_socket.getaddrinfo(TestGeventOrg.HOSTNAME, None, socket.AF_INET), self.getresult()) def test_unspec(self): self.assertEqual(gevent_socket.getaddrinfo(TestGeventOrg.HOSTNAME, None, socket.AF_UNSPEC), self.getresult()) def test_badvalue(self): self._test('getaddrinfo', TestGeventOrg.HOSTNAME, None, 255) self._test('getaddrinfo', TestGeventOrg.HOSTNAME, None, 255000) self._test('getaddrinfo', TestGeventOrg.HOSTNAME, None, -1) def test_badtype(self): self._test('getaddrinfo', TestGeventOrg.HOSTNAME, 'x') class Test_getaddrinfo(TestCase): def _test_getaddrinfo(self, *args): self._test('getaddrinfo', *args) def test_80(self): self._test_getaddrinfo(TestGeventOrg.HOSTNAME, 80) def test_int_string(self): self._test_getaddrinfo(TestGeventOrg.HOSTNAME, '80') def test_0(self): self._test_getaddrinfo(TestGeventOrg.HOSTNAME, 0) def test_http(self): self._test_getaddrinfo(TestGeventOrg.HOSTNAME, 'http') def test_notexistent_tld(self): self._test_getaddrinfo('myhost.mytld', 53) def test_notexistent_dot_com(self): self._test_getaddrinfo('sdfsdfgu5e66098032453245wfdggd.com', 80) def test1(self): return self._test_getaddrinfo(TestGeventOrg.HOSTNAME, 52, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, 0) def test2(self): return self._test_getaddrinfo(TestGeventOrg.HOSTNAME, 53, socket.AF_INET, socket.SOCK_DGRAM, 17) def test3(self): return self._test_getaddrinfo('google.com', 'http', socket.AF_INET6) class TestInternational(TestCase): pass add(TestInternational, u'президент.рф', 'russian') add(TestInternational, u'президент.рф'.encode('idna'), 'idna') class TestInterrupted_gethostbyname(greentest.GenericWaitTestCase): def wait(self, timeout): with gevent.Timeout(timeout, False): for index in xrange(1000000): try: gevent_socket.gethostbyname('www.x%s.com' % index) except socket.error: pass raise AssertionError('Timeout was not raised') def cleanup(self): gevent.get_hub().threadpool.join() # class TestInterrupted_getaddrinfo(greentest.GenericWaitTestCase): # # def wait(self, timeout): # with gevent.Timeout(timeout, False): # for index in range(1000): # try: # gevent_socket.getaddrinfo('www.a%s.com' % index, 'http') # except socket.gaierror: # pass class TestBadName(TestCase): pass add(TestBadName, 'xxxxxxxxxxxx') class TestBadIP(TestCase): pass add(TestBadIP, '1.2.3.400') class Test_getnameinfo_127001(TestCase): def test(self): assert gevent_socket.getnameinfo is not socket.getnameinfo self._test('getnameinfo', ('127.0.0.1', 80), 0) def test_DGRAM(self): self._test('getnameinfo', ('127.0.0.1', 779), 0) self._test('getnameinfo', ('127.0.0.1', 779), socket.NI_DGRAM) def test_NOFQDN(self): # I get ('localhost', 'www') with _socket but ('localhost.localdomain', 'www') with gevent.socket self._test('getnameinfo', ('127.0.0.1', 80), socket.NI_NOFQDN) def test_NAMEREQD(self): self._test('getnameinfo', ('127.0.0.1', 80), socket.NI_NAMEREQD) class Test_getnameinfo_geventorg(TestCase): def test_NUMERICHOST(self): self._test('getnameinfo', (TestGeventOrg.HOSTNAME, 80), 0) self._test('getnameinfo', (TestGeventOrg.HOSTNAME, 80), socket.NI_NUMERICHOST) def test_NUMERICSERV(self): self._test('getnameinfo', (TestGeventOrg.HOSTNAME, 80), socket.NI_NUMERICSERV) def test_domain1(self): self._test('getnameinfo', (TestGeventOrg.HOSTNAME, 80), 0) def test_domain2(self): self._test('getnameinfo', ('www.gevent.org', 80), 0) def test_port_zero(self): self._test('getnameinfo', ('www.gevent.org', 0), 0) class Test_getnameinfo_fail(TestCase): def test_port_string(self): self._test('getnameinfo', ('www.gevent.org', 'http'), 0) def test_bad_flags(self): self._test('getnameinfo', ('127.0.0.1', 80), 55555555) class TestInvalidPort(TestCase): def test1(self): self._test('getnameinfo', ('www.gevent.org', -1), 0) def test2(self): self._test('getnameinfo', ('www.gevent.org', None), 0) def test3(self): self._test('getnameinfo', ('www.gevent.org', 'x'), 0) def test4(self): self._test('getnameinfo', ('www.gevent.org', 65536), 0) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__socket_dns6.py0000644000076500000000000000155212666555342021534 0ustar jmaddenwheel00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- import greentest import socket from test__socket_dns import TestCase, add class Test6(TestCase): # host that only has AAAA record host = 'aaaa.test-ipv6.com' def test_empty(self): self._test('getaddrinfo', self.host, 'http') def test_inet(self): self._test('getaddrinfo', self.host, None, socket.AF_INET) def test_inet6(self): self._test('getaddrinfo', self.host, None, socket.AF_INET6) def test_unspec(self): self._test('getaddrinfo', self.host, None, socket.AF_UNSPEC) class Test6_google(Test6): host = 'ipv6.google.com' class Test6_ds(Test6): # host that has both A and AAAA records host = 'ds.test-ipv6.com' add(Test6, Test6.host) add(Test6_google, Test6_google.host) add(Test6_ds, Test6_ds.host) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__socket_errors.py0000644000076500000000000000320112666555342022167 0ustar jmaddenwheel00000000000000# Copyright (c) 2008-2009 AG Projects # Author: Denis Bilenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import greentest from gevent.socket import socket, error try: from errno import WSAECONNREFUSED as ECONNREFUSED except ImportError: from errno import ECONNREFUSED class TestSocketErrors(greentest.TestCase): __timeout__ = 5 def test_connection_refused(self): s = socket() try: s.connect(('127.0.0.1', 81)) except error as ex: assert ex.args[0] == ECONNREFUSED, repr(ex) assert 'refused' in str(ex).lower(), str(ex) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__socket_ex.py0000644000076500000000000000212612666555342021274 0ustar jmaddenwheel00000000000000import greentest from gevent import socket import errno import sys class TestClosedSocket(greentest.TestCase): switch_expected = False def test(self): sock = socket.socket() sock.close() try: sock.send(b'a', timeout=1) raise AssertionError("Should not get here") except (socket.error, OSError) as ex: if ex.args[0] != errno.EBADF: if sys.platform.startswith('win'): # Windows/Py3 raises "OSError: [WinError 10038] " # which is not standard and not what it does # on Py2. pass else: raise class TestRef(greentest.TestCase): switch_expected = False def test(self): sock = socket.socket() assert sock.ref is True, sock.ref sock.ref = False assert sock.ref is False, sock.ref assert sock._read_event.ref is False, sock.ref assert sock._write_event.ref is False, sock.ref sock.close() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__socket_send_memoryview.py0000644000076500000000000000136512666555342024100 0ustar jmaddenwheel00000000000000# See issue #466 import ctypes class AnStructure(ctypes.Structure): _fields_ = [("x", ctypes.c_int)] def _send(socket): for meth in ('sendall', 'send'): anStructure = AnStructure() sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(('127.0.0.1', 12345)) getattr(sock, meth)(anStructure) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(('127.0.0.1', 12345)) sock.settimeout(1.0) getattr(sock, meth)(anStructure) def TestSendBuiltinSocket(): import socket _send(socket) def TestSendGeventSocket(): import gevent.socket _send(gevent.socket) if __name__ == '__main__': TestSendBuiltinSocket() TestSendGeventSocket() gevent-1.1.0/greentest/test__socket_ssl.py0000644000076500000000000000135512666555342021464 0ustar jmaddenwheel00000000000000#!/usr/bin/python from gevent import monkey; monkey.patch_all() import sys import greentest try: import httplib except ImportError: from http import client as httplib import socket if not hasattr(socket, 'ssl'): sys.exit(0) class AmazonHTTPSTests(greentest.TestCase): __timeout__ = 30 def test_amazon_response(self): conn = httplib.HTTPSConnection('sdb.amazonaws.com') conn.debuglevel = 1 conn.request('GET', '/') conn.getresponse() def test_str_and_repr(self): conn = socket.socket() conn.connect(('sdb.amazonaws.com', 443)) ssl_conn = socket.ssl(conn) assert str(ssl_conn) assert repr(ssl_conn) if __name__ == "__main__": greentest.main() gevent-1.1.0/greentest/test__socket_timeout.py0000644000076500000000000000220112666555342022340 0ustar jmaddenwheel00000000000000import gevent from gevent import socket import greentest class Test(greentest.TestCase): def start(self): self.server = socket.socket() self.server.bind(('127.0.0.1', 0)) self.server.listen(1) self.server_port = self.server.getsockname()[1] self.acceptor = gevent.spawn(self.server.accept) def stop(self): self.server.close() self.acceptor.kill() del self.acceptor del self.server def test(self): self.start() try: sock = socket.socket() sock.connect(('127.0.0.1', self.server_port)) try: sock.settimeout(0.1) try: result = sock.recv(1024) raise AssertionError('Expected timeout to be raised, instead recv() returned %r' % (result, )) except socket.error as ex: self.assertEqual(ex.args, ('timed out',)) self.assertEqual(str(ex), 'timed out') finally: sock.close() finally: self.stop() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__socketpair.py0000644000076500000000000000152312666555342021454 0ustar jmaddenwheel00000000000000from gevent import monkey; monkey.patch_all() import socket import unittest class TestSocketpair(unittest.TestCase): def test_makefile(self): msg = b'hello world' x, y = socket.socketpair() x.sendall(msg) x.close() with y.makefile('rb') as f: read = f.read() self.assertEqual(msg, read) y.close() def test_fromfd(self): msg = b'hello world' x, y = socket.socketpair() xx = socket.fromfd(x.fileno(), x.family, socket.SOCK_STREAM) x.close() yy = socket.fromfd(y.fileno(), y.family, socket.SOCK_STREAM) y.close() xx.sendall(msg) xx.close() with yy.makefile('rb') as f: read = f.read() self.assertEqual(msg, read) yy.close() if __name__ == '__main__': unittest.main() gevent-1.1.0/greentest/test__ssl.py0000644000076500000000000000617712666555342020123 0ustar jmaddenwheel00000000000000from gevent import monkey; monkey.patch_all() import os import sys import socket import greentest # Be careful not to have TestTCP as a bare attribute in this module, # even aliased, to avoid running duplicate tests import test__socket import ssl class TestSSL(test__socket.TestTCP): certfile = os.path.join(os.path.dirname(__file__), 'test_server.crt') privfile = os.path.join(os.path.dirname(__file__), 'test_server.key') # Python 2.x has socket.sslerror (which is an alias for # ssl.SSLError); That's gone in Py3 though. In Python 2, most timeouts are raised # as SSLError, but Python 3 raises the normal socket.timeout instead. So this has # the effect of making TIMEOUT_ERROR be SSLError on Py2 and socket.timeout on Py3 # See https://bugs.python.org/issue10272 TIMEOUT_ERROR = getattr(socket, 'sslerror', socket.timeout) def setUp(self): greentest.TestCase.setUp(self) self.listener, _raw_listener = ssl_listener(('127.0.0.1', 0), self.privfile, self.certfile) self.port = self.listener.getsockname()[1] def create_connection(self, *args, **kwargs): return ssl.wrap_socket(super(TestSSL, self).create_connection(*args, **kwargs)) if not sys.platform.startswith('win32'): # The SSL library can take a long time to buffer the large amount of data we're trying # to send, so we can't compare to the timeout values _test_sendall_timeout_check_time = False # The SSL layer has extra buffering, so test_sendall needs # to send a very large amount to make it timeout _test_sendall_data = data_sent = b'hello' * 100000000 def test_ssl_sendall_timeout0(self): # Issue #317: SSL_WRITE_PENDING in some corner cases server_sock = [] acceptor = test__socket.Thread(target=lambda: server_sock.append(self.listener.accept())) client = self.create_connection() client.setblocking(False) try: # Python 3 raises ssl.SSLWantWriteError; Python 2 simply *hangs* # on non-blocking sockets because it's a simple loop around # send(). Python 2.6 doesn't have SSLWantWriteError expected = getattr(ssl, 'SSLWantWriteError', ssl.SSLError) self.assertRaises(expected, client.sendall, self._test_sendall_data) finally: acceptor.join() client.close() server_sock[0][0].close() def test_empty_send(self): # Issue 719 # Sending empty bytes with the 'send' method raises # ssl.SSLEOFError in the stdlib. PyPy 4.0 and CPython 2.6 # both just raise the superclass, ssl.SSLError. expected = ssl.SSLError self.assertRaises(expected, self._test_sendall, b'', client_method='send') def ssl_listener(address, private_key, certificate): raw_listener = socket.socket() greentest.bind_and_listen(raw_listener, address) sock = ssl.wrap_socket(raw_listener, private_key, certificate) return sock, raw_listener if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__subprocess.py0000644000076500000000000002145712666555342021510 0ustar jmaddenwheel00000000000000import sys import os import errno import greentest import gevent from gevent import subprocess import time import gc PYPY = hasattr(sys, 'pypy_version_info') PY3 = sys.version_info[0] >= 3 if subprocess.mswindows: SETBINARY = 'import msvcrt; msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY);' else: SETBINARY = '' python_universal_newlines = hasattr(sys.stdout, 'newlines') # The stdlib of Python 3 on Windows doesn't properly handle universal newlines # (it produces broken results compared to Python 2) # See gevent.subprocess for more details. if PY3 and subprocess.mswindows: python_universal_newlines_broken = True else: python_universal_newlines_broken = False class Test(greentest.TestCase): def setUp(self): gc.collect() gc.collect() def test_exit(self): popen = subprocess.Popen([sys.executable, '-c', 'import sys; sys.exit(10)']) self.assertEqual(popen.wait(), 10) def test_wait(self): popen = subprocess.Popen([sys.executable, '-c', 'import sys; sys.exit(11)']) gevent.wait([popen]) self.assertEqual(popen.poll(), 11) def test_child_exception(self): try: subprocess.Popen(['*']).wait() except OSError as ex: assert ex.errno == 2, ex else: raise AssertionError('Expected OSError: [Errno 2] No such file or directory') def test_leak(self): num_before = greentest.get_number_open_files() p = subprocess.Popen([sys.executable, "-c", "print()"], stdout=subprocess.PIPE) p.wait() del p if PYPY: gc.collect() gc.collect() num_after = greentest.get_number_open_files() self.assertEqual(num_before, num_after) def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' 'sys.stderr.write("pineapple");' 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate(b"banana") self.assertEqual(stdout, b"banana") if sys.executable.endswith('-dbg'): assert stderr.startswith(b'pineapple') else: self.assertEqual(stderr, b"pineapple") def test_universal1(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, universal_newlines=1, bufsize=1) try: stdout = p.stdout.read() if python_universal_newlines: # Interpreter with universal newline support if not python_universal_newlines_broken: self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Note the extra newline after line 3 self.assertEqual(stdout, 'line1\nline2\nline3\n\nline4\n\nline5\nline6') else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") finally: p.stdout.close() def test_universal2(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' + SETBINARY + 'sys.stdout.write("line1\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line2\\r");' 'sys.stdout.flush();' 'sys.stdout.write("line3\\r\\n");' 'sys.stdout.flush();' 'sys.stdout.write("line4\\r\\nline5");' 'sys.stdout.flush();' 'sys.stdout.write("\\nline6");'], stdout=subprocess.PIPE, universal_newlines=1, bufsize=1) try: stdout = p.stdout.read() if python_universal_newlines: # Interpreter with universal newline support if not python_universal_newlines_broken: self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") else: # Note the extra newline after line 3 self.assertEqual(stdout, 'line1\nline2\nline3\n\nline4\n\nline5\nline6') else: # Interpreter without universal newline support self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6") finally: p.stdout.close() if sys.platform != 'win32': def test_nonblock_removed(self): # see issue #134 r, w = os.pipe() stdin = subprocess.FileObject(r) p = subprocess.Popen(['grep', 'text'], stdin=stdin) try: # Closing one half of the pipe causes Python 3 on OS X to terminate the # child process; it exits with code 1 and the assert that p.poll is None # fails. Removing the close lets it pass under both Python 3 and 2.7. # If subprocess.Popen._remove_nonblock_flag is changed to a noop, then # the test fails (as expected) even with the close removed #os.close(w) time.sleep(0.1) self.assertEqual(p.poll(), None) finally: if p.poll() is None: p.kill() stdin.close() os.close(w) def test_issue148(self): for i in range(7): try: subprocess.Popen('this_name_must_not_exist') except OSError as ex: if ex.errno != errno.ENOENT: raise else: raise AssertionError('must fail with ENOENT') def test_check_output_keyword_error(self): try: subprocess.check_output([sys.executable, '-c', 'import sys; sys.exit(44)']) except subprocess.CalledProcessError as e: self.assertEqual(e.returncode, 44) else: raise AssertionError('must fail with CalledProcessError') def test_popen_bufsize(self): # Test that subprocess has unbuffered output by default # (as the vanilla subprocess module) if PY3: # The default changed under python 3. return p = subprocess.Popen([sys.executable, '-u', '-c', 'import sys; sys.stdout.write(sys.stdin.readline())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) p.stdin.write(b'foobar\n') r = p.stdout.readline() self.assertEqual(r, b'foobar\n') if sys.platform != 'win32': def test_subprocess_in_native_thread(self): # gevent.subprocess doesn't work from a background # native thread. See #688 from gevent import monkey # must be a native thread; defend against monkey-patching ex = [] Thread = monkey.get_original('threading', 'Thread') def fn(): try: gevent.subprocess.Popen('echo 123', shell=True) raise AssertionError("Should not be able to construct Popen") except Exception as e: ex.append(e) thread = Thread(target=fn) thread.start() thread.join() self.assertEqual(len(ex), 1) self.assertTrue(isinstance(ex[0], TypeError), ex) self.assertEqual(ex[0].args[0], 'child watchers are only available on the default loop') test_subprocess_in_native_thread.ignore_leakcheck = True if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__subprocess_interrupted.py0000644000076500000000000000103512666555342024123 0ustar jmaddenwheel00000000000000import sys from six import xrange if 'runtestcase' in sys.argv[1:]: import gevent import gevent.subprocess gevent.spawn(sys.exit, 'bye') gevent.subprocess.Popen('python -c "1/0"'.split()) gevent.sleep(1) else: import subprocess for _ in xrange(5): out, err = subprocess.Popen([sys.executable, __file__, 'runtestcase'], stderr=subprocess.PIPE).communicate() if b'refs' in err: assert err.startswith(b'bye'), repr(err) else: assert err.strip() == b'bye', repr(err) gevent-1.1.0/greentest/test__subprocess_poll.py0000644000076500000000000000024412666555342022525 0ustar jmaddenwheel00000000000000import sys from gevent.subprocess import Popen from util import alarm alarm(3) popen = Popen([sys.executable, '-c', 'pass']) while popen.poll() is None: pass gevent-1.1.0/greentest/test__systemerror.py0000644000076500000000000000304312666555342021705 0ustar jmaddenwheel00000000000000import sys import greentest import gevent from gevent.hub import get_hub def raise_(ex): raise ex MSG = 'should be re-raised and caught' class Test(greentest.TestCase): error_fatal = False def test_sys_exit(self): self.start(sys.exit, MSG) try: gevent.sleep(0.001) except SystemExit as ex: assert str(ex) == MSG, repr(str(ex)) else: raise AssertionError('must raise SystemExit') def test_keyboard_interrupt(self): self.start(raise_, KeyboardInterrupt) try: gevent.sleep(0.001) except KeyboardInterrupt: pass else: raise AssertionError('must raise KeyboardInterrupt') def test_system_error(self): self.start(raise_, SystemError(MSG)) try: gevent.sleep(0.001) except SystemError as ex: assert str(ex) == MSG, repr(str(ex)) else: raise AssertionError('must raise SystemError') def test_exception(self): self.start(raise_, Exception('regular exception must not kill the program')) gevent.sleep(0.001) class TestCallback(Test): def tearDown(self): assert not self.x.pending, self.x def start(self, *args): self.x = get_hub().loop.run_callback(*args) class TestSpawn(Test): def tearDown(self): gevent.sleep(0.0001) assert self.x.dead, self.x def start(self, *args): self.x = gevent.spawn(*args) del Test if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__threading.py0000644000076500000000000000123712666555342021257 0ustar jmaddenwheel00000000000000from gevent import monkey; monkey.patch_all() import gevent.hub # check that the locks initialized by 'threading' did not init the hub assert gevent.hub._get_hub() is None, 'monkey.patch_all() should not init hub' import gevent import greentest import threading def helper(): threading.currentThread() gevent.sleep(0.2) class Test(greentest.TestCase): def test(self): before = len(threading._active) g = gevent.spawn(helper) gevent.sleep(0.1) self.assertEqual(len(threading._active), before + 1) g.join() self.assertEqual(len(threading._active), before) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__threading_before_monkey.py0000644000076500000000000000122112666555342024154 0ustar jmaddenwheel00000000000000# If stdlib threading is imported *BEFORE* monkey patching, # we can still get the current (main) thread, and it's not a DummyThread. import threading from gevent import monkey monkey.patch_all() import greentest class Test(greentest.TestCase): def test_main_thread(self): current = threading.current_thread() self.assertFalse(isinstance(current, threading._DummyThread)) self.assertTrue(isinstance(current, monkey.get_original('threading', 'Thread'))) # in 3.4, if the patch is incorrectly done, getting the repr # of the thread fails repr(current) if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__threading_holding_lock_while_monkey.py0000644000076500000000000000052112666555342026540 0ustar jmaddenwheel00000000000000from gevent import monkey import threading # Make sure that we can patch gevent while holding # a threading lock. Under Python2, where RLock is implemented # in python code, this used to throw RuntimeErro("Cannot release un-acquired lock") # See https://github.com/gevent/gevent/issues/615 with threading.RLock(): monkey.patch_all() gevent-1.1.0/greentest/test__threading_patched_local.py0000644000076500000000000000077612666555342024130 0ustar jmaddenwheel00000000000000from gevent import monkey; monkey.patch_all() import threading localdata = threading.local() localdata.x = "hello" assert localdata.x == 'hello' success = [] def func(): try: localdata.x raise AssertionError('localdata.x must raise AttributeError') except AttributeError: pass assert localdata.__dict__ == {}, localdata.__dict__ success.append(1) t = threading.Thread(None, func) t.start() t.join() assert success == [1], 'test failed' assert localdata.x == 'hello' gevent-1.1.0/greentest/test__threading_vs_settrace.py0000644000076500000000000001231612666555342023661 0ustar jmaddenwheel00000000000000from __future__ import print_function import sys import subprocess import unittest from gevent.thread import allocate_lock script = """ from gevent import monkey monkey.patch_all() import sys, os, threading, time # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): time.sleep(0.1) sys.stdout.write('..program blocked; aborting!') sys.stdout.flush() os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() def trace(frame, event, arg): if threading is not None: threading.currentThread() return trace def doit(): sys.stdout.write("..thread started..") def test1(): t = threading.Thread(target=doit) t.start() t.join() sys.settrace(None) sys.settrace(trace) if len(sys.argv) > 1: test1() sys.stdout.write("..finishing..") """ class TestTrace(unittest.TestCase): def test_untraceable_lock(self): # Untraceable locks were part of the solution to https://bugs.python.org/issue1733757 # which details a deadlock that could happen if a trace function invoked # threading.currentThread at shutdown time---the cleanup lock would be held # by the VM, and calling currentThread would try to acquire it again. The interpreter # changed in 2.6 to use the `with` statement (https://hg.python.org/cpython/rev/76f577a9ec03/), # which apparently doesn't trace in quite the same way. if hasattr(sys, 'gettrace'): old = sys.gettrace() else: old = None PYPY = hasattr(sys, 'pypy_version_info') lst = [] try: def trace(frame, ev, arg): lst.append((frame.f_code.co_filename, frame.f_lineno, ev)) if not PYPY: # because we expect to trace on PyPy print("TRACE: %s:%s %s" % lst[-1]) return trace with allocate_lock(): sys.settrace(trace) finally: sys.settrace(old) if not PYPY: self.assertEqual(lst, [], "trace not empty") else: # Have an assert so that we know if we miscompile self.assertTrue(len(lst) > 0, "should not compile on pypy") def test_untraceable_lock_uses_different_lock(self): if hasattr(sys, 'gettrace'): old = sys.gettrace() else: old = None PYPY = hasattr(sys, 'pypy_version_info') PY3 = sys.version_info[0] > 2 lst = [] # we should be able to use unrelated locks from within the trace function l = allocate_lock() try: def trace(frame, ev, arg): with l: lst.append((frame.f_code.co_filename, frame.f_lineno, ev)) if not PYPY: # because we expect to trace on PyPy print("TRACE: %s:%s %s" % lst[-1]) return trace l2 = allocate_lock() sys.settrace(trace) # Separate functions, not the C-implemented `with` so the trace # function gets a crack at them l2.acquire() l2.release() finally: sys.settrace(old) if not PYPY and not PY3: # Py3 overrides acquire in Python to do argument checking self.assertEqual(lst, [], "trace not empty") else: # Have an assert so that we know if we miscompile self.assertTrue(len(lst) > 0, "should not compile on pypy") def test_untraceable_lock_uses_same_lock(self): from gevent.hub import LoopExit if hasattr(sys, 'gettrace'): old = sys.gettrace() else: old = None PYPY = hasattr(sys, 'pypy_version_info') PY3 = sys.version_info[0] > 2 lst = [] e = None # we should not be able to use the same lock from within the trace function # because it's over acquired but instead of deadlocking it raises an exception l = allocate_lock() try: def trace(frame, ev, arg): with l: lst.append((frame.f_code.co_filename, frame.f_lineno, ev)) return trace sys.settrace(trace) # Separate functions, not the C-implemented `with` so the trace # function gets a crack at them l.acquire() except LoopExit as ex: e = ex finally: sys.settrace(old) if not PYPY and not PY3: # Py3 overrides acquire in Python to do argument checking self.assertEqual(lst, [], "trace not empty") else: # Have an assert so that we know if we miscompile self.assertTrue(len(lst) > 0, "should not compile on pypy") self.assertTrue(isinstance(e, LoopExit)) def run_script(self, more_args=()): args = [sys.executable, "-c", script] args.extend(more_args) rc = subprocess.call(args) self.assertNotEqual(rc, 2, "interpreter was blocked") self.assertEqual(rc, 0, "Unexpected error") def test_finalize_with_trace(self): self.run_script() def test_bootstrap_inner_with_trace(self): self.run_script(["1"]) if __name__ == "__main__": import greentest greentest.main() gevent-1.1.0/greentest/test__threadpool.py0000644000076500000000000002651012666555342021454 0ustar jmaddenwheel00000000000000import sys from time import time, sleep import random import weakref import greentest from gevent.threadpool import ThreadPool import gevent from greentest import ExpectedException import six import gc PYPY = hasattr(sys, 'pypy_version_info') class TestCase(greentest.TestCase): def cleanup(self): pool = getattr(self, 'pool', None) if pool is not None: pool.kill() del self.pool class PoolBasicTests(TestCase): def test_execute_async(self): self.pool = pool = ThreadPool(2) r = [] first = pool.spawn(r.append, 1) first.get() self.assertEqual(r, [1]) gevent.sleep(0) pool.apply_async(r.append, (2, )) self.assertEqual(r, [1]) pool.apply_async(r.append, (3, )) self.assertEqual(r, [1]) pool.apply_async(r.append, (4, )) self.assertEqual(r, [1]) gevent.sleep(0.01) self.assertEqual(sorted(r), [1, 2, 3, 4]) def test_apply(self): self.pool = pool = ThreadPool(1) result = pool.apply(lambda a: ('foo', a), (1, )) self.assertEqual(result, ('foo', 1)) def test_apply_raises(self): self.pool = pool = ThreadPool(1) def raiser(): raise ExpectedException() try: pool.apply(raiser) except ExpectedException: pass else: self.fail("Should have raised ExpectedException") # Don't let the metaclass automatically force any error # that reaches the hub from a spawned greenlet to become # fatal; that defeats the point of the test. test_apply_raises.error_fatal = False def test_init_valueerror(self): self.switch_expected = False self.assertRaises(ValueError, ThreadPool, -1) self.pool = None # # tests from standard library test/test_multiprocessing.py class TimingWrapper(object): def __init__(self, func): self.func = func self.elapsed = None def __call__(self, *args, **kwds): t = time() try: return self.func(*args, **kwds) finally: self.elapsed = time() - t def sqr(x, wait=0.0): sleep(wait) return x * x def sqr_random_sleep(x): sleep(random.random() * 0.1) return x * x TIMEOUT1, TIMEOUT2, TIMEOUT3 = 0.082, 0.035, 0.14 class TestPool(TestCase): __timeout__ = 5 size = 1 def setUp(self): greentest.TestCase.setUp(self) self.pool = ThreadPool(self.size) def test_apply(self): papply = self.pool.apply self.assertEqual(papply(sqr, (5,)), sqr(5)) self.assertEqual(papply(sqr, (), {'x': 3}), sqr(x=3)) def test_map(self): pmap = self.pool.map self.assertEqual(pmap(sqr, range(10)), list(map(sqr, range(10)))) self.assertEqual(pmap(sqr, range(100)), list(map(sqr, range(100)))) def test_async(self): res = self.pool.apply_async(sqr, (7, TIMEOUT1,)) get = TimingWrapper(res.get) self.assertEqual(get(), 49) self.assertAlmostEqual(get.elapsed, TIMEOUT1, 1) def test_async_callback(self): result = [] res = self.pool.apply_async(sqr, (7, TIMEOUT1,), callback=lambda x: result.append(x)) get = TimingWrapper(res.get) self.assertEqual(get(), 49) self.assertAlmostEqual(get.elapsed, TIMEOUT1, 1) gevent.sleep(0) # let's the callback run assert result == [49], result def test_async_timeout(self): res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 0.2)) get = TimingWrapper(res.get) self.assertRaises(gevent.Timeout, get, timeout=TIMEOUT2) self.assertAlmostEqual(get.elapsed, TIMEOUT2, 1) self.pool.join() def test_imap(self): it = self.pool.imap(sqr, range(10)) self.assertEqual(list(it), list(map(sqr, range(10)))) it = self.pool.imap(sqr, range(10)) for i in range(10): self.assertEqual(six.advance_iterator(it), i * i) self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) it = self.pool.imap(sqr, range(1000)) for i in range(1000): self.assertEqual(six.advance_iterator(it), i * i) self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) def test_imap_gc(self): it = self.pool.imap(sqr, range(10)) for i in range(10): self.assertEqual(six.advance_iterator(it), i * i) gc.collect() self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) def test_imap_unordered_gc(self): it = self.pool.imap_unordered(sqr, range(10)) result = [] for i in range(10): result.append(six.advance_iterator(it)) gc.collect() self.assertRaises(StopIteration, lambda: six.advance_iterator(it)) self.assertEqual(sorted(result), [x * x for x in range(10)]) def test_imap_random(self): it = self.pool.imap(sqr_random_sleep, range(10)) self.assertEqual(list(it), list(map(sqr, range(10)))) def test_imap_unordered(self): it = self.pool.imap_unordered(sqr, range(1000)) self.assertEqual(sorted(it), list(map(sqr, range(1000)))) it = self.pool.imap_unordered(sqr, range(1000)) self.assertEqual(sorted(it), list(map(sqr, range(1000)))) def test_imap_unordered_random(self): it = self.pool.imap_unordered(sqr_random_sleep, range(10)) self.assertEqual(sorted(it), list(map(sqr, range(10)))) def test_terminate(self): size = self.size or 10 result = self.pool.map_async(sleep, [0.1] * (size * 2)) gevent.sleep(0.1) kill = TimingWrapper(self.pool.kill) kill() assert kill.elapsed < 0.1 * self.size + 0.5, kill.elapsed result.join() def sleep(self, x): sleep(float(x) / 10.) return str(x) def test_imap_unordered_sleep(self): # testing that imap_unordered returns items in competion order result = list(self.pool.imap_unordered(self.sleep, [10, 1, 2])) if self.pool.size == 1: expected = ['10', '1', '2'] else: expected = ['1', '2', '10'] self.assertEqual(result, expected) class TestPool2(TestPool): size = 2 def test_recursive_apply(self): p = self.pool def a(): return p.apply(b) def b(): # make sure we can do both types of callbacks # (loop iteration and end-of-loop) in the recursive # call gevent.sleep() gevent.sleep(0.001) return "B" result = p.apply(a) self.assertEqual(result, "B") # Asking for the hub in the new thread shows up as a "leak" test_recursive_apply.ignore_leakcheck = True class TestPool3(TestPool): size = 3 class TestPool10(TestPool): size = 10 __timeout__ = 5 # class TestJoinSleep(greentest.GenericGetTestCase): # # def wait(self, timeout): # pool = ThreadPool(1) # pool.spawn(gevent.sleep, 10) # pool.join(timeout=timeout) # # # class TestJoinSleep_raise_error(greentest.GenericWaitTestCase): # # def wait(self, timeout): # pool = ThreadPool(1) # g = pool.spawn(gevent.sleep, 10) # pool.join(timeout=timeout, raise_error=True) class TestJoinEmpty(TestCase): switch_expected = False def test(self): self.pool = ThreadPool(1) self.pool.join() class TestSpawn(TestCase): switch_expected = True def test(self): self.pool = pool = ThreadPool(1) self.assertEqual(len(pool), 0) log = [] sleep_n_log = lambda item, seconds: [sleep(seconds), log.append(item)] pool.spawn(sleep_n_log, 'a', 0.1) self.assertEqual(len(pool), 1) pool.spawn(sleep_n_log, 'b', 0.1) # even though the pool is of size 1, it can contain 2 items # since we allow +1 for better throughput self.assertEqual(len(pool), 2) gevent.sleep(0.15) self.assertEqual(log, ['a']) self.assertEqual(len(pool), 1) gevent.sleep(0.15) self.assertEqual(log, ['a', 'b']) self.assertEqual(len(pool), 0) def error_iter(): yield 1 yield 2 raise greentest.ExpectedException class TestErrorInIterator(TestCase): error_fatal = False def test(self): self.pool = ThreadPool(3) self.assertRaises(greentest.ExpectedException, self.pool.map, lambda x: None, error_iter()) gevent.sleep(0.001) def test_unordered(self): self.pool = ThreadPool(3) def unordered(): return list(self.pool.imap_unordered(lambda x: None, error_iter())) self.assertRaises(greentest.ExpectedException, unordered) gevent.sleep(0.001) class TestMaxsize(TestCase): def test_inc(self): self.pool = ThreadPool(0) done = [] gevent.spawn(self.pool.spawn, done.append, 1) gevent.spawn_later(0.0001, self.pool.spawn, done.append, 2) gevent.sleep(0.01) self.assertEqual(done, []) self.pool.maxsize = 1 gevent.sleep(0.01) self.assertEqual(done, [1, 2]) def test_setzero(self): pool = self.pool = ThreadPool(3) pool.spawn(sleep, 0.1) pool.spawn(sleep, 0.2) pool.spawn(sleep, 0.3) gevent.sleep(0.2) self.assertEqual(pool.size, 3) pool.maxsize = 0 gevent.sleep(0.2) self.assertEqual(pool.size, 0) class TestSize(TestCase): def test(self): pool = self.pool = ThreadPool(2) self.assertEqual(pool.size, 0) pool.size = 1 self.assertEqual(pool.size, 1) pool.size = 2 self.assertEqual(pool.size, 2) pool.size = 1 self.assertEqual(pool.size, 1) def set_neg(): pool.size = -1 self.assertRaises(ValueError, set_neg) def set_too_big(): pool.size = 3 self.assertRaises(ValueError, set_too_big) pool.size = 0 self.assertEqual(pool.size, 0) pool.size = 2 self.assertEqual(pool.size, 2) class TestRef(TestCase): def test(self): pool = self.pool = ThreadPool(2) refs = [] obj = SomeClass() obj.refs = refs func = obj.func del obj with greentest.disabled_gc(): # we do this: # result = func(Object(), kwarg1=Object()) # but in a thread pool and see that arguments', result's and func's references are not leaked result = pool.apply(func, (Object(), ), {'kwarg1': Object()}) assert isinstance(result, Object), repr(result) gevent.sleep(0.1) # XXX should not be needed refs.append(weakref.ref(func)) del func, result if PYPY: gc.collect() gc.collect() for index, r in enumerate(refs): assert r() is None, (index, r(), greentest.getrefcount(r()), refs) assert len(refs) == 4, refs class Object(object): pass class SomeClass(object): def func(self, arg1, kwarg1=None): result = Object() self.refs.extend([weakref.ref(x) for x in [arg1, kwarg1, result]]) return result def func(): pass class TestRefCount(TestCase): def test(self): pool = ThreadPool(1) pool.spawn(func) gevent.sleep(0) pool.kill() if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test__timeout.py0000644000076500000000000001144312666555342021000 0ustar jmaddenwheel00000000000000import greentest import gevent from gevent.hub import get_hub import sys SHOULD_EXPIRE = 0.01 if not greentest.RUNNING_ON_APPVEYOR: SHOULD_NOT_EXPIRE = SHOULD_EXPIRE * 2.0 else: SHOULD_NOT_EXPIRE = SHOULD_EXPIRE * 20.0 class TestDirectRaise(greentest.TestCase): switch_expected = False def test_direct_raise_class(self): try: raise gevent.Timeout except gevent.Timeout as t: assert not t.pending, repr(t) def test_direct_raise_instance(self): timeout = gevent.Timeout() try: raise timeout except gevent.Timeout as t: assert timeout is t, (timeout, t) assert not t.pending, repr(t) class Test(greentest.TestCase): def _test(self, timeout): try: get_hub().switch() self.fail('Must raise Timeout') except gevent.Timeout as ex: if ex is not timeout: raise return ex def _check_expires(self, timeout): timeout.start() self._test(timeout) # Restart timeout.start() return self._test(timeout) def test_expires(self): timeout = gevent.Timeout(SHOULD_EXPIRE) self._check_expires(timeout) def test_expires_false(self): # A False exception value only matters to a # context manager timeout = gevent.Timeout(SHOULD_EXPIRE, False) self._check_expires(timeout) def test_expires_str(self): # str values are accepted but not documented; they change # the message timeout = gevent.Timeout(SHOULD_EXPIRE, 'XXX') ex = self._check_expires(timeout) self.assertTrue(str(ex).endswith('XXX')) def test_expires_non_exception(self): timeout = gevent.Timeout(SHOULD_EXPIRE, object()) timeout.start() try: get_hub().switch() self.fail("Most raise TypeError") except TypeError as ex: self.assertTrue("exceptions must be" in str(ex), str(ex)) timeout.cancel() class OldStyle: pass timeout = gevent.Timeout(SHOULD_EXPIRE, OldStyle) # Type timeout.start() try: get_hub().switch() self.fail("Must raise OldStyle") except TypeError as ex: self.assertTrue(greentest.PY3, "Py3 raises a TypeError for non-BaseExceptions") self.assertTrue("exceptions must be" in str(ex), str(ex)) except: self.assertTrue(greentest.PY2, "Old style classes can only be raised on Py2") t = sys.exc_info()[0] self.assertEqual(t, OldStyle) timeout.cancel() timeout = gevent.Timeout(SHOULD_EXPIRE, OldStyle()) # instance timeout.start() try: get_hub().switch() self.fail("Must raise OldStyle") except TypeError as ex: self.assertTrue(greentest.PY3, "Py3 raises a TypeError for non-BaseExceptions") self.assertTrue("exceptions must be" in str(ex), str(ex)) except: self.assertTrue(greentest.PY2, "Old style classes can only be raised on Py2") t = sys.exc_info()[0] self.assertEqual(t, OldStyle) timeout.cancel() def _check_context_manager_expires(self, timeout, raises=True): try: with timeout: get_hub().switch() except gevent.Timeout as ex: if ex is not timeout: raise return ex if raises: self.fail("Must raise Timeout") def test_context_manager(self): timeout = gevent.Timeout(SHOULD_EXPIRE) self._check_context_manager_expires(timeout) def test_context_manager_false(self): # Suppress the exception timeout = gevent.Timeout(SHOULD_EXPIRE, False) self._check_context_manager_expires(timeout, raises=False) self.assertTrue(str(timeout).endswith('(silent)'), str(timeout)) def test_context_manager_str(self): timeout = gevent.Timeout(SHOULD_EXPIRE, 'XXX') ex = self._check_context_manager_expires(timeout) self.assertTrue(str(ex).endswith('XXX'), str(ex)) def test_cancel(self): timeout = gevent.Timeout(SHOULD_EXPIRE) timeout.start() timeout.cancel() gevent.sleep(SHOULD_NOT_EXPIRE) assert not timeout.pending, timeout def test_with_timeout(self): self.assertRaises(gevent.Timeout, gevent.with_timeout, SHOULD_EXPIRE, gevent.sleep, SHOULD_NOT_EXPIRE) X = object() r = gevent.with_timeout(SHOULD_EXPIRE, gevent.sleep, SHOULD_NOT_EXPIRE, timeout_value=X) assert r is X, (r, X) r = gevent.with_timeout(SHOULD_NOT_EXPIRE, gevent.sleep, SHOULD_EXPIRE, timeout_value=X) assert r is None, r if __name__ == '__main__': greentest.main() gevent-1.1.0/greentest/test_ares_timeout.py0000644000076500000000000000176612666555342021662 0ustar jmaddenwheel00000000000000from __future__ import print_function import sys import errno import gevent try: from gevent.resolver_ares import Resolver except ImportError as ex: print(ex) sys.exit(0) from gevent import socket print(gevent.__file__) address = ('', 7153) listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: listener.bind(address) except socket.error as ex: if ex.errno in (errno.EPERM, errno.EADDRNOTAVAIL) or 'permission denied' in str(ex).lower(): sys.stderr.write('This test binds on port a port that was already in use or not allowed.\n') sys.exit(0) raise def reader(): while True: print(listener.recvfrom(10000)) gevent.spawn(reader) r = gevent.get_hub().resolver = Resolver(servers=['127.0.0.1'], timeout=0.001, tries=1, udp_port=address[-1]) try: result = r.gethostbyname('www.google.com') except socket.gaierror as ex: if 'ARES_ETIMEOUT' not in str(ex): raise else: raise AssertionError('Expected timeout, got %r' % (result, )) gevent-1.1.0/greentest/test_close_backend_fd.py0000644000076500000000000000175012666555342022400 0ustar jmaddenwheel00000000000000from __future__ import print_function import os import gevent from gevent import core from six import xrange for count in xrange(2): for backend in core.supported_backends(): hub = gevent.get_hub(backend, default=False) assert hub.loop.backend == backend, (hub.loop.backend, backend) gevent.sleep(0.001) fileno = hub.loop.fileno() if fileno is not None: print('%s. Testing %r: %r' % (count, backend, hub)) os.close(fileno) try: gevent.sleep(0.001) except SystemError as ex: if '(libev)' in str(ex): print('The error is expected: %s' % ex) else: raise else: raise AssertionError('gevent.sleep() is expected to fail after loop fd was closed') else: print('%s. %r lacks fileno()' % (count, backend)) hub.destroy() assert 'destroyed' in repr(hub), repr(hub) gevent-1.1.0/greentest/test_hub_join.py0000644000076500000000000000045712666555342020753 0ustar jmaddenwheel00000000000000import gevent # hub.join() guarantees that loop has exited cleanly res = gevent.get_hub().join() assert res is True, res res = gevent.get_hub().join() assert res is True, res # but it is still possible to use gevent afterwards gevent.sleep(0.01) res = gevent.get_hub().join() assert res is True, res gevent-1.1.0/greentest/test_hub_join_timeout.py0000644000076500000000000000552512666555342022522 0ustar jmaddenwheel00000000000000from contextlib import contextmanager import gevent from gevent.event import Event from time import time from six import xrange SMALL = 0.1 FUZZY = SMALL / 2 # setting up signal does not affect join() gevent.signal(1, lambda: None) # wouldn't work on windows from greentest import RUNNING_ON_APPVEYOR @contextmanager def expected_time(expected, fuzzy=None): if fuzzy is None: if RUNNING_ON_APPVEYOR: # The noted timer jitter issues on appveyor fuzzy = expected * 5.0 else: fuzzy = expected / 2.0 start = time() yield elapsed = time() - start assert expected - fuzzy <= elapsed <= expected + fuzzy, 'Expected: %r; elapsed: %r; fuzzy %r' % (expected, elapsed, fuzzy) def no_time(fuzzy=0.001): return expected_time(0, fuzzy=fuzzy) for _a in xrange(2): # exiting because the spawned greenlet finished execution (spawn (=callback) variant) for _ in xrange(2): x = gevent.spawn(lambda: 5) with no_time(SMALL): result = gevent.wait(timeout=10) assert result is True, repr(result) assert x.dead, x assert x.value == 5, x # exiting because the spawned greenlet finished execution (spawn_later (=timer) variant) for _ in xrange(2): x = gevent.spawn_later(SMALL, lambda: 5) with expected_time(SMALL): result = gevent.wait(timeout=10) assert result is True, repr(result) assert x.dead, x # exiting because of timeout (the spawned greenlet still runs) for _ in xrange(2): x = gevent.spawn_later(10, lambda: 5) with expected_time(SMALL): result = gevent.wait(timeout=SMALL) assert result is False, repr(result) assert not x.dead, (x, x._start_event) x.kill() with no_time(): result = gevent.wait() assert result is True # exiting because of event (the spawned greenlet still runs) for _ in xrange(2): x = gevent.spawn_later(10, lambda: 5) event = Event() event_set = gevent.spawn_later(SMALL, event.set) with expected_time(SMALL): result = gevent.wait([event]) assert result == [event], repr(result) assert not x.dead, x assert event_set.dead assert event.is_set() x.kill() with no_time(): result = gevent.wait() assert result is True # checking "ref=False" argument for _ in xrange(2): gevent.get_hub().loop.timer(10, ref=False).start(lambda: None) with no_time(): result = gevent.wait() assert result is True # checking "ref=False" attribute for _d in xrange(2): w = gevent.get_hub().loop.timer(10) w.start(lambda: None) w.ref = False with no_time(): result = gevent.wait() assert result is True gevent-1.1.0/greentest/test_issue112.py0000644000076500000000000000030512666555342020522 0ustar jmaddenwheel00000000000000import sys if sys.version_info[0] == 2: import threading import gevent.monkey gevent.monkey.patch_all() import gevent assert threading._sleep is gevent.sleep, threading._sleep gevent-1.1.0/greentest/test_queue.py0000644000076500000000000003166312666555342020305 0ustar jmaddenwheel00000000000000# Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. from gevent import monkey; monkey.patch_all() from gevent import queue as Queue import threading import time import unittest try: from test import support as test_support except ImportError: from test import test_support from six import xrange QUEUE_SIZE = 5 # A thread to run a function that unclogs a blocked Queue. class _TriggerThread(threading.Thread): def __init__(self, fn, args): self.fn = fn self.args = args #self.startedEvent = threading.Event() from gevent.event import Event self.startedEvent = Event() threading.Thread.__init__(self) def run(self): # The sleep isn't necessary, but is intended to give the blocking # function in the main thread a chance at actually blocking before # we unclog it. But if the sleep is longer than the timeout-based # tests wait in their blocking functions, those tests will fail. # So we give them much longer timeout values compared to the # sleep here (I aimed at 10 seconds for blocking functions -- # they should never actually wait that long - they should make # progress as soon as we call self.fn()). time.sleep(0.01) self.startedEvent.set() self.fn(*self.args) # Execute a function that blocks, and in a separate thread, a function that # triggers the release. Returns the result of the blocking function. Caution: # block_func must guarantee to block until trigger_func is called, and # trigger_func must guarantee to change queue state so that block_func can make # enough progress to return. In particular, a block_func that just raises an # exception regardless of whether trigger_func is called will lead to # timing-dependent sporadic failures, and one of those went rarely seen but # undiagnosed for years. Now block_func must be unexceptional. If block_func # is supposed to raise an exception, call do_exceptional_blocking_test() # instead. class BlockingTestMixin: def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() self.result = block_func(*block_args) # If block_func returned before our thread made the call, we failed! if not self.t.startedEvent.isSet(): self.fail("blocking function '%r' appeared not to block" % block_func) self.t.join(10) # make sure the thread terminates if self.t.isAlive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) return self.result # Call this instead if block_func is supposed to raise an exception. def do_exceptional_blocking_test(self,block_func, block_args, trigger_func, trigger_args, expected_exception_class): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() try: try: block_func(*block_args) except expected_exception_class: raise else: self.fail("expected exception of kind %r" % expected_exception_class) finally: self.t.join(10) # make sure the thread terminates if self.t.isAlive(): self.fail("trigger function '%r' appeared to not return" % trigger_func) if not self.t.startedEvent.isSet(): self.fail("trigger thread ended but event never set") class BaseQueueTest(unittest.TestCase, BlockingTestMixin): def setUp(self): self.cum = 0 self.cumlock = threading.Lock() def simple_queue_test(self, q): if not q.empty(): raise RuntimeError("Call this function with an empty queue") # I guess we better check things actually queue correctly a little :) q.put(111) q.put(333) q.put(222) q.put(444) target_first_items = dict( Queue = 111, LifoQueue = 444, PriorityQueue = 111) actual_first_item = (q.peek(), q.get()) self.assertEquals(actual_first_item, (target_first_items[q.__class__.__name__], target_first_items[q.__class__.__name__]), "q.peek() and q.get() are not equal!") target_order = dict(Queue = [333, 222, 444], LifoQueue = [222, 333, 111], PriorityQueue = [222, 333, 444]) actual_order = [q.get(), q.get(), q.get()] self.assertEquals(actual_order, target_order[q.__class__.__name__], "Didn't seem to queue the correct data!") for i in range(QUEUE_SIZE-1): q.put(i) self.assert_(not q.empty(), "Queue should not be empty") self.assert_(not q.full(), "Queue should not be full") q.put(999) self.assert_(q.full(), "Queue should be full") try: q.put(888, block=0) self.fail("Didn't appear to block with a full queue") except Queue.Full: pass try: q.put(888, timeout=0.01) self.fail("Didn't appear to time-out with a full queue") except Queue.Full: pass self.assertEquals(q.qsize(), QUEUE_SIZE) # Test a blocking put self.do_blocking_test(q.put, (888,), q.get, ()) self.do_blocking_test(q.put, (888, True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assert_(q.empty(), "Queue should be empty") try: q.get(block=0) self.fail("Didn't appear to block with an empty queue") except Queue.Empty: pass try: q.get(timeout=0.01) self.fail("Didn't appear to time-out with an empty queue") except Queue.Empty: pass # Test a blocking get self.do_blocking_test(q.get, (), q.put, ('empty',)) self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) def worker(self, q): while True: x = q.get() if x is None: q.task_done() return #with self.cumlock: self.cum += x q.task_done() def queue_join_test(self, q): self.cum = 0 for i in (0,1): threading.Thread(target=self.worker, args=(q,)).start() for i in xrange(100): q.put(i) q.join() self.assertEquals(self.cum, sum(range(100)), "q.join() did not block until all tasks were done") for i in (0,1): q.put(None) # instruct the threads to close q.join() # verify that you can join twice def test_queue_task_done(self): # Test to make sure a queue task completed successfully. q = Queue.JoinableQueue() # self.type2test() # XXX the same test in subclasses try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_queue_join(self): # Test that a queue join()s successfully, and before anything else # (done twice for insurance). q = Queue.JoinableQueue() # self.type2test() # XXX the same test in subclass self.queue_join_test(q) self.queue_join_test(q) try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") def test_queue_task_done_with_items(self): # Passing items to the constructor allows for as # many task_done calls. Joining before all the task done # are called returns false # XXX the same test in subclass l = [1, 2, 3] q = Queue.JoinableQueue(items=l) for i in l: self.assertFalse(q.join(timeout=0.001)) self.assertEqual(i, q.get()) q.task_done() try: q.task_done() except ValueError: pass else: self.fail("Did not detect task count going negative") self.assertTrue(q.join(timeout=0.001)) def test_simple_queue(self): # Do it a couple of times on the same queue. # Done twice to make sure works with same instance reused. q = self.type2test(QUEUE_SIZE) self.simple_queue_test(q) self.simple_queue_test(q) class QueueTest(BaseQueueTest): type2test = Queue.Queue class LifoQueueTest(BaseQueueTest): type2test = Queue.LifoQueue class PriorityQueueTest(BaseQueueTest): type2test = Queue.PriorityQueue # A Queue subclass that can provoke failure at a moment's notice :) class FailingQueueException(Exception): pass class FailingQueue(Queue.Queue): def __init__(self, *args): self.fail_next_put = False self.fail_next_get = False Queue.Queue.__init__(self, *args) def _put(self, item): if self.fail_next_put: self.fail_next_put = False raise FailingQueueException("You Lose") return Queue.Queue._put(self, item) def _get(self): if self.fail_next_get: self.fail_next_get = False raise FailingQueueException("You Lose") return Queue.Queue._get(self) class FailingQueueTest(unittest.TestCase, BlockingTestMixin): def failing_queue_test(self, q): if not q.empty(): raise RuntimeError("Call this function with an empty queue") for i in range(QUEUE_SIZE-1): q.put(i) # Test a failing non-blocking put. q.fail_next_put = True try: q.put("oops", block=0) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.fail_next_put = True try: q.put("oops", timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass q.put(999) self.assert_(q.full(), "Queue should be full") # Test a failing blocking put q.fail_next_put = True try: self.do_blocking_test(q.put, (888,), q.get, ()) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put(999) # Test a failing timeout put q.fail_next_put = True try: self.do_exceptional_blocking_test(q.put, (888, True, 10), q.get, (), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # Check the Queue isn't damaged. # put failed, but get succeeded - re-add q.put(999) self.assert_(q.full(), "Queue should be full") q.get() self.assert_(not q.full(), "Queue should not be full") q.put(999) self.assert_(q.full(), "Queue should be full") # Test a blocking put self.do_blocking_test(q.put, (888,), q.get, ()) # Empty it for i in range(QUEUE_SIZE): q.get() self.assert_(q.empty(), "Queue should be empty") q.put("first") q.fail_next_get = True try: q.get() self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assert_(not q.empty(), "Queue should not be empty") q.fail_next_get = True try: q.get(timeout=0.1) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass self.assert_(not q.empty(), "Queue should not be empty") q.get() self.assert_(q.empty(), "Queue should be empty") q.fail_next_get = True try: self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',), FailingQueueException) self.fail("The queue didn't fail when it should have") except FailingQueueException: pass # put succeeded, but get failed. self.assert_(not q.empty(), "Queue should not be empty") q.get() self.assert_(q.empty(), "Queue should be empty") def test_failing_queue(self): # Test to make sure a queue is functioning correctly. # Done twice to the same instance. q = FailingQueue(QUEUE_SIZE) self.failing_queue_test(q) self.failing_queue_test(q) def test_main(): test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) if __name__ == "__main__": test_main() gevent-1.1.0/greentest/test_server.crt0000644000076500000000000000156712666555342020627 0ustar jmaddenwheel00000000000000-----BEGIN CERTIFICATE----- MIICYzCCAcwCCQD5jx1Aa0dytjANBgkqhkiG9w0BAQQFADB2MQswCQYDVQQGEwJU UzENMAsGA1UECBMEVGVzdDENMAsGA1UEBxMEVGVzdDEWMBQGA1UEChMNVGVzdCBF dmVudGxldDENMAsGA1UECxMEVGVzdDENMAsGA1UEAxMEVGVzdDETMBEGCSqGSIb3 DQEJARYEVGVzdDAeFw0wODA3MDgyMTExNDJaFw0xMDAyMDgwODE1MTBaMHYxCzAJ BgNVBAYTAlRTMQ0wCwYDVQQIEwRUZXN0MQ0wCwYDVQQHEwRUZXN0MRYwFAYDVQQK Ew1UZXN0IEV2ZW50bGV0MQ0wCwYDVQQLEwRUZXN0MQ0wCwYDVQQDEwRUZXN0MRMw EQYJKoZIhvcNAQkBFgRUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDM WcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6OxFVq7XWZMDnDFVnb ZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOGHjxw++Opjf1uoHwP EBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQABMA0GCSqGSIb3DQEB BAUAA4GBAKM71aP0r26gEEEBzovfXm1IwKav6R9/xiWsJ4pFsUXVotcaIjcVBDG1 Z7tz688hokb+GNxsTI2gNfqanqUnfP9wZxnKRmfTSOvb5aWHIiaiMXSgjiPlqBcm 6mnSeEbSMM9cw479wWhh1YqY8tf3gYJa+sxznVWLSfVLpsjRMphe -----END CERTIFICATE----- gevent-1.1.0/greentest/test_server.key0000644000076500000000000000157312666555342020624 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQDMWcyeIiHQuEGQxgTIvu0aOW4iRFAyUEi8pLWNCxMEHglF8k6O xFVq7XWZMDnDFVnbZjmQh5Tc21Ae6cXzxXln578fROXHEzXo3Is8HUlq3ug1yYOG Hjxw++Opjf1uoHwPEBUKsz/flS7knuscgFM9FO05KSPn2wHnZeIDta4yTwIDAQAB AoGBAKWfvq0IIvok7Ncm92ew/0D6/R1+2rT8xwdGQ/Nt31q98WwkqLEjxctlbKPd J2PLIUomf0955BhhFH4JoSwjiHJQ6uishY7srjQQDX/Dxdi5wZAyxYCIVW/kAA9N /u2s75hSD3s/rqAwOZ182DwAPIqJc4KQoYzvlKERSMDT1PJhAkEA5SUFsiSzBEMX FyZ++ZMMs1vHrTu5oTK7WHznh9lk7dvsnp9BoUPqhiu8iJ7Q23zj0u5asz2czu11 nnczXgU6XwJBAORM5Ib4I7nAsoUWn9wDiTwVQeE+D9P1ac9p7EHm7XXuf8o2irRZ wYYfpXXsjk496YfyQFcQRMk0tU0gegCP7hECQFWRWqwoajUoPIInnPjjwbVki48U I4CfqjgkBG3Fb5wnKRgezmpDK1vJD1FRRRsBay4EVhhi5KCdKfPv/V2ZxC8CQQCu U5SxBytofJ8UhxkcTErvaR/8GYLGi//21GAGVop+YdaMlydE3cCrZODYcgCb+CSp nS7KDG8p4KiMMz9VzJGxAkEAv85K6Sa3H8g9h7LwopBZ5tFNZUaFWo7lEP7DDMH0 eckZTb1JVpyT/8zrDtsis4WlV9zVkVHxkIaad503BjqvEQ== -----END RSA PRIVATE KEY----- gevent-1.1.0/greentest/test_threading_2.py0000644000076500000000000004723712666555342021353 0ustar jmaddenwheel00000000000000# testing gevent's Event, Lock, RLock, Semaphore, BoundedSemaphore with standard test_threading from __future__ import print_function from six import xrange setup_ = '''from gevent import monkey; monkey.patch_all() from gevent.event import Event from gevent.lock import RLock, Semaphore, BoundedSemaphore from gevent.thread import allocate_lock as Lock import threading threading.Event = Event threading.Lock = Lock # NOTE: We're completely patching around the allocate_lock # patch we try to do with RLock; our monkey patch doesn't # behave this way, but we do it in tests to make sure that # our RLock implementation behaves correctly by itself. # However, we must test the patched version too, so make it # available. threading.NativeRLock = threading.RLock threading.RLock = RLock threading.Semaphore = Semaphore threading.BoundedSemaphore = BoundedSemaphore ''' exec(setup_) setup_3 = '\n'.join(' %s' % line for line in setup_.split('\n')) setup_4 = '\n'.join(' %s' % line for line in setup_.split('\n')) try: from test import support from test.support import verbose except ImportError: from test import test_support as support from test.test_support import verbose import random import re import sys import threading try: import thread except ImportError: import _thread as thread import time import unittest import weakref import lock_tests # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print('task %s will run for %.1f usec' % ( self.name, delay * 1e6)) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print(self.nrunning.get(), 'tasks are running') self.testcase.assert_(self.nrunning.get() <= 3) time.sleep(delay) if verbose: print('task', self.name, 'done') with self.mutex: self.nrunning.dec() self.testcase.assert_(self.nrunning.get() >= 0) if verbose: print('%s is finished. %d tasks are running' % ( self.name, self.nrunning.get())) class ThreadTests(unittest.TestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread("" % i, self, sema, mutex, numrunning) threads.append(t) t.daemon = False # Under PYPY we get daemon by default? if hasattr(t, 'ident'): self.failUnlessEqual(t.ident, None) self.assertFalse(t.daemon) self.assert_(re.match(r'', repr(t))) t.start() if verbose: print('waiting for all tasks to complete') for t in threads: t.join(NUMTASKS) self.assert_(not t.is_alive()) if hasattr(t, 'ident'): self.failIfEqual(t.ident, 0) self.assertFalse(t.ident is None) self.assert_(re.match(r'', repr(t))) if verbose: print('all tasks done') self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads, # as must the repr and str. t = threading.currentThread() self.assertFalse(t.ident is None) str(t) repr(t) def f(): t = threading.currentThread() ident.append(t.ident) str(t) repr(t) done.set() done = threading.Event() ident = [] thread.start_new_thread(f, ()) done.wait() self.assertFalse(ident[0] is None) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print('with 256kB thread stack size...') try: threading.stack_size(262144) except thread.error: if verbose: print('platform does not support changing thread stack size') return self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print('with 1MB thread stack size...') try: threading.stack_size(0x100000) except thread.error: if verbose: print('platform does not support changing thread stack size') return self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() tid = thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assert_(tid in threading._active) self.assert_(isinstance(threading._active[tid], threading._DummyThread)) del threading._active[tid] # in gevent, we actually clean up threading._active, but it's not happended there yet # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. def SKIP_test_PyThreadState_SetAsyncExc(self): try: import ctypes except ImportError: if verbose: print("test_PyThreadState_SetAsyncExc can't import ctypes") return # can't do anything set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc class AsyncExc(Exception): pass exception = ctypes.py_object(AsyncExc) # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that # exception. worker_started = threading.Event() worker_saw_exception = threading.Event() class Worker(threading.Thread): def run(self): self.id = thread.get_ident() self.finished = False try: while True: worker_started.set() time.sleep(0.1) except AsyncExc: self.finished = True worker_saw_exception.set() t = Worker() t.daemon = True # so if this fails, we don't hang Python at shutdown t.start() if verbose: print(" started worker thread") # Try a thread id that doesn't make sense. if verbose: print(" trying nonsensical thread id") result = set_async_exc(ctypes.c_long(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. if verbose: print(" waiting for worker thread to get started") worker_started.wait() if verbose: print(" verifying worker hasn't exited") self.assert_(not t.finished) if verbose: print(" attempting to raise asynch exception in worker") result = set_async_exc(ctypes.c_long(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print(" waiting for worker to say it caught the exception") worker_saw_exception.wait(timeout=10) self.assert_(t.finished) if verbose: print(" all OK -- joining worker") if t.finished: t.join() # else the thread is still running, and we have no way to kill it def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise thread.error() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(thread.error, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. try: import ctypes getattr(ctypes, 'pythonapi') # not available on PyPy except (ImportError,AttributeError): if verbose: print("test_finalize_with_runnning_thread can't import ctypes") return # can't do anything del ctypes # pyflakes fix import subprocess rc = subprocess.call([sys.executable, "-c", """if 1: %s import ctypes, sys, time try: import thread except ImportError: import _thread as thread # Py3 # This lock is used as a simple event variable. ready = thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """ % setup_3]) self.assertEqual(rc, 42) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown import subprocess p = subprocess.Popen([sys.executable, "-c", """if 1: %s import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print("Woke up, sleep function is: %%r" %% sleep) threading.Thread(target=child).start() raise SystemExit """ % setup_4], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() stdout = stdout.strip() stdout = stdout.decode('utf-8') stderr = stderr.decode('utf-8') assert re.match('^Woke up, sleep function is: <.*?sleep.*?>$', stdout), repr(stdout) stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getcheckinterval() try: for i in xrange(1, 100): # Try a couple times at each thread-switching interval # to get more interleavings. sys.setcheckinterval(i // 5) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertFalse(t in l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setcheckinterval(old_interval) if not hasattr(sys, 'pypy_version_info'): def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another': self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertEquals(None, weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertEquals(None, weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) class ThreadJoinOnShutdown(unittest.TestCase): def _run_and_join(self, script): script = """if 1: %s import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print('end of thread') \n""" % setup_3 + script import subprocess p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) rc = p.wait() data = p.stdout.read().replace(b'\r', b'') self.assertEqual(data, b"end of main\nend of thread\n") self.failIf(rc == 2, b"interpreter was blocked") self.failUnless(rc == 0, b"Unexpected error") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print('end of main') """ self._run_and_join(script) def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter import os if not hasattr(os, 'fork'): return script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print('end of main') """ self._run_and_join(script) def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. import os if not hasattr(os, 'fork'): return # Skip platforms with known problems forking from a worker thread. # See http://bugs.python.org/issue3863. # skip disable because I think the bug shouldn't apply to gevent -- denis #if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'): # print(('Skipping test_3_join_in_forked_from_thread' # ' due to known OS bugs on'), sys.platform, file=sys.stderr) # return script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print('end of main') t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) class ThreadingExceptionTests(unittest.TestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join) def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class RLockTests(lock_tests.RLockTests): locktype = staticmethod(threading.RLock) class NativeRLockTests(lock_tests.RLockTests): # See comments at the top of the file for the difference # between this and RLockTests, and why they both matter locktype = staticmethod(threading.NativeRLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) class ConditionAsRLockTests(lock_tests.RLockTests): # An Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) def main(): support.run_unittest(LockTests, RLockTests, EventTests, ConditionAsRLockTests, ConditionTests, SemaphoreTests, BoundedSemaphoreTests, ThreadTests, ThreadJoinOnShutdown, ThreadingExceptionTests, NativeRLockTests, ) if __name__ == "__main__": main() gevent-1.1.0/greentest/testrunner.py0000644000076500000000000002114012666555342020320 0ustar jmaddenwheel00000000000000#!/usr/bin/env python from __future__ import print_function import six import sys import os import glob import traceback import time from datetime import timedelta from multiprocessing.pool import ThreadPool import util from util import log TIMEOUT = 180 NWORKERS = int(os.environ.get('NWORKERS') or 4) # tests that don't do well when run on busy box RUN_ALONE = [ 'test__threadpool.py', 'test__examples.py' ] # tests that can't be run when coverage is enabled IGNORE_COVERAGE = [ # Hangs forever 'test__threading_vs_settrace.py', # XXX ? 'test__issue302monkey.py', "test_subprocess.py", ] def run_many(tests, expected=(), failfast=False): global NWORKERS start = time.time() total = 0 failed = {} passed = {} NWORKERS = min(len(tests), NWORKERS) or 1 print('thread pool size: %s' % NWORKERS) pool = ThreadPool(NWORKERS) util.BUFFER_OUTPUT = NWORKERS > 1 def run_one(cmd, **kwargs): result = util.run(cmd, **kwargs) if result: if failfast: sys.exit(1) failed[result.name] = [cmd, kwargs] else: passed[result.name] = True results = [] def reap(): for r in results[:]: if not r.ready(): continue if r.successful(): results.remove(r) else: r.get() sys.exit('Internal error in testrunner.py: %r' % (r, )) return len(results) def reap_all(): while reap() > 0: time.sleep(0.1) def spawn(args, kwargs): while True: if reap() < NWORKERS: r = pool.apply_async(run_one, (cmd, ), options or {}) results.append(r) return else: time.sleep(0.1) run_alone = [] try: try: for cmd, options in tests: total += 1 options = options or {} if matches(RUN_ALONE, cmd): run_alone.append((cmd, options)) else: spawn((cmd, ), options) pool.close() pool.join() for cmd, options in run_alone: run_one(cmd, **options) except KeyboardInterrupt: try: log('Waiting for currently running to finish...') reap_all() except KeyboardInterrupt: pool.terminate() report(total, failed, passed, exit=False, took=time.time() - start, expected=expected) log('(partial results)\n') raise except: traceback.print_exc() pool.terminate() raise reap_all() report(total, failed, passed, took=time.time() - start, expected=expected) def discover(tests=None, ignore=(), coverage=False): if isinstance(ignore, six.string_types): ignore = load_list_from_file(ignore) ignore = set(ignore or ()) if coverage: ignore.update(IGNORE_COVERAGE) if not tests: tests = set(glob.glob('test_*.py')) - set(['test_support.py']) else: tests = set(tests) if ignore: # Always ignore the designated list, even if tests were specified # on the command line. This fixes a nasty interaction with test__threading_vs_settrace.py # being run under coverage when 'grep -l subprocess test*py' is used to list the tests # to run. tests -= ignore tests = sorted(tests) to_process = [] default_options = {'timeout': TIMEOUT} for filename in tests: with open(filename, 'rb') as f: # Some of the test files (e.g., test__socket_dns) are # UTF8 encoded. Depending on the environment, Python 3 may # try to decode those as ASCII, which fails with UnicodeDecodeError. # Thus, be sure to open and compare in binary mode. contents = f.read() if b'TESTRUNNER' in contents: # test__monkey_patching.py module = __import__(filename.rsplit('.', 1)[0]) for cmd, options in module.TESTRUNNER(): if remove_options(cmd)[-1] in ignore: continue to_process.append((cmd, options)) else: cmd = [sys.executable, '-u', filename] to_process.append((cmd, default_options.copy())) return to_process def remove_options(lst): return [x for x in lst if x and not x.startswith('-')] def load_list_from_file(filename): result = [] if filename: for x in open(filename): x = x.split('#', 1)[0].strip() if x: result.append(x) return result def matches(expected, command, include_flaky=True): if isinstance(command, list): command = ' '.join(command) for line in expected: if not include_flaky and line.startswith('FLAKY '): continue if command.endswith(' ' + line.replace('FLAKY ', '')): return True return False def format_seconds(seconds): if seconds < 20: return '%.1fs' % seconds seconds = str(timedelta(seconds=round(seconds))) if seconds.startswith('0:'): seconds = seconds[2:] return seconds def report(total, failed, passed, exit=True, took=None, expected=None): runtimelog = util.runtimelog if runtimelog: log('\nLongest-running tests:') runtimelog.sort() length = len('%.1f' % -runtimelog[0][0]) frmt = '%' + str(length) + '.1f seconds: %s' for delta, name in runtimelog[:5]: log(frmt, -delta, name) if took: took = ' in %s' % format_seconds(took) else: took = '' failed_expected = [] failed_unexpected = [] passed_unexpected = [] for name in passed: if matches(expected, name, include_flaky=False): passed_unexpected.append(name) if passed_unexpected: log('\n%s/%s unexpected passes', len(passed_unexpected), total) print_list(passed_unexpected) if failed: log('\n%s/%s tests failed%s', len(failed), total, took) expected = set(expected or []) for name in failed: if matches(expected, name, include_flaky=True): failed_expected.append(name) else: failed_unexpected.append(name) if failed_expected: log('\n%s/%s expected failures', len(failed_expected), total) print_list(failed_expected) if failed_unexpected: log('\n%s/%s unexpected failures', len(failed_unexpected), total) print_list(failed_unexpected) else: log('\n%s tests passed%s', total, took) if exit: if failed_unexpected: sys.exit(min(100, len(failed_unexpected))) if passed_unexpected: sys.exit(101) if total <= 0: sys.exit('No tests found.') def print_list(lst): for name in lst: log(' - %s', name) def main(): import optparse parser = optparse.OptionParser() parser.add_option('--ignore') parser.add_option('--discover', action='store_true') parser.add_option('--full', action='store_true') parser.add_option('--config') parser.add_option('--failfast', action='store_true') parser.add_option("--coverage", action="store_true") options, args = parser.parse_args() FAILING_TESTS = [] coverage = False if options.coverage or os.environ.get("GEVENTTEST_COVERAGE"): coverage = True # NOTE: This must be run from the greentest directory os.environ['COVERAGE_PROCESS_START'] = os.path.abspath(".coveragerc") os.environ['PYTHONPATH'] = os.path.abspath("coveragesite") + os.pathsep + os.environ.get("PYTHONPATH", "") # We change directory often, use an absolute path to keep all the # coverage files (which will have distinct suffixes because of parallel=true in .coveragerc # in this directory; makes them easier to combine and use with coverage report) os.environ['COVERAGE_FILE'] = os.path.abspath(".") + os.sep + ".coverage" print("Enabling coverage to", os.environ['COVERAGE_FILE']) if options.config: config = {} six.exec_(open(options.config).read(), config) FAILING_TESTS = config['FAILING_TESTS'] tests = discover(args, options.ignore, coverage) if options.discover: for cmd, options in tests: print(util.getname(cmd, env=options.get('env'), setenv=options.get('setenv'))) print('%s tests found.' % len(tests)) else: run_many(tests, expected=FAILING_TESTS, failfast=options.failfast) if __name__ == '__main__': main() gevent-1.1.0/greentest/tests_that_dont_use_resolver.txt0000644000076500000000000000345612666555342024313 0ustar jmaddenwheel00000000000000test__all__.py #uses socket test__api.py test__api_timeout.py test__ares_host_result.py test_ares_timeout.py # explicitly uses ares resolver # uses socket test__backdoor.py test_close_backend_fd.py test__core_async.py test__core_callback.py test__core_loop_run.py test__core.py test__core_stat.py test__core_timer.py test__core_watcher.py test__destroy.py # uses socket test__doctests.py test__environ.py test__event.py # uses socket test__example_echoserver.py # uses socket test__example_portforwarder.py # uses socket test___example_servers.py # uses bunch of things test__examples.py # uses socket test__example_udp_client.py # uses socket test__example_udp_server.py test__exc_info.py #test__execmodules.py test__fileobject.py # uses socket test__greenio.py test__GreenletExit.py test__greenlet.py test__greenletset.py # uses socket test__greenness.py test_hub_join.py test_hub_join_timeout.py # uses socket test__hub.py test_issue112.py test__joinall.py test__local.py test__loop_callback.py test__memleak.py # uses lots of things test___monkey_patching.py test__monkey.py test__order.py test__os.py test__pool.py # uses socket test__pywsgi.py test__queue.py test_queue.py # uses socket test__refcount.py test__select.py test__semaphore.py # uses socket test__server.py # test__server_pywsgi.py test__signal.py # uses socket test__socket_close.py # test__socket_dns6.py # test__socket_dns.py # test__socket_errors.py # test__socket.py # test__socket_ssl.py # test__socket_timeout.py test__subprocess_interrupted.py test__subprocess.py test__systemerror.py test_threading_2.py test__threading_patched_local.py test__threading_vs_settrace.py test__threadpool.py test__timeout.py # monkey patched standard tests: test_queue.py test_select.py test_signal.py test_subprocess.py test_threading_local.py test_threading.py test_thread.py gevent-1.1.0/greentest/util.py0000644000076500000000000001575112666555342017077 0ustar jmaddenwheel00000000000000import sys import os import six import traceback import unittest import threading import subprocess import time runtimelog = [] MIN_RUNTIME = 1.0 BUFFER_OUTPUT = False class Popen(subprocess.Popen): def __enter__(self): return self def __exit__(self, *args): kill(self) def log(message, *args): try: if args: string = message % args else: string = message except Exception: traceback.print_exc() try: string = '%r %% %r\n\n' % (message, args) except Exception: pass try: sys.stderr.write(string) except Exception: traceback.print_exc() else: sys.stderr.write(string + '\n') def killpg(pid): if not hasattr(os, 'killpg'): return try: return os.killpg(pid, 9) except OSError as ex: if ex.errno != 3: log('killpg(%r, 9) failed: %s: %s', pid, type(ex).__name__, ex) except Exception as ex: log('killpg(%r, 9) failed: %s: %s', pid, type(ex).__name__, ex) def kill_processtree(pid): ignore_msg = 'ERROR: The process "%s" not found.' % pid err = subprocess.Popen('taskkill /F /PID %s /T' % pid, stderr=subprocess.PIPE).communicate()[1] if err and err.strip() not in [ignore_msg, '']: log('%r', err) def _kill(popen): if hasattr(popen, 'kill'): try: popen.kill() except OSError as ex: if ex.errno == 3: # No such process return if ex.errno == 13: # Permission denied (translated from windows error 5: "Access is denied") return raise else: try: os.kill(popen.pid, 9) except EnvironmentError: pass def kill(popen): if popen.timer is not None: popen.timer.cancel() if popen.poll() is not None: return popen.was_killed = True try: if getattr(popen, 'setpgrp_enabled', None): killpg(popen.pid) elif sys.platform.startswith('win'): kill_processtree(popen.pid) except Exception: traceback.print_exc() try: _kill(popen) except Exception: traceback.print_exc() try: popen.wait() except Exception: traceback.print_exc() def getname(command, env=None, setenv=None): result = [] env = (env or os.environ).copy() env.update(setenv or {}) for key, value in sorted(env.items()): if key.startswith('GEVENT_') or key.startswith('GEVENTARES_'): result.append('%s=%s' % (key, value)) if isinstance(command, six.string_types): result.append(command) else: result.extend(command) return ' '.join(result) def start(command, **kwargs): timeout = kwargs.pop('timeout', None) preexec_fn = None if not os.environ.get('DO_NOT_SETPGRP'): preexec_fn = getattr(os, 'setpgrp', None) env = kwargs.pop('env', None) setenv = kwargs.pop('setenv', None) or {} name = getname(command, env=env, setenv=setenv) if preexec_fn is not None: setenv['DO_NOT_SETPGRP'] = '1' if setenv: if env: env = env.copy() else: env = os.environ.copy() env.update(setenv) log('+ %s', name) popen = Popen(command, preexec_fn=preexec_fn, env=env, **kwargs) popen.name = name popen.setpgrp_enabled = preexec_fn is not None popen.was_killed = False popen.timer = None if timeout is not None: t = threading.Timer(timeout, kill, args=(popen, )) t.setDaemon(True) t.start() popen.timer = t return popen class RunResult(object): def __init__(self, code, output=None, name=None): self.code = code self.output = output self.name = name if six.PY3: def __bool__(self): return bool(self.code) else: def __nonzero__(self): return bool(self.code) def __int__(self): return self.code lock = threading.Lock() def run(command, **kwargs): buffer_output = kwargs.pop('buffer_output', BUFFER_OUTPUT) if buffer_output: assert 'stdout' not in kwargs and 'stderr' not in kwargs, kwargs kwargs['stderr'] = subprocess.STDOUT kwargs['stdout'] = subprocess.PIPE popen = start(command, **kwargs) name = popen.name try: time_start = time.time() out, err = popen.communicate() took = time.time() - time_start if popen.was_killed or popen.poll() is None: result = 'TIMEOUT' else: result = popen.poll() finally: kill(popen) assert not err with lock: if out: out = out.strip().decode('utf-8', 'ignore') if out: out = ' ' + out.replace('\n', '\n ') out = out.rstrip() out += '\n' log('| %s\n%s', name, out) if result: log('! %s [code %s] [took %.1fs]', name, result, took) else: log('- %s [took %.1fs]', name, took) if took >= MIN_RUNTIME: runtimelog.append((-took, name)) return RunResult(result, out, name) class TestServer(unittest.TestCase): cwd = '../examples/' args = [] before_delay = 3 after_delay = 0.5 popen = None server = None # subclasses define this to be the path to the server.py start_kwargs = None def start(self): kwargs = self.start_kwargs or {} return start([sys.executable, '-u', self.server] + self.args, cwd=self.cwd, **kwargs) def running_server(self): from contextlib import contextmanager @contextmanager def running_server(): with self.start() as popen: self.popen = popen self.before() yield self.after() return running_server() def test(self): with self.running_server(): self._run_all_tests() def before(self): if self.before_delay is not None: time.sleep(self.before_delay) assert self.popen.poll() is None, '%s died with code %s' % (self.server, self.popen.poll(), ) def after(self): if self.after_delay is not None: time.sleep(self.after_delay) assert self.popen.poll() is None, '%s died with code %s' % (self.server, self.popen.poll(), ) def _run_all_tests(self): ran = False for method in sorted(dir(self)): if method.startswith('_test'): function = getattr(self, method) if callable(function): function() ran = True assert ran class alarm(threading.Thread): # can't use signal.alarm because of Windows def __init__(self, timeout): threading.Thread.__init__(self) self.setDaemon(True) self.timeout = timeout self.start() def run(self): time.sleep(self.timeout) sys.stderr.write('Timeout.\n') os._exit(5) gevent-1.1.0/greentest/wrongcert.pem0000644000076500000000000000353012666555342020255 0ustar jmaddenwheel00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq 1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW 7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe 19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666 lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk 2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6 +bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK 24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9 OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+ 43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw eSHj5jpC8iZKjCHBn+mAi4cQ514= -----END CERTIFICATE----- gevent-1.1.0/greentest/xtest__benchmarks.py0000644000076500000000000000252412666555342021617 0ustar jmaddenwheel00000000000000# testrunner timeout: 300 import sys import glob import subprocess import time TIMEOUT = 30 def kill(popen): if popen.poll() is not None: return try: popen.kill() except OSError as ex: if ex.errno == 3: # No such process return if ex.errno == 13: # Permission denied (translated from windows error 5: "Access is denied") return raise def wait(popen): end = time.time() + TIMEOUT while popen.poll() is None: if time.time() > end: kill(popen) popen.wait() return 'TIMEOUT' time.sleep(0.1) return popen.poll() def system(command): popen = subprocess.Popen(command, shell=False) try: return wait(popen) finally: kill(popen) modules = set() for path in glob.glob('bench_*.py'): modules.add(path) if __name__ == '__main__': assert modules errors = [] for path in modules: sys.stderr.write(path + '\n') sys.stdout.flush() command = [sys.executable, '-u', path, 'all'] res = system(command) if res: error = '%r failed with %s' % (' '.join(command), res) sys.stderr.write(error + '\n') errors.append(error) sys.stderr.write('-----\n\n') if errors: sys.exit('\n'.join(errors)) gevent-1.1.0/greentest/xtest__issue91.py0000644000076500000000000000057312666555342021006 0ustar jmaddenwheel00000000000000from gevent.select import select from gevent.server import StreamServer from gevent import socket def handler(socket, address): while True: if not socket.recv(1000): break server = StreamServer(('127.0.0.1', 0), handler) server.start() s = socket.create_connection(('127.0.0.1', server.server_port)) while True: select([], [s.fileno()] * 10, []) gevent-1.1.0/greentest/xtest__server_close.py0000644000076500000000000000400212666555342022166 0ustar jmaddenwheel00000000000000import unittest from gevent import socket import gevent import errno import os from test__server import SimpleStreamServer class Test(unittest.TestCase): ServerSubClass = SimpleStreamServer def makefile(self, timeout=0.1, bufsize=1): sock = socket.create_connection((self.server.server_host, self.server.server_port)) sock.settimeout(timeout) return sock.makefile(bufsize=bufsize) def assertConnectionRefused(self): try: conn = self.makefile() raise AssertionError('Connection was not refused: %r' % (conn._sock, )) except socket.error as ex: if ex.args[0] != errno.ECONNREFUSED: raise def assertRequestSucceeded(self): conn = self.makefile() conn.write('GET /ping HTTP/1.0\r\n\r\n') result = conn.read() assert result.endswith('\r\n\r\nPONG'), repr(result) def init_server(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() gevent.sleep(0.01) def test_socket_shutdown(self): self.init_server() self.server.socket.shutdown(socket.SHUT_RDWR) self.assertConnectionRefused() assert not self.server.started, self.server def test_socket_close(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() self.server.socket.close() self.assertConnectionRefused() #assert not self.server.started def test_socket_close_fileno(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() os.close(self.server.socket.fileno()) self.assertConnectionRefused() #assert not self.server.started def test_socket_file(self): self.server = self.ServerSubClass(('127.0.0.1', 0)) self.server.start() os.close(self.server.socket.fileno()) f = open("/dev/zero", "r") self.assertConnectionRefused() del f if __name__ == '__main__': unittest.main() gevent-1.1.0/greentest/xtest_signal.py0000644000076500000000000000525112666555342020620 0ustar jmaddenwheel00000000000000"""This is the extract from test_signal.py that runs forever until it fails. It reproduces the bug where SIGCHLD either not delivered or somehow lost and thus if libev does not poll waitpid() periodically, popen.wait() blocks forever. The patch that fixes it: https://bitbucket.org/denis/gevent/changeset/adb8b5ac698c Comment out the lines in ev.c that start the timer if you want to see for yourself. Reproduced on my machine (Linux 3.0.0-16-generic) with backend epoll and select. With signalfd enabled (GEVENT_BACKEND=signalfd) it seems to work. """ from __future__ import print_function import gevent from contextlib import closing import gc import pickle from gevent import select from gevent import subprocess import traceback import sys import os gc.disable() MAX_DURATION = 10 def run_test(): child = subprocess.Popen(['/bin/true']) child.wait() # << this is where it blocks def test_main(): # This function spawns a child process to insulate the main # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child # throws. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with closing(os.fdopen(os_done_r)) as done_r: with closing(os.fdopen(os_done_w, 'w')) as done_w: child = gevent.fork() if not child: # In the child process; run the test and report results # through the pipe. try: done_r.close() # Have to close done_w again here because # exit_subprocess() will skip the enclosing with block. with closing(done_w): try: run_test() except: pickle.dump(traceback.format_exc(), done_w) else: pickle.dump(None, done_w) except: print('Uh oh, raised from pickle.') traceback.print_exc() finally: os._exit(0) done_w.close() # Block for up to MAX_DURATION seconds for the test to finish. r, w, x = select.select([done_r], [], [], MAX_DURATION) if done_r in r: tb = pickle.load(done_r) assert not tb, tb else: os.kill(child, 9) assert False, 'Test deadlocked after %d seconds.' % MAX_DURATION if __name__ == "__main__": print(gevent.get_hub()) while True: test_main() sys.stderr.write('.') gevent-1.1.0/greentest/xtest_stdlib.py0000644000076500000000000000032512666555342020621 0ustar jmaddenwheel00000000000000import sys import os if os.system("ack 'from test import (?!test_support)|from test\.(?!test_support)' 2.5 2.6 2.7") != 256: sys.exit('FAILED: Some tests in stdlib were not updated to not reference "test".') gevent-1.1.0/known_failures.py0000644000076500000000000002154512666555342017146 0ustar jmaddenwheel00000000000000# This is a list of known failures (=bugs). # The tests listed there must fail (or testrunner.py will report error) unless they are prefixed with FLAKY # in which cases the result of them is simply ignored from __future__ import print_function import os import sys import struct APPVEYOR = os.getenv('APPVEYOR') TRAVIS = os.getenv('TRAVIS') LEAKTEST = os.getenv('GEVENTTEST_LEAKCHECK') COVERAGE = os.getenv("COVERAGE_PROCESS_START") PYPY = hasattr(sys, 'pypy_version_info') PY3 = sys.version_info[0] >= 3 PY26 = sys.version_info[0] == 2 and sys.version_info[1] == 6 PY27 = sys.version_info[0] == 2 and sys.version_info[1] == 7 PY35 = sys.version_info[0] >= 3 and sys.version_info[1] >= 5 PYGTE279 = ( sys.version_info[0] == 2 and sys.version_info[1] >= 7 and sys.version_info[2] >= 9 ) FAILING_TESTS = [ # Sometimes fails with AssertionError: ...\nIOError: close() called during concurrent operation on the same file object.\n' # Sometimes it contains "\nUnhandled exception in thread started by \nsys.excepthook is missing\nlost sys.stderr\n" "FLAKY test__subprocess_interrupted.py", # test__issue6 (see comments in test file) is really flaky on both Travis and Appveyor; # on Travis we could just run the test again (but that gets old fast), but on appveyor # we don't have that option without a new commit---and sometimes we really need a build # to succeed in order to get a release wheel 'FLAKY test__issue6.py', ] if os.environ.get('GEVENT_RESOLVER') == 'ares' or LEAKTEST: # XXX fix this FAILING_TESTS += [ 'FLAKY test__socket_dns.py', 'FLAKY test__socket_dns6.py', ] else: FAILING_TESTS += [ # A number of the host names hardcoded have multiple, load # balanced DNS entries. Therefore, multiple sequential calls # of the resolution function, whether gevent or stdlib, can # return non-equal results, possibly dependent on the host # dns configuration 'FLAKY test__socket_dns6.py', ] if sys.platform == 'win32': # other Windows-related issues (need investigating) FAILING_TESTS += [ # fork watchers don't get called in multithreaded programs on windows # No idea why. 'test__core_fork.py', 'FLAKY test__greenletset.py', # This has been seen to fail on Py3 and Py2 due to socket reuse # errors, probably timing related again. 'FLAKY test___example_servers.py', ] if APPVEYOR: FAILING_TESTS += [ # These both run on port 9000 and can step on each other...seems like the # appveyor containers aren't fully port safe? Or it takes longer # for the processes to shut down? Or we run them in a different order # in the process pool than we do other places? 'FLAKY test__example_udp_client.py', 'FLAKY test__example_udp_server.py', # This one sometimes times out, often after output "The process with PID XXX could not be # terminated. Reason: There is no running instance of the task." 'FLAKY test__example_portforwarder.py', # We only use FileObjectThread on Win32. Sometimes the # visibility of the 'close' operation, which happens in a # background thread, doesn't make it to the foreground # thread in a timely fashion, leading to 'os.close(4) must # not succeed' in test_del_close. We have the same thing # with flushing and closing in test_newlines. Both of # these are most commonly (only?) observed on Py27/64-bit 'FLAKY test__fileobject.py', ] if PY27: FAILING_TESTS += [ # This sometimes fails with a timeout, meaning # one of the tests hangs (test_fullduplex, maybe?). # But only sometimes, and only seen on Py2.7, beginning # ~2016-02-24 'FLAKY test__socket.py', ] if PY3: FAILING_TESTS += [ # test_set_and_clear in Py3 relies on 5 threads all starting and # coming to an Event wait point while a sixth thread sleeps for a half # second. The sixth thread then does something and checks that # the 5 threads were all at the wait point. But the timing is sometimes # too tight for appveyor. This happens even if Event isn't # monkey-patched 'FLAKY test_threading.py', ] if not PY35: # Py35 added socket.socketpair, all other releases # are missing it FAILING_TESTS += [ 'test__socketpair.py', ] if struct.calcsize('P') * 8 == 64: # could be a problem of appveyor - not sure # ====================================================================== # ERROR: test_af (__main__.TestIPv6Environment) # ---------------------------------------------------------------------- # File "C:\Python27-x64\lib\ftplib.py", line 135, in connect # self.sock = socket.create_connection((self.host, self.port), self.timeout) # File "c:\projects\gevent\gevent\socket.py", line 73, in create_connection # raise err # error: [Errno 10049] [Error 10049] The requested address is not valid in its context. # XXX: On Jan 3 2016 this suddenly started passing on Py27/64; no idea why, the python version # was 2.7.11 before and after. FAILING_TESTS.append('FLAKY test_ftplib.py') if PY3: pass if LEAKTEST: FAILING_TESTS += [ 'FLAKY test__backdoor.py', 'FLAKY test__socket_errors.py', ] if os.environ.get("TRAVIS") == "true": FAILING_TESTS += [ # On Travis, this very frequently fails due to timing 'FLAKY test_signal.py', ] if PYPY: FAILING_TESTS += [ ## Different in PyPy: ## Not implemented: ## --- ## BUGS: ] if PY26: FAILING_TESTS += [ # http://bugs.python.org/issue9446, fixed in 2.7/3 # https://github.com/python/cpython/commit/a104f91ff4c4560bec7c336afecb094e73a5ab7e 'FLAKY test_urllib2.py', ] if TRAVIS: # Started seeing this with a fresh build of 2.6.9 # on 2016-02-11. Can't reproduce locally. # test__all__.test_ssl: items 'name', 'value' from # stdlib module not found in gevent module. # Which makes no sense. 2.6 isn't supported by python.org # anymore, though, and we're starting to get warnings about # pip. FAILING_TESTS += [ 'test__all__.py', ] if PY3: # No idea / TODO FAILING_TESTS += [ 'FLAKY test__socket_dns.py', ] if os.environ.get("TRAVIS") == "true": FAILING_TESTS += [ # test_cwd_with_relative_executable tends to fail # on Travis...it looks like the test processes are stepping # on each other and messing up their temp directories 'FLAKY test_subprocess.py' ] if LEAKTEST: FAILING_TESTS += ['FLAKY test__threadpool.py'] # refcount problems: FAILING_TESTS += [ 'test__timeout.py', 'FLAKY test__greenletset.py', 'test__core.py', 'test__systemerror.py', 'test__exc_info.py', 'test__api_timeout.py', 'test__event.py', 'test__api.py', 'test__hub.py', 'test__queue.py', 'test__socket_close.py', 'test__select.py', 'test__greenlet.py', 'FLAKY test__socket.py', ] if sys.version_info[:2] == (3, 3) and os.environ.get('TRAVIS') == 'true': # Builds after Sept 29th 2015 have all been failing here, but no code that could # affect this was changed. Travis is using 3.3.5; # locally I cannot reproduce with 3.3.6. Don't mark this FLAKY so that if it starts to # work again we get a failure and can remove this. # XXX: Builds after Nov 13, 2015 have suddenly started to work again. The # Python version reported by Travis is unchanged. Commenting out for now since # it's such a bizarre thing I'm expecting it to come back again. FAILING_TESTS += [ #'test__refcount_core.py' ] if sys.version_info[:2] >= (3, 4) and APPVEYOR: FAILING_TESTS += [ # Timing issues on appveyor 'FLAKY test_selectors.py' ] if COVERAGE: # The gevent concurrency plugin tends to slow things # down and get us past our default timeout value. These # tests in particular are sensitive to it FAILING_TESTS += [ 'FLAKY test__issue302monkey.py', 'FLAKY test__example_portforwarder.py', 'FLAKY test__threading_vs_settrace.py', ] FAILING_TESTS = [x.strip() for x in set(FAILING_TESTS) if x.strip()] if __name__ == '__main__': print('known_failures:\n', FAILING_TESTS) gevent-1.1.0/libev/0000755000076500000000000000000012666555433014641 5ustar jmaddenwheel00000000000000gevent-1.1.0/libev/Changes0000644000076500000000000006520012666555342016136 0ustar jmaddenwheel00000000000000Revision history for libev, a high-performance and full-featured event loop. TODO: ev_loop_wakeup TODO: EV_STANDALONE == NO_HASSEL (do not use clock_gettime in ev_standalone) TODO: faq, process a thing in each iteration TODO: dbeugging tips, ev_verify, ev_init twice TODO: ev_break for immediate exit (EVBREAK_NOW?) TODO: ev_feed_child_event TODO: document the special problem of signals around fork. TODO: store pid for each signal TODO: document file descriptor usage per loop TODO: store loop pid_t and compare isndie signal handler,store 1 for same, 2 for differign pid, clean up in loop_fork TODO: embed watchers need updating when fd changes TODO: document portability requirements for atomic pointer access TODO: document requirements for function pointers and calling conventions. 4.20 Sat Jun 20 13:01:43 CEST 2015 - prefer noexcept over throw () with C++ 11. - update ecb.h due to incompatibilities with c11. - fix a potential aliasing issue when reading and writing watcher callbacks. 4.19 Thu Sep 25 08:18:25 CEST 2014 - ev.h wasn't valid C++ anymore, which tripped compilers other than clang, msvc or gcc (analyzed by Raphael 'kena' Poss). Unfortunately, C++ doesn't support typedefs for function pointers fully, so the affected declarations have to spell out the types each time. - when not using autoconf, tighten the check for clock_gettime and related functionality. 4.18 Fri Sep 5 17:55:26 CEST 2014 - events on files were not always generated properly with the epoll backend (testcase by Assaf Inbal). - mark event pipe fd as cloexec after a fork (analyzed by Sami Farin). - (ecb) support m68k, m88k and sh (patch by Miod Vallat). - use a reasonable fallback for EV_NSIG instead of erroring out when we can't detect the signal set size. - in the absence of autoconf, do not use the clock syscall on glibc >= 2.17 (avoids the syscall AND -lrt on systems doing clock_gettime in userspace). - ensure extern "C" function pointers are used for externally-visible loop callbacks (not watcher callbacks yet). - (ecb) work around memory barriers and volatile apparently both being broken in visual studio 2008 and later (analysed and patch by Nicolas Noble). 4.15 Fri Mar 1 12:04:50 CET 2013 - destroying a non-default loop would stop the global waitpid watcher (Denis Bilenko). - queueing pending watchers of higher priority from a watcher now invokes them in a timely fashion (reported by Denis Bilenko). - add throw() to all libev functions that cannot throw exceptions, for further code size decrease when compiling for C++. - add throw () to callbacks that must not throw exceptions (allocator, syserr, loop acquire/release, periodic reschedule cbs). - fix event_base_loop return code, add event_get_callback, event_base_new, event_base_get_method calls to improve libevent 1.x emulation and add some libevent 2.x functionality (based on a patch by Jeff Davey). - add more memory fences to fix a bug reported by Jeff Davey. Better be overfenced than underprotected. - ev_run now returns a boolean status (true meaning watchers are still active). - ev_once: undef EV_ERROR in ev_kqueue.c, to avoid clashing with libev's EV_ERROR (reported by 191919). - (ecb) add memory fence support for xlC (Darin McBride). - (ecb) add memory fence support for gcc-mips (Anton Kirilov). - (ecb) add memory fence support for gcc-alpha (Christian Weisgerber). - work around some kernels losing file descriptors by leaking the kqueue descriptor in the child. - work around linux inotify not reporting IN_ATTRIB changes for directories in many cases. - include sys/syscall.h instead of plain syscall.h. - check for io watcher loops in ev_verify, check for the most common reported usage bug in ev_io_start. - choose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET. - always use WSASend/WSARecv directly on windows, hoping that this works in all cases (unlike read/write/send/recv...). - try to detect signals around a fork faster (test program by Denis Bilenko). - work around recent glibc versions that leak memory in realloc. - rename ev::embed::set to ev::embed::set_embed to avoid clashing the watcher base set (loop) method. - rewrite the async/signal pipe logic to always keep a valid fd, which simplifies (and hopefully correctifies :) the race checking on fork, at the cost of one extra fd. - add fat, msdos, jffs2, ramfs, ntfs and btrfs to the list of inotify-supporting filesystems. - move orig_CFLAGS assignment to after AC_INIT, as newer autoconf versions ignore it before (https://bugzilla.redhat.com/show_bug.cgi?id=908096). - add some untested android support. - enum expressions must be of type int (reported by Juan Pablo L). 4.11 Sat Feb 4 19:52:39 CET 2012 - INCOMPATIBLE CHANGE: ev_timer_again now clears the pending status, as was documented already, but not implemented in the repeating case. - new compiletime symbols: EV_NO_SMP and EV_NO_THREADS. - fix a race where the workaround against the epoll fork bugs caused signals to not be handled anymore. - correct backend_fudge for most backends, and implement a windows specific workaround to avoid looping because we call both select and Sleep, both with different time resolutions. - document range and guarantees of ev_sleep. - document reasonable ranges for periodics interval and offset. - rename backend_fudge to backend_mintime to avoid future confusion :) - change the default periodic reschedule function to hopefully be more exact and correct even in corner cases or in the far future. - do not rely on -lm anymore: use it when available but use our own floor () if it is missing. This should make it easier to embed, as no external libraries are required. - strategically import macros from libecb and mark rarely-used functions as cache-cold (saving almost 2k code size on typical amd64 setups). - add Symbols.ev and Symbols.event files, that were missing. - fix backend_mintime value for epoll (was 1/1024, is 1/1000 now). - fix #3 "be smart about timeouts" to not "deadlock" when timeout == now, also improve the section overall. - avoid "AVOIDING FINISHING BEFORE RETURNING" idiom. - support new EV_API_STATIC mode to make all libev symbols static. - supply default CFLAGS of -g -O3 with gcc when original CFLAGS were empty. 4.04 Wed Feb 16 09:01:51 CET 2011 - fix two problems in the native win32 backend, where reuse of fd's with different underlying handles caused handles not to be removed or added to the select set (analyzed and tested by Bert Belder). - do no rely on ceil() in ev_e?poll.c. - backport libev to HP-UX versions before 11 v3. - configure did not detect nanosleep and clock_gettime properly when they are available in the libc (as opposed to -lrt). 4.03 Tue Jan 11 14:37:25 CET 2011 - officially support polling files with all backends. - support files, /dev/zero etc. the same way as select in the epoll backend, by generating events on our own. - ports backend: work around solaris bug 6874410 and many related ones (EINTR, maybe more), with no performance loss (note that the solaris bug report is actually wrong, reality is far more bizarre and broken than that). - define EV_READ/EV_WRITE as macros in event.h, as some programs use #ifdef to test for them. - new (experimental) function: ev_feed_signal. - new (to become default) EVFLAG_NOSIGMASK flag. - new EVBACKEND_MASK symbol. - updated COMMON IDIOMS SECTION. 4.01 Fri Nov 5 21:51:29 CET 2010 - automake fucked it up, apparently, --add-missing -f is not quite enough to make it update its files, so 4.00 didn't install ev++.h and event.h on make install. grrr. - ev_loop(count|depth) didn't return anything (Robin Haberkorn). - change EV_UNDEF to 0xffffffff to silence some overzealous compilers. - use "(libev) " prefix for all libev error messages now. 4.00 Mon Oct 25 12:32:12 CEST 2010 - "PORTING FROM LIBEV 3.X TO 4.X" (in ev.pod) is recommended reading. - ev_embed_stop did not correctly stop the watcher (very good testcase by Vladimir Timofeev). - ev_run will now always update the current loop time - it erroneously didn't when idle watchers were active, causing timers not to fire. - fix a bug where a timeout of zero caused the timer not to fire in the libevent emulation (testcase by Péter Szabó). - applied win32 fixes by Michael Lenaghan (also James Mansion). - replace EV_MINIMAL by EV_FEATURES. - prefer EPOLL_CTL_ADD over EPOLL_CTL_MOD in some more cases, as it seems the former is *much* faster than the latter. - linux kernel version detection (for inotify bug workarounds) did not work properly. - reduce the number of spurious wake-ups with the ports backend. - remove dependency on sys/queue.h on freebsd (patch by Vanilla Hsu). - do async init within ev_async_start, not ev_async_set, which avoids an API quirk where the set function must be called in the C++ API even when there is nothing to set. - add (undocumented) EV_ENABLE when adding events with kqueue, this might help with OS X, which seems to need it despite documenting not to need it (helpfully pointed out by Tilghman Lesher). - do not use poll by default on freebsd, it's broken (what isn't on freebsd...). - allow to embed epoll on kernels >= 2.6.32. - configure now prepends -O3, not appends it, so one can still override it. - ev.pod: greatly expanded the portability section, added a porting section, a description of watcher states and made lots of minor fixes. - disable poll backend on AIX, the poll header spams the namespace and it's not worth working around dead platforms (reported and analyzed by Aivars Kalvans). - improve header file compatibility of the standalone eventfd code in an obscure case. - implement EV_AVOID_STDIO option. - do not use sscanf to parse linux version number (smaller, faster, no sscanf dependency). - new EV_CHILD_ENABLE and EV_SIGNAL_ENABLE configurable settings. - update libev.m4 HAVE_CLOCK_SYSCALL test for newer glibcs. - add section on accept() problems to the manpage. - rename EV_TIMEOUT to EV_TIMER. - rename ev_loop_count/depth/verify/loop/unloop. - remove ev_default_destroy and ev_default_fork. - switch to two-digit minor version. - work around an apparent gentoo compiler bug. - define _DARWIN_UNLIMITED_SELECT. just so. - use enum instead of #define for most constants. - improve compatibility to older C++ compilers. - (experimental) ev_run/ev_default_loop/ev_break/ev_loop_new have now default arguments when compiled as C++. - enable automake dependency tracking. - ev_loop_new no longer leaks memory when loop creation failed. - new ev_cleanup watcher type. 3.9 Thu Dec 31 07:59:59 CET 2009 - signalfd is no longer used by default and has to be requested explicitly - this means that easy to catch bugs become hard to catch race conditions, but the users have spoken. - point out the unspecified signal mask in the documentation, and that this is a race condition regardless of EV_SIGNALFD. - backport inotify code to C89. - inotify file descriptors could leak into child processes. - ev_stat watchers could keep an erroneous extra ref on the loop, preventing exit when unregistering all watchers (testcases provided by ry@tinyclouds.org). - implement EV_WIN32_HANDLE_TO_FD and EV_WIN32_CLOSE_FD configuration symbols to make it easier for apps to do their own fd management. - support EV_IDLE_ENABLE being disabled in ev++.h (patch by Didier Spezia). - take advantage of inotify_init1, if available, to set cloexec/nonblock on fd creation, to avoid races. - the signal handling pipe wasn't always initialised under windows (analysed by lekma). - changed minimum glibc requirement from glibc 2.9 to 2.7, for signalfd. - add missing string.h include (Denis F. Latypoff). - only replace ev_stat.prev when we detect an actual difference, so prev is (almost) always different to attr. this might have caused the problems with 04_stat.t. - add ev::timer->remaining () method to C++ API. 3.8 Sun Aug 9 14:30:45 CEST 2009 - incompatible change: do not necessarily reset signal handler to SIG_DFL when a sighandler is stopped. - ev_default_destroy did not properly free or zero some members, potentially causing crashes and memory corruption on repeated ev_default_destroy/ev_default_loop calls. - take advantage of signalfd on GNU/Linux systems. - document that the signal mask might be in an unspecified state when using libev's signal handling. - take advantage of some GNU/Linux calls to set cloexec/nonblock on fd creation, to avoid race conditions. 3.7 Fri Jul 17 16:36:32 CEST 2009 - ev_unloop and ev_loop wrongly used a global variable to exit loops, instead of using a per-loop variable (bug caught by accident...). - the ev_set_io_collect_interval interpretation has changed. - add new functionality: ev_set_userdata, ev_userdata, ev_set_invoke_pending_cb, ev_set_loop_release_cb, ev_invoke_pending, ev_pending_count, together with a long example about thread locking. - add ev_timer_remaining (as requested by Denis F. Latypoff). - add ev_loop_depth. - calling ev_unloop in fork/prepare watchers will no longer poll for new events. - Denis F. Latypoff corrected many typos in example code snippets. - honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double- check that the syscall number is available before trying to use it (reported by ry@tinyclouds). - use GetSystemTimeAsFileTime instead of _timeb on windows, for slightly higher accuracy. - properly declare ev_loop_verify and ev_now_update even when !EV_MULTIPLICITY. - do not compile in any priority code when EV_MAXPRI == EV_MINPRI. - support EV_MINIMAL==2 for a reduced API. - actually 0-initialise struct sigaction when installing signals. - add section on hibernate and stopped processes to ev_timer docs. 3.6 Tue Apr 28 02:49:30 CEST 2009 - multiple timers becoming ready within an event loop iteration will be invoked in the "correct" order now. - do not leave the event loop early just because we have no active watchers, fixing a problem when embedding a kqueue loop that has active kernel events but no registered watchers (reported by blacksand blacksand). - correctly zero the idx values for arrays, so destroying and reinitialising the default loop actually works (patch by Malek Hadj-Ali). - implement ev_suspend and ev_resume. - new EV_CUSTOM revents flag for use by applications. - add documentation section about priorities. - add a glossary to the documentation. - extend the ev_fork description slightly. - optimize a jump out of call_pending. 3.53 Sun Feb 15 02:38:20 CET 2009 - fix a bug in event pipe creation on win32 that would cause a failed assertion on event loop creation (patch by Malek Hadj-Ali). - probe for CLOCK_REALTIME support at runtime as well and fall back to gettimeofday if there is an error, to support older operating systems with newer header files/libraries. - prefer gettimeofday over clock_gettime with USE_CLOCK_SYSCALL (default most everywhere), otherwise not. 3.52 Wed Jan 7 21:43:02 CET 2009 - fix compilation of select backend in fd_set mode when NFDBITS is missing (to get it to compile on QNX, reported by Rodrigo Campos). - better select-nfds handling when select backend is in fd_set mode. - diagnose fd_set overruns when select backend is in fd_set mode. - due to a thinko, instead of disabling everything but select on the borked OS X platform, everything but select was allowed (reported by Emanuele Giaquinta). - actually verify that local and remote port are matching in libev's socketpair emulation, which makes denial-of-service attacks harder (but not impossible - it's windows). Make sure it even works under vista, which thinks that getpeer/sockname should return fantasy port numbers. - include "libev" in all assertion messages for potentially clearer diagnostics. - event_get_version (libevent compatibility) returned a useless string instead of the expected version string (patch by W.C.A. Wijngaards). 3.51 Wed Dec 24 23:00:11 CET 2008 - fix a bug where an inotify watcher was added twice, causing freezes on hash collisions (reported and analysed by Graham Leggett). - new config symbol, EV_USE_CLOCK_SYSCALL, to make libev use a direct syscall - slower, but no dependency on librt et al. - assume negative return values != -1 signals success of port_getn (http://cvs.epicsol.org/cgi/viewcvs.cgi/epic5/source/newio.c?rev=1.52) (no known failure reports, but it doesn't hurt). - fork detection in ev_embed now stops and restarts the watcher automatically. - EXPERIMENTAL: default the method to operator () in ev++.h, to make it nicer to use functors (requested by Benedek László). - fixed const object callbacks in ev++.h. - replaced loop_ref argument of watcher.set (loop) by a direct ev_loop * in ev++.h, to avoid clashes with functor patch. - do not try to watch the empty string via inotify. - inotify watchers could be leaked under certain circumstances. - OS X 10.5 is actually even more broken than earlier versions, so fall back to select on that piece of garbage. - fixed some weirdness in the ev_embed documentation. 3.49 Wed Nov 19 11:26:53 CET 2008 - ev_stat watchers will now use inotify as a mere hint on kernels <2.6.25, or if the filesystem is not in the "known to be good" list. - better mingw32 compatibility (it's not as borked as native win32) (analysed by Roger Pack). - include stdio.h in the example program, as too many people are confused by the weird C language otherwise. I guess the next thing I get told is that the "..." ellipses in the examples don't compile with their C compiler. 3.48 Thu Oct 30 09:02:37 CET 2008 - further optimise away the EPOLL_CTL_ADD/MOD combo in the epoll backend by assuming the kernel event mask hasn't changed if ADD fails with EEXIST. - work around spurious event notification bugs in epoll by using a 32-bit generation counter. recreate kernel state if we receive spurious notifications or unwanted events. this is very costly, but I didn't come up with this horrible design. - use memset to initialise most arrays now and do away with the init functions. - expand time-out strategies into a "Be smart about timeouts" section. - drop the "struct" from all ev_watcher declarations in the documentation and did other clarifications (yeah, it was a mistake to have a struct AND a function called ev_loop). - fix a bug where ev_default would not initialise the default loop again after it was destroyed with ev_default_destroy. - rename syserr to ev_syserr to avoid name clashes when embedding, do similar changes for event.c. 3.45 Tue Oct 21 21:59:26 CEST 2008 - disable inotify usage on linux <2.6.25, as it is broken (reported by Yoann Vandoorselaere). - ev_stat erroneously would try to add inotify watchers even when inotify wasn't available (this should only have a performance impact). - ev_once now passes both timeout and io to the callback if both occur concurrently, instead of giving timeouts precedence. - disable EV_USE_INOTIFY when sys/inotify.h is too old. 3.44 Mon Sep 29 05:18:39 CEST 2008 - embed watchers now automatically invoke ev_loop_fork on the embedded loop when the parent loop forks. - new function: ev_now_update (loop). - verify_watcher was not marked static. - improve the "associating..." manpage section. - documentation tweaks here and there. 3.43 Sun Jul 6 05:34:41 CEST 2008 - include more include files on windows to get struct _stati64 (reported by Chris Hulbert, but doesn't quite fix his issue). - add missing #include in ev.c on windows (reported by Matt Tolton). 3.42 Tue Jun 17 12:12:07 CEST 2008 - work around yet another windows bug: FD_SET actually adds fd's multiple times to the fd_*SET*, despite official MSN docs claiming otherwise. Reported and well-analysed by Matt Tolton. - define NFDBITS to 0 when EV_SELECT_IS_WINSOCKET to make it compile (reported any analysed by Chris Hulbert). - fix a bug in ev_ebadf (this function is only used to catch programming errors in the libev user). reported by Matt Tolton. - fix a bug in fd_intern on win32 (could lead to compile errors under some circumstances, but would work correctly if it compiles). reported by Matt Tolton. - (try to) work around missing lstat on windows. - pass in the write fd set as except fd set under windows. windows is so uncontrollably lame that it requires this. this means that switching off oobinline is not supported (but tcp/ip doesn't have oob, so that would be stupid anyways. - use posix module symbol to auto-detect monotonic clock presence and some other default values. 3.41 Fri May 23 18:42:54 CEST 2008 - work around an obscure bug in winsocket select: if you provide only empty fd sets then select returns WSAEINVAL. how sucky. - improve timer scheduling stability and reduce use of time_epsilon. - use 1-based 2-heap for EV_MINIMAL, simplifies code, reduces codesize and makes for better cache-efficiency. - use 3-based 4-heap for !EV_MINIMAL. this makes better use of cpu cache lines and gives better growth behaviour than 2-based heaps. - cache timestamp within heap for !EV_MINIMAL, to avoid random memory accesses. - document/add EV_USE_4HEAP and EV_HEAP_CACHE_AT. - fix a potential aliasing issue in ev_timer_again. - add/document ev_periodic_at, retract direct access to ->at. - improve ev_stat docs. - add portability requirements section. - fix manpage headers etc. - normalise WSA error codes to lower range on windows. - add consistency check code that can be called automatically or on demand to check for internal structures (ev_loop_verify). 3.31 Wed Apr 16 20:45:04 CEST 2008 - added last minute fix for ev_poll.c by Brandon Black. 3.3 Wed Apr 16 19:04:10 CEST 2008 - event_base_loopexit should return 0 on success (W.C.A. Wijngaards). - added linux eventfd support. - try to autodetect epoll and inotify support by libc header version if not using autoconf. - new symbols: EV_DEFAULT_UC and EV_DEFAULT_UC_. - declare functions defined in ev.h as inline if C99 or gcc are available. - enable inlining with gcc versions 2 and 3. - work around broken poll implementations potentially not clearing revents field in ev_poll (Brandon Black) (no such systems are known at this time). - work around a bug in realloc on openbsd and darwin, also makes the erroneous valgrind complaints go away (noted by various people). - fix ev_async_pending, add c++ wrapper for ev_async (based on patch sent by Johannes Deisenhofer). - add sensible set method to ev::embed. - made integer constants type int in ev.h. 3.2 Wed Apr 2 17:11:19 CEST 2008 - fix a 64 bit overflow issue in the select backend, by using fd_mask instead of int for the mask. - rename internal sighandler to avoid clash with very old perls. - entering ev_loop will not clear the ONESHOT or NONBLOCKING flags of any outer loops anymore. - add ev_async_pending. 3.1 Thu Mar 13 13:45:22 CET 2008 - implement ev_async watchers. - only initialise signal pipe on demand. - make use of sig_atomic_t configurable. - improved documentation. 3.0 Mon Jan 28 13:14:47 CET 2008 - API/ABI bump to version 3.0. - ev++.h includes "ev.h" by default now, not . - slightly improved documentation. - speed up signal detection after a fork. - only optionally return trace status changed in ev_child watchers. - experimental (and undocumented) loop wrappers for ev++.h. 2.01 Tue Dec 25 08:04:41 CET 2007 - separate Changes file. - fix ev_path_set => ev_stat_set typo. - remove event_compat.h from the libev tarball. - change how include files are found. - doc updates. - update licenses, explicitly allow for GPL relicensing. 2.0 Sat Dec 22 17:47:03 CET 2007 - new ev_sleep, ev_set_(io|timeout)_collect_interval. - removed epoll from embeddable fd set. - fix embed watchers. - renamed ev_embed.loop to other. - added exported Symbol tables. - undefine member wrapper macros at the end of ev.c. - respect EV_H in ev++.h. 1.86 Tue Dec 18 02:36:57 CET 2007 - fix memleak on loop destroy (not relevant for perl). 1.85 Fri Dec 14 20:32:40 CET 2007 - fix some aliasing issues w.r.t. timers and periodics (not relevant for perl). (for historic versions refer to EV/Changes, found in the Perl interface) 0.1 Wed Oct 31 21:31:48 CET 2007 - original version; hacked together in <24h. gevent-1.1.0/libev/config.guess0000755000076500000000000012463712666555342017175 0ustar jmaddenwheel00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-03-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gevent-1.1.0/libev/config.h.in0000644000076500000000000000636712666555342016677 0ustar jmaddenwheel00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 to use the syscall interface for clock_gettime */ #undef HAVE_CLOCK_SYSCALL /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the `epoll_ctl' function. */ #undef HAVE_EPOLL_CTL /* Define to 1 if you have the `eventfd' function. */ #undef HAVE_EVENTFD /* Define to 1 if the floor function is available */ #undef HAVE_FLOOR /* Define to 1 if you have the `inotify_init' function. */ #undef HAVE_INOTIFY_INIT /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `kqueue' function. */ #undef HAVE_KQUEUE /* Define to 1 if you have the `rt' library (-lrt). */ #undef HAVE_LIBRT /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* Define to 1 if you have the `port_create' function. */ #undef HAVE_PORT_CREATE /* Define to 1 if you have the header file. */ #undef HAVE_PORT_H /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `signalfd' function. */ #undef HAVE_SIGNALFD /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EPOLL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENTFD_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_INOTIFY_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SIGNALFD_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION gevent-1.1.0/libev/config.sub0000755000076500000000000010636712666555342016640 0ustar jmaddenwheel00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-03-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: gevent-1.1.0/libev/configure0000755000076500000000000146434612666555342016571 0ustar jmaddenwheel00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="ev_epoll.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu orig_CFLAGS="$CFLAGS" am__api_version='1.14' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=libev VERSION=4.20 cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi ac_config_headers="$ac_config_headers config.h" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test -z "$orig_CFLAGS"; then if test x$GCC = xyes; then CFLAGS="-g -O3" fi fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: for ac_header in sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.h sys/eventfd.h sys/signalfd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in clock_gettime do : ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" if test "x$ac_cv_func_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOCK_GETTIME 1 _ACEOF else if test $(uname) = Linux; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime syscall" >&5 $as_echo_n "checking for clock_gettime syscall... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { struct timespec ts; int status = syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_have_clock_syscall=1 $as_echo "#define HAVE_CLOCK_SYSCALL 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test -z "$LIBEV_M4_AVOID_LIBRT" && test -z "$ac_have_clock_syscall"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 $as_echo_n "checking for clock_gettime in -lrt... " >&6; } if ${ac_cv_lib_rt_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes else ac_cv_lib_rt_clock_gettime=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF LIBS="-lrt $LIBS" fi unset ac_cv_func_clock_gettime for ac_func in clock_gettime do : ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" if test "x$ac_cv_func_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOCK_GETTIME 1 _ACEOF fi done fi fi done for ac_func in nanosleep do : ac_fn_c_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep" if test "x$ac_cv_func_nanosleep" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NANOSLEEP 1 _ACEOF else if test -z "$LIBEV_M4_AVOID_LIBRT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nanosleep in -lrt" >&5 $as_echo_n "checking for nanosleep in -lrt... " >&6; } if ${ac_cv_lib_rt_nanosleep+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char nanosleep (); int main () { return nanosleep (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_nanosleep=yes else ac_cv_lib_rt_nanosleep=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_nanosleep" >&5 $as_echo "$ac_cv_lib_rt_nanosleep" >&6; } if test "x$ac_cv_lib_rt_nanosleep" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF LIBS="-lrt $LIBS" fi unset ac_cv_func_nanosleep for ac_func in nanosleep do : ac_fn_c_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep" if test "x$ac_cv_func_nanosleep" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NANOSLEEP 1 _ACEOF fi done fi fi done if test -z "$LIBEV_M4_AVOID_LIBM"; then LIBM=m fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing floor" >&5 $as_echo_n "checking for library containing floor... " >&6; } if ${ac_cv_search_floor+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char floor (); int main () { return floor (); ; return 0; } _ACEOF for ac_lib in '' $LIBM; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_floor=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_floor+:} false; then : break fi done if ${ac_cv_search_floor+:} false; then : else ac_cv_search_floor=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_floor" >&5 $as_echo "$ac_cv_search_floor" >&6; } ac_res=$ac_cv_search_floor if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_FLOOR 1" >>confdefs.h fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi gevent-1.1.0/libev/ev.c0000644000076500000000000036476312666555342015441 0ustar jmaddenwheel00000000000000/* * libev event processing core, watcher management * * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ /* this big block deduces configuration from config.h */ #ifndef EV_STANDALONE # ifdef EV_CONFIG_H # include EV_CONFIG_H # else # include "config.h" # endif # if HAVE_FLOOR # ifndef EV_USE_FLOOR # define EV_USE_FLOOR 1 # endif # endif # if HAVE_CLOCK_SYSCALL # ifndef EV_USE_CLOCK_SYSCALL # define EV_USE_CLOCK_SYSCALL 1 # ifndef EV_USE_REALTIME # define EV_USE_REALTIME 0 # endif # ifndef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 1 # endif # endif # elif !defined EV_USE_CLOCK_SYSCALL # define EV_USE_CLOCK_SYSCALL 0 # endif # if HAVE_CLOCK_GETTIME # ifndef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 1 # endif # ifndef EV_USE_REALTIME # define EV_USE_REALTIME 0 # endif # else # ifndef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 0 # endif # ifndef EV_USE_REALTIME # define EV_USE_REALTIME 0 # endif # endif # if HAVE_NANOSLEEP # ifndef EV_USE_NANOSLEEP # define EV_USE_NANOSLEEP EV_FEATURE_OS # endif # else # undef EV_USE_NANOSLEEP # define EV_USE_NANOSLEEP 0 # endif # if HAVE_SELECT && HAVE_SYS_SELECT_H # ifndef EV_USE_SELECT # define EV_USE_SELECT EV_FEATURE_BACKENDS # endif # else # undef EV_USE_SELECT # define EV_USE_SELECT 0 # endif # if HAVE_POLL && HAVE_POLL_H # ifndef EV_USE_POLL # define EV_USE_POLL EV_FEATURE_BACKENDS # endif # else # undef EV_USE_POLL # define EV_USE_POLL 0 # endif # if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H # ifndef EV_USE_EPOLL # define EV_USE_EPOLL EV_FEATURE_BACKENDS # endif # else # undef EV_USE_EPOLL # define EV_USE_EPOLL 0 # endif # if HAVE_KQUEUE && HAVE_SYS_EVENT_H # ifndef EV_USE_KQUEUE # define EV_USE_KQUEUE EV_FEATURE_BACKENDS # endif # else # undef EV_USE_KQUEUE # define EV_USE_KQUEUE 0 # endif # if HAVE_PORT_H && HAVE_PORT_CREATE # ifndef EV_USE_PORT # define EV_USE_PORT EV_FEATURE_BACKENDS # endif # else # undef EV_USE_PORT # define EV_USE_PORT 0 # endif # if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H # ifndef EV_USE_INOTIFY # define EV_USE_INOTIFY EV_FEATURE_OS # endif # else # undef EV_USE_INOTIFY # define EV_USE_INOTIFY 0 # endif # if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H # ifndef EV_USE_SIGNALFD # define EV_USE_SIGNALFD EV_FEATURE_OS # endif # else # undef EV_USE_SIGNALFD # define EV_USE_SIGNALFD 0 # endif # if HAVE_EVENTFD # ifndef EV_USE_EVENTFD # define EV_USE_EVENTFD EV_FEATURE_OS # endif # else # undef EV_USE_EVENTFD # define EV_USE_EVENTFD 0 # endif #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef EV_H # include EV_H #else # include "ev.h" #endif #if EV_NO_THREADS # undef EV_NO_SMP # define EV_NO_SMP 1 # undef ECB_NO_THREADS # define ECB_NO_THREADS 1 #endif #if EV_NO_SMP # undef EV_NO_SMP # define ECB_NO_SMP 1 #endif #ifndef _WIN32 # include # include # include #else # include # define WIN32_LEAN_AND_MEAN # include # include # ifndef EV_SELECT_IS_WINSOCKET # define EV_SELECT_IS_WINSOCKET 1 # endif # undef EV_AVOID_STDIO #endif /* OS X, in its infinite idiocy, actually HARDCODES * a limit of 1024 into their select. Where people have brains, * OS X engineers apparently have a vacuum. Or maybe they were * ordered to have a vacuum, or they do anything for money. * This might help. Or not. */ #define _DARWIN_UNLIMITED_SELECT 1 /* this block tries to deduce configuration from header-defined symbols and defaults */ /* try to deduce the maximum number of signals on this platform */ #if defined EV_NSIG /* use what's provided */ #elif defined NSIG # define EV_NSIG (NSIG) #elif defined _NSIG # define EV_NSIG (_NSIG) #elif defined SIGMAX # define EV_NSIG (SIGMAX+1) #elif defined SIG_MAX # define EV_NSIG (SIG_MAX+1) #elif defined _SIG_MAX # define EV_NSIG (_SIG_MAX+1) #elif defined MAXSIG # define EV_NSIG (MAXSIG+1) #elif defined MAX_SIG # define EV_NSIG (MAX_SIG+1) #elif defined SIGARRAYSIZE # define EV_NSIG (SIGARRAYSIZE) /* Assume ary[SIGARRAYSIZE] */ #elif defined _sys_nsig # define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ #else # define EV_NSIG (8 * sizeof (sigset_t) + 1) #endif #ifndef EV_USE_FLOOR # define EV_USE_FLOOR 0 #endif #ifndef EV_USE_CLOCK_SYSCALL # if __linux && __GLIBC__ == 2 && __GLIBC_MINOR__ < 17 # define EV_USE_CLOCK_SYSCALL EV_FEATURE_OS # else # define EV_USE_CLOCK_SYSCALL 0 # endif #endif #if !(_POSIX_TIMERS > 0) # ifndef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 0 # endif # ifndef EV_USE_REALTIME # define EV_USE_REALTIME 0 # endif #endif #ifndef EV_USE_MONOTONIC # if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0 # define EV_USE_MONOTONIC EV_FEATURE_OS # else # define EV_USE_MONOTONIC 0 # endif #endif #ifndef EV_USE_REALTIME # define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL #endif #ifndef EV_USE_NANOSLEEP # if _POSIX_C_SOURCE >= 199309L # define EV_USE_NANOSLEEP EV_FEATURE_OS # else # define EV_USE_NANOSLEEP 0 # endif #endif #ifndef EV_USE_SELECT # define EV_USE_SELECT EV_FEATURE_BACKENDS #endif #ifndef EV_USE_POLL # ifdef _WIN32 # define EV_USE_POLL 0 # else # define EV_USE_POLL EV_FEATURE_BACKENDS # endif #endif #ifndef EV_USE_EPOLL # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) # define EV_USE_EPOLL EV_FEATURE_BACKENDS # else # define EV_USE_EPOLL 0 # endif #endif #ifndef EV_USE_KQUEUE # define EV_USE_KQUEUE 0 #endif #ifndef EV_USE_PORT # define EV_USE_PORT 0 #endif #ifndef EV_USE_INOTIFY # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) # define EV_USE_INOTIFY EV_FEATURE_OS # else # define EV_USE_INOTIFY 0 # endif #endif #ifndef EV_PID_HASHSIZE # define EV_PID_HASHSIZE EV_FEATURE_DATA ? 16 : 1 #endif #ifndef EV_INOTIFY_HASHSIZE # define EV_INOTIFY_HASHSIZE EV_FEATURE_DATA ? 16 : 1 #endif #ifndef EV_USE_EVENTFD # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) # define EV_USE_EVENTFD EV_FEATURE_OS # else # define EV_USE_EVENTFD 0 # endif #endif #ifndef EV_USE_SIGNALFD # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) # define EV_USE_SIGNALFD EV_FEATURE_OS # else # define EV_USE_SIGNALFD 0 # endif #endif #if 0 /* debugging */ # define EV_VERIFY 3 # define EV_USE_4HEAP 1 # define EV_HEAP_CACHE_AT 1 #endif #ifndef EV_VERIFY # define EV_VERIFY (EV_FEATURE_API ? 1 : 0) #endif #ifndef EV_USE_4HEAP # define EV_USE_4HEAP EV_FEATURE_DATA #endif #ifndef EV_HEAP_CACHE_AT # define EV_HEAP_CACHE_AT EV_FEATURE_DATA #endif #ifdef ANDROID /* supposedly, android doesn't typedef fd_mask */ # undef EV_USE_SELECT # define EV_USE_SELECT 0 /* supposedly, we need to include syscall.h, not sys/syscall.h, so just disable */ # undef EV_USE_CLOCK_SYSCALL # define EV_USE_CLOCK_SYSCALL 0 #endif /* aix's poll.h seems to cause lots of trouble */ #ifdef _AIX /* AIX has a completely broken poll.h header */ # undef EV_USE_POLL # define EV_USE_POLL 0 #endif /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ /* which makes programs even slower. might work on other unices, too. */ #if EV_USE_CLOCK_SYSCALL # include # ifdef SYS_clock_gettime # define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) # undef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 1 # else # undef EV_USE_CLOCK_SYSCALL # define EV_USE_CLOCK_SYSCALL 0 # endif #endif /* this block fixes any misconfiguration where we know we run into trouble otherwise */ #ifndef CLOCK_MONOTONIC # undef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 0 #endif #ifndef CLOCK_REALTIME # undef EV_USE_REALTIME # define EV_USE_REALTIME 0 #endif #if !EV_STAT_ENABLE # undef EV_USE_INOTIFY # define EV_USE_INOTIFY 0 #endif #if !EV_USE_NANOSLEEP /* hp-ux has it in sys/time.h, which we unconditionally include above */ # if !defined _WIN32 && !defined __hpux # include # endif #endif #if EV_USE_INOTIFY # include # include /* some very old inotify.h headers don't have IN_DONT_FOLLOW */ # ifndef IN_DONT_FOLLOW # undef EV_USE_INOTIFY # define EV_USE_INOTIFY 0 # endif #endif #if EV_USE_EVENTFD /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ # include # ifndef EFD_NONBLOCK # define EFD_NONBLOCK O_NONBLOCK # endif # ifndef EFD_CLOEXEC # ifdef O_CLOEXEC # define EFD_CLOEXEC O_CLOEXEC # else # define EFD_CLOEXEC 02000000 # endif # endif EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags); #endif #if EV_USE_SIGNALFD /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ # include # ifndef SFD_NONBLOCK # define SFD_NONBLOCK O_NONBLOCK # endif # ifndef SFD_CLOEXEC # ifdef O_CLOEXEC # define SFD_CLOEXEC O_CLOEXEC # else # define SFD_CLOEXEC 02000000 # endif # endif EV_CPP (extern "C") int signalfd (int fd, const sigset_t *mask, int flags); struct signalfd_siginfo { uint32_t ssi_signo; char pad[128 - sizeof (uint32_t)]; }; #endif /**/ #if EV_VERIFY >= 3 # define EV_FREQUENT_CHECK ev_verify (EV_A) #else # define EV_FREQUENT_CHECK do { } while (0) #endif /* * This is used to work around floating point rounding problems. * This value is good at least till the year 4000. */ #define MIN_INTERVAL 0.0001220703125 /* 1/2**13, good till 4000 */ /*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */ #define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ #define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ #define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0) #define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0) /* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */ /* ECB.H BEGIN */ /* * libecb - http://software.schmorp.de/pkg/libecb * * Copyright (©) 2009-2015 Marc Alexander Lehmann * Copyright (©) 2011 Emanuele Giaquinta * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #ifndef ECB_H #define ECB_H /* 16 bits major, 16 bits minor */ #define ECB_VERSION 0x00010004 #ifdef _WIN32 typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; #if __GNUC__ typedef signed long long int64_t; typedef unsigned long long uint64_t; #else /* _MSC_VER || __BORLANDC__ */ typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; #endif #ifdef _WIN64 #define ECB_PTRSIZE 8 typedef uint64_t uintptr_t; typedef int64_t intptr_t; #else #define ECB_PTRSIZE 4 typedef uint32_t uintptr_t; typedef int32_t intptr_t; #endif #else #include #if UINTMAX_MAX > 0xffffffffU #define ECB_PTRSIZE 8 #else #define ECB_PTRSIZE 4 #endif #endif #define ECB_GCC_AMD64 (__amd64 || __amd64__ || __x86_64 || __x86_64__) #define ECB_MSVC_AMD64 (_M_AMD64 || _M_X64) /* work around x32 idiocy by defining proper macros */ #if ECB_GCC_AMD64 || ECB_MSVC_AMD64 #if _ILP32 #define ECB_AMD64_X32 1 #else #define ECB_AMD64 1 #endif #endif /* many compilers define _GNUC_ to some versions but then only implement * what their idiot authors think are the "more important" extensions, * causing enormous grief in return for some better fake benchmark numbers. * or so. * we try to detect these and simply assume they are not gcc - if they have * an issue with that they should have done it right in the first place. */ #if !defined __GNUC_MINOR__ || defined __INTEL_COMPILER || defined __SUNPRO_C || defined __SUNPRO_CC || defined __llvm__ || defined __clang__ #define ECB_GCC_VERSION(major,minor) 0 #else #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #endif #define ECB_CLANG_VERSION(major,minor) (__clang_major__ > (major) || (__clang_major__ == (major) && __clang_minor__ >= (minor))) #if __clang__ && defined __has_builtin #define ECB_CLANG_BUILTIN(x) __has_builtin (x) #else #define ECB_CLANG_BUILTIN(x) 0 #endif #if __clang__ && defined __has_extension #define ECB_CLANG_EXTENSION(x) __has_extension (x) #else #define ECB_CLANG_EXTENSION(x) 0 #endif #define ECB_CPP (__cplusplus+0) #define ECB_CPP11 (__cplusplus >= 201103L) #if ECB_CPP #define ECB_C 0 #define ECB_STDC_VERSION 0 #else #define ECB_C 1 #define ECB_STDC_VERSION __STDC_VERSION__ #endif #define ECB_C99 (ECB_STDC_VERSION >= 199901L) #define ECB_C11 (ECB_STDC_VERSION >= 201112L) #if ECB_CPP #define ECB_EXTERN_C extern "C" #define ECB_EXTERN_C_BEG ECB_EXTERN_C { #define ECB_EXTERN_C_END } #else #define ECB_EXTERN_C extern #define ECB_EXTERN_C_BEG #define ECB_EXTERN_C_END #endif /*****************************************************************************/ /* ECB_NO_THREADS - ecb is not used by multiple threads, ever */ /* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */ #if ECB_NO_THREADS #define ECB_NO_SMP 1 #endif #if ECB_NO_SMP #define ECB_MEMORY_FENCE do { } while (0) #endif /* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_ref/compiler_builtins.html */ #if __xlC__ && ECB_CPP #include #endif #ifndef ECB_MEMORY_FENCE #if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 #if __i386 || __i386__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") #elif ECB_GCC_AMD64 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") #elif defined __ARM_ARCH_6__ || defined __ARM_ARCH_6J__ \ || defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6ZK__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,5" : : "r" (0) : "memory") #elif defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ \ || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory") #elif __aarch64__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb ish" : : : "memory") #elif (__sparc || __sparc__) && !__sparcv8 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory") #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") #elif defined __s390__ || defined __s390x__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory") #elif defined __mips__ /* GNU/Linux emulates sync on mips1 architectures, so we force its use */ /* anybody else who still uses mips1 is supposed to send in their version, with detection code. */ #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0" : : : "memory") #elif defined __alpha__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory") #elif defined __hppa__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") #elif defined __ia64__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mf" : : : "memory") #elif defined __m68k__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") #elif defined __m88k__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("tb1 0,%%r0,128" : : : "memory") #elif defined __sh__ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") #endif #endif #endif #ifndef ECB_MEMORY_FENCE #if ECB_GCC_VERSION(4,7) /* see comment below (stdatomic.h) about the C11 memory model. */ #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) #define ECB_MEMORY_FENCE_ACQUIRE __atomic_thread_fence (__ATOMIC_ACQUIRE) #define ECB_MEMORY_FENCE_RELEASE __atomic_thread_fence (__ATOMIC_RELEASE) #elif ECB_CLANG_EXTENSION(c_atomic) /* see comment below (stdatomic.h) about the C11 memory model. */ #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST) #define ECB_MEMORY_FENCE_ACQUIRE __c11_atomic_thread_fence (__ATOMIC_ACQUIRE) #define ECB_MEMORY_FENCE_RELEASE __c11_atomic_thread_fence (__ATOMIC_RELEASE) #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ #define ECB_MEMORY_FENCE __sync_synchronize () #elif _MSC_VER >= 1500 /* VC++ 2008 */ /* apparently, microsoft broke all the memory barrier stuff in Visual Studio 2008... */ #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) #define ECB_MEMORY_FENCE _ReadWriteBarrier (); MemoryBarrier() #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier (); MemoryBarrier() /* according to msdn, _ReadBarrier is not a load fence */ #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier (); MemoryBarrier() #elif _MSC_VER >= 1400 /* VC++ 2005 */ #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) #define ECB_MEMORY_FENCE _ReadWriteBarrier () #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier () /* according to msdn, _ReadBarrier is not a load fence */ #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier () #elif defined _WIN32 #include #define ECB_MEMORY_FENCE MemoryBarrier () /* actually just xchg on x86... scary */ #elif __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 #include #define ECB_MEMORY_FENCE __machine_rw_barrier () #define ECB_MEMORY_FENCE_ACQUIRE __machine_r_barrier () #define ECB_MEMORY_FENCE_RELEASE __machine_w_barrier () #elif __xlC__ #define ECB_MEMORY_FENCE __sync () #endif #endif #ifndef ECB_MEMORY_FENCE #if ECB_C11 && !defined __STDC_NO_ATOMICS__ /* we assume that these memory fences work on all variables/all memory accesses, */ /* not just C11 atomics and atomic accesses */ #include /* Unfortunately, neither gcc 4.7 nor clang 3.1 generate any instructions for */ /* any fence other than seq_cst, which isn't very efficient for us. */ /* Why that is, we don't know - either the C11 memory model is quite useless */ /* for most usages, or gcc and clang have a bug */ /* I *currently* lean towards the latter, and inefficiently implement */ /* all three of ecb's fences as a seq_cst fence */ /* Update, gcc-4.8 generates mfence for all c++ fences, but nothing */ /* for all __atomic_thread_fence's except seq_cst */ #define ECB_MEMORY_FENCE atomic_thread_fence (memory_order_seq_cst) #endif #endif #ifndef ECB_MEMORY_FENCE #if !ECB_AVOID_PTHREADS /* * if you get undefined symbol references to pthread_mutex_lock, * or failure to find pthread.h, then you should implement * the ECB_MEMORY_FENCE operations for your cpu/compiler * OR provide pthread.h and link against the posix thread library * of your system. */ #include #define ECB_NEEDS_PTHREADS 1 #define ECB_MEMORY_FENCE_NEEDS_PTHREADS 1 static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER; #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0) #endif #endif #if !defined ECB_MEMORY_FENCE_ACQUIRE && defined ECB_MEMORY_FENCE #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE #endif #if !defined ECB_MEMORY_FENCE_RELEASE && defined ECB_MEMORY_FENCE #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE #endif /*****************************************************************************/ #if ECB_CPP #define ecb_inline static inline #elif ECB_GCC_VERSION(2,5) #define ecb_inline static __inline__ #elif ECB_C99 #define ecb_inline static inline #else #define ecb_inline static #endif #if ECB_GCC_VERSION(3,3) #define ecb_restrict __restrict__ #elif ECB_C99 #define ecb_restrict restrict #else #define ecb_restrict #endif typedef int ecb_bool; #define ECB_CONCAT_(a, b) a ## b #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) #define ECB_STRINGIFY_(a) # a #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) #define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr)) #define ecb_function_ ecb_inline #if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) #define ecb_attribute(attrlist) __attribute__ (attrlist) #else #define ecb_attribute(attrlist) #endif #if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_constant_p) #define ecb_is_constant(expr) __builtin_constant_p (expr) #else /* possible C11 impl for integral types typedef struct ecb_is_constant_struct ecb_is_constant_struct; #define ecb_is_constant(expr) _Generic ((1 ? (struct ecb_is_constant_struct *)0 : (void *)((expr) - (expr)), ecb_is_constant_struct *: 0, default: 1)) */ #define ecb_is_constant(expr) 0 #endif #if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_expect) #define ecb_expect(expr,value) __builtin_expect ((expr),(value)) #else #define ecb_expect(expr,value) (expr) #endif #if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_prefetch) #define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) #else #define ecb_prefetch(addr,rw,locality) #endif /* no emulation for ecb_decltype */ #if ECB_CPP11 // older implementations might have problems with decltype(x)::type, work around it template struct ecb_decltype_t { typedef T type; }; #define ecb_decltype(x) ecb_decltype_t::type #elif ECB_GCC_VERSION(3,0) || ECB_CLANG_VERSION(2,8) #define ecb_decltype(x) __typeof__ (x) #endif #if _MSC_VER >= 1300 #define ecb_deprecated __declspec (deprecated) #else #define ecb_deprecated ecb_attribute ((__deprecated__)) #endif #if _MSC_VER >= 1500 #define ecb_deprecated_message(msg) __declspec (deprecated (msg)) #elif ECB_GCC_VERSION(4,5) #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg)) #else #define ecb_deprecated_message(msg) ecb_deprecated #endif #if _MSC_VER >= 1400 #define ecb_noinline __declspec (noinline) #else #define ecb_noinline ecb_attribute ((__noinline__)) #endif #define ecb_unused ecb_attribute ((__unused__)) #define ecb_const ecb_attribute ((__const__)) #define ecb_pure ecb_attribute ((__pure__)) #if ECB_C11 || __IBMC_NORETURN /* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/language_ref/noreturn.html */ #define ecb_noreturn _Noreturn #elif ECB_CPP11 #define ecb_noreturn [[noreturn]] #elif _MSC_VER >= 1200 /* http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx */ #define ecb_noreturn __declspec (noreturn) #else #define ecb_noreturn ecb_attribute ((__noreturn__)) #endif #if ECB_GCC_VERSION(4,3) #define ecb_artificial ecb_attribute ((__artificial__)) #define ecb_hot ecb_attribute ((__hot__)) #define ecb_cold ecb_attribute ((__cold__)) #else #define ecb_artificial #define ecb_hot #define ecb_cold #endif /* put around conditional expressions if you are very sure that the */ /* expression is mostly true or mostly false. note that these return */ /* booleans, not the expression. */ #define ecb_expect_false(expr) ecb_expect (!!(expr), 0) #define ecb_expect_true(expr) ecb_expect (!!(expr), 1) /* for compatibility to the rest of the world */ #define ecb_likely(expr) ecb_expect_true (expr) #define ecb_unlikely(expr) ecb_expect_false (expr) /* count trailing zero bits and count # of one bits */ #if ECB_GCC_VERSION(3,4) \ || (ECB_CLANG_BUILTIN(__builtin_clz) && ECB_CLANG_BUILTIN(__builtin_clzll) \ && ECB_CLANG_BUILTIN(__builtin_ctz) && ECB_CLANG_BUILTIN(__builtin_ctzll) \ && ECB_CLANG_BUILTIN(__builtin_popcount)) /* we assume int == 32 bit, long == 32 or 64 bit and long long == 64 bit */ #define ecb_ld32(x) (__builtin_clz (x) ^ 31) #define ecb_ld64(x) (__builtin_clzll (x) ^ 63) #define ecb_ctz32(x) __builtin_ctz (x) #define ecb_ctz64(x) __builtin_ctzll (x) #define ecb_popcount32(x) __builtin_popcount (x) /* no popcountll */ #else ecb_function_ ecb_const int ecb_ctz32 (uint32_t x); ecb_function_ ecb_const int ecb_ctz32 (uint32_t x) { int r = 0; x &= ~x + 1; /* this isolates the lowest bit */ #if ECB_branchless_on_i386 r += !!(x & 0xaaaaaaaa) << 0; r += !!(x & 0xcccccccc) << 1; r += !!(x & 0xf0f0f0f0) << 2; r += !!(x & 0xff00ff00) << 3; r += !!(x & 0xffff0000) << 4; #else if (x & 0xaaaaaaaa) r += 1; if (x & 0xcccccccc) r += 2; if (x & 0xf0f0f0f0) r += 4; if (x & 0xff00ff00) r += 8; if (x & 0xffff0000) r += 16; #endif return r; } ecb_function_ ecb_const int ecb_ctz64 (uint64_t x); ecb_function_ ecb_const int ecb_ctz64 (uint64_t x) { int shift = x & 0xffffffffU ? 0 : 32; return ecb_ctz32 (x >> shift) + shift; } ecb_function_ ecb_const int ecb_popcount32 (uint32_t x); ecb_function_ ecb_const int ecb_popcount32 (uint32_t x) { x -= (x >> 1) & 0x55555555; x = ((x >> 2) & 0x33333333) + (x & 0x33333333); x = ((x >> 4) + x) & 0x0f0f0f0f; x *= 0x01010101; return x >> 24; } ecb_function_ ecb_const int ecb_ld32 (uint32_t x); ecb_function_ ecb_const int ecb_ld32 (uint32_t x) { int r = 0; if (x >> 16) { x >>= 16; r += 16; } if (x >> 8) { x >>= 8; r += 8; } if (x >> 4) { x >>= 4; r += 4; } if (x >> 2) { x >>= 2; r += 2; } if (x >> 1) { r += 1; } return r; } ecb_function_ ecb_const int ecb_ld64 (uint64_t x); ecb_function_ ecb_const int ecb_ld64 (uint64_t x) { int r = 0; if (x >> 32) { x >>= 32; r += 32; } return r + ecb_ld32 (x); } #endif ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x); ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); } ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x); ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); } ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x); ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x) { return ( (x * 0x0802U & 0x22110U) | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16; } ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x); ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x) { x = ((x >> 1) & 0x5555) | ((x & 0x5555) << 1); x = ((x >> 2) & 0x3333) | ((x & 0x3333) << 2); x = ((x >> 4) & 0x0f0f) | ((x & 0x0f0f) << 4); x = ( x >> 8 ) | ( x << 8); return x; } ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x); ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x) { x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1); x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2); x = ((x >> 4) & 0x0f0f0f0f) | ((x & 0x0f0f0f0f) << 4); x = ((x >> 8) & 0x00ff00ff) | ((x & 0x00ff00ff) << 8); x = ( x >> 16 ) | ( x << 16); return x; } /* popcount64 is only available on 64 bit cpus as gcc builtin */ /* so for this version we are lazy */ ecb_function_ ecb_const int ecb_popcount64 (uint64_t x); ecb_function_ ecb_const int ecb_popcount64 (uint64_t x) { return ecb_popcount32 (x) + ecb_popcount32 (x >> 32); } ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count); ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count); ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count); ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count); ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count); ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count); ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count); ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count); ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); } ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); } ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); } ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); } ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); } ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } #if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64)) #if ECB_GCC_VERSION(4,8) || ECB_CLANG_BUILTIN(__builtin_bswap16) #define ecb_bswap16(x) __builtin_bswap16 (x) #else #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) #endif #define ecb_bswap32(x) __builtin_bswap32 (x) #define ecb_bswap64(x) __builtin_bswap64 (x) #elif _MSC_VER #include #define ecb_bswap16(x) ((uint16_t)_byteswap_ushort ((uint16_t)(x))) #define ecb_bswap32(x) ((uint32_t)_byteswap_ulong ((uint32_t)(x))) #define ecb_bswap64(x) ((uint64_t)_byteswap_uint64 ((uint64_t)(x))) #else ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x); ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x) { return ecb_rotl16 (x, 8); } ecb_function_ ecb_const uint32_t ecb_bswap32 (uint32_t x); ecb_function_ ecb_const uint32_t ecb_bswap32 (uint32_t x) { return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16); } ecb_function_ ecb_const uint64_t ecb_bswap64 (uint64_t x); ecb_function_ ecb_const uint64_t ecb_bswap64 (uint64_t x) { return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32); } #endif #if ECB_GCC_VERSION(4,5) || ECB_CLANG_BUILTIN(__builtin_unreachable) #define ecb_unreachable() __builtin_unreachable () #else /* this seems to work fine, but gcc always emits a warning for it :/ */ ecb_inline ecb_noreturn void ecb_unreachable (void); ecb_inline ecb_noreturn void ecb_unreachable (void) { } #endif /* try to tell the compiler that some condition is definitely true */ #define ecb_assume(cond) if (!(cond)) ecb_unreachable (); else 0 ecb_inline ecb_const unsigned char ecb_byteorder_helper (void); ecb_inline ecb_const unsigned char ecb_byteorder_helper (void) { /* the union code still generates code under pressure in gcc, */ /* but less than using pointers, and always seems to */ /* successfully return a constant. */ /* the reason why we have this horrible preprocessor mess */ /* is to avoid it in all cases, at least on common architectures */ /* or when using a recent enough gcc version (>= 4.6) */ #if ((__i386 || __i386__) && !__VOS__) || _M_IX86 || ECB_GCC_AMD64 || ECB_MSVC_AMD64 return 0x44; #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ return 0x44; #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ return 0x11; #else union { uint32_t i; uint8_t c; } u = { 0x11223344 }; return u.c; #endif } ecb_inline ecb_const ecb_bool ecb_big_endian (void); ecb_inline ecb_const ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; } ecb_inline ecb_const ecb_bool ecb_little_endian (void); ecb_inline ecb_const ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; } #if ECB_GCC_VERSION(3,0) || ECB_C99 #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0)) #else #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n))) #endif #if ECB_CPP template static inline T ecb_div_rd (T val, T div) { return val < 0 ? - ((-val + div - 1) / div) : (val ) / div; } template static inline T ecb_div_ru (T val, T div) { return val < 0 ? - ((-val ) / div) : (val + div - 1) / div; } #else #define ecb_div_rd(val,div) ((val) < 0 ? - ((-(val) + (div) - 1) / (div)) : ((val) ) / (div)) #define ecb_div_ru(val,div) ((val) < 0 ? - ((-(val) ) / (div)) : ((val) + (div) - 1) / (div)) #endif #if ecb_cplusplus_does_not_suck /* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) */ template static inline int ecb_array_length (const T (&arr)[N]) { return N; } #else #define ecb_array_length(name) (sizeof (name) / sizeof (name [0])) #endif /*******************************************************************************/ /* floating point stuff, can be disabled by defining ECB_NO_LIBM */ /* basically, everything uses "ieee pure-endian" floating point numbers */ /* the only noteworthy exception is ancient armle, which uses order 43218765 */ #if 0 \ || __i386 || __i386__ \ || ECB_GCC_AMD64 \ || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \ || defined __s390__ || defined __s390x__ \ || defined __mips__ \ || defined __alpha__ \ || defined __hppa__ \ || defined __ia64__ \ || defined __m68k__ \ || defined __m88k__ \ || defined __sh__ \ || defined _M_IX86 || defined ECB_MSVC_AMD64 || defined _M_IA64 \ || (defined __arm__ && (defined __ARM_EABI__ || defined __EABI__ || defined __VFP_FP__ || defined _WIN32_WCE || defined __ANDROID__)) \ || defined __aarch64__ #define ECB_STDFP 1 #include /* for memcpy */ #else #define ECB_STDFP 0 #endif #ifndef ECB_NO_LIBM #include /* for frexp*, ldexp*, INFINITY, NAN */ /* only the oldest of old doesn't have this one. solaris. */ #ifdef INFINITY #define ECB_INFINITY INFINITY #else #define ECB_INFINITY HUGE_VAL #endif #ifdef NAN #define ECB_NAN NAN #else #define ECB_NAN ECB_INFINITY #endif #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L #define ecb_ldexpf(x,e) ldexpf ((x), (e)) #define ecb_frexpf(x,e) frexpf ((x), (e)) #else #define ecb_ldexpf(x,e) (float) ldexp ((double) (x), (e)) #define ecb_frexpf(x,e) (float) frexp ((double) (x), (e)) #endif /* converts an ieee half/binary16 to a float */ ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x) { int e = (x >> 10) & 0x1f; int m = x & 0x3ff; float r; if (!e ) r = ecb_ldexpf (m , -24); else if (e != 31) r = ecb_ldexpf (m + 0x400, e - 25); else if (m ) r = ECB_NAN; else r = ECB_INFINITY; return x & 0x8000 ? -r : r; } /* convert a float to ieee single/binary32 */ ecb_function_ ecb_const uint32_t ecb_float_to_binary32 (float x); ecb_function_ ecb_const uint32_t ecb_float_to_binary32 (float x) { uint32_t r; #if ECB_STDFP memcpy (&r, &x, 4); #else /* slow emulation, works for anything but -0 */ uint32_t m; int e; if (x == 0e0f ) return 0x00000000U; if (x > +3.40282346638528860e+38f) return 0x7f800000U; if (x < -3.40282346638528860e+38f) return 0xff800000U; if (x != x ) return 0x7fbfffffU; m = ecb_frexpf (x, &e) * 0x1000000U; r = m & 0x80000000U; if (r) m = -m; if (e <= -126) { m &= 0xffffffU; m >>= (-125 - e); e = -126; } r |= (e + 126) << 23; r |= m & 0x7fffffU; #endif return r; } /* converts an ieee single/binary32 to a float */ ecb_function_ ecb_const float ecb_binary32_to_float (uint32_t x); ecb_function_ ecb_const float ecb_binary32_to_float (uint32_t x) { float r; #if ECB_STDFP memcpy (&r, &x, 4); #else /* emulation, only works for normals and subnormals and +0 */ int neg = x >> 31; int e = (x >> 23) & 0xffU; x &= 0x7fffffU; if (e) x |= 0x800000U; else e = 1; /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ r = ecb_ldexpf (x * (0.5f / 0x800000U), e - 126); r = neg ? -r : r; #endif return r; } /* convert a double to ieee double/binary64 */ ecb_function_ ecb_const uint64_t ecb_double_to_binary64 (double x); ecb_function_ ecb_const uint64_t ecb_double_to_binary64 (double x) { uint64_t r; #if ECB_STDFP memcpy (&r, &x, 8); #else /* slow emulation, works for anything but -0 */ uint64_t m; int e; if (x == 0e0 ) return 0x0000000000000000U; if (x > +1.79769313486231470e+308) return 0x7ff0000000000000U; if (x < -1.79769313486231470e+308) return 0xfff0000000000000U; if (x != x ) return 0X7ff7ffffffffffffU; m = frexp (x, &e) * 0x20000000000000U; r = m & 0x8000000000000000;; if (r) m = -m; if (e <= -1022) { m &= 0x1fffffffffffffU; m >>= (-1021 - e); e = -1022; } r |= ((uint64_t)(e + 1022)) << 52; r |= m & 0xfffffffffffffU; #endif return r; } /* converts an ieee double/binary64 to a double */ ecb_function_ ecb_const double ecb_binary64_to_double (uint64_t x); ecb_function_ ecb_const double ecb_binary64_to_double (uint64_t x) { double r; #if ECB_STDFP memcpy (&r, &x, 8); #else /* emulation, only works for normals and subnormals and +0 */ int neg = x >> 63; int e = (x >> 52) & 0x7ffU; x &= 0xfffffffffffffU; if (e) x |= 0x10000000000000U; else e = 1; /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */ r = ldexp (x * (0.5 / 0x10000000000000U), e - 1022); r = neg ? -r : r; #endif return r; } #endif #endif /* ECB.H END */ #if ECB_MEMORY_FENCE_NEEDS_PTHREADS /* if your architecture doesn't need memory fences, e.g. because it is * single-cpu/core, or if you use libev in a project that doesn't use libev * from multiple threads, then you can define ECB_AVOID_PTHREADS when compiling * libev, in which cases the memory fences become nops. * alternatively, you can remove this #error and link against libpthread, * which will then provide the memory fences. */ # error "memory fences not defined for your architecture, please report" #endif #ifndef ECB_MEMORY_FENCE # define ECB_MEMORY_FENCE do { } while (0) # define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE # define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE #endif #define expect_false(cond) ecb_expect_false (cond) #define expect_true(cond) ecb_expect_true (cond) #define noinline ecb_noinline #define inline_size ecb_inline #if EV_FEATURE_CODE # define inline_speed ecb_inline #else # define inline_speed static noinline #endif #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) #if EV_MINPRI == EV_MAXPRI # define ABSPRI(w) (((W)w), 0) #else # define ABSPRI(w) (((W)w)->priority - EV_MINPRI) #endif #define EMPTY /* required for microsofts broken pseudo-c compiler */ #define EMPTY2(a,b) /* used to suppress some warnings */ typedef ev_watcher *W; typedef ev_watcher_list *WL; typedef ev_watcher_time *WT; #define ev_active(w) ((W)(w))->active #define ev_at(w) ((WT)(w))->at #if EV_USE_REALTIME /* sig_atomic_t is used to avoid per-thread variables or locking but still */ /* giving it a reasonably high chance of working on typical architectures */ static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */ #endif #if EV_USE_MONOTONIC static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ #endif #ifndef EV_FD_TO_WIN32_HANDLE # define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) #endif #ifndef EV_WIN32_HANDLE_TO_FD # define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (handle, 0) #endif #ifndef EV_WIN32_CLOSE_FD # define EV_WIN32_CLOSE_FD(fd) close (fd) #endif #ifdef _WIN32 # include "ev_win32.c" #endif /*****************************************************************************/ /* define a suitable floor function (only used by periodics atm) */ #if EV_USE_FLOOR # include # define ev_floor(v) floor (v) #else #include /* a floor() replacement function, should be independent of ev_tstamp type */ static ev_tstamp noinline ev_floor (ev_tstamp v) { /* the choice of shift factor is not terribly important */ #if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 10000000000000000000. : 1000000000.; #else const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 18446744073709551616. : 4294967296.; #endif /* argument too large for an unsigned long? */ if (expect_false (v >= shift)) { ev_tstamp f; if (v == v - 1.) return v; /* very large number */ f = shift * ev_floor (v * (1. / shift)); return f + ev_floor (v - f); } /* special treatment for negative args? */ if (expect_false (v < 0.)) { ev_tstamp f = -ev_floor (-v); return f - (f == v ? 0 : 1); } /* fits into an unsigned long */ return (unsigned long)v; } #endif /*****************************************************************************/ #ifdef __linux # include #endif static unsigned int noinline ecb_cold ev_linux_version (void) { #ifdef __linux unsigned int v = 0; struct utsname buf; int i; char *p = buf.release; if (uname (&buf)) return 0; for (i = 3+1; --i; ) { unsigned int c = 0; for (;;) { if (*p >= '0' && *p <= '9') c = c * 10 + *p++ - '0'; else { p += *p == '.'; break; } } v = (v << 8) | c; } return v; #else return 0; #endif } /*****************************************************************************/ #if EV_AVOID_STDIO static void noinline ecb_cold ev_printerr (const char *msg) { write (STDERR_FILENO, msg, strlen (msg)); } #endif static void (*syserr_cb)(const char *msg) EV_THROW; void ecb_cold ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW { syserr_cb = cb; } static void noinline ecb_cold ev_syserr (const char *msg) { if (!msg) msg = "(libev) system error"; if (syserr_cb) syserr_cb (msg); else { #if EV_AVOID_STDIO ev_printerr (msg); ev_printerr (": "); ev_printerr (strerror (errno)); ev_printerr ("\n"); #else perror (msg); #endif abort (); } } static void * ev_realloc_emul (void *ptr, long size) EV_THROW { /* some systems, notably openbsd and darwin, fail to properly * implement realloc (x, 0) (as required by both ansi c-89 and * the single unix specification, so work around them here. * recently, also (at least) fedora and debian started breaking it, * despite documenting it otherwise. */ if (size) return realloc (ptr, size); free (ptr); return 0; } static void *(*alloc)(void *ptr, long size) EV_THROW = ev_realloc_emul; void ecb_cold ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW { alloc = cb; } inline_speed void * ev_realloc (void *ptr, long size) { ptr = alloc (ptr, size); if (!ptr && size) { #if EV_AVOID_STDIO ev_printerr ("(libev) memory allocation failed, aborting.\n"); #else fprintf (stderr, "(libev) cannot allocate %ld bytes, aborting.", size); #endif abort (); } return ptr; } #define ev_malloc(size) ev_realloc (0, (size)) #define ev_free(ptr) ev_realloc ((ptr), 0) /*****************************************************************************/ /* set in reify when reification needed */ #define EV_ANFD_REIFY 1 /* file descriptor info structure */ typedef struct { WL head; unsigned char events; /* the events watched for */ unsigned char reify; /* flag set when this ANFD needs reification (EV_ANFD_REIFY, EV__IOFDSET) */ unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ unsigned char unused; #if EV_USE_EPOLL unsigned int egen; /* generation counter to counter epoll bugs */ #endif #if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP SOCKET handle; #endif #if EV_USE_IOCP OVERLAPPED or, ow; #endif } ANFD; /* stores the pending event set for a given watcher */ typedef struct { W w; int events; /* the pending event set for the given watcher */ } ANPENDING; #if EV_USE_INOTIFY /* hash table entry per inotify-id */ typedef struct { WL head; } ANFS; #endif /* Heap Entry */ #if EV_HEAP_CACHE_AT /* a heap element */ typedef struct { ev_tstamp at; WT w; } ANHE; #define ANHE_w(he) (he).w /* access watcher, read-write */ #define ANHE_at(he) (he).at /* access cached at, read-only */ #define ANHE_at_cache(he) (he).at = (he).w->at /* update at from watcher */ #else /* a heap element */ typedef WT ANHE; #define ANHE_w(he) (he) #define ANHE_at(he) (he)->at #define ANHE_at_cache(he) #endif #if EV_MULTIPLICITY struct ev_loop { ev_tstamp ev_rt_now; #define ev_rt_now ((loop)->ev_rt_now) #define VAR(name,decl) decl; #include "ev_vars.h" #undef VAR }; #include "ev_wrap.h" static struct ev_loop default_loop_struct; EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */ #else EV_API_DECL ev_tstamp ev_rt_now = 0; /* needs to be initialised to make it a definition despite extern */ #define VAR(name,decl) static decl; #include "ev_vars.h" #undef VAR static int ev_default_loop_ptr; #endif #if EV_FEATURE_API # define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A) # define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A) # define EV_INVOKE_PENDING invoke_cb (EV_A) #else # define EV_RELEASE_CB (void)0 # define EV_ACQUIRE_CB (void)0 # define EV_INVOKE_PENDING ev_invoke_pending (EV_A) #endif #define EVBREAK_RECURSE 0x80 /*****************************************************************************/ #ifndef EV_HAVE_EV_TIME ev_tstamp ev_time (void) EV_THROW { #if EV_USE_REALTIME if (expect_true (have_realtime)) { struct timespec ts; clock_gettime (CLOCK_REALTIME, &ts); return ts.tv_sec + ts.tv_nsec * 1e-9; } #endif struct timeval tv; gettimeofday (&tv, 0); return tv.tv_sec + tv.tv_usec * 1e-6; } #endif inline_size ev_tstamp get_clock (void) { #if EV_USE_MONOTONIC if (expect_true (have_monotonic)) { struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return ts.tv_sec + ts.tv_nsec * 1e-9; } #endif return ev_time (); } #if EV_MULTIPLICITY ev_tstamp ev_now (EV_P) EV_THROW { return ev_rt_now; } #endif void ev_sleep (ev_tstamp delay) EV_THROW { if (delay > 0.) { #if EV_USE_NANOSLEEP struct timespec ts; EV_TS_SET (ts, delay); nanosleep (&ts, 0); #elif defined _WIN32 Sleep ((unsigned long)(delay * 1e3)); #else struct timeval tv; /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ /* something not guaranteed by newer posix versions, but guaranteed */ /* by older ones */ EV_TV_SET (tv, delay); select (0, 0, 0, 0, &tv); #endif } } /*****************************************************************************/ #define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ /* find a suitable new size for the given array, */ /* hopefully by rounding to a nice-to-malloc size */ inline_size int array_nextsize (int elem, int cur, int cnt) { int ncur = cur + 1; do ncur <<= 1; while (cnt > ncur); /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) { ncur *= elem; ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); ncur = ncur - sizeof (void *) * 4; ncur /= elem; } return ncur; } static void * ecb_cold array_realloc (int elem, void *base, int *cur, int cnt) { *cur = array_nextsize (elem, *cur, cnt); return ev_realloc (base, elem * *cur); } #define array_init_zero(base,count) \ memset ((void *)(base), 0, sizeof (*(base)) * (count)) #define array_needsize(type,base,cur,cnt,init) \ if (expect_false ((cnt) > (cur))) \ { \ int ecb_unused ocur_ = (cur); \ (base) = (type *)array_realloc \ (sizeof (type), (base), &(cur), (cnt)); \ init ((base) + (ocur_), (cur) - ocur_); \ } #if 0 #define array_slim(type,stem) \ if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ { \ stem ## max = array_roundsize (stem ## cnt >> 1); \ base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ } #endif #define array_free(stem, idx) \ ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 /*****************************************************************************/ /* dummy callback for pending events */ static void noinline pendingcb (EV_P_ ev_prepare *w, int revents) { } void noinline ev_feed_event (EV_P_ void *w, int revents) EV_THROW { W w_ = (W)w; int pri = ABSPRI (w_); if (expect_false (w_->pending)) pendings [pri][w_->pending - 1].events |= revents; else { w_->pending = ++pendingcnt [pri]; array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); pendings [pri][w_->pending - 1].w = w_; pendings [pri][w_->pending - 1].events = revents; } pendingpri = NUMPRI - 1; } inline_speed void feed_reverse (EV_P_ W w) { array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, EMPTY2); rfeeds [rfeedcnt++] = w; } inline_size void feed_reverse_done (EV_P_ int revents) { do ev_feed_event (EV_A_ rfeeds [--rfeedcnt], revents); while (rfeedcnt); } inline_speed void queue_events (EV_P_ W *events, int eventcnt, int type) { int i; for (i = 0; i < eventcnt; ++i) ev_feed_event (EV_A_ events [i], type); } /*****************************************************************************/ inline_speed void fd_event_nocheck (EV_P_ int fd, int revents) { ANFD *anfd = anfds + fd; ev_io *w; for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) { int ev = w->events & revents; if (ev) ev_feed_event (EV_A_ (W)w, ev); } } /* do not submit kernel events for fds that have reify set */ /* because that means they changed while we were polling for new events */ inline_speed void fd_event (EV_P_ int fd, int revents) { ANFD *anfd = anfds + fd; if (expect_true (!anfd->reify)) fd_event_nocheck (EV_A_ fd, revents); } void ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW { if (fd >= 0 && fd < anfdmax) fd_event_nocheck (EV_A_ fd, revents); } /* make sure the external fd watch events are in-sync */ /* with the kernel/libev internal state */ inline_size void fd_reify (EV_P) { int i; #if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP for (i = 0; i < fdchangecnt; ++i) { int fd = fdchanges [i]; ANFD *anfd = anfds + fd; if (anfd->reify & EV__IOFDSET && anfd->head) { SOCKET handle = EV_FD_TO_WIN32_HANDLE (fd); if (handle != anfd->handle) { unsigned long arg; assert (("libev: only socket fds supported in this configuration", ioctlsocket (handle, FIONREAD, &arg) == 0)); /* handle changed, but fd didn't - we need to do it in two steps */ backend_modify (EV_A_ fd, anfd->events, 0); anfd->events = 0; anfd->handle = handle; } } } #endif for (i = 0; i < fdchangecnt; ++i) { int fd = fdchanges [i]; ANFD *anfd = anfds + fd; ev_io *w; unsigned char o_events = anfd->events; unsigned char o_reify = anfd->reify; anfd->reify = 0; /*if (expect_true (o_reify & EV_ANFD_REIFY)) probably a deoptimisation */ { anfd->events = 0; for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) anfd->events |= (unsigned char)w->events; if (o_events != anfd->events) o_reify = EV__IOFDSET; /* actually |= */ } if (o_reify & EV__IOFDSET) backend_modify (EV_A_ fd, o_events, anfd->events); } fdchangecnt = 0; } /* something about the given fd changed */ inline_size void fd_change (EV_P_ int fd, int flags) { unsigned char reify = anfds [fd].reify; anfds [fd].reify |= flags; if (expect_true (!reify)) { ++fdchangecnt; array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2); fdchanges [fdchangecnt - 1] = fd; } } /* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */ inline_speed void ecb_cold fd_kill (EV_P_ int fd) { ev_io *w; while ((w = (ev_io *)anfds [fd].head)) { ev_io_stop (EV_A_ w); ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); } } /* check whether the given fd is actually valid, for error recovery */ inline_size int ecb_cold fd_valid (int fd) { #ifdef _WIN32 return EV_FD_TO_WIN32_HANDLE (fd) != -1; #else return fcntl (fd, F_GETFD) != -1; #endif } /* called on EBADF to verify fds */ static void noinline ecb_cold fd_ebadf (EV_P) { int fd; for (fd = 0; fd < anfdmax; ++fd) if (anfds [fd].events) if (!fd_valid (fd) && errno == EBADF) fd_kill (EV_A_ fd); } /* called on ENOMEM in select/poll to kill some fds and retry */ static void noinline ecb_cold fd_enomem (EV_P) { int fd; for (fd = anfdmax; fd--; ) if (anfds [fd].events) { fd_kill (EV_A_ fd); break; } } /* usually called after fork if backend needs to re-arm all fds from scratch */ static void noinline fd_rearm_all (EV_P) { int fd; for (fd = 0; fd < anfdmax; ++fd) if (anfds [fd].events) { anfds [fd].events = 0; anfds [fd].emask = 0; fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); } } /* used to prepare libev internal fd's */ /* this is not fork-safe */ inline_speed void fd_intern (int fd) { #ifdef _WIN32 unsigned long arg = 1; ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg); #else fcntl (fd, F_SETFD, FD_CLOEXEC); fcntl (fd, F_SETFL, O_NONBLOCK); #endif } /*****************************************************************************/ /* * the heap functions want a real array index. array index 0 is guaranteed to not * be in-use at any time. the first heap entry is at array [HEAP0]. DHEAP gives * the branching factor of the d-tree. */ /* * at the moment we allow libev the luxury of two heaps, * a small-code-size 2-heap one and a ~1.5kb larger 4-heap * which is more cache-efficient. * the difference is about 5% with 50000+ watchers. */ #if EV_USE_4HEAP #define DHEAP 4 #define HEAP0 (DHEAP - 1) /* index of first element in heap */ #define HPARENT(k) ((((k) - HEAP0 - 1) / DHEAP) + HEAP0) #define UPHEAP_DONE(p,k) ((p) == (k)) /* away from the root */ inline_speed void downheap (ANHE *heap, int N, int k) { ANHE he = heap [k]; ANHE *E = heap + N + HEAP0; for (;;) { ev_tstamp minat; ANHE *minpos; ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0 + 1; /* find minimum child */ if (expect_true (pos + DHEAP - 1 < E)) { /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); if ( ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); if ( ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); if ( ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); } else if (pos < E) { /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); if (pos + 1 < E && ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); if (pos + 2 < E && ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); if (pos + 3 < E && ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); } else break; if (ANHE_at (he) <= minat) break; heap [k] = *minpos; ev_active (ANHE_w (*minpos)) = k; k = minpos - heap; } heap [k] = he; ev_active (ANHE_w (he)) = k; } #else /* 4HEAP */ #define HEAP0 1 #define HPARENT(k) ((k) >> 1) #define UPHEAP_DONE(p,k) (!(p)) /* away from the root */ inline_speed void downheap (ANHE *heap, int N, int k) { ANHE he = heap [k]; for (;;) { int c = k << 1; if (c >= N + HEAP0) break; c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1]) ? 1 : 0; if (ANHE_at (he) <= ANHE_at (heap [c])) break; heap [k] = heap [c]; ev_active (ANHE_w (heap [k])) = k; k = c; } heap [k] = he; ev_active (ANHE_w (he)) = k; } #endif /* towards the root */ inline_speed void upheap (ANHE *heap, int k) { ANHE he = heap [k]; for (;;) { int p = HPARENT (k); if (UPHEAP_DONE (p, k) || ANHE_at (heap [p]) <= ANHE_at (he)) break; heap [k] = heap [p]; ev_active (ANHE_w (heap [k])) = k; k = p; } heap [k] = he; ev_active (ANHE_w (he)) = k; } /* move an element suitably so it is in a correct place */ inline_size void adjustheap (ANHE *heap, int N, int k) { if (k > HEAP0 && ANHE_at (heap [k]) <= ANHE_at (heap [HPARENT (k)])) upheap (heap, k); else downheap (heap, N, k); } /* rebuild the heap: this function is used only once and executed rarely */ inline_size void reheap (ANHE *heap, int N) { int i; /* we don't use floyds algorithm, upheap is simpler and is more cache-efficient */ /* also, this is easy to implement and correct for both 2-heaps and 4-heaps */ for (i = 0; i < N; ++i) upheap (heap, i + HEAP0); } /*****************************************************************************/ /* associate signal watchers to a signal signal */ typedef struct { EV_ATOMIC_T pending; #if EV_MULTIPLICITY EV_P; #endif WL head; } ANSIG; static ANSIG signals [EV_NSIG - 1]; /*****************************************************************************/ #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE static void noinline ecb_cold evpipe_init (EV_P) { if (!ev_is_active (&pipe_w)) { int fds [2]; # if EV_USE_EVENTFD fds [0] = -1; fds [1] = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); if (fds [1] < 0 && errno == EINVAL) fds [1] = eventfd (0, 0); if (fds [1] < 0) # endif { while (pipe (fds)) ev_syserr ("(libev) error creating signal/async pipe"); fd_intern (fds [0]); } evpipe [0] = fds [0]; if (evpipe [1] < 0) evpipe [1] = fds [1]; /* first call, set write fd */ else { /* on subsequent calls, do not change evpipe [1] */ /* so that evpipe_write can always rely on its value. */ /* this branch does not do anything sensible on windows, */ /* so must not be executed on windows */ dup2 (fds [1], evpipe [1]); close (fds [1]); } fd_intern (evpipe [1]); ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ); ev_io_start (EV_A_ &pipe_w); ev_unref (EV_A); /* watcher should not keep loop alive */ } } inline_speed void evpipe_write (EV_P_ EV_ATOMIC_T *flag) { ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */ if (expect_true (*flag)) return; *flag = 1; ECB_MEMORY_FENCE_RELEASE; /* make sure flag is visible before the wakeup */ pipe_write_skipped = 1; ECB_MEMORY_FENCE; /* make sure pipe_write_skipped is visible before we check pipe_write_wanted */ if (pipe_write_wanted) { int old_errno; pipe_write_skipped = 0; ECB_MEMORY_FENCE_RELEASE; old_errno = errno; /* save errno because write will clobber it */ #if EV_USE_EVENTFD if (evpipe [0] < 0) { uint64_t counter = 1; write (evpipe [1], &counter, sizeof (uint64_t)); } else #endif { #ifdef _WIN32 WSABUF buf; DWORD sent; buf.buf = &buf; buf.len = 1; WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0); #else write (evpipe [1], &(evpipe [1]), 1); #endif } errno = old_errno; } } /* called whenever the libev signal pipe */ /* got some events (signal, async) */ static void pipecb (EV_P_ ev_io *iow, int revents) { int i; if (revents & EV_READ) { #if EV_USE_EVENTFD if (evpipe [0] < 0) { uint64_t counter; read (evpipe [1], &counter, sizeof (uint64_t)); } else #endif { char dummy[4]; #ifdef _WIN32 WSABUF buf; DWORD recvd; DWORD flags = 0; buf.buf = dummy; buf.len = sizeof (dummy); WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, &flags, 0, 0); #else read (evpipe [0], &dummy, sizeof (dummy)); #endif } } pipe_write_skipped = 0; ECB_MEMORY_FENCE; /* push out skipped, acquire flags */ #if EV_SIGNAL_ENABLE if (sig_pending) { sig_pending = 0; ECB_MEMORY_FENCE; for (i = EV_NSIG - 1; i--; ) if (expect_false (signals [i].pending)) ev_feed_signal_event (EV_A_ i + 1); } #endif #if EV_ASYNC_ENABLE if (async_pending) { async_pending = 0; ECB_MEMORY_FENCE; for (i = asynccnt; i--; ) if (asyncs [i]->sent) { asyncs [i]->sent = 0; ECB_MEMORY_FENCE_RELEASE; ev_feed_event (EV_A_ asyncs [i], EV_ASYNC); } } #endif } /*****************************************************************************/ void ev_feed_signal (int signum) EV_THROW { #if EV_MULTIPLICITY EV_P; ECB_MEMORY_FENCE_ACQUIRE; EV_A = signals [signum - 1].loop; if (!EV_A) return; #endif signals [signum - 1].pending = 1; evpipe_write (EV_A_ &sig_pending); } static void ev_sighandler (int signum) { #ifdef _WIN32 signal (signum, ev_sighandler); #endif ev_feed_signal (signum); } void noinline ev_feed_signal_event (EV_P_ int signum) EV_THROW { WL w; if (expect_false (signum <= 0 || signum >= EV_NSIG)) return; --signum; #if EV_MULTIPLICITY /* it is permissible to try to feed a signal to the wrong loop */ /* or, likely more useful, feeding a signal nobody is waiting for */ if (expect_false (signals [signum].loop != EV_A)) return; #endif signals [signum].pending = 0; ECB_MEMORY_FENCE_RELEASE; for (w = signals [signum].head; w; w = w->next) ev_feed_event (EV_A_ (W)w, EV_SIGNAL); } #if EV_USE_SIGNALFD static void sigfdcb (EV_P_ ev_io *iow, int revents) { struct signalfd_siginfo si[2], *sip; /* these structs are big */ for (;;) { ssize_t res = read (sigfd, si, sizeof (si)); /* not ISO-C, as res might be -1, but works with SuS */ for (sip = si; (char *)sip < (char *)si + res; ++sip) ev_feed_signal_event (EV_A_ sip->ssi_signo); if (res < (ssize_t)sizeof (si)) break; } } #endif #endif /*****************************************************************************/ #if EV_CHILD_ENABLE static WL childs [EV_PID_HASHSIZE]; static ev_signal childev; #ifndef WIFCONTINUED # define WIFCONTINUED(status) 0 #endif /* handle a single child status event */ inline_speed void child_reap (EV_P_ int chain, int pid, int status) { ev_child *w; int traced = WIFSTOPPED (status) || WIFCONTINUED (status); for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) { if ((w->pid == pid || !w->pid) && (!traced || (w->flags & 1))) { ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ w->rpid = pid; w->rstatus = status; ev_feed_event (EV_A_ (W)w, EV_CHILD); } } } #ifndef WCONTINUED # define WCONTINUED 0 #endif /* called on sigchld etc., calls waitpid */ static void childcb (EV_P_ ev_signal *sw, int revents) { int pid, status; /* some systems define WCONTINUED but then fail to support it (linux 2.4) */ if (0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) if (!WCONTINUED || errno != EINVAL || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) return; /* make sure we are called again until all children have been reaped */ /* we need to do it this way so that the callback gets called before we continue */ ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); child_reap (EV_A_ pid, pid, status); if ((EV_PID_HASHSIZE) > 1) child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ } #endif /*****************************************************************************/ #if EV_USE_IOCP # include "ev_iocp.c" #endif #if EV_USE_PORT # include "ev_port.c" #endif #if EV_USE_KQUEUE # include "ev_kqueue.c" #endif #if EV_USE_EPOLL # include "ev_epoll.c" #endif #if EV_USE_POLL # include "ev_poll.c" #endif #if EV_USE_SELECT # include "ev_select.c" #endif int ecb_cold ev_version_major (void) EV_THROW { return EV_VERSION_MAJOR; } int ecb_cold ev_version_minor (void) EV_THROW { return EV_VERSION_MINOR; } /* return true if we are running with elevated privileges and should ignore env variables */ int inline_size ecb_cold enable_secure (void) { #ifdef _WIN32 return 0; #else return getuid () != geteuid () || getgid () != getegid (); #endif } unsigned int ecb_cold ev_supported_backends (void) EV_THROW { unsigned int flags = 0; if (EV_USE_PORT ) flags |= EVBACKEND_PORT; if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE; if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; if (EV_USE_POLL ) flags |= EVBACKEND_POLL; if (EV_USE_SELECT) flags |= EVBACKEND_SELECT; return flags; } unsigned int ecb_cold ev_recommended_backends (void) EV_THROW { unsigned int flags = ev_supported_backends (); #ifndef __NetBSD__ /* kqueue is borked on everything but netbsd apparently */ /* it usually doesn't work correctly on anything but sockets and pipes */ flags &= ~EVBACKEND_KQUEUE; #endif #ifdef __APPLE__ /* only select works correctly on that "unix-certified" platform */ flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ #endif #ifdef __FreeBSD__ flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ #endif return flags; } unsigned int ecb_cold ev_embeddable_backends (void) EV_THROW { int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ flags &= ~EVBACKEND_EPOLL; return flags; } unsigned int ev_backend (EV_P) EV_THROW { return backend; } #if EV_FEATURE_API unsigned int ev_iteration (EV_P) EV_THROW { return loop_count; } unsigned int ev_depth (EV_P) EV_THROW { return loop_depth; } void ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW { io_blocktime = interval; } void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW { timeout_blocktime = interval; } void ev_set_userdata (EV_P_ void *data) EV_THROW { userdata = data; } void * ev_userdata (EV_P) EV_THROW { return userdata; } void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW { invoke_cb = invoke_pending_cb; } void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW { release_cb = release; acquire_cb = acquire; } #endif /* initialise a loop structure, must be zero-initialised */ static void noinline ecb_cold loop_init (EV_P_ unsigned int flags) EV_THROW { if (!backend) { origflags = flags; #if EV_USE_REALTIME if (!have_realtime) { struct timespec ts; if (!clock_gettime (CLOCK_REALTIME, &ts)) have_realtime = 1; } #endif #if EV_USE_MONOTONIC if (!have_monotonic) { struct timespec ts; if (!clock_gettime (CLOCK_MONOTONIC, &ts)) have_monotonic = 1; } #endif /* pid check not overridable via env */ #ifndef _WIN32 if (flags & EVFLAG_FORKCHECK) curpid = getpid (); #endif if (!(flags & EVFLAG_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS")) flags = atoi (getenv ("LIBEV_FLAGS")); ev_rt_now = ev_time (); mn_now = get_clock (); now_floor = mn_now; rtmn_diff = ev_rt_now - mn_now; #if EV_FEATURE_API invoke_cb = ev_invoke_pending; #endif io_blocktime = 0.; timeout_blocktime = 0.; backend = 0; backend_fd = -1; sig_pending = 0; #if EV_ASYNC_ENABLE async_pending = 0; #endif pipe_write_skipped = 0; pipe_write_wanted = 0; evpipe [0] = -1; evpipe [1] = -1; #if EV_USE_INOTIFY fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; #endif #if EV_USE_SIGNALFD sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1; #endif if (!(flags & EVBACKEND_MASK)) flags |= ev_recommended_backends (); #if EV_USE_IOCP if (!backend && (flags & EVBACKEND_IOCP )) backend = iocp_init (EV_A_ flags); #endif #if EV_USE_PORT if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); #endif #if EV_USE_KQUEUE if (!backend && (flags & EVBACKEND_KQUEUE)) backend = kqueue_init (EV_A_ flags); #endif #if EV_USE_EPOLL if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags); #endif #if EV_USE_POLL if (!backend && (flags & EVBACKEND_POLL )) backend = poll_init (EV_A_ flags); #endif #if EV_USE_SELECT if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); #endif ev_prepare_init (&pending_w, pendingcb); #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE ev_init (&pipe_w, pipecb); ev_set_priority (&pipe_w, EV_MAXPRI); #endif } } /* free up a loop structure */ void ecb_cold ev_loop_destroy (EV_P) { int i; #if EV_MULTIPLICITY /* mimic free (0) */ if (!EV_A) return; #endif #if EV_CLEANUP_ENABLE /* queue cleanup watchers (and execute them) */ if (expect_false (cleanupcnt)) { queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); EV_INVOKE_PENDING; } #endif #if EV_CHILD_ENABLE if (ev_is_default_loop (EV_A) && ev_is_active (&childev)) { ev_ref (EV_A); /* child watcher */ ev_signal_stop (EV_A_ &childev); } #endif if (ev_is_active (&pipe_w)) { /*ev_ref (EV_A);*/ /*ev_io_stop (EV_A_ &pipe_w);*/ if (evpipe [0] >= 0) EV_WIN32_CLOSE_FD (evpipe [0]); if (evpipe [1] >= 0) EV_WIN32_CLOSE_FD (evpipe [1]); } #if EV_USE_SIGNALFD if (ev_is_active (&sigfd_w)) close (sigfd); #endif #if EV_USE_INOTIFY if (fs_fd >= 0) close (fs_fd); #endif if (backend_fd >= 0) close (backend_fd); #if EV_USE_IOCP if (backend == EVBACKEND_IOCP ) iocp_destroy (EV_A); #endif #if EV_USE_PORT if (backend == EVBACKEND_PORT ) port_destroy (EV_A); #endif #if EV_USE_KQUEUE if (backend == EVBACKEND_KQUEUE) kqueue_destroy (EV_A); #endif #if EV_USE_EPOLL if (backend == EVBACKEND_EPOLL ) epoll_destroy (EV_A); #endif #if EV_USE_POLL if (backend == EVBACKEND_POLL ) poll_destroy (EV_A); #endif #if EV_USE_SELECT if (backend == EVBACKEND_SELECT) select_destroy (EV_A); #endif for (i = NUMPRI; i--; ) { array_free (pending, [i]); #if EV_IDLE_ENABLE array_free (idle, [i]); #endif } ev_free (anfds); anfds = 0; anfdmax = 0; /* have to use the microsoft-never-gets-it-right macro */ array_free (rfeed, EMPTY); array_free (fdchange, EMPTY); array_free (timer, EMPTY); #if EV_PERIODIC_ENABLE array_free (periodic, EMPTY); #endif #if EV_FORK_ENABLE array_free (fork, EMPTY); #endif #if EV_CLEANUP_ENABLE array_free (cleanup, EMPTY); #endif array_free (prepare, EMPTY); array_free (check, EMPTY); #if EV_ASYNC_ENABLE array_free (async, EMPTY); #endif backend = 0; #if EV_MULTIPLICITY if (ev_is_default_loop (EV_A)) #endif ev_default_loop_ptr = 0; #if EV_MULTIPLICITY else ev_free (EV_A); #endif } #if EV_USE_INOTIFY inline_size void infy_fork (EV_P); #endif inline_size void loop_fork (EV_P) { #if EV_USE_PORT if (backend == EVBACKEND_PORT ) port_fork (EV_A); #endif #if EV_USE_KQUEUE if (backend == EVBACKEND_KQUEUE) kqueue_fork (EV_A); #endif #if EV_USE_EPOLL if (backend == EVBACKEND_EPOLL ) epoll_fork (EV_A); #endif #if EV_USE_INOTIFY infy_fork (EV_A); #endif #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE if (ev_is_active (&pipe_w)) { /* pipe_write_wanted must be false now, so modifying fd vars should be safe */ ev_ref (EV_A); ev_io_stop (EV_A_ &pipe_w); if (evpipe [0] >= 0) EV_WIN32_CLOSE_FD (evpipe [0]); evpipe_init (EV_A); /* iterate over everything, in case we missed something before */ ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); } #endif postfork = 0; } #if EV_MULTIPLICITY struct ev_loop * ecb_cold ev_loop_new (unsigned int flags) EV_THROW { EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); memset (EV_A, 0, sizeof (struct ev_loop)); loop_init (EV_A_ flags); if (ev_backend (EV_A)) return EV_A; ev_free (EV_A); return 0; } #endif /* multiplicity */ #if EV_VERIFY static void noinline ecb_cold verify_watcher (EV_P_ W w) { assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); if (w->pending) assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); } static void noinline ecb_cold verify_heap (EV_P_ ANHE *heap, int N) { int i; for (i = HEAP0; i < N + HEAP0; ++i) { assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i)); assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i]))); assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i])))); verify_watcher (EV_A_ (W)ANHE_w (heap [i])); } } static void noinline ecb_cold array_verify (EV_P_ W *ws, int cnt) { while (cnt--) { assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1)); verify_watcher (EV_A_ ws [cnt]); } } #endif #if EV_FEATURE_API void ecb_cold ev_verify (EV_P) EV_THROW { #if EV_VERIFY int i; WL w, w2; assert (activecnt >= -1); assert (fdchangemax >= fdchangecnt); for (i = 0; i < fdchangecnt; ++i) assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); assert (anfdmax >= 0); for (i = 0; i < anfdmax; ++i) { int j = 0; for (w = w2 = anfds [i].head; w; w = w->next) { verify_watcher (EV_A_ (W)w); if (j++ & 1) { assert (("libev: io watcher list contains a loop", w != w2)); w2 = w2->next; } assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); } } assert (timermax >= timercnt); verify_heap (EV_A_ timers, timercnt); #if EV_PERIODIC_ENABLE assert (periodicmax >= periodiccnt); verify_heap (EV_A_ periodics, periodiccnt); #endif for (i = NUMPRI; i--; ) { assert (pendingmax [i] >= pendingcnt [i]); #if EV_IDLE_ENABLE assert (idleall >= 0); assert (idlemax [i] >= idlecnt [i]); array_verify (EV_A_ (W *)idles [i], idlecnt [i]); #endif } #if EV_FORK_ENABLE assert (forkmax >= forkcnt); array_verify (EV_A_ (W *)forks, forkcnt); #endif #if EV_CLEANUP_ENABLE assert (cleanupmax >= cleanupcnt); array_verify (EV_A_ (W *)cleanups, cleanupcnt); #endif #if EV_ASYNC_ENABLE assert (asyncmax >= asynccnt); array_verify (EV_A_ (W *)asyncs, asynccnt); #endif #if EV_PREPARE_ENABLE assert (preparemax >= preparecnt); array_verify (EV_A_ (W *)prepares, preparecnt); #endif #if EV_CHECK_ENABLE assert (checkmax >= checkcnt); array_verify (EV_A_ (W *)checks, checkcnt); #endif # if 0 #if EV_CHILD_ENABLE for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) #endif # endif #endif } #endif #if EV_MULTIPLICITY struct ev_loop * ecb_cold #else int #endif ev_default_loop (unsigned int flags) EV_THROW { if (!ev_default_loop_ptr) { #if EV_MULTIPLICITY EV_P = ev_default_loop_ptr = &default_loop_struct; #else ev_default_loop_ptr = 1; #endif loop_init (EV_A_ flags); if (ev_backend (EV_A)) { #if EV_CHILD_ENABLE ev_signal_init (&childev, childcb, SIGCHLD); ev_set_priority (&childev, EV_MAXPRI); ev_signal_start (EV_A_ &childev); ev_unref (EV_A); /* child watcher should not keep loop alive */ #endif } else ev_default_loop_ptr = 0; } return ev_default_loop_ptr; } void ev_loop_fork (EV_P) EV_THROW { postfork = 1; } /*****************************************************************************/ void ev_invoke (EV_P_ void *w, int revents) { EV_CB_INVOKE ((W)w, revents); } unsigned int ev_pending_count (EV_P) EV_THROW { int pri; unsigned int count = 0; for (pri = NUMPRI; pri--; ) count += pendingcnt [pri]; return count; } void noinline ev_invoke_pending (EV_P) { pendingpri = NUMPRI; while (pendingpri) /* pendingpri possibly gets modified in the inner loop */ { --pendingpri; while (pendingcnt [pendingpri]) { ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; p->w->pending = 0; EV_CB_INVOKE (p->w, p->events); EV_FREQUENT_CHECK; } } } #if EV_IDLE_ENABLE /* make idle watchers pending. this handles the "call-idle */ /* only when higher priorities are idle" logic */ inline_size void idle_reify (EV_P) { if (expect_false (idleall)) { int pri; for (pri = NUMPRI; pri--; ) { if (pendingcnt [pri]) break; if (idlecnt [pri]) { queue_events (EV_A_ (W *)idles [pri], idlecnt [pri], EV_IDLE); break; } } } } #endif /* make timers pending */ inline_size void timers_reify (EV_P) { EV_FREQUENT_CHECK; if (timercnt && ANHE_at (timers [HEAP0]) < mn_now) { do { ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]); /*assert (("libev: inactive timer on timer heap detected", ev_is_active (w)));*/ /* first reschedule or stop timer */ if (w->repeat) { ev_at (w) += w->repeat; if (ev_at (w) < mn_now) ev_at (w) = mn_now; assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.)); ANHE_at_cache (timers [HEAP0]); downheap (timers, timercnt, HEAP0); } else ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ EV_FREQUENT_CHECK; feed_reverse (EV_A_ (W)w); } while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); feed_reverse_done (EV_A_ EV_TIMER); } } #if EV_PERIODIC_ENABLE static void noinline periodic_recalc (EV_P_ ev_periodic *w) { ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); /* the above almost always errs on the low side */ while (at <= ev_rt_now) { ev_tstamp nat = at + w->interval; /* when resolution fails us, we use ev_rt_now */ if (expect_false (nat == at)) { at = ev_rt_now; break; } at = nat; } ev_at (w) = at; } /* make periodics pending */ inline_size void periodics_reify (EV_P) { EV_FREQUENT_CHECK; while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now) { do { ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]); /*assert (("libev: inactive timer on periodic heap detected", ev_is_active (w)));*/ /* first reschedule or stop timer */ if (w->reschedule_cb) { ev_at (w) = w->reschedule_cb (w, ev_rt_now); assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now)); ANHE_at_cache (periodics [HEAP0]); downheap (periodics, periodiccnt, HEAP0); } else if (w->interval) { periodic_recalc (EV_A_ w); ANHE_at_cache (periodics [HEAP0]); downheap (periodics, periodiccnt, HEAP0); } else ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ EV_FREQUENT_CHECK; feed_reverse (EV_A_ (W)w); } while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now); feed_reverse_done (EV_A_ EV_PERIODIC); } } /* simply recalculate all periodics */ /* TODO: maybe ensure that at least one event happens when jumping forward? */ static void noinline ecb_cold periodics_reschedule (EV_P) { int i; /* adjust periodics after time jump */ for (i = HEAP0; i < periodiccnt + HEAP0; ++i) { ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]); if (w->reschedule_cb) ev_at (w) = w->reschedule_cb (w, ev_rt_now); else if (w->interval) periodic_recalc (EV_A_ w); ANHE_at_cache (periodics [i]); } reheap (periodics, periodiccnt); } #endif /* adjust all timers by a given offset */ static void noinline ecb_cold timers_reschedule (EV_P_ ev_tstamp adjust) { int i; for (i = 0; i < timercnt; ++i) { ANHE *he = timers + i + HEAP0; ANHE_w (*he)->at += adjust; ANHE_at_cache (*he); } } /* fetch new monotonic and realtime times from the kernel */ /* also detect if there was a timejump, and act accordingly */ inline_speed void time_update (EV_P_ ev_tstamp max_block) { #if EV_USE_MONOTONIC if (expect_true (have_monotonic)) { int i; ev_tstamp odiff = rtmn_diff; mn_now = get_clock (); /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */ /* interpolate in the meantime */ if (expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5)) { ev_rt_now = rtmn_diff + mn_now; return; } now_floor = mn_now; ev_rt_now = ev_time (); /* loop a few times, before making important decisions. * on the choice of "4": one iteration isn't enough, * in case we get preempted during the calls to * ev_time and get_clock. a second call is almost guaranteed * to succeed in that case, though. and looping a few more times * doesn't hurt either as we only do this on time-jumps or * in the unlikely event of having been preempted here. */ for (i = 4; --i; ) { ev_tstamp diff; rtmn_diff = ev_rt_now - mn_now; diff = odiff - rtmn_diff; if (expect_true ((diff < 0. ? -diff : diff) < MIN_TIMEJUMP)) return; /* all is well */ ev_rt_now = ev_time (); mn_now = get_clock (); now_floor = mn_now; } /* no timer adjustment, as the monotonic clock doesn't jump */ /* timers_reschedule (EV_A_ rtmn_diff - odiff) */ # if EV_PERIODIC_ENABLE periodics_reschedule (EV_A); # endif } else #endif { ev_rt_now = ev_time (); if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP)) { /* adjust timers. this is easy, as the offset is the same for all of them */ timers_reschedule (EV_A_ ev_rt_now - mn_now); #if EV_PERIODIC_ENABLE periodics_reschedule (EV_A); #endif } mn_now = ev_rt_now; } } int ev_run (EV_P_ int flags) { #if EV_FEATURE_API ++loop_depth; #endif assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE)); loop_done = EVBREAK_CANCEL; EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ do { #if EV_VERIFY >= 2 ev_verify (EV_A); #endif #ifndef _WIN32 if (expect_false (curpid)) /* penalise the forking check even more */ if (expect_false (getpid () != curpid)) { curpid = getpid (); postfork = 1; } #endif #if EV_FORK_ENABLE /* we might have forked, so queue fork handlers */ if (expect_false (postfork)) if (forkcnt) { queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); EV_INVOKE_PENDING; } #endif #if EV_PREPARE_ENABLE /* queue prepare watchers (and execute them) */ if (expect_false (preparecnt)) { queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); EV_INVOKE_PENDING; } #endif if (expect_false (loop_done)) break; /* we might have forked, so reify kernel state if necessary */ if (expect_false (postfork)) loop_fork (EV_A); /* update fd-related kernel structures */ fd_reify (EV_A); /* calculate blocking time */ { ev_tstamp waittime = 0.; ev_tstamp sleeptime = 0.; /* remember old timestamp for io_blocktime calculation */ ev_tstamp prev_mn_now = mn_now; /* update time to cancel out callback processing overhead */ time_update (EV_A_ 1e100); /* from now on, we want a pipe-wake-up */ pipe_write_wanted = 1; ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible before we check for potential skips */ if (expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped))) { waittime = MAX_BLOCKTIME; if (timercnt) { ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; if (waittime > to) waittime = to; } #if EV_PERIODIC_ENABLE if (periodiccnt) { ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now; if (waittime > to) waittime = to; } #endif /* don't let timeouts decrease the waittime below timeout_blocktime */ if (expect_false (waittime < timeout_blocktime)) waittime = timeout_blocktime; /* at this point, we NEED to wait, so we have to ensure */ /* to pass a minimum nonzero value to the backend */ if (expect_false (waittime < backend_mintime)) waittime = backend_mintime; /* extra check because io_blocktime is commonly 0 */ if (expect_false (io_blocktime)) { sleeptime = io_blocktime - (mn_now - prev_mn_now); if (sleeptime > waittime - backend_mintime) sleeptime = waittime - backend_mintime; if (expect_true (sleeptime > 0.)) { ev_sleep (sleeptime); waittime -= sleeptime; } } } #if EV_FEATURE_API ++loop_count; #endif assert ((loop_done = EVBREAK_RECURSE, 1)); /* assert for side effect */ backend_poll (EV_A_ waittime); assert ((loop_done = EVBREAK_CANCEL, 1)); /* assert for side effect */ pipe_write_wanted = 0; /* just an optimisation, no fence needed */ ECB_MEMORY_FENCE_ACQUIRE; if (pipe_write_skipped) { assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w))); ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); } /* update ev_rt_now, do magic */ time_update (EV_A_ waittime + sleeptime); } /* queue pending timers and reschedule them */ timers_reify (EV_A); /* relative timers called last */ #if EV_PERIODIC_ENABLE periodics_reify (EV_A); /* absolute timers called first */ #endif #if EV_IDLE_ENABLE /* queue idle watchers unless other events are pending */ idle_reify (EV_A); #endif #if EV_CHECK_ENABLE /* queue check watchers, to be executed first */ if (expect_false (checkcnt)) queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); #endif EV_INVOKE_PENDING; } while (expect_true ( activecnt && !loop_done && !(flags & (EVRUN_ONCE | EVRUN_NOWAIT)) )); if (loop_done == EVBREAK_ONE) loop_done = EVBREAK_CANCEL; #if EV_FEATURE_API --loop_depth; #endif return activecnt; } void ev_break (EV_P_ int how) EV_THROW { loop_done = how; } void ev_ref (EV_P) EV_THROW { ++activecnt; } void ev_unref (EV_P) EV_THROW { --activecnt; } void ev_now_update (EV_P) EV_THROW { time_update (EV_A_ 1e100); } void ev_suspend (EV_P) EV_THROW { ev_now_update (EV_A); } void ev_resume (EV_P) EV_THROW { ev_tstamp mn_prev = mn_now; ev_now_update (EV_A); timers_reschedule (EV_A_ mn_now - mn_prev); #if EV_PERIODIC_ENABLE /* TODO: really do this? */ periodics_reschedule (EV_A); #endif } /*****************************************************************************/ /* singly-linked list management, used when the expected list length is short */ inline_size void wlist_add (WL *head, WL elem) { elem->next = *head; *head = elem; } inline_size void wlist_del (WL *head, WL elem) { while (*head) { if (expect_true (*head == elem)) { *head = elem->next; break; } head = &(*head)->next; } } /* internal, faster, version of ev_clear_pending */ inline_speed void clear_pending (EV_P_ W w) { if (w->pending) { pendings [ABSPRI (w)][w->pending - 1].w = (W)&pending_w; w->pending = 0; } } int ev_clear_pending (EV_P_ void *w) EV_THROW { W w_ = (W)w; int pending = w_->pending; if (expect_true (pending)) { ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; p->w = (W)&pending_w; w_->pending = 0; return p->events; } else return 0; } inline_size void pri_adjust (EV_P_ W w) { int pri = ev_priority (w); pri = pri < EV_MINPRI ? EV_MINPRI : pri; pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; ev_set_priority (w, pri); } inline_speed void ev_start (EV_P_ W w, int active) { pri_adjust (EV_A_ w); w->active = active; ev_ref (EV_A); } inline_size void ev_stop (EV_P_ W w) { ev_unref (EV_A); w->active = 0; } /*****************************************************************************/ void noinline ev_io_start (EV_P_ ev_io *w) EV_THROW { int fd = w->fd; if (expect_false (ev_is_active (w))) return; assert (("libev: ev_io_start called with negative fd", fd >= 0)); assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE)))); EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, 1); array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); wlist_add (&anfds[fd].head, (WL)w); /* common bug, apparently */ assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w)); fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); w->events &= ~EV__IOFDSET; EV_FREQUENT_CHECK; } void noinline ev_io_stop (EV_P_ ev_io *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); EV_FREQUENT_CHECK; wlist_del (&anfds[w->fd].head, (WL)w); ev_stop (EV_A_ (W)w); fd_change (EV_A_ w->fd, EV_ANFD_REIFY); EV_FREQUENT_CHECK; } void noinline ev_timer_start (EV_P_ ev_timer *w) EV_THROW { if (expect_false (ev_is_active (w))) return; ev_at (w) += mn_now; assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); EV_FREQUENT_CHECK; ++timercnt; ev_start (EV_A_ (W)w, timercnt + HEAP0 - 1); array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2); ANHE_w (timers [ev_active (w)]) = (WT)w; ANHE_at_cache (timers [ev_active (w)]); upheap (timers, ev_active (w)); EV_FREQUENT_CHECK; /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ } void noinline ev_timer_stop (EV_P_ ev_timer *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w)); --timercnt; if (expect_true (active < timercnt + HEAP0)) { timers [active] = timers [timercnt + HEAP0]; adjustheap (timers, timercnt, active); } } ev_at (w) -= mn_now; ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } void noinline ev_timer_again (EV_P_ ev_timer *w) EV_THROW { EV_FREQUENT_CHECK; clear_pending (EV_A_ (W)w); if (ev_is_active (w)) { if (w->repeat) { ev_at (w) = mn_now + w->repeat; ANHE_at_cache (timers [ev_active (w)]); adjustheap (timers, timercnt, ev_active (w)); } else ev_timer_stop (EV_A_ w); } else if (w->repeat) { ev_at (w) = w->repeat; ev_timer_start (EV_A_ w); } EV_FREQUENT_CHECK; } ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW { return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); } #if EV_PERIODIC_ENABLE void noinline ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW { if (expect_false (ev_is_active (w))) return; if (w->reschedule_cb) ev_at (w) = w->reschedule_cb (w, ev_rt_now); else if (w->interval) { assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.)); periodic_recalc (EV_A_ w); } else ev_at (w) = w->offset; EV_FREQUENT_CHECK; ++periodiccnt; ev_start (EV_A_ (W)w, periodiccnt + HEAP0 - 1); array_needsize (ANHE, periodics, periodicmax, ev_active (w) + 1, EMPTY2); ANHE_w (periodics [ev_active (w)]) = (WT)w; ANHE_at_cache (periodics [ev_active (w)]); upheap (periodics, ev_active (w)); EV_FREQUENT_CHECK; /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ } void noinline ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w)); --periodiccnt; if (expect_true (active < periodiccnt + HEAP0)) { periodics [active] = periodics [periodiccnt + HEAP0]; adjustheap (periodics, periodiccnt, active); } } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } void noinline ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW { /* TODO: use adjustheap and recalculation */ ev_periodic_stop (EV_A_ w); ev_periodic_start (EV_A_ w); } #endif #ifndef SA_RESTART # define SA_RESTART 0 #endif #if EV_SIGNAL_ENABLE void noinline ev_signal_start (EV_P_ ev_signal *w) EV_THROW { if (expect_false (ev_is_active (w))) return; assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); #if EV_MULTIPLICITY assert (("libev: a signal must not be attached to two different loops", !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop)); signals [w->signum - 1].loop = EV_A; ECB_MEMORY_FENCE_RELEASE; #endif EV_FREQUENT_CHECK; #if EV_USE_SIGNALFD if (sigfd == -2) { sigfd = signalfd (-1, &sigfd_set, SFD_NONBLOCK | SFD_CLOEXEC); if (sigfd < 0 && errno == EINVAL) sigfd = signalfd (-1, &sigfd_set, 0); /* retry without flags */ if (sigfd >= 0) { fd_intern (sigfd); /* doing it twice will not hurt */ sigemptyset (&sigfd_set); ev_io_init (&sigfd_w, sigfdcb, sigfd, EV_READ); ev_set_priority (&sigfd_w, EV_MAXPRI); ev_io_start (EV_A_ &sigfd_w); ev_unref (EV_A); /* signalfd watcher should not keep loop alive */ } } if (sigfd >= 0) { /* TODO: check .head */ sigaddset (&sigfd_set, w->signum); sigprocmask (SIG_BLOCK, &sigfd_set, 0); signalfd (sigfd, &sigfd_set, 0); } #endif ev_start (EV_A_ (W)w, 1); wlist_add (&signals [w->signum - 1].head, (WL)w); if (!((WL)w)->next) # if EV_USE_SIGNALFD if (sigfd < 0) /*TODO*/ # endif { # ifdef _WIN32 evpipe_init (EV_A); signal (w->signum, ev_sighandler); # else struct sigaction sa; evpipe_init (EV_A); sa.sa_handler = ev_sighandler; sigfillset (&sa.sa_mask); sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ sigaction (w->signum, &sa, 0); if (origflags & EVFLAG_NOSIGMASK) { sigemptyset (&sa.sa_mask); sigaddset (&sa.sa_mask, w->signum); sigprocmask (SIG_UNBLOCK, &sa.sa_mask, 0); } #endif } EV_FREQUENT_CHECK; } void noinline ev_signal_stop (EV_P_ ev_signal *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; wlist_del (&signals [w->signum - 1].head, (WL)w); ev_stop (EV_A_ (W)w); if (!signals [w->signum - 1].head) { #if EV_MULTIPLICITY signals [w->signum - 1].loop = 0; /* unattach from signal */ #endif #if EV_USE_SIGNALFD if (sigfd >= 0) { sigset_t ss; sigemptyset (&ss); sigaddset (&ss, w->signum); sigdelset (&sigfd_set, w->signum); signalfd (sigfd, &sigfd_set, 0); sigprocmask (SIG_UNBLOCK, &ss, 0); } else #endif signal (w->signum, SIG_DFL); } EV_FREQUENT_CHECK; } #endif #if EV_CHILD_ENABLE void ev_child_start (EV_P_ ev_child *w) EV_THROW { #if EV_MULTIPLICITY assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); #endif if (expect_false (ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, 1); wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); EV_FREQUENT_CHECK; } void ev_child_stop (EV_P_ ev_child *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_STAT_ENABLE # ifdef _WIN32 # undef lstat # define lstat(a,b) _stati64 (a,b) # endif #define DEF_STAT_INTERVAL 5.0074891 #define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ #define MIN_STAT_INTERVAL 0.1074891 static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); #if EV_USE_INOTIFY /* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ # define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) static void noinline infy_add (EV_P_ ev_stat *w) { w->wd = inotify_add_watch (fs_fd, w->path, IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO | IN_DONT_FOLLOW | IN_MASK_ADD); if (w->wd >= 0) { struct statfs sfs; /* now local changes will be tracked by inotify, but remote changes won't */ /* unless the filesystem is known to be local, we therefore still poll */ /* also do poll on <2.6.25, but with normal frequency */ if (!fs_2625) w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; else if (!statfs (w->path, &sfs) && (sfs.f_type == 0x1373 /* devfs */ || sfs.f_type == 0x4006 /* fat */ || sfs.f_type == 0x4d44 /* msdos */ || sfs.f_type == 0xEF53 /* ext2/3 */ || sfs.f_type == 0x72b6 /* jffs2 */ || sfs.f_type == 0x858458f6 /* ramfs */ || sfs.f_type == 0x5346544e /* ntfs */ || sfs.f_type == 0x3153464a /* jfs */ || sfs.f_type == 0x9123683e /* btrfs */ || sfs.f_type == 0x52654973 /* reiser3 */ || sfs.f_type == 0x01021994 /* tmpfs */ || sfs.f_type == 0x58465342 /* xfs */)) w->timer.repeat = 0.; /* filesystem is local, kernel new enough */ else w->timer.repeat = w->interval ? w->interval : NFS_STAT_INTERVAL; /* remote, use reduced frequency */ } else { /* can't use inotify, continue to stat */ w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; /* if path is not there, monitor some parent directory for speedup hints */ /* note that exceeding the hardcoded path limit is not a correctness issue, */ /* but an efficiency issue only */ if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) { char path [4096]; strcpy (path, w->path); do { int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF | (errno == EACCES ? IN_ATTRIB : IN_CREATE | IN_MOVED_TO); char *pend = strrchr (path, '/'); if (!pend || pend == path) break; *pend = 0; w->wd = inotify_add_watch (fs_fd, path, mask); } while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); } } if (w->wd >= 0) wlist_add (&fs_hash [w->wd & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); /* now re-arm timer, if required */ if (ev_is_active (&w->timer)) ev_ref (EV_A); ev_timer_again (EV_A_ &w->timer); if (ev_is_active (&w->timer)) ev_unref (EV_A); } static void noinline infy_del (EV_P_ ev_stat *w) { int slot; int wd = w->wd; if (wd < 0) return; w->wd = -2; slot = wd & ((EV_INOTIFY_HASHSIZE) - 1); wlist_del (&fs_hash [slot].head, (WL)w); /* remove this watcher, if others are watching it, they will rearm */ inotify_rm_watch (fs_fd, wd); } static void noinline infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) { if (slot < 0) /* overflow, need to check for all hash slots */ for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) infy_wd (EV_A_ slot, wd, ev); else { WL w_; for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; ) { ev_stat *w = (ev_stat *)w_; w_ = w_->next; /* lets us remove this watcher and all before it */ if (w->wd == wd || wd == -1) { if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) { wlist_del (&fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); w->wd = -1; infy_add (EV_A_ w); /* re-add, no matter what */ } stat_timer_cb (EV_A_ &w->timer, 0); } } } } static void infy_cb (EV_P_ ev_io *w, int revents) { char buf [EV_INOTIFY_BUFSIZE]; int ofs; int len = read (fs_fd, buf, sizeof (buf)); for (ofs = 0; ofs < len; ) { struct inotify_event *ev = (struct inotify_event *)(buf + ofs); infy_wd (EV_A_ ev->wd, ev->wd, ev); ofs += sizeof (struct inotify_event) + ev->len; } } inline_size void ecb_cold ev_check_2625 (EV_P) { /* kernels < 2.6.25 are borked * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html */ if (ev_linux_version () < 0x020619) return; fs_2625 = 1; } inline_size int infy_newfd (void) { #if defined IN_CLOEXEC && defined IN_NONBLOCK int fd = inotify_init1 (IN_CLOEXEC | IN_NONBLOCK); if (fd >= 0) return fd; #endif return inotify_init (); } inline_size void infy_init (EV_P) { if (fs_fd != -2) return; fs_fd = -1; ev_check_2625 (EV_A); fs_fd = infy_newfd (); if (fs_fd >= 0) { fd_intern (fs_fd); ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); ev_set_priority (&fs_w, EV_MAXPRI); ev_io_start (EV_A_ &fs_w); ev_unref (EV_A); } } inline_size void infy_fork (EV_P) { int slot; if (fs_fd < 0) return; ev_ref (EV_A); ev_io_stop (EV_A_ &fs_w); close (fs_fd); fs_fd = infy_newfd (); if (fs_fd >= 0) { fd_intern (fs_fd); ev_io_set (&fs_w, fs_fd, EV_READ); ev_io_start (EV_A_ &fs_w); ev_unref (EV_A); } for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) { WL w_ = fs_hash [slot].head; fs_hash [slot].head = 0; while (w_) { ev_stat *w = (ev_stat *)w_; w_ = w_->next; /* lets us add this watcher */ w->wd = -1; if (fs_fd >= 0) infy_add (EV_A_ w); /* re-add, no matter what */ else { w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; if (ev_is_active (&w->timer)) ev_ref (EV_A); ev_timer_again (EV_A_ &w->timer); if (ev_is_active (&w->timer)) ev_unref (EV_A); } } } } #endif #ifdef _WIN32 # define EV_LSTAT(p,b) _stati64 (p, b) #else # define EV_LSTAT(p,b) lstat (p, b) #endif void ev_stat_stat (EV_P_ ev_stat *w) EV_THROW { if (lstat (w->path, &w->attr) < 0) w->attr.st_nlink = 0; else if (!w->attr.st_nlink) w->attr.st_nlink = 1; } static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents) { ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); ev_statdata prev = w->attr; ev_stat_stat (EV_A_ w); /* memcmp doesn't work on netbsd, they.... do stuff to their struct stat */ if ( prev.st_dev != w->attr.st_dev || prev.st_ino != w->attr.st_ino || prev.st_mode != w->attr.st_mode || prev.st_nlink != w->attr.st_nlink || prev.st_uid != w->attr.st_uid || prev.st_gid != w->attr.st_gid || prev.st_rdev != w->attr.st_rdev || prev.st_size != w->attr.st_size || prev.st_atime != w->attr.st_atime || prev.st_mtime != w->attr.st_mtime || prev.st_ctime != w->attr.st_ctime ) { /* we only update w->prev on actual differences */ /* in case we test more often than invoke the callback, */ /* to ensure that prev is always different to attr */ w->prev = prev; #if EV_USE_INOTIFY if (fs_fd >= 0) { infy_del (EV_A_ w); infy_add (EV_A_ w); ev_stat_stat (EV_A_ w); /* avoid race... */ } #endif ev_feed_event (EV_A_ w, EV_STAT); } } void ev_stat_start (EV_P_ ev_stat *w) EV_THROW { if (expect_false (ev_is_active (w))) return; ev_stat_stat (EV_A_ w); if (w->interval < MIN_STAT_INTERVAL && w->interval) w->interval = MIN_STAT_INTERVAL; ev_timer_init (&w->timer, stat_timer_cb, 0., w->interval ? w->interval : DEF_STAT_INTERVAL); ev_set_priority (&w->timer, ev_priority (w)); #if EV_USE_INOTIFY infy_init (EV_A); if (fs_fd >= 0) infy_add (EV_A_ w); else #endif { ev_timer_again (EV_A_ &w->timer); ev_unref (EV_A); } ev_start (EV_A_ (W)w, 1); EV_FREQUENT_CHECK; } void ev_stat_stop (EV_P_ ev_stat *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; #if EV_USE_INOTIFY infy_del (EV_A_ w); #endif if (ev_is_active (&w->timer)) { ev_ref (EV_A); ev_timer_stop (EV_A_ &w->timer); } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_IDLE_ENABLE void ev_idle_start (EV_P_ ev_idle *w) EV_THROW { if (expect_false (ev_is_active (w))) return; pri_adjust (EV_A_ (W)w); EV_FREQUENT_CHECK; { int active = ++idlecnt [ABSPRI (w)]; ++idleall; ev_start (EV_A_ (W)w, active); array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, EMPTY2); idles [ABSPRI (w)][active - 1] = w; } EV_FREQUENT_CHECK; } void ev_idle_stop (EV_P_ ev_idle *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; ev_active (idles [ABSPRI (w)][active - 1]) = active; ev_stop (EV_A_ (W)w); --idleall; } EV_FREQUENT_CHECK; } #endif #if EV_PREPARE_ENABLE void ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW { if (expect_false (ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, ++preparecnt); array_needsize (ev_prepare *, prepares, preparemax, preparecnt, EMPTY2); prepares [preparecnt - 1] = w; EV_FREQUENT_CHECK; } void ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); prepares [active - 1] = prepares [--preparecnt]; ev_active (prepares [active - 1]) = active; } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_CHECK_ENABLE void ev_check_start (EV_P_ ev_check *w) EV_THROW { if (expect_false (ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, ++checkcnt); array_needsize (ev_check *, checks, checkmax, checkcnt, EMPTY2); checks [checkcnt - 1] = w; EV_FREQUENT_CHECK; } void ev_check_stop (EV_P_ ev_check *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); checks [active - 1] = checks [--checkcnt]; ev_active (checks [active - 1]) = active; } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_EMBED_ENABLE void noinline ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW { ev_run (w->other, EVRUN_NOWAIT); } static void embed_io_cb (EV_P_ ev_io *io, int revents) { ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); if (ev_cb (w)) ev_feed_event (EV_A_ (W)w, EV_EMBED); else ev_run (w->other, EVRUN_NOWAIT); } static void embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) { ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); { EV_P = w->other; while (fdchangecnt) { fd_reify (EV_A); ev_run (EV_A_ EVRUN_NOWAIT); } } } static void embed_fork_cb (EV_P_ ev_fork *fork_w, int revents) { ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); ev_embed_stop (EV_A_ w); { EV_P = w->other; ev_loop_fork (EV_A); ev_run (EV_A_ EVRUN_NOWAIT); } ev_embed_start (EV_A_ w); } #if 0 static void embed_idle_cb (EV_P_ ev_idle *idle, int revents) { ev_idle_stop (EV_A_ idle); } #endif void ev_embed_start (EV_P_ ev_embed *w) EV_THROW { if (expect_false (ev_is_active (w))) return; { EV_P = w->other; assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); } EV_FREQUENT_CHECK; ev_set_priority (&w->io, ev_priority (w)); ev_io_start (EV_A_ &w->io); ev_prepare_init (&w->prepare, embed_prepare_cb); ev_set_priority (&w->prepare, EV_MINPRI); ev_prepare_start (EV_A_ &w->prepare); ev_fork_init (&w->fork, embed_fork_cb); ev_fork_start (EV_A_ &w->fork); /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ ev_start (EV_A_ (W)w, 1); EV_FREQUENT_CHECK; } void ev_embed_stop (EV_P_ ev_embed *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_io_stop (EV_A_ &w->io); ev_prepare_stop (EV_A_ &w->prepare); ev_fork_stop (EV_A_ &w->fork); ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_FORK_ENABLE void ev_fork_start (EV_P_ ev_fork *w) EV_THROW { if (expect_false (ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, ++forkcnt); array_needsize (ev_fork *, forks, forkmax, forkcnt, EMPTY2); forks [forkcnt - 1] = w; EV_FREQUENT_CHECK; } void ev_fork_stop (EV_P_ ev_fork *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); forks [active - 1] = forks [--forkcnt]; ev_active (forks [active - 1]) = active; } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_CLEANUP_ENABLE void ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW { if (expect_false (ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, ++cleanupcnt); array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); cleanups [cleanupcnt - 1] = w; /* cleanup watchers should never keep a refcount on the loop */ ev_unref (EV_A); EV_FREQUENT_CHECK; } void ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; ev_ref (EV_A); { int active = ev_active (w); cleanups [active - 1] = cleanups [--cleanupcnt]; ev_active (cleanups [active - 1]) = active; } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } #endif #if EV_ASYNC_ENABLE void ev_async_start (EV_P_ ev_async *w) EV_THROW { if (expect_false (ev_is_active (w))) return; w->sent = 0; evpipe_init (EV_A); EV_FREQUENT_CHECK; ev_start (EV_A_ (W)w, ++asynccnt); array_needsize (ev_async *, asyncs, asyncmax, asynccnt, EMPTY2); asyncs [asynccnt - 1] = w; EV_FREQUENT_CHECK; } void ev_async_stop (EV_P_ ev_async *w) EV_THROW { clear_pending (EV_A_ (W)w); if (expect_false (!ev_is_active (w))) return; EV_FREQUENT_CHECK; { int active = ev_active (w); asyncs [active - 1] = asyncs [--asynccnt]; ev_active (asyncs [active - 1]) = active; } ev_stop (EV_A_ (W)w); EV_FREQUENT_CHECK; } void ev_async_send (EV_P_ ev_async *w) EV_THROW { w->sent = 1; evpipe_write (EV_A_ &async_pending); } #endif /*****************************************************************************/ struct ev_once { ev_io io; ev_timer to; void (*cb)(int revents, void *arg); void *arg; }; static void once_cb (EV_P_ struct ev_once *once, int revents) { void (*cb)(int revents, void *arg) = once->cb; void *arg = once->arg; ev_io_stop (EV_A_ &once->io); ev_timer_stop (EV_A_ &once->to); ev_free (once); cb (revents, arg); } static void once_cb_io (EV_P_ ev_io *w, int revents) { struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)); once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to)); } static void once_cb_to (EV_P_ ev_timer *w, int revents) { struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)); once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); } void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW { struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); if (expect_false (!once)) { cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMER, arg); return; } once->cb = cb; once->arg = arg; ev_init (&once->io, once_cb_io); if (fd >= 0) { ev_io_set (&once->io, fd, events); ev_io_start (EV_A_ &once->io); } ev_init (&once->to, once_cb_to); if (timeout >= 0.) { ev_timer_set (&once->to, timeout, 0.); ev_timer_start (EV_A_ &once->to); } } /*****************************************************************************/ #if EV_WALK_ENABLE void ecb_cold ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW { int i, j; ev_watcher_list *wl, *wn; if (types & (EV_IO | EV_EMBED)) for (i = 0; i < anfdmax; ++i) for (wl = anfds [i].head; wl; ) { wn = wl->next; #if EV_EMBED_ENABLE if (ev_cb ((ev_io *)wl) == embed_io_cb) { if (types & EV_EMBED) cb (EV_A_ EV_EMBED, ((char *)wl) - offsetof (struct ev_embed, io)); } else #endif #if EV_USE_INOTIFY if (ev_cb ((ev_io *)wl) == infy_cb) ; else #endif if ((ev_io *)wl != &pipe_w) if (types & EV_IO) cb (EV_A_ EV_IO, wl); wl = wn; } if (types & (EV_TIMER | EV_STAT)) for (i = timercnt + HEAP0; i-- > HEAP0; ) #if EV_STAT_ENABLE /*TODO: timer is not always active*/ if (ev_cb ((ev_timer *)ANHE_w (timers [i])) == stat_timer_cb) { if (types & EV_STAT) cb (EV_A_ EV_STAT, ((char *)ANHE_w (timers [i])) - offsetof (struct ev_stat, timer)); } else #endif if (types & EV_TIMER) cb (EV_A_ EV_TIMER, ANHE_w (timers [i])); #if EV_PERIODIC_ENABLE if (types & EV_PERIODIC) for (i = periodiccnt + HEAP0; i-- > HEAP0; ) cb (EV_A_ EV_PERIODIC, ANHE_w (periodics [i])); #endif #if EV_IDLE_ENABLE if (types & EV_IDLE) for (j = NUMPRI; j--; ) for (i = idlecnt [j]; i--; ) cb (EV_A_ EV_IDLE, idles [j][i]); #endif #if EV_FORK_ENABLE if (types & EV_FORK) for (i = forkcnt; i--; ) if (ev_cb (forks [i]) != embed_fork_cb) cb (EV_A_ EV_FORK, forks [i]); #endif #if EV_ASYNC_ENABLE if (types & EV_ASYNC) for (i = asynccnt; i--; ) cb (EV_A_ EV_ASYNC, asyncs [i]); #endif #if EV_PREPARE_ENABLE if (types & EV_PREPARE) for (i = preparecnt; i--; ) # if EV_EMBED_ENABLE if (ev_cb (prepares [i]) != embed_prepare_cb) # endif cb (EV_A_ EV_PREPARE, prepares [i]); #endif #if EV_CHECK_ENABLE if (types & EV_CHECK) for (i = checkcnt; i--; ) cb (EV_A_ EV_CHECK, checks [i]); #endif #if EV_SIGNAL_ENABLE if (types & EV_SIGNAL) for (i = 0; i < EV_NSIG - 1; ++i) for (wl = signals [i].head; wl; ) { wn = wl->next; cb (EV_A_ EV_SIGNAL, wl); wl = wn; } #endif #if EV_CHILD_ENABLE if (types & EV_CHILD) for (i = (EV_PID_HASHSIZE); i--; ) for (wl = childs [i]; wl; ) { wn = wl->next; cb (EV_A_ EV_CHILD, wl); wl = wn; } #endif /* EV_STAT 0x00001000 /* stat data changed */ /* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ } #endif #if EV_MULTIPLICITY #include "ev_wrap.h" #endif gevent-1.1.0/libev/ev.h0000644000076500000000000007137512666555342015440 0ustar jmaddenwheel00000000000000/* * libev native API header * * Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #ifndef EV_H_ #define EV_H_ #ifdef __cplusplus # define EV_CPP(x) x # if __cplusplus >= 201103L # define EV_THROW noexcept # else # define EV_THROW throw () # endif #else # define EV_CPP(x) # define EV_THROW #endif EV_CPP(extern "C" {) /*****************************************************************************/ /* pre-4.0 compatibility */ #ifndef EV_COMPAT3 # define EV_COMPAT3 1 #endif #ifndef EV_FEATURES # if defined __OPTIMIZE_SIZE__ # define EV_FEATURES 0x7c # else # define EV_FEATURES 0x7f # endif #endif #define EV_FEATURE_CODE ((EV_FEATURES) & 1) #define EV_FEATURE_DATA ((EV_FEATURES) & 2) #define EV_FEATURE_CONFIG ((EV_FEATURES) & 4) #define EV_FEATURE_API ((EV_FEATURES) & 8) #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16) #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32) #define EV_FEATURE_OS ((EV_FEATURES) & 64) /* these priorities are inclusive, higher priorities will be invoked earlier */ #ifndef EV_MINPRI # define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0) #endif #ifndef EV_MAXPRI # define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0) #endif #ifndef EV_MULTIPLICITY # define EV_MULTIPLICITY EV_FEATURE_CONFIG #endif #ifndef EV_PERIODIC_ENABLE # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_STAT_ENABLE # define EV_STAT_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_PREPARE_ENABLE # define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_CHECK_ENABLE # define EV_CHECK_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_IDLE_ENABLE # define EV_IDLE_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_FORK_ENABLE # define EV_FORK_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_CLEANUP_ENABLE # define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_SIGNAL_ENABLE # define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_CHILD_ENABLE # ifdef _WIN32 # define EV_CHILD_ENABLE 0 # else # define EV_CHILD_ENABLE EV_FEATURE_WATCHERS #endif #endif #ifndef EV_ASYNC_ENABLE # define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_EMBED_ENABLE # define EV_EMBED_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_WALK_ENABLE # define EV_WALK_ENABLE 0 /* not yet */ #endif /*****************************************************************************/ #if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE # undef EV_SIGNAL_ENABLE # define EV_SIGNAL_ENABLE 1 #endif /*****************************************************************************/ typedef double ev_tstamp; #include /* for memmove */ #ifndef EV_ATOMIC_T # include # define EV_ATOMIC_T sig_atomic_t volatile #endif #if EV_STAT_ENABLE # ifdef _WIN32 # include # include # endif # include #endif /* support multiple event loops? */ #if EV_MULTIPLICITY struct ev_loop; # define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */ # define EV_P_ EV_P, /* a loop as first of multiple parameters */ # define EV_A loop /* a loop as sole argument to a function call */ # define EV_A_ EV_A, /* a loop as first of multiple arguments */ # define EV_DEFAULT_UC ev_default_loop_uc_ () /* the default loop, if initialised, as sole arg */ # define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */ # define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */ # define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */ #else # define EV_P void # define EV_P_ # define EV_A # define EV_A_ # define EV_DEFAULT # define EV_DEFAULT_ # define EV_DEFAULT_UC # define EV_DEFAULT_UC_ # undef EV_EMBED_ENABLE #endif /* EV_INLINE is used for functions in header files */ #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 # define EV_INLINE static inline #else # define EV_INLINE static #endif #ifdef EV_API_STATIC # define EV_API_DECL static #else # define EV_API_DECL extern #endif /* EV_PROTOTYPES can be used to switch of prototype declarations */ #ifndef EV_PROTOTYPES # define EV_PROTOTYPES 1 #endif /*****************************************************************************/ #define EV_VERSION_MAJOR 4 #define EV_VERSION_MINOR 20 /* eventmask, revents, events... */ enum { EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */ EV_NONE = 0x00, /* no events */ EV_READ = 0x01, /* ev_io detected read will not block */ EV_WRITE = 0x02, /* ev_io detected write will not block */ EV__IOFDSET = 0x80, /* internal use only */ EV_IO = EV_READ, /* alias for type-detection */ EV_TIMER = 0x00000100, /* timer timed out */ #if EV_COMPAT3 EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */ #endif EV_PERIODIC = 0x00000200, /* periodic timer timed out */ EV_SIGNAL = 0x00000400, /* signal was received */ EV_CHILD = 0x00000800, /* child/pid had status change */ EV_STAT = 0x00001000, /* stat data changed */ EV_IDLE = 0x00002000, /* event loop is idling */ EV_PREPARE = 0x00004000, /* event loop about to poll */ EV_CHECK = 0x00008000, /* event loop finished poll */ EV_EMBED = 0x00010000, /* embedded event loop needs sweep */ EV_FORK = 0x00020000, /* event loop resumed in child */ EV_CLEANUP = 0x00040000, /* event loop resumed in child */ EV_ASYNC = 0x00080000, /* async intra-loop signal */ EV_CUSTOM = 0x01000000, /* for use by user code */ EV_ERROR = (int)0x80000000 /* sent when an error occurs */ }; /* can be used to add custom fields to all watchers, while losing binary compatibility */ #ifndef EV_COMMON # define EV_COMMON void *data; #endif #ifndef EV_CB_DECLARE # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents); #endif #ifndef EV_CB_INVOKE # define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents)) #endif /* not official, do not use */ #define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents) /* * struct member types: * private: you may look at them, but not change them, * and they might not mean anything to you. * ro: can be read anytime, but only changed when the watcher isn't active. * rw: can be read and modified anytime, even when the watcher is active. * * some internal details that might be helpful for debugging: * * active is either 0, which means the watcher is not active, * or the array index of the watcher (periodics, timers) * or the array index + 1 (most other watchers) * or simply 1 for watchers that aren't in some array. * pending is either 0, in which case the watcher isn't, * or the array index + 1 in the pendings array. */ #if EV_MINPRI == EV_MAXPRI # define EV_DECL_PRIORITY #elif !defined (EV_DECL_PRIORITY) # define EV_DECL_PRIORITY int priority; #endif /* shared by all watchers */ #define EV_WATCHER(type) \ int active; /* private */ \ int pending; /* private */ \ EV_DECL_PRIORITY /* private */ \ EV_COMMON /* rw */ \ EV_CB_DECLARE (type) /* private */ #define EV_WATCHER_LIST(type) \ EV_WATCHER (type) \ struct ev_watcher_list *next; /* private */ #define EV_WATCHER_TIME(type) \ EV_WATCHER (type) \ ev_tstamp at; /* private */ /* base class, nothing to see here unless you subclass */ typedef struct ev_watcher { EV_WATCHER (ev_watcher) } ev_watcher; /* base class, nothing to see here unless you subclass */ typedef struct ev_watcher_list { EV_WATCHER_LIST (ev_watcher_list) } ev_watcher_list; /* base class, nothing to see here unless you subclass */ typedef struct ev_watcher_time { EV_WATCHER_TIME (ev_watcher_time) } ev_watcher_time; /* invoked when fd is either EV_READable or EV_WRITEable */ /* revent EV_READ, EV_WRITE */ typedef struct ev_io { EV_WATCHER_LIST (ev_io) int fd; /* ro */ int events; /* ro */ } ev_io; /* invoked after a specific time, repeatable (based on monotonic clock) */ /* revent EV_TIMEOUT */ typedef struct ev_timer { EV_WATCHER_TIME (ev_timer) ev_tstamp repeat; /* rw */ } ev_timer; /* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */ /* revent EV_PERIODIC */ typedef struct ev_periodic { EV_WATCHER_TIME (ev_periodic) ev_tstamp offset; /* rw */ ev_tstamp interval; /* rw */ ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) EV_THROW; /* rw */ } ev_periodic; /* invoked when the given signal has been received */ /* revent EV_SIGNAL */ typedef struct ev_signal { EV_WATCHER_LIST (ev_signal) int signum; /* ro */ } ev_signal; /* invoked when sigchld is received and waitpid indicates the given pid */ /* revent EV_CHILD */ /* does not support priorities */ typedef struct ev_child { EV_WATCHER_LIST (ev_child) int flags; /* private */ int pid; /* ro */ int rpid; /* rw, holds the received pid */ int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */ } ev_child; #if EV_STAT_ENABLE /* st_nlink = 0 means missing file or other error */ # ifdef _WIN32 typedef struct _stati64 ev_statdata; # else typedef struct stat ev_statdata; # endif /* invoked each time the stat data changes for a given path */ /* revent EV_STAT */ typedef struct ev_stat { EV_WATCHER_LIST (ev_stat) ev_timer timer; /* private */ ev_tstamp interval; /* ro */ const char *path; /* ro */ ev_statdata prev; /* ro */ ev_statdata attr; /* ro */ int wd; /* wd for inotify, fd for kqueue */ } ev_stat; #endif #if EV_IDLE_ENABLE /* invoked when the nothing else needs to be done, keeps the process from blocking */ /* revent EV_IDLE */ typedef struct ev_idle { EV_WATCHER (ev_idle) } ev_idle; #endif /* invoked for each run of the mainloop, just before the blocking call */ /* you can still change events in any way you like */ /* revent EV_PREPARE */ typedef struct ev_prepare { EV_WATCHER (ev_prepare) } ev_prepare; /* invoked for each run of the mainloop, just after the blocking call */ /* revent EV_CHECK */ typedef struct ev_check { EV_WATCHER (ev_check) } ev_check; #if EV_FORK_ENABLE /* the callback gets invoked before check in the child process when a fork was detected */ /* revent EV_FORK */ typedef struct ev_fork { EV_WATCHER (ev_fork) } ev_fork; #endif #if EV_CLEANUP_ENABLE /* is invoked just before the loop gets destroyed */ /* revent EV_CLEANUP */ typedef struct ev_cleanup { EV_WATCHER (ev_cleanup) } ev_cleanup; #endif #if EV_EMBED_ENABLE /* used to embed an event loop inside another */ /* the callback gets invoked when the event loop has handled events, and can be 0 */ typedef struct ev_embed { EV_WATCHER (ev_embed) struct ev_loop *other; /* ro */ ev_io io; /* private */ ev_prepare prepare; /* private */ ev_check check; /* unused */ ev_timer timer; /* unused */ ev_periodic periodic; /* unused */ ev_idle idle; /* unused */ ev_fork fork; /* private */ #if EV_CLEANUP_ENABLE ev_cleanup cleanup; /* unused */ #endif } ev_embed; #endif #if EV_ASYNC_ENABLE /* invoked when somebody calls ev_async_send on the watcher */ /* revent EV_ASYNC */ typedef struct ev_async { EV_WATCHER (ev_async) EV_ATOMIC_T sent; /* private */ } ev_async; # define ev_async_pending(w) (+(w)->sent) #endif /* the presence of this union forces similar struct layout */ union ev_any_watcher { struct ev_watcher w; struct ev_watcher_list wl; struct ev_io io; struct ev_timer timer; struct ev_periodic periodic; struct ev_signal signal; struct ev_child child; #if EV_STAT_ENABLE struct ev_stat stat; #endif #if EV_IDLE_ENABLE struct ev_idle idle; #endif struct ev_prepare prepare; struct ev_check check; #if EV_FORK_ENABLE struct ev_fork fork; #endif #if EV_CLEANUP_ENABLE struct ev_cleanup cleanup; #endif #if EV_EMBED_ENABLE struct ev_embed embed; #endif #if EV_ASYNC_ENABLE struct ev_async async; #endif }; /* flag bits for ev_default_loop and ev_loop_new */ enum { /* the default */ EVFLAG_AUTO = 0x00000000U, /* not quite a mask */ /* flag bits */ EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */ EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */ /* debugging/feature disable */ EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */ #if EV_COMPAT3 EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */ #endif EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */ EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */ }; /* method bits to be ored together */ enum { EVBACKEND_SELECT = 0x00000001U, /* about anywhere */ EVBACKEND_POLL = 0x00000002U, /* !win */ EVBACKEND_EPOLL = 0x00000004U, /* linux */ EVBACKEND_KQUEUE = 0x00000008U, /* bsd */ EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */ EVBACKEND_PORT = 0x00000020U, /* solaris 10 */ EVBACKEND_ALL = 0x0000003FU, /* all known backends */ EVBACKEND_MASK = 0x0000FFFFU /* all future backends */ }; #if EV_PROTOTYPES EV_API_DECL int ev_version_major (void) EV_THROW; EV_API_DECL int ev_version_minor (void) EV_THROW; EV_API_DECL unsigned int ev_supported_backends (void) EV_THROW; EV_API_DECL unsigned int ev_recommended_backends (void) EV_THROW; EV_API_DECL unsigned int ev_embeddable_backends (void) EV_THROW; EV_API_DECL ev_tstamp ev_time (void) EV_THROW; EV_API_DECL void ev_sleep (ev_tstamp delay) EV_THROW; /* sleep for a while */ /* Sets the allocation function to use, works like realloc. * It is used to allocate and free memory. * If it returns zero when memory needs to be allocated, the library might abort * or take some potentially destructive action. * The default is your system realloc function. */ EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW; /* set the callback function to call on a * retryable syscall error * (such as failed select, poll, epoll_wait) */ EV_API_DECL void ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW; #if EV_MULTIPLICITY /* the default loop is the only one that handles signals and child watchers */ /* you can call this as often as you like */ EV_API_DECL struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW; #ifdef EV_API_STATIC EV_API_DECL struct ev_loop *ev_default_loop_ptr; #endif EV_INLINE struct ev_loop * ev_default_loop_uc_ (void) EV_THROW { extern struct ev_loop *ev_default_loop_ptr; return ev_default_loop_ptr; } EV_INLINE int ev_is_default_loop (EV_P) EV_THROW { return EV_A == EV_DEFAULT_UC; } /* create and destroy alternative loops that don't handle signals */ EV_API_DECL struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)) EV_THROW; EV_API_DECL ev_tstamp ev_now (EV_P) EV_THROW; /* time w.r.t. timers and the eventloop, updated after each poll */ #else EV_API_DECL int ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW; /* returns true when successful */ EV_API_DECL ev_tstamp ev_rt_now; EV_INLINE ev_tstamp ev_now (void) EV_THROW { return ev_rt_now; } /* looks weird, but ev_is_default_loop (EV_A) still works if this exists */ EV_INLINE int ev_is_default_loop (void) EV_THROW { return 1; } #endif /* multiplicity */ /* destroy event loops, also works for the default loop */ EV_API_DECL void ev_loop_destroy (EV_P); /* this needs to be called after fork, to duplicate the loop */ /* when you want to re-use it in the child */ /* you can call it in either the parent or the child */ /* you can actually call it at any time, anywhere :) */ EV_API_DECL void ev_loop_fork (EV_P) EV_THROW; EV_API_DECL unsigned int ev_backend (EV_P) EV_THROW; /* backend in use by loop */ EV_API_DECL void ev_now_update (EV_P) EV_THROW; /* update event loop time */ #if EV_WALK_ENABLE /* walk (almost) all watchers in the loop of a given type, invoking the */ /* callback on every such watcher. The callback might stop the watcher, */ /* but do nothing else with the loop */ EV_API_DECL void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW; #endif #endif /* prototypes */ /* ev_run flags values */ enum { EVRUN_NOWAIT = 1, /* do not block/wait */ EVRUN_ONCE = 2 /* block *once* only */ }; /* ev_break how values */ enum { EVBREAK_CANCEL = 0, /* undo unloop */ EVBREAK_ONE = 1, /* unloop once */ EVBREAK_ALL = 2 /* unloop all loops */ }; #if EV_PROTOTYPES EV_API_DECL int ev_run (EV_P_ int flags EV_CPP (= 0)); EV_API_DECL void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)) EV_THROW; /* break out of the loop */ /* * ref/unref can be used to add or remove a refcount on the mainloop. every watcher * keeps one reference. if you have a long-running watcher you never unregister that * should not keep ev_loop from running, unref() after starting, and ref() before stopping. */ EV_API_DECL void ev_ref (EV_P) EV_THROW; EV_API_DECL void ev_unref (EV_P) EV_THROW; /* * convenience function, wait for a single event, without registering an event watcher * if timeout is < 0, do wait indefinitely */ EV_API_DECL void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW; # if EV_FEATURE_API EV_API_DECL unsigned int ev_iteration (EV_P) EV_THROW; /* number of loop iterations */ EV_API_DECL unsigned int ev_depth (EV_P) EV_THROW; /* #ev_loop enters - #ev_loop leaves */ EV_API_DECL void ev_verify (EV_P) EV_THROW; /* abort if loop data corrupted */ EV_API_DECL void ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */ EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */ /* advanced stuff for threading etc. support, see docs */ EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW; EV_API_DECL void *ev_userdata (EV_P) EV_THROW; typedef void (*ev_loop_callback)(EV_P); EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW; /* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */ EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW; EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */ EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */ /* * stop/start the timer handling. */ EV_API_DECL void ev_suspend (EV_P) EV_THROW; EV_API_DECL void ev_resume (EV_P) EV_THROW; #endif #endif /* these may evaluate ev multiple times, and the other arguments at most once */ /* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ #define ev_init(ev,cb_) do { \ ((ev_watcher *)(void *)(ev))->active = \ ((ev_watcher *)(void *)(ev))->pending = 0; \ ev_set_priority ((ev), 0); \ ev_set_cb ((ev), cb_); \ } while (0) #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0) #define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0) #define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0) #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) #define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0) #define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0) #define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_check_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0) #define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_cleanup_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_async_set(ev) /* nop, yes, this is a serious in-joke */ #define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) #define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0) #define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0) #define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0) #define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0) #define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0) #define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) #define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) #define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) #define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0) #define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0) #define ev_cleanup_init(ev,cb) do { ev_init ((ev), (cb)); ev_cleanup_set ((ev)); } while (0) #define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0) #define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ #define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ #define ev_cb_(ev) (ev)->cb /* rw */ #define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb) #if EV_MINPRI == EV_MAXPRI # define ev_priority(ev) ((ev), EV_MINPRI) # define ev_set_priority(ev,pri) ((ev), (pri)) #else # define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority)) # define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri) #endif #define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at) #ifndef ev_set_cb # define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev)))) #endif /* stopping (enabling, adding) a watcher does nothing if it is already running */ /* stopping (disabling, deleting) a watcher does nothing unless it's already running */ #if EV_PROTOTYPES /* feeds an event into a watcher as if the event actually occurred */ /* accepts any ev_watcher type */ EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_THROW; EV_API_DECL void ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW; #if EV_SIGNAL_ENABLE EV_API_DECL void ev_feed_signal (int signum) EV_THROW; EV_API_DECL void ev_feed_signal_event (EV_P_ int signum) EV_THROW; #endif EV_API_DECL void ev_invoke (EV_P_ void *w, int revents); EV_API_DECL int ev_clear_pending (EV_P_ void *w) EV_THROW; EV_API_DECL void ev_io_start (EV_P_ ev_io *w) EV_THROW; EV_API_DECL void ev_io_stop (EV_P_ ev_io *w) EV_THROW; EV_API_DECL void ev_timer_start (EV_P_ ev_timer *w) EV_THROW; EV_API_DECL void ev_timer_stop (EV_P_ ev_timer *w) EV_THROW; /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */ EV_API_DECL void ev_timer_again (EV_P_ ev_timer *w) EV_THROW; /* return remaining time */ EV_API_DECL ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW; #if EV_PERIODIC_ENABLE EV_API_DECL void ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW; EV_API_DECL void ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW; EV_API_DECL void ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW; #endif /* only supported in the default loop */ #if EV_SIGNAL_ENABLE EV_API_DECL void ev_signal_start (EV_P_ ev_signal *w) EV_THROW; EV_API_DECL void ev_signal_stop (EV_P_ ev_signal *w) EV_THROW; #endif /* only supported in the default loop */ # if EV_CHILD_ENABLE EV_API_DECL void ev_child_start (EV_P_ ev_child *w) EV_THROW; EV_API_DECL void ev_child_stop (EV_P_ ev_child *w) EV_THROW; # endif # if EV_STAT_ENABLE EV_API_DECL void ev_stat_start (EV_P_ ev_stat *w) EV_THROW; EV_API_DECL void ev_stat_stop (EV_P_ ev_stat *w) EV_THROW; EV_API_DECL void ev_stat_stat (EV_P_ ev_stat *w) EV_THROW; # endif # if EV_IDLE_ENABLE EV_API_DECL void ev_idle_start (EV_P_ ev_idle *w) EV_THROW; EV_API_DECL void ev_idle_stop (EV_P_ ev_idle *w) EV_THROW; # endif #if EV_PREPARE_ENABLE EV_API_DECL void ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW; EV_API_DECL void ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW; #endif #if EV_CHECK_ENABLE EV_API_DECL void ev_check_start (EV_P_ ev_check *w) EV_THROW; EV_API_DECL void ev_check_stop (EV_P_ ev_check *w) EV_THROW; #endif # if EV_FORK_ENABLE EV_API_DECL void ev_fork_start (EV_P_ ev_fork *w) EV_THROW; EV_API_DECL void ev_fork_stop (EV_P_ ev_fork *w) EV_THROW; # endif # if EV_CLEANUP_ENABLE EV_API_DECL void ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW; EV_API_DECL void ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW; # endif # if EV_EMBED_ENABLE /* only supported when loop to be embedded is in fact embeddable */ EV_API_DECL void ev_embed_start (EV_P_ ev_embed *w) EV_THROW; EV_API_DECL void ev_embed_stop (EV_P_ ev_embed *w) EV_THROW; EV_API_DECL void ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW; # endif # if EV_ASYNC_ENABLE EV_API_DECL void ev_async_start (EV_P_ ev_async *w) EV_THROW; EV_API_DECL void ev_async_stop (EV_P_ ev_async *w) EV_THROW; EV_API_DECL void ev_async_send (EV_P_ ev_async *w) EV_THROW; # endif #if EV_COMPAT3 #define EVLOOP_NONBLOCK EVRUN_NOWAIT #define EVLOOP_ONESHOT EVRUN_ONCE #define EVUNLOOP_CANCEL EVBREAK_CANCEL #define EVUNLOOP_ONE EVBREAK_ONE #define EVUNLOOP_ALL EVBREAK_ALL #if EV_PROTOTYPES EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); } EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); } EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); } EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); } #if EV_FEATURE_API EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); } EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); } EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); } #endif #endif #else typedef struct ev_loop ev_loop; #endif #endif EV_CPP(}) #endif gevent-1.1.0/libev/ev_epoll.c0000644000076500000000000002321412666555342016613 0ustar jmaddenwheel00000000000000/* * libev epoll fd activity backend * * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ /* * general notes about epoll: * * a) epoll silently removes fds from the fd set. as nothing tells us * that an fd has been removed otherwise, we have to continually * "rearm" fds that we suspect *might* have changed (same * problem with kqueue, but much less costly there). * b) the fact that ADD != MOD creates a lot of extra syscalls due to a) * and seems not to have any advantage. * c) the inability to handle fork or file descriptors (think dup) * limits the applicability over poll, so this is not a generic * poll replacement. * d) epoll doesn't work the same as select with many file descriptors * (such as files). while not critical, no other advanced interface * seems to share this (rather non-unixy) limitation. * e) epoll claims to be embeddable, but in practise you never get * a ready event for the epoll fd (broken: <=2.6.26, working: >=2.6.32). * f) epoll_ctl returning EPERM means the fd is always ready. * * lots of "weird code" and complication handling in this file is due * to these design problems with epoll, as we try very hard to avoid * epoll_ctl syscalls for common usage patterns and handle the breakage * ensuing from receiving events for closed and otherwise long gone * file descriptors. */ #include #define EV_EMASK_EPERM 0x80 static void epoll_modify (EV_P_ int fd, int oev, int nev) { struct epoll_event ev; unsigned char oldmask; /* * we handle EPOLL_CTL_DEL by ignoring it here * on the assumption that the fd is gone anyways * if that is wrong, we have to handle the spurious * event in epoll_poll. * if the fd is added again, we try to ADD it, and, if that * fails, we assume it still has the same eventmask. */ if (!nev) return; oldmask = anfds [fd].emask; anfds [fd].emask = nev; /* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */ ev.data.u64 = (uint64_t)(uint32_t)fd | ((uint64_t)(uint32_t)++anfds [fd].egen << 32); ev.events = (nev & EV_READ ? EPOLLIN : 0) | (nev & EV_WRITE ? EPOLLOUT : 0); if (expect_true (!epoll_ctl (backend_fd, oev && oldmask != nev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev))) return; if (expect_true (errno == ENOENT)) { /* if ENOENT then the fd went away, so try to do the right thing */ if (!nev) goto dec_egen; if (!epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev)) return; } else if (expect_true (errno == EEXIST)) { /* EEXIST means we ignored a previous DEL, but the fd is still active */ /* if the kernel mask is the same as the new mask, we assume it hasn't changed */ if (oldmask == nev) goto dec_egen; if (!epoll_ctl (backend_fd, EPOLL_CTL_MOD, fd, &ev)) return; } else if (expect_true (errno == EPERM)) { /* EPERM means the fd is always ready, but epoll is too snobbish */ /* to handle it, unlike select or poll. */ anfds [fd].emask = EV_EMASK_EPERM; /* add fd to epoll_eperms, if not already inside */ if (!(oldmask & EV_EMASK_EPERM)) { array_needsize (int, epoll_eperms, epoll_epermmax, epoll_epermcnt + 1, EMPTY2); epoll_eperms [epoll_epermcnt++] = fd; } return; } fd_kill (EV_A_ fd); dec_egen: /* we didn't successfully call epoll_ctl, so decrement the generation counter again */ --anfds [fd].egen; } static void epoll_poll (EV_P_ ev_tstamp timeout) { int i; int eventcnt; if (expect_false (epoll_epermcnt)) timeout = 0.; /* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */ /* the default libev max wait time, however. */ EV_RELEASE_CB; eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout * 1e3); EV_ACQUIRE_CB; if (expect_false (eventcnt < 0)) { if (errno != EINTR) ev_syserr ("(libev) epoll_wait"); return; } for (i = 0; i < eventcnt; ++i) { struct epoll_event *ev = epoll_events + i; int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */ int want = anfds [fd].events; int got = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0) | (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0); /* * check for spurious notification. * this only finds spurious notifications on egen updates * other spurious notifications will be found by epoll_ctl, below * we assume that fd is always in range, as we never shrink the anfds array */ if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32))) { /* recreate kernel state */ postfork = 1; continue; } if (expect_false (got & ~want)) { anfds [fd].emask = want; /* * we received an event but are not interested in it, try mod or del * this often happens because we optimistically do not unregister fds * when we are no longer interested in them, but also when we get spurious * notifications for fds from another process. this is partially handled * above with the gencounter check (== our fd is not the event fd), and * partially here, when epoll_ctl returns an error (== a child has the fd * but we closed it). */ ev->events = (want & EV_READ ? EPOLLIN : 0) | (want & EV_WRITE ? EPOLLOUT : 0); /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */ /* which is fortunately easy to do for us. */ if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) { postfork = 1; /* an error occurred, recreate kernel state */ continue; } } fd_event (EV_A_ fd, got); } /* if the receive array was full, increase its size */ if (expect_false (eventcnt == epoll_eventmax)) { ev_free (epoll_events); epoll_eventmax = array_nextsize (sizeof (struct epoll_event), epoll_eventmax, epoll_eventmax + 1); epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); } /* now synthesize events for all fds where epoll fails, while select works... */ for (i = epoll_epermcnt; i--; ) { int fd = epoll_eperms [i]; unsigned char events = anfds [fd].events & (EV_READ | EV_WRITE); if (anfds [fd].emask & EV_EMASK_EPERM && events) fd_event (EV_A_ fd, events); else { epoll_eperms [i] = epoll_eperms [--epoll_epermcnt]; anfds [fd].emask = 0; } } } int inline_size epoll_init (EV_P_ int flags) { #ifdef EPOLL_CLOEXEC backend_fd = epoll_create1 (EPOLL_CLOEXEC); if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) #endif backend_fd = epoll_create (256); if (backend_fd < 0) return 0; fcntl (backend_fd, F_SETFD, FD_CLOEXEC); backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */ backend_modify = epoll_modify; backend_poll = epoll_poll; epoll_eventmax = 64; /* initial number of events receivable per poll */ epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); return EVBACKEND_EPOLL; } void inline_size epoll_destroy (EV_P) { ev_free (epoll_events); array_free (epoll_eperm, EMPTY); } void inline_size epoll_fork (EV_P) { close (backend_fd); while ((backend_fd = epoll_create (256)) < 0) ev_syserr ("(libev) epoll_create"); fcntl (backend_fd, F_SETFD, FD_CLOEXEC); fd_rearm_all (EV_A); } gevent-1.1.0/libev/ev_kqueue.c0000644000076500000000000001523212666555342017000 0ustar jmaddenwheel00000000000000/* * libev kqueue backend * * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #include #include #include #include #include void inline_speed kqueue_change (EV_P_ int fd, int filter, int flags, int fflags) { ++kqueue_changecnt; array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2); EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0); } /* OS X at least needs this */ #ifndef EV_ENABLE # define EV_ENABLE 0 #endif #ifndef NOTE_EOF # define NOTE_EOF 0 #endif static void kqueue_modify (EV_P_ int fd, int oev, int nev) { if (oev != nev) { if (oev & EV_READ) kqueue_change (EV_A_ fd, EVFILT_READ , EV_DELETE, 0); if (oev & EV_WRITE) kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_DELETE, 0); } /* to detect close/reopen reliably, we have to re-add */ /* event requests even when oev == nev */ if (nev & EV_READ) kqueue_change (EV_A_ fd, EVFILT_READ , EV_ADD | EV_ENABLE, NOTE_EOF); if (nev & EV_WRITE) kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_ADD | EV_ENABLE, NOTE_EOF); } static void kqueue_poll (EV_P_ ev_tstamp timeout) { int res, i; struct timespec ts; /* need to resize so there is enough space for errors */ if (kqueue_changecnt > kqueue_eventmax) { ev_free (kqueue_events); kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); } EV_RELEASE_CB; EV_TS_SET (ts, timeout); res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); EV_ACQUIRE_CB; kqueue_changecnt = 0; if (expect_false (res < 0)) { if (errno != EINTR) ev_syserr ("(libev) kevent"); return; } for (i = 0; i < res; ++i) { int fd = kqueue_events [i].ident; if (expect_false (kqueue_events [i].flags & EV_ERROR)) { int err = kqueue_events [i].data; /* we are only interested in errors for fds that we are interested in :) */ if (anfds [fd].events) { if (err == ENOENT) /* resubmit changes on ENOENT */ kqueue_modify (EV_A_ fd, 0, anfds [fd].events); else if (err == EBADF) /* on EBADF, we re-check the fd */ { if (fd_valid (fd)) kqueue_modify (EV_A_ fd, 0, anfds [fd].events); else fd_kill (EV_A_ fd); } else /* on all other errors, we error out on the fd */ fd_kill (EV_A_ fd); } } else fd_event ( EV_A_ fd, kqueue_events [i].filter == EVFILT_READ ? EV_READ : kqueue_events [i].filter == EVFILT_WRITE ? EV_WRITE : 0 ); } if (expect_false (res == kqueue_eventmax)) { ev_free (kqueue_events); kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1); kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); } } int inline_size kqueue_init (EV_P_ int flags) { /* initialize the kernel queue */ kqueue_fd_pid = getpid (); if ((backend_fd = kqueue ()) < 0) return 0; fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ backend_mintime = 1e-9; /* apparently, they did the right thing in freebsd */ backend_modify = kqueue_modify; backend_poll = kqueue_poll; kqueue_eventmax = 64; /* initial number of events receivable per poll */ kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); kqueue_changes = 0; kqueue_changemax = 0; kqueue_changecnt = 0; return EVBACKEND_KQUEUE; } void inline_size kqueue_destroy (EV_P) { ev_free (kqueue_events); ev_free (kqueue_changes); } void inline_size kqueue_fork (EV_P) { /* some BSD kernels don't just destroy the kqueue itself, * but also close the fd, which isn't documented, and * impossible to support properly. * we remember the pid of the kqueue call and only close * the fd if the pid is still the same. * this leaks fds on sane kernels, but BSD interfaces are * notoriously buggy and rarely get fixed. */ pid_t newpid = getpid (); if (newpid == kqueue_fd_pid) close (backend_fd); kqueue_fd_pid = newpid; while ((backend_fd = kqueue ()) < 0) ev_syserr ("(libev) kqueue"); fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* re-register interest in fds */ fd_rearm_all (EV_A); } /* sys/event.h defines EV_ERROR */ #undef EV_ERROR gevent-1.1.0/libev/ev_poll.c0000644000076500000000000001053312666555342016446 0ustar jmaddenwheel00000000000000/* * libev poll fd activity backend * * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #include void inline_size pollidx_init (int *base, int count) { /* consider using memset (.., -1, ...), which is practically guaranteed * to work on all systems implementing poll */ while (count--) *base++ = -1; } static void poll_modify (EV_P_ int fd, int oev, int nev) { int idx; if (oev == nev) return; array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init); idx = pollidxs [fd]; if (idx < 0) /* need to allocate a new pollfd */ { pollidxs [fd] = idx = pollcnt++; array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2); polls [idx].fd = fd; } assert (polls [idx].fd == fd); if (nev) polls [idx].events = (nev & EV_READ ? POLLIN : 0) | (nev & EV_WRITE ? POLLOUT : 0); else /* remove pollfd */ { pollidxs [fd] = -1; if (expect_true (idx < --pollcnt)) { polls [idx] = polls [pollcnt]; pollidxs [polls [idx].fd] = idx; } } } static void poll_poll (EV_P_ ev_tstamp timeout) { struct pollfd *p; int res; EV_RELEASE_CB; res = poll (polls, pollcnt, timeout * 1e3); EV_ACQUIRE_CB; if (expect_false (res < 0)) { if (errno == EBADF) fd_ebadf (EV_A); else if (errno == ENOMEM && !syserr_cb) fd_enomem (EV_A); else if (errno != EINTR) ev_syserr ("(libev) poll"); } else for (p = polls; res; ++p) { assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt)); if (expect_false (p->revents)) /* this expect is debatable */ { --res; if (expect_false (p->revents & POLLNVAL)) fd_kill (EV_A_ p->fd); else fd_event ( EV_A_ p->fd, (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) ); } } } int inline_size poll_init (EV_P_ int flags) { backend_mintime = 1e-3; backend_modify = poll_modify; backend_poll = poll_poll; pollidxs = 0; pollidxmax = 0; polls = 0; pollmax = 0; pollcnt = 0; return EVBACKEND_POLL; } void inline_size poll_destroy (EV_P) { ev_free (pollidxs); ev_free (polls); } gevent-1.1.0/libev/ev_port.c0000644000076500000000000001440412666555342016465 0ustar jmaddenwheel00000000000000/* * libev solaris event port backend * * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ /* useful reading: * * http://bugs.opensolaris.org/view_bug.do?bug_id=6268715 (random results) * http://bugs.opensolaris.org/view_bug.do?bug_id=6455223 (just totally broken) * http://bugs.opensolaris.org/view_bug.do?bug_id=6873782 (manpage ETIME) * http://bugs.opensolaris.org/view_bug.do?bug_id=6874410 (implementation ETIME) * http://www.mail-archive.com/networking-discuss@opensolaris.org/msg11898.html ETIME vs. nget * http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/event_port.c (libc) * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/portfs/port.c#1325 (kernel) */ #include #include #include #include #include #include void inline_speed port_associate_and_check (EV_P_ int fd, int ev) { if (0 > port_associate ( backend_fd, PORT_SOURCE_FD, fd, (ev & EV_READ ? POLLIN : 0) | (ev & EV_WRITE ? POLLOUT : 0), 0 ) ) { if (errno == EBADFD) fd_kill (EV_A_ fd); else ev_syserr ("(libev) port_associate"); } } static void port_modify (EV_P_ int fd, int oev, int nev) { /* we need to reassociate no matter what, as closes are * once more silently being discarded. */ if (!nev) { if (oev) port_dissociate (backend_fd, PORT_SOURCE_FD, fd); } else port_associate_and_check (EV_A_ fd, nev); } static void port_poll (EV_P_ ev_tstamp timeout) { int res, i; struct timespec ts; uint_t nget = 1; /* we initialise this to something we will skip in the loop, as */ /* port_getn can return with nget unchanged, but no indication */ /* whether it was the original value or has been updated :/ */ port_events [0].portev_source = 0; EV_RELEASE_CB; EV_TS_SET (ts, timeout); res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); EV_ACQUIRE_CB; /* port_getn may or may not set nget on error */ /* so we rely on port_events [0].portev_source not being updated */ if (res == -1 && errno != ETIME && errno != EINTR) ev_syserr ("(libev) port_getn (see http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, try LIBEV_FLAGS=3 env variable)"); for (i = 0; i < nget; ++i) { if (port_events [i].portev_source == PORT_SOURCE_FD) { int fd = port_events [i].portev_object; fd_event ( EV_A_ fd, (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) ); fd_change (EV_A_ fd, EV__IOFDSET); } } if (expect_false (nget == port_eventmax)) { ev_free (port_events); port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1); port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); } } int inline_size port_init (EV_P_ int flags) { /* Initialize the kernel queue */ if ((backend_fd = port_create ()) < 0) return 0; assert (("libev: PORT_SOURCE_FD must not be zero", PORT_SOURCE_FD)); fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ /* if my reading of the opensolaris kernel sources are correct, then * opensolaris does something very stupid: it checks if the time has already * elapsed and doesn't round up if that is the case,m otherwise it DOES round * up. Since we can't know what the case is, we need to guess by using a * "large enough" timeout. Normally, 1e-9 would be correct. */ backend_mintime = 1e-3; /* needed to compensate for port_getn returning early */ backend_modify = port_modify; backend_poll = port_poll; port_eventmax = 64; /* initial number of events receivable per poll */ port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); return EVBACKEND_PORT; } void inline_size port_destroy (EV_P) { ev_free (port_events); } void inline_size port_fork (EV_P) { close (backend_fd); while ((backend_fd = port_create ()) < 0) ev_syserr ("(libev) port"); fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* re-register interest in fds */ fd_rearm_all (EV_A); } gevent-1.1.0/libev/ev_select.c0000644000076500000000000002115512666555342016761 0ustar jmaddenwheel00000000000000/* * libev select fd activity backend * * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #ifndef _WIN32 /* for unix systems */ # include # ifndef __hpux /* for REAL unix systems */ # include # endif #endif #ifndef EV_SELECT_USE_FD_SET # ifdef NFDBITS # define EV_SELECT_USE_FD_SET 0 # else # define EV_SELECT_USE_FD_SET 1 # endif #endif #if EV_SELECT_IS_WINSOCKET # undef EV_SELECT_USE_FD_SET # define EV_SELECT_USE_FD_SET 1 # undef NFDBITS # define NFDBITS 0 #endif #if !EV_SELECT_USE_FD_SET # define NFDBYTES (NFDBITS / 8) #endif #include static void select_modify (EV_P_ int fd, int oev, int nev) { if (oev == nev) return; { #if EV_SELECT_USE_FD_SET #if EV_SELECT_IS_WINSOCKET SOCKET handle = anfds [fd].handle; #else int handle = fd; #endif assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE)); /* FD_SET is broken on windows (it adds the fd to a set twice or more, * which eventually leads to overflows). Need to call it only on changes. */ #if EV_SELECT_IS_WINSOCKET if ((oev ^ nev) & EV_READ) #endif if (nev & EV_READ) FD_SET (handle, (fd_set *)vec_ri); else FD_CLR (handle, (fd_set *)vec_ri); #if EV_SELECT_IS_WINSOCKET if ((oev ^ nev) & EV_WRITE) #endif if (nev & EV_WRITE) FD_SET (handle, (fd_set *)vec_wi); else FD_CLR (handle, (fd_set *)vec_wi); #else int word = fd / NFDBITS; fd_mask mask = 1UL << (fd % NFDBITS); if (expect_false (vec_max <= word)) { int new_max = word + 1; vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES); vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */ vec_wi = ev_realloc (vec_wi, new_max * NFDBYTES); vec_wo = ev_realloc (vec_wo, new_max * NFDBYTES); /* could free/malloc */ #ifdef _WIN32 vec_eo = ev_realloc (vec_eo, new_max * NFDBYTES); /* could free/malloc */ #endif for (; vec_max < new_max; ++vec_max) ((fd_mask *)vec_ri) [vec_max] = ((fd_mask *)vec_wi) [vec_max] = 0; } ((fd_mask *)vec_ri) [word] |= mask; if (!(nev & EV_READ)) ((fd_mask *)vec_ri) [word] &= ~mask; ((fd_mask *)vec_wi) [word] |= mask; if (!(nev & EV_WRITE)) ((fd_mask *)vec_wi) [word] &= ~mask; #endif } } static void select_poll (EV_P_ ev_tstamp timeout) { struct timeval tv; int res; int fd_setsize; EV_RELEASE_CB; EV_TV_SET (tv, timeout); #if EV_SELECT_USE_FD_SET fd_setsize = sizeof (fd_set); #else fd_setsize = vec_max * NFDBYTES; #endif memcpy (vec_ro, vec_ri, fd_setsize); memcpy (vec_wo, vec_wi, fd_setsize); #ifdef _WIN32 /* pass in the write set as except set. * the idea behind this is to work around a windows bug that causes * errors to be reported as an exception and not by setting * the writable bit. this is so uncontrollably lame. */ memcpy (vec_eo, vec_wi, fd_setsize); res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_eo, &tv); #elif EV_SELECT_USE_FD_SET fd_setsize = anfdmax < FD_SETSIZE ? anfdmax : FD_SETSIZE; res = select (fd_setsize, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); #else res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); #endif EV_ACQUIRE_CB; if (expect_false (res < 0)) { #if EV_SELECT_IS_WINSOCKET errno = WSAGetLastError (); #endif #ifdef WSABASEERR /* on windows, select returns incompatible error codes, fix this */ if (errno >= WSABASEERR && errno < WSABASEERR + 1000) if (errno == WSAENOTSOCK) errno = EBADF; else errno -= WSABASEERR; #endif #ifdef _WIN32 /* select on windows erroneously returns EINVAL when no fd sets have been * provided (this is documented). what microsoft doesn't tell you that this bug * exists even when the fd sets _are_ provided, so we have to check for this bug * here and emulate by sleeping manually. * we also get EINVAL when the timeout is invalid, but we ignore this case here * and assume that EINVAL always means: you have to wait manually. */ if (errno == EINVAL) { if (timeout) { unsigned long ms = timeout * 1e3; Sleep (ms ? ms : 1); } return; } #endif if (errno == EBADF) fd_ebadf (EV_A); else if (errno == ENOMEM && !syserr_cb) fd_enomem (EV_A); else if (errno != EINTR) ev_syserr ("(libev) select"); return; } #if EV_SELECT_USE_FD_SET { int fd; for (fd = 0; fd < anfdmax; ++fd) if (anfds [fd].events) { int events = 0; #if EV_SELECT_IS_WINSOCKET SOCKET handle = anfds [fd].handle; #else int handle = fd; #endif if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ; if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE; #ifdef _WIN32 if (FD_ISSET (handle, (fd_set *)vec_eo)) events |= EV_WRITE; #endif if (expect_true (events)) fd_event (EV_A_ fd, events); } } #else { int word, bit; for (word = vec_max; word--; ) { fd_mask word_r = ((fd_mask *)vec_ro) [word]; fd_mask word_w = ((fd_mask *)vec_wo) [word]; #ifdef _WIN32 word_w |= ((fd_mask *)vec_eo) [word]; #endif if (word_r || word_w) for (bit = NFDBITS; bit--; ) { fd_mask mask = 1UL << bit; int events = 0; events |= word_r & mask ? EV_READ : 0; events |= word_w & mask ? EV_WRITE : 0; if (expect_true (events)) fd_event (EV_A_ word * NFDBITS + bit, events); } } } #endif } int inline_size select_init (EV_P_ int flags) { backend_mintime = 1e-6; backend_modify = select_modify; backend_poll = select_poll; #if EV_SELECT_USE_FD_SET vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri); vec_ro = ev_malloc (sizeof (fd_set)); vec_wi = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_wi); vec_wo = ev_malloc (sizeof (fd_set)); #ifdef _WIN32 vec_eo = ev_malloc (sizeof (fd_set)); #endif #else vec_max = 0; vec_ri = 0; vec_ro = 0; vec_wi = 0; vec_wo = 0; #ifdef _WIN32 vec_eo = 0; #endif #endif return EVBACKEND_SELECT; } void inline_size select_destroy (EV_P) { ev_free (vec_ri); ev_free (vec_ro); ev_free (vec_wi); ev_free (vec_wo); #ifdef _WIN32 ev_free (vec_eo); #endif } gevent-1.1.0/libev/ev_vars.h0000644000076500000000000001412512666555342016461 0ustar jmaddenwheel00000000000000/* * loop member variable declarations * * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #define VARx(type,name) VAR(name, type name) VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */ VARx(ev_tstamp, mn_now) /* monotonic clock "now" */ VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */ /* for reverse feeding of events */ VARx(W *, rfeeds) VARx(int, rfeedmax) VARx(int, rfeedcnt) VAR (pendings, ANPENDING *pendings [NUMPRI]) VAR (pendingmax, int pendingmax [NUMPRI]) VAR (pendingcnt, int pendingcnt [NUMPRI]) VARx(int, pendingpri) /* highest priority currently pending */ VARx(ev_prepare, pending_w) /* dummy pending watcher */ VARx(ev_tstamp, io_blocktime) VARx(ev_tstamp, timeout_blocktime) VARx(int, backend) VARx(int, activecnt) /* total number of active events ("refcount") */ VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */ VARx(int, backend_fd) VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */ VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev)) VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout)) VARx(ANFD *, anfds) VARx(int, anfdmax) VAR (evpipe, int evpipe [2]) VARx(ev_io, pipe_w) VARx(EV_ATOMIC_T, pipe_write_wanted) VARx(EV_ATOMIC_T, pipe_write_skipped) #if !defined(_WIN32) || EV_GENWRAP VARx(pid_t, curpid) #endif VARx(char, postfork) /* true if we need to recreate kernel state after fork */ #if EV_USE_SELECT || EV_GENWRAP VARx(void *, vec_ri) VARx(void *, vec_ro) VARx(void *, vec_wi) VARx(void *, vec_wo) #if defined(_WIN32) || EV_GENWRAP VARx(void *, vec_eo) #endif VARx(int, vec_max) #endif #if EV_USE_POLL || EV_GENWRAP VARx(struct pollfd *, polls) VARx(int, pollmax) VARx(int, pollcnt) VARx(int *, pollidxs) /* maps fds into structure indices */ VARx(int, pollidxmax) #endif #if EV_USE_EPOLL || EV_GENWRAP VARx(struct epoll_event *, epoll_events) VARx(int, epoll_eventmax) VARx(int *, epoll_eperms) VARx(int, epoll_epermcnt) VARx(int, epoll_epermmax) #endif #if EV_USE_KQUEUE || EV_GENWRAP VARx(pid_t, kqueue_fd_pid) VARx(struct kevent *, kqueue_changes) VARx(int, kqueue_changemax) VARx(int, kqueue_changecnt) VARx(struct kevent *, kqueue_events) VARx(int, kqueue_eventmax) #endif #if EV_USE_PORT || EV_GENWRAP VARx(struct port_event *, port_events) VARx(int, port_eventmax) #endif #if EV_USE_IOCP || EV_GENWRAP VARx(HANDLE, iocp) #endif VARx(int *, fdchanges) VARx(int, fdchangemax) VARx(int, fdchangecnt) VARx(ANHE *, timers) VARx(int, timermax) VARx(int, timercnt) #if EV_PERIODIC_ENABLE || EV_GENWRAP VARx(ANHE *, periodics) VARx(int, periodicmax) VARx(int, periodiccnt) #endif #if EV_IDLE_ENABLE || EV_GENWRAP VAR (idles, ev_idle **idles [NUMPRI]) VAR (idlemax, int idlemax [NUMPRI]) VAR (idlecnt, int idlecnt [NUMPRI]) #endif VARx(int, idleall) /* total number */ VARx(struct ev_prepare **, prepares) VARx(int, preparemax) VARx(int, preparecnt) VARx(struct ev_check **, checks) VARx(int, checkmax) VARx(int, checkcnt) #if EV_FORK_ENABLE || EV_GENWRAP VARx(struct ev_fork **, forks) VARx(int, forkmax) VARx(int, forkcnt) #endif #if EV_CLEANUP_ENABLE || EV_GENWRAP VARx(struct ev_cleanup **, cleanups) VARx(int, cleanupmax) VARx(int, cleanupcnt) #endif #if EV_ASYNC_ENABLE || EV_GENWRAP VARx(EV_ATOMIC_T, async_pending) VARx(struct ev_async **, asyncs) VARx(int, asyncmax) VARx(int, asynccnt) #endif #if EV_USE_INOTIFY || EV_GENWRAP VARx(int, fs_fd) VARx(ev_io, fs_w) VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */ VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE]) #endif VARx(EV_ATOMIC_T, sig_pending) #if EV_USE_SIGNALFD || EV_GENWRAP VARx(int, sigfd) VARx(ev_io, sigfd_w) VARx(sigset_t, sigfd_set) #endif VARx(unsigned int, origflags) /* original loop flags */ #if EV_FEATURE_API || EV_GENWRAP VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */ VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */ VARx(void *, userdata) /* C++ doesn't support the ev_loop_callback typedef here. stinks. */ VAR (release_cb, void (*release_cb)(EV_P) EV_THROW) VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_THROW) VAR (invoke_cb , ev_loop_callback invoke_cb) #endif #undef VARx gevent-1.1.0/libev/ev_win32.c0000644000076500000000000001273212666555342016445 0ustar jmaddenwheel00000000000000/* * libev win32 compatibility cruft (_not_ a backend) * * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License ("GPL") version 2 or any later version, * in which case the provisions of the GPL are applicable instead of * the above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the BSD license, indicate your decision * by deleting the provisions above and replace them with the notice * and other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ #ifdef _WIN32 /* timeb.h is actually xsi legacy functionality */ /* JAM: gevent: A CHANGES entry says that GetSystemTimeAsFileTime is now * used instead of timeb. So maybe this isn't needed? It breaks the build * on Visual Studio 2014. * UPDATE: upstream confirms this isn't needed and has removed it from what will * become 4.22. See http://lists.schmorp.de/pipermail/libev/2015q4/002586.html */ #if 0 #include #endif /* note: the comment below could not be substantiated, but what would I care */ /* MSDN says this is required to handle SIGFPE */ /* my wild guess would be that using something floating-pointy is required */ /* for the crt to do something about it */ volatile double SIGFPE_REQ = 0.0f; static SOCKET ev_tcp_socket (void) { #if EV_USE_WSASOCKET return WSASocket (AF_INET, SOCK_STREAM, 0, 0, 0, 0); #else return socket (AF_INET, SOCK_STREAM, 0); #endif } /* oh, the humanity! */ static int ev_pipe (int filedes [2]) { struct sockaddr_in addr = { 0 }; int addr_size = sizeof (addr); struct sockaddr_in adr2; int adr2_size = sizeof (adr2); SOCKET listener; SOCKET sock [2] = { -1, -1 }; if ((listener = ev_tcp_socket ()) == INVALID_SOCKET) return -1; addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); addr.sin_port = 0; if (bind (listener, (struct sockaddr *)&addr, addr_size)) goto fail; if (getsockname (listener, (struct sockaddr *)&addr, &addr_size)) goto fail; if (listen (listener, 1)) goto fail; if ((sock [0] = ev_tcp_socket ()) == INVALID_SOCKET) goto fail; if (connect (sock [0], (struct sockaddr *)&addr, addr_size)) goto fail; if ((sock [1] = accept (listener, 0, 0)) < 0) goto fail; /* windows vista returns fantasy port numbers for sockets: * example for two interconnected tcp sockets: * * (Socket::unpack_sockaddr_in getsockname $sock0)[0] == 53364 * (Socket::unpack_sockaddr_in getpeername $sock0)[0] == 53363 * (Socket::unpack_sockaddr_in getsockname $sock1)[0] == 53363 * (Socket::unpack_sockaddr_in getpeername $sock1)[0] == 53365 * * wow! tridirectional sockets! * * this way of checking ports seems to work: */ if (getpeername (sock [0], (struct sockaddr *)&addr, &addr_size)) goto fail; if (getsockname (sock [1], (struct sockaddr *)&adr2, &adr2_size)) goto fail; errno = WSAEINVAL; if (addr_size != adr2_size || addr.sin_addr.s_addr != adr2.sin_addr.s_addr /* just to be sure, I mean, it's windows */ || addr.sin_port != adr2.sin_port) goto fail; closesocket (listener); #if EV_SELECT_IS_WINSOCKET filedes [0] = EV_WIN32_HANDLE_TO_FD (sock [0]); filedes [1] = EV_WIN32_HANDLE_TO_FD (sock [1]); #else /* when select isn't winsocket, we also expect socket, connect, accept etc. * to work on fds */ filedes [0] = sock [0]; filedes [1] = sock [1]; #endif return 0; fail: closesocket (listener); if (sock [0] != INVALID_SOCKET) closesocket (sock [0]); if (sock [1] != INVALID_SOCKET) closesocket (sock [1]); return -1; } #undef pipe #define pipe(filedes) ev_pipe (filedes) #define EV_HAVE_EV_TIME 1 ev_tstamp ev_time (void) { FILETIME ft; ULARGE_INTEGER ui; GetSystemTimeAsFileTime (&ft); ui.u.LowPart = ft.dwLowDateTime; ui.u.HighPart = ft.dwHighDateTime; /* msvc cannot convert ulonglong to double... yes, it is that sucky */ return (LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-7; } #endif gevent-1.1.0/libev/ev_wrap.h0000644000076500000000000001260612666555342016461 0ustar jmaddenwheel00000000000000/* DO NOT EDIT, automatically generated by update_ev_wrap */ #ifndef EV_WRAP_H #define EV_WRAP_H #define acquire_cb ((loop)->acquire_cb) #define activecnt ((loop)->activecnt) #define anfdmax ((loop)->anfdmax) #define anfds ((loop)->anfds) #define async_pending ((loop)->async_pending) #define asynccnt ((loop)->asynccnt) #define asyncmax ((loop)->asyncmax) #define asyncs ((loop)->asyncs) #define backend ((loop)->backend) #define backend_fd ((loop)->backend_fd) #define backend_mintime ((loop)->backend_mintime) #define backend_modify ((loop)->backend_modify) #define backend_poll ((loop)->backend_poll) #define checkcnt ((loop)->checkcnt) #define checkmax ((loop)->checkmax) #define checks ((loop)->checks) #define cleanupcnt ((loop)->cleanupcnt) #define cleanupmax ((loop)->cleanupmax) #define cleanups ((loop)->cleanups) #define curpid ((loop)->curpid) #define epoll_epermcnt ((loop)->epoll_epermcnt) #define epoll_epermmax ((loop)->epoll_epermmax) #define epoll_eperms ((loop)->epoll_eperms) #define epoll_eventmax ((loop)->epoll_eventmax) #define epoll_events ((loop)->epoll_events) #define evpipe ((loop)->evpipe) #define fdchangecnt ((loop)->fdchangecnt) #define fdchangemax ((loop)->fdchangemax) #define fdchanges ((loop)->fdchanges) #define forkcnt ((loop)->forkcnt) #define forkmax ((loop)->forkmax) #define forks ((loop)->forks) #define fs_2625 ((loop)->fs_2625) #define fs_fd ((loop)->fs_fd) #define fs_hash ((loop)->fs_hash) #define fs_w ((loop)->fs_w) #define idleall ((loop)->idleall) #define idlecnt ((loop)->idlecnt) #define idlemax ((loop)->idlemax) #define idles ((loop)->idles) #define invoke_cb ((loop)->invoke_cb) #define io_blocktime ((loop)->io_blocktime) #define iocp ((loop)->iocp) #define kqueue_changecnt ((loop)->kqueue_changecnt) #define kqueue_changemax ((loop)->kqueue_changemax) #define kqueue_changes ((loop)->kqueue_changes) #define kqueue_eventmax ((loop)->kqueue_eventmax) #define kqueue_events ((loop)->kqueue_events) #define kqueue_fd_pid ((loop)->kqueue_fd_pid) #define loop_count ((loop)->loop_count) #define loop_depth ((loop)->loop_depth) #define loop_done ((loop)->loop_done) #define mn_now ((loop)->mn_now) #define now_floor ((loop)->now_floor) #define origflags ((loop)->origflags) #define pending_w ((loop)->pending_w) #define pendingcnt ((loop)->pendingcnt) #define pendingmax ((loop)->pendingmax) #define pendingpri ((loop)->pendingpri) #define pendings ((loop)->pendings) #define periodiccnt ((loop)->periodiccnt) #define periodicmax ((loop)->periodicmax) #define periodics ((loop)->periodics) #define pipe_w ((loop)->pipe_w) #define pipe_write_skipped ((loop)->pipe_write_skipped) #define pipe_write_wanted ((loop)->pipe_write_wanted) #define pollcnt ((loop)->pollcnt) #define pollidxmax ((loop)->pollidxmax) #define pollidxs ((loop)->pollidxs) #define pollmax ((loop)->pollmax) #define polls ((loop)->polls) #define port_eventmax ((loop)->port_eventmax) #define port_events ((loop)->port_events) #define postfork ((loop)->postfork) #define preparecnt ((loop)->preparecnt) #define preparemax ((loop)->preparemax) #define prepares ((loop)->prepares) #define release_cb ((loop)->release_cb) #define rfeedcnt ((loop)->rfeedcnt) #define rfeedmax ((loop)->rfeedmax) #define rfeeds ((loop)->rfeeds) #define rtmn_diff ((loop)->rtmn_diff) #define sig_pending ((loop)->sig_pending) #define sigfd ((loop)->sigfd) #define sigfd_set ((loop)->sigfd_set) #define sigfd_w ((loop)->sigfd_w) #define timeout_blocktime ((loop)->timeout_blocktime) #define timercnt ((loop)->timercnt) #define timermax ((loop)->timermax) #define timers ((loop)->timers) #define userdata ((loop)->userdata) #define vec_eo ((loop)->vec_eo) #define vec_max ((loop)->vec_max) #define vec_ri ((loop)->vec_ri) #define vec_ro ((loop)->vec_ro) #define vec_wi ((loop)->vec_wi) #define vec_wo ((loop)->vec_wo) #else #undef EV_WRAP_H #undef acquire_cb #undef activecnt #undef anfdmax #undef anfds #undef async_pending #undef asynccnt #undef asyncmax #undef asyncs #undef backend #undef backend_fd #undef backend_mintime #undef backend_modify #undef backend_poll #undef checkcnt #undef checkmax #undef checks #undef cleanupcnt #undef cleanupmax #undef cleanups #undef curpid #undef epoll_epermcnt #undef epoll_epermmax #undef epoll_eperms #undef epoll_eventmax #undef epoll_events #undef evpipe #undef fdchangecnt #undef fdchangemax #undef fdchanges #undef forkcnt #undef forkmax #undef forks #undef fs_2625 #undef fs_fd #undef fs_hash #undef fs_w #undef idleall #undef idlecnt #undef idlemax #undef idles #undef invoke_cb #undef io_blocktime #undef iocp #undef kqueue_changecnt #undef kqueue_changemax #undef kqueue_changes #undef kqueue_eventmax #undef kqueue_events #undef kqueue_fd_pid #undef loop_count #undef loop_depth #undef loop_done #undef mn_now #undef now_floor #undef origflags #undef pending_w #undef pendingcnt #undef pendingmax #undef pendingpri #undef pendings #undef periodiccnt #undef periodicmax #undef periodics #undef pipe_w #undef pipe_write_skipped #undef pipe_write_wanted #undef pollcnt #undef pollidxmax #undef pollidxs #undef pollmax #undef polls #undef port_eventmax #undef port_events #undef postfork #undef preparecnt #undef preparemax #undef prepares #undef release_cb #undef rfeedcnt #undef rfeedmax #undef rfeeds #undef rtmn_diff #undef sig_pending #undef sigfd #undef sigfd_set #undef sigfd_w #undef timeout_blocktime #undef timercnt #undef timermax #undef timers #undef userdata #undef vec_eo #undef vec_max #undef vec_ri #undef vec_ro #undef vec_wi #undef vec_wo #endif gevent-1.1.0/libev/install-sh0000755000076500000000000003325512666555342016654 0ustar jmaddenwheel00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gevent-1.1.0/libev/LICENSE0000644000076500000000000000400712666555342015646 0ustar jmaddenwheel00000000000000All files in libev are Copyright (c)2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Alternatively, the contents of this package may be used under the terms of the GNU General Public License ("GPL") version 2 or any later version, in which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this package only under the terms of the GPL and not to allow others to use your version of this file under the BSD license, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL in this and the other files of this package. If you do not delete the provisions above, a recipient may use your version of this file under either the BSD or the GPL. gevent-1.1.0/libev/ltmain.sh0000644000076500000000000105203012666555342016461 0ustar jmaddenwheel00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1.11" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 gevent-1.1.0/libev/Makefile.in0000644000076500000000000007240412666555342016714 0ustar jmaddenwheel00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in mkinstalldirs depcomp $(include_HEADERS) \ README compile config.guess config.sub install-sh missing \ ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/libev.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" \ "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) libev_la_LIBADD = am_libev_la_OBJECTS = ev.lo event.lo libev_la_OBJECTS = $(am_libev_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libev_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libev_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libev_la_SOURCES) DIST_SOURCES = $(libev_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac man3dir = $(mandir)/man3 NROFF = nroff MANS = $(man_MANS) HEADERS = $(include_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign VERSION_INFO = 4:0:0 EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \ ev_vars.h ev_wrap.h \ ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c \ ev.3 ev.pod Symbols.ev Symbols.event man_MANS = ev.3 include_HEADERS = ev.h ev++.h event.h lib_LTLIBRARIES = libev.la libev_la_SOURCES = ev.c event.c libev_la_LDFLAGS = -version-info $(VERSION_INFO) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libev.la: $(libev_la_OBJECTS) $(libev_la_DEPENDENCIES) $(EXTRA_libev_la_DEPENDENCIES) $(AM_V_CCLD)$(libev_la_LINK) -rpath $(libdir) $(libev_la_OBJECTS) $(libev_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ev.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-man3: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man3dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.3[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ done; } uninstall-man3: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man3dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS) config.h installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-includeHEADERS install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man3 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \ uninstall-man uninstall-man: uninstall-man3 .MAKE: all install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-includeHEADERS \ install-info install-info-am install-libLTLIBRARIES \ install-man install-man3 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-includeHEADERS uninstall-libLTLIBRARIES \ uninstall-man uninstall-man3 ev.3: ev.pod pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: gevent-1.1.0/libev/missing0000755000076500000000000001533012666555342016241 0ustar jmaddenwheel00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gevent-1.1.0/libev/README0000644000076500000000000000477412666555342015534 0ustar jmaddenwheel00000000000000libev is a high-performance event loop/event model with lots of features. (see benchmark at http://libev.schmorp.de/bench.html) ABOUT Homepage: http://software.schmorp.de/pkg/libev Mailinglist: libev@lists.schmorp.de http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev Library Documentation: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod Libev is modelled (very losely) after libevent and the Event perl module, but is faster, scales better and is more correct, and also more featureful. And also smaller. Yay. Some of the specialties of libev not commonly found elsewhere are: - extensive and detailed, readable documentation (not doxygen garbage). - fully supports fork, can detect fork in various ways and automatically re-arms kernel mechanisms that do not support fork. - highly optimised select, poll, epoll, kqueue and event ports backends. - filesystem object (path) watching (with optional linux inotify support). - wallclock-based times (using absolute time, cron-like). - relative timers/timeouts (handle time jumps). - fast intra-thread communication between multiple event loops (with optional fast linux eventfd backend). - extremely easy to embed (fully documented, no dependencies, autoconf supported but optional). - very small codebase, no bloated library, simple code. - fully extensible by being able to plug into the event loop, integrate other event loops, integrate other event loop users. - very little memory use (small watchers, small event loop data). - optional C++ interface allowing method and function callbacks at no extra memory or runtime overhead. - optional Perl interface with similar characteristics (capable of running Glib/Gtk2 on libev). - support for other languages (multiple C++ interfaces, D, Ruby, Python) available from third-parties. Examples of programs that embed libev: the EV perl module, node.js, auditd, rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the Deliantra MMORPG server (http://www.deliantra.net/), Rubinius (a next-generation Ruby VM), the Ebb web server, the Rev event toolkit. CONTRIBUTORS libev was written and designed by Marc Lehmann and Emanuele Giaquinta. The following people sent in patches or made other noteworthy contributions to the design (for minor patches, see the Changes file. If I forgot to include you, please shout at me, it was an accident): W.C.A. Wijngaards Christopher Layne Chris Brody gevent-1.1.0/LICENSE0000644000076500000000000000241112666555342014542 0ustar jmaddenwheel00000000000000Except when otherwise stated (look at the beginning of each file) the software and the documentation in this project are copyrighted by: Denis Bilenko and the contributors, http://www.gevent.org and licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gevent-1.1.0/Makefile.ext0000644000076500000000000001356412666555342016007 0ustar jmaddenwheel00000000000000# This file is renamed to "Makefile.ext" in release tarballs so that setup.py won't try to # run it. If you want setup.py to run "make" automatically, rename it back to "Makefile". # The pyvenv multiple runtime support is based on https://github.com/DRMacIver/hypothesis/blob/master/Makefile PYTHON?=python${TRAVIS_PYTHON_VERSION} CYTHON?=cython export PATH:=$(BUILD_RUNTIMES)/snakepit:$(TOOLS):$(PATH) export LC_ALL=C.UTF-8 all: gevent/gevent.corecext.c gevent/gevent.ares.c gevent/gevent._semaphore.c gevent/gevent.corecext.c: gevent/corecext.ppyx gevent/libev.pxd $(PYTHON) util/cythonpp.py -o gevent.corecext.c gevent/corecext.ppyx echo '#include "callbacks.c"' >> gevent.corecext.c mv gevent.corecext.* gevent/ gevent/gevent.ares.c: gevent/ares.pyx gevent/*.pxd $(CYTHON) -o gevent.ares.c gevent/ares.pyx mv gevent.ares.* gevent/ gevent/gevent._semaphore.c: gevent/_semaphore.py gevent/_semaphore.pxd # On PyPy, if we wanted to use Cython to compile _semaphore.py, we'd # need to have _semaphore named as a .pyx file so it doesn't get # loaded in preference to the .so. (We want to keep the definitions # separate in a .pxd file for ease of reading, and that only works # with .py files, so we'd have to copy them back and forth.) # cp gevent/_semaphore.pyx gevent/_semaphore.py $(CYTHON) -o gevent._semaphore.c gevent/_semaphore.py mv gevent._semaphore.* gevent/ # rm gevent/_semaphore.py clean: rm -f corecext.pyx gevent/corecext.pyx rm -f gevent.corecext.c gevent.corecext.h gevent/gevent.corecext.c gevent/gevent.corecext.h rm -f gevent.ares.c gevent.ares.h gevent/gevent.ares.c gevent/gevent.ares.h rm -f gevent._semaphore.c gevent._semaphore.h gevent/gevent._semaphore.c gevent/gevent._semaphore.h doc: cd doc && PYTHONPATH=.. make html whitespace: ! find . -not -path "*.pem" -not -path "./.eggs/*" -not -path "./greentest/htmlcov/*" -not -path "./greentest/.coverage.*" -not -path "./.tox/*" -not -path "*/__pycache__/*" -not -path "*.so" -not -path "*.pyc" -not -path "./.git/*" -not -path "./build/*" -not -path "./libev/*" -not -path "./gevent/libev/*" -not -path "./gevent.egg-info/*" -not -path "./dist/*" -not -path "./.DS_Store" -not -path "./c-ares/*" -not -path "./gevent/gevent.*.[ch]" -not -path "./gevent/corecext.pyx" -not -path "./doc/_build/*" -not -path "./doc/mytheme/static/*" -type f | xargs egrep -l " $$" pep8: ${PYTHON} `which pep8` . pyflakes: ${PYTHON} util/pyflakes.py lint: whitespace pyflakes pep8 test_prelim: which ${PYTHON} ${PYTHON} --version ${PYTHON} -c 'import greenlet; print(greenlet, greenlet.__version__)' ${PYTHON} -c 'import gevent.core; print(gevent.core.loop)' make bench toxtest: test_prelim cd greentest && GEVENT_RESOLVER=thread python testrunner.py --config ../known_failures.py fulltoxtest: test_prelim cd greentest && GEVENT_RESOLVER=thread ${PYTHON} testrunner.py --config ../known_failures.py cd greentest && GEVENT_RESOLVER=ares GEVENTARES_SERVERS=8.8.8.8 ${PYTHON} testrunner.py --config ../known_failures.py --ignore tests_that_dont_use_resolver.txt cd greentest && GEVENT_FILE=thread ${PYTHON} testrunner.py --config ../known_failures.py `grep -l subprocess test_*.py` leaktest: GEVENTSETUP_EV_VERIFY=3 GEVENTTEST_LEAKCHECK=1 make fulltoxtest bench: ${PYTHON} greentest/bench_sendall.py travis_test_linters: make lint GEVENTTEST_COVERAGE=1 make leaktest # because we set parallel=true, each run produces new and different coverage files; they all need # to be combined coverage combine . greentest/ coveralls --rcfile=greentest/.coveragerc .PHONY: clean all doc pep8 whitespace pyflakes lint travistest travis # Managing runtimes BUILD_RUNTIMES?=$(PWD)/.runtimes PY26=$(BUILD_RUNTIMES)/snakepit/python2.6 PY27=$(BUILD_RUNTIMES)/snakepit/python2.7 PY33=$(BUILD_RUNTIMES)/snakepit/python3.3 PY34=$(BUILD_RUNTIMES)/snakepit/python3.4 PY35=$(BUILD_RUNTIMES)/snakepit/python3.5 PYPY=$(BUILD_RUNTIMES)/snakepit/pypy TOOLS=$(BUILD_RUNTIMES)/tools TOX=$(TOOLS)/tox TOOL_VIRTUALENV=$(BUILD_RUNTIMES)/virtualenvs/tools ISORT_VIRTUALENV=$(BUILD_RUNTIMES)/virtualenvs/isort TOOL_PYTHON=$(TOOL_VIRTUALENV)/bin/python TOOL_PIP=$(TOOL_VIRTUALENV)/bin/pip TOOL_INSTALL=$(TOOL_PIP) install --upgrade $(PY26): scripts/install.sh 2.6 $(PY27): scripts/install.sh 2.7 $(PY33): scripts/install.sh 3.3 $(PY34): scripts/install.sh 3.4 $(PY35): scripts/install.sh 3.5 $(PYPY): scripts/install.sh pypy PIP?=$(BUILD_RUNTIMES)/versions/$(PYTHON)/bin/pip develop: echo $(PIP) $(PYTHON) # First install a newer pip so that it can use the wheel cache # (only needed until travis upgrades pip to 7.x; note that the 3.5 # environment uses pip 7.1 by default) ${PIP} install -U pip # Then start installing our deps so they can be cached. Note that use of --build-options / --global-options / --install-options # disables the cache. # We need wheel>=0.26 on Python 3.5. See previous revisions. ${PIP} install -U wheel ${PIP} install -U tox cython cffi greenlet pep8 pyflakes "coverage>=4.0" "coveralls>=1.0" ${PYTHON} setup.py develop lint-py27: $(PY27) PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop travis_test_linters test-py27: $(PY27) PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop fulltoxtest test-py26: $(PY26) PYTHON=python2.6 PATH=$(BUILD_RUNTIMES)/versions/python2.6/bin:$(PATH) make develop fulltoxtest test-py33: $(PY33) PYTHON=python3.3 PATH=$(BUILD_RUNTIMES)/versions/python3.3/bin:$(PATH) make develop fulltoxtest test-py34: $(PY34) PYTHON=python3.4 PATH=$(BUILD_RUNTIMES)/versions/python3.4/bin:$(PATH) make develop fulltoxtest test-py35: $(PY35) PYTHON=python3.5 PATH=$(BUILD_RUNTIMES)/versions/python3.5/bin:$(PATH) make develop fulltoxtest test-pypy: $(PYPY) PYTHON=pypy PATH=$(BUILD_RUNTIMES)/versions/pypy/bin:$(PATH) make develop toxtest test-py27-cffi: $(PY27) GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop toxtest gevent-1.1.0/MANIFEST.in0000644000076500000000000000253212666555342015277 0ustar jmaddenwheel00000000000000recursive-include greentest * recursive-include examples * recursive-include gevent * recursive-include doc * recursive-include libev * recursive-include c-ares * recursive-include util * include LICENSE include README.rst include TODO include changelog.rst include MANIFEST.in include AUTHORS include Makefile.ext include known_failures.py include *.yml include *.txt include tox.ini include .pep8 recursive-include benchmarks *.sh recursive-include appveyor *.cmd recursive-include appveyor *.ps1 recursive-include scripts *.sh ### Artifacts of configuring/building in place # These we want, they come from the Makefile step #- recursive-exclude gevent corecext.pyx *.c *.h # This we want if we're on PyPy it's moved there ahead of time # by setup.py #- prune gevent/libev prune */__pycache__ global-exclude *.so global-exclude *.o global-exclude config.log config.status prune doc/_build global-exclude *.pyc recursive-exclude greentest .coverage prune greentest/htmlcov recursive-exclude c-ares stamp-h? ares_build.h.orig prune libev/.deps recursive-exclude libev Makefile libtool stamp-h? config.h # This is the output of _corecffi_build.py and may be particular # to each CFFI version/platform recursive-exclude gevent _corecffi.c # See comments in Makefile; this is renamed to Makefile.ext # this exclude keeps check-manifest from complaining exclude Makefile gevent-1.1.0/PKG-INFO0000644000076500000000000001541212666555433014640 0ustar jmaddenwheel00000000000000Metadata-Version: 1.1 Name: gevent Version: 1.1.0 Summary: Coroutine-based network library Home-page: http://www.gevent.org/ Author: Jason Madden Author-email: jason@nextthought.com License: MIT Description: ======== gevent ======== gevent_ is a coroutine-based Python networking library. Features include: * Fast event loop based on libev_. * Lightweight execution units based on greenlet_. * Familiar API that re-uses concepts from the Python standard library. * Cooperative sockets with SSL support. * DNS queries performed through c-ares_ or a threadpool. * Ability to use standard library and 3rd party modules written for standard blocking sockets gevent_ is `inspired by eventlet`_ but features more consistent API, simpler implementation and better performance. Read why others `use gevent`_ and check out the list of the `open source projects based on gevent`_. gevent is licensed under the MIT license. See `what's new`_ in the latest major release. Check out the detailed changelog_ for this version. Get gevent ========== Gevent runs on Python >= 2.6, Python >= 3.3, or PyPy >= 4.0.1 (but not PyPy3) (*Note*: PyPy is not supported in Windows). On all platforms, installing setuptools is recommended (this is done automatically if working in a virtual environment). You can use pip to install gevent:: pip install gevent .. tip:: You need Pip 8.0 or later to install the binary wheels for 1.1. Download the latest release from `Python Package Index`_ or clone `the repository`_. Read the documentation online at http://www.gevent.org. Additional installation information can be found `here `_. Post feedback and issues on the `bug tracker`_, `mailing list`_, blog_ and `twitter (@gevent)`_. Development =========== To install the latest development version:: pip install setuptools 'cython>=0.23.4' git+git://github.com/gevent/gevent.git#egg=gevent To hack on gevent (using a virtualenv):: $ git clone https://github.com/gevent/gevent.git $ cd gevent $ virtualenv env $ source env/bin/activate (env) $ pip install -r dev-requirements.txt .. note:: You must have Cython, a C compiler, and the Python development headers installed to build a checkout. Installing CFFI on CPython (it's standard on PyPy) allows building the CFFI backend for testing, and tox is the command used to test multiple versions of Python. Running Tests ------------- There are a few different ways to run the tests. To simply run the tests on one version of Python during development, try this:: python setup.py develop cd greentest PYTHONPATH=.. python testrunner.py --config ../known_failures.py Before submitting a pull request, it's a good idea to run the tests across all supported versions of Python, and to check the code quality using pep8 and pyflakes. This is what is done on Travis CI. Locally it can be done using tox:: pip install tox tox The testrunner accepts a ``--coverage`` argument to enable code coverage metrics through the `coverage.py`_ package. That would go something like this:: cd greentest PYTHONPATH=.. python testrunner.py --config ../known_failures.py --coverage coverage combine coverage html -i Builds on Travis CI automatically submit updates to `coveralls.io`_. .. image:: https://coveralls.io/repos/gevent/gevent/badge.svg?branch=master&service=github :target: https://coveralls.io/github/gevent/gevent?branch=master Continuous integration ---------------------- A test suite is run for every push and pull request submitted. Travis CI is used to test on Linux, and `AppVeyor`_ runs the builds on Windows. .. image:: https://travis-ci.org/gevent/gevent.svg?branch=master :target: https://travis-ci.org/gevent/gevent .. image:: https://ci.appveyor.com/api/projects/status/q4kl21ng2yo2ixur?svg=true :target: https://ci.appveyor.com/project/denik/gevent .. _gevent: http://www.gevent.org .. _greenlet: http://pypi.python.org/pypi/greenlet .. _libev: http://libev.schmorp.de/ .. _c-ares: http://c-ares.haxx.se/ .. _inspired by eventlet: http://blog.gevent.org/2010/02/27/why-gevent/ .. _use gevent: http://groups.google.com/group/gevent/browse_thread/thread/4de9703e5dca8271 .. _open source projects based on gevent: https://github.com/gevent/gevent/wiki/Projects .. _Python Package Index: http://pypi.python.org/pypi/gevent .. _the repository: https://github.com/gevent/gevent .. _bug tracker: https://github.com/gevent/gevent/wiki/Projects .. _mailing list: http://groups.google.com/group/gevent .. _blog: http://blog.gevent.org .. _twitter (@gevent): http://twitter.com/gevent .. _coverage.py: https://pypi.python.org/pypi/coverage/ .. _coveralls.io: https://coveralls.io/github/gevent/gevent .. _AppVeyor: https://ci.appveyor.com/project/denik/gevent .. _what's new: http://www.gevent.org/whatsnew_1_1.html .. _changelog: http://www.gevent.org/changelog.html Keywords: greenlet coroutine cooperative multitasking light threads monkey Platform: UNKNOWN Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: POSIX Classifier: Operating System :: Microsoft :: Windows Classifier: Topic :: Internet Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Intended Audience :: Developers Classifier: Development Status :: 4 - Beta gevent-1.1.0/README.rst0000644000076500000000000001123012666555342015223 0ustar jmaddenwheel00000000000000======== gevent ======== gevent_ is a coroutine-based Python networking library. Features include: * Fast event loop based on libev_. * Lightweight execution units based on greenlet_. * Familiar API that re-uses concepts from the Python standard library. * Cooperative sockets with SSL support. * DNS queries performed through c-ares_ or a threadpool. * Ability to use standard library and 3rd party modules written for standard blocking sockets gevent_ is `inspired by eventlet`_ but features more consistent API, simpler implementation and better performance. Read why others `use gevent`_ and check out the list of the `open source projects based on gevent`_. gevent is licensed under the MIT license. See `what's new`_ in the latest major release. Check out the detailed changelog_ for this version. Get gevent ========== Gevent runs on Python >= 2.6, Python >= 3.3, or PyPy >= 4.0.1 (but not PyPy3) (*Note*: PyPy is not supported in Windows). On all platforms, installing setuptools is recommended (this is done automatically if working in a virtual environment). You can use pip to install gevent:: pip install gevent .. tip:: You need Pip 8.0 or later to install the binary wheels for 1.1. Download the latest release from `Python Package Index`_ or clone `the repository`_. Read the documentation online at http://www.gevent.org. Additional installation information can be found `here `_. Post feedback and issues on the `bug tracker`_, `mailing list`_, blog_ and `twitter (@gevent)`_. Development =========== To install the latest development version:: pip install setuptools 'cython>=0.23.4' git+git://github.com/gevent/gevent.git#egg=gevent To hack on gevent (using a virtualenv):: $ git clone https://github.com/gevent/gevent.git $ cd gevent $ virtualenv env $ source env/bin/activate (env) $ pip install -r dev-requirements.txt .. note:: You must have Cython, a C compiler, and the Python development headers installed to build a checkout. Installing CFFI on CPython (it's standard on PyPy) allows building the CFFI backend for testing, and tox is the command used to test multiple versions of Python. Running Tests ------------- There are a few different ways to run the tests. To simply run the tests on one version of Python during development, try this:: python setup.py develop cd greentest PYTHONPATH=.. python testrunner.py --config ../known_failures.py Before submitting a pull request, it's a good idea to run the tests across all supported versions of Python, and to check the code quality using pep8 and pyflakes. This is what is done on Travis CI. Locally it can be done using tox:: pip install tox tox The testrunner accepts a ``--coverage`` argument to enable code coverage metrics through the `coverage.py`_ package. That would go something like this:: cd greentest PYTHONPATH=.. python testrunner.py --config ../known_failures.py --coverage coverage combine coverage html -i Builds on Travis CI automatically submit updates to `coveralls.io`_. .. image:: https://coveralls.io/repos/gevent/gevent/badge.svg?branch=master&service=github :target: https://coveralls.io/github/gevent/gevent?branch=master Continuous integration ---------------------- A test suite is run for every push and pull request submitted. Travis CI is used to test on Linux, and `AppVeyor`_ runs the builds on Windows. .. image:: https://travis-ci.org/gevent/gevent.svg?branch=master :target: https://travis-ci.org/gevent/gevent .. image:: https://ci.appveyor.com/api/projects/status/q4kl21ng2yo2ixur?svg=true :target: https://ci.appveyor.com/project/denik/gevent .. _gevent: http://www.gevent.org .. _greenlet: http://pypi.python.org/pypi/greenlet .. _libev: http://libev.schmorp.de/ .. _c-ares: http://c-ares.haxx.se/ .. _inspired by eventlet: http://blog.gevent.org/2010/02/27/why-gevent/ .. _use gevent: http://groups.google.com/group/gevent/browse_thread/thread/4de9703e5dca8271 .. _open source projects based on gevent: https://github.com/gevent/gevent/wiki/Projects .. _Python Package Index: http://pypi.python.org/pypi/gevent .. _the repository: https://github.com/gevent/gevent .. _bug tracker: https://github.com/gevent/gevent/wiki/Projects .. _mailing list: http://groups.google.com/group/gevent .. _blog: http://blog.gevent.org .. _twitter (@gevent): http://twitter.com/gevent .. _coverage.py: https://pypi.python.org/pypi/coverage/ .. _coveralls.io: https://coveralls.io/github/gevent/gevent .. _AppVeyor: https://ci.appveyor.com/project/denik/gevent .. _what's new: http://www.gevent.org/whatsnew_1_1.html .. _changelog: http://www.gevent.org/changelog.html gevent-1.1.0/rtd-requirements.txt0000644000076500000000000000002112666555342017603 0ustar jmaddenwheel00000000000000cython >= 0.23.4 gevent-1.1.0/scripts/0000755000076500000000000000000012666555433015227 5ustar jmaddenwheel00000000000000gevent-1.1.0/scripts/install.sh0000755000076500000000000000533212666555342017236 0ustar jmaddenwheel00000000000000#!/usr/bin/env bash # GEVENT: Taken from https://raw.githubusercontent.com/DRMacIver/hypothesis/master/scripts/install.sh # Special license: Take literally anything you want out of this file. I don't # care. Consider it WTFPL licensed if you like. # Basically there's a lot of suffering encoded here that I don't want you to # have to go through and you should feel free to use this to avoid some of # that suffering in advance. set -e set -x # This is to guard against multiple builds in parallel. The various installers will tend # to stomp all over eachother if you do this and they haven't previously successfully # succeeded. We use a lock file to block progress so only one install runs at a time. # This script should be pretty fast once files are cached, so the lost of concurrency # is not a major problem. # This should be using the lockfile command, but that's not available on the # containerized travis and we can't install it without sudo. # Is is unclear if this is actually useful. I was seeing behaviour that suggested # concurrent runs of the installer, but I can't seem to find any evidence of this lock # ever not being acquired. BASE=${BUILD_RUNTIMES-$PWD/.runtimes} echo $BASE mkdir -p $BASE LOCKFILE="$BASE/.install-lockfile" while true; do if mkdir $LOCKFILE 2>/dev/null; then echo "Successfully acquired installer." break else echo "Failed to acquire lock. Is another installer running? Waiting a bit." fi sleep $[ ( $RANDOM % 10) + 1 ].$[ ( $RANDOM % 100) ]s if (( $(date '+%s') > 300 + $(stat --format=%X $LOCKFILE) )); then echo "We've waited long enough" rm -rf $LOCKFILE fi done trap "rm -rf $LOCKFILE" EXIT PYENV=$BASE/pyenv if [ ! -d "$PYENV/.git" ]; then rm -rf $PYENV git clone https://github.com/yyuu/pyenv.git $BASE/pyenv else back=$PWD cd $PYENV git fetch || echo "Update failed to complete. Ignoring" git reset --hard origin/master cd $back fi SNAKEPIT=$BASE/snakepit install () { VERSION="$1" ALIAS="$2" mkdir -p $BASE/versions SOURCE=$BASE/versions/$ALIAS if [ ! -e "$SOURCE" ]; then mkdir -p $SNAKEPIT mkdir -p $BASE/versions $BASE/pyenv/plugins/python-build/bin/python-build $VERSION $SOURCE fi rm -f $SNAKEPIT/$ALIAS mkdir -p $SNAKEPIT $SOURCE/bin/python -m pip.__main__ install --upgrade pip wheel virtualenv ln -s $SOURCE/bin/python $SNAKEPIT/$ALIAS } for var in "$@"; do case "${var}" in 2.6) install 2.6.9 python2.6 ;; 2.7) install 2.7.11 python2.7 ;; 3.2) install 3.2.6 python3.2 ;; 3.3) install 3.3.6 python3.3 ;; 3.4) install 3.4.4 python3.4 ;; 3.5) install 3.5.1 python3.5 ;; pypy) install pypy-4.0.1 pypy ;; esac done gevent-1.1.0/scripts/releases/0000755000076500000000000000000012666555433017032 5ustar jmaddenwheel00000000000000gevent-1.1.0/scripts/releases/geventrel.sh0000755000076500000000000000122612666555342021364 0ustar jmaddenwheel00000000000000#!/opt/local/bin/bash # # Quick hack script to build a single gevent release in a virtual env. Takes one # argument, the path to python to use. # Has hardcoded paths, probably only works on my (JAM) machine. set -e export WORKON_HOME=$HOME/Projects/VirtualEnvs export VIRTUALENVWRAPPER_LOG_DIR=~/.virtualenvs source `which virtualenvwrapper.sh` cd /tmp/gevent virtualenv -p $1 `basename $1` cd `basename $1` echo "Made tmpenv" echo `pwd` source bin/activate git clone https://github.com/gevent/gevent cd gevent pip install -U pip pip install -U setuptools cython greenlet cffi pip install -U wheel python ./setup.py sdist bdist_wheel cp dist/*whl /tmp/gevent/ gevent-1.1.0/scripts/releases/geventreleases.sh0000755000076500000000000000136112666555342022405 0ustar jmaddenwheel00000000000000#!/opt/local/bin/bash # Quick hack script to create many gevent releases. # Contains hardcoded paths. Probably only works on my (JAM) machine # (OS X 10.11) mkdir /tmp/gevent/ # 2.6 is provided by Apple, builds a 10_11_intel wheel # no python.org build available ./geventrel.sh /usr/bin/python2.6 # 2.7 is a python.org build, builds a 10_6_intel wheel ./geventrel.sh /usr/local/bin/python2.7 # 3.3 is built by macports, builds a 10_11_64 wheel # no python.org build available ./geventrel.sh /opt/local/bin/python3.3 # 3.4 is a python.org build, builds a 10_6_intel wheel ./geventrel.sh /usr/local/bin/python3.4 # 3.5 is a python.org build, builds a 10_6_intel wheel ./geventrel.sh /usr/local/bin/python3.5 # PyPy 4.0 ./geventrel.sh `which pypy` gevent-1.1.0/setup.py0000755000076500000000000004352312666555342015263 0ustar jmaddenwheel00000000000000#!/usr/bin/env python """gevent build & installation script""" from __future__ import print_function import sys import os import re import shutil import traceback from os.path import join, abspath, basename, dirname from subprocess import check_call from glob import glob PYPY = hasattr(sys, 'pypy_version_info') WIN = sys.platform.startswith('win') CFFI_WIN_BUILD_ANYWAY = os.environ.get("PYPY_WIN_BUILD_ANYWAY") if PYPY and WIN and not CFFI_WIN_BUILD_ANYWAY: # We can't properly handle (hah!) file-descriptors and # handle mapping on Windows/CFFI, because the file needed, # libev_vfd.h, can't be included, linked, and used: it uses # Python API functions, and you're not supposed to do that from # CFFI code. Plus I could never get the libraries= line to ffi.compile() # correct to make linking work. raise Exception("Unable to install on PyPy/Windows") if WIN: # https://bugs.python.org/issue23246 # We must have setuptools on windows __import__('setuptools') # Make sure the env vars that make.cmd needs are set if not os.environ.get('PYTHON_EXE'): os.environ['PYTHON_EXE'] = 'pypy' if PYPY else 'python' if not os.environ.get('PYEXE'): os.environ['PYEXE'] = os.environ['PYTHON_EXE'] import distutils import distutils.sysconfig # to get CFLAGS to pass into c-ares configure script try: from setuptools import Extension, setup except ImportError: if PYPY: # need setuptools for include_package_data to work raise from distutils.core import Extension, setup from distutils.command.build_ext import build_ext from distutils.command.sdist import sdist as _sdist from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError) with open('gevent/__init__.py') as _: __version__ = re.search(r"__version__\s*=\s*'(.*)'", _.read(), re.M).group(1) assert __version__ def _quoted_abspath(p): return '"' + abspath(p) + '"' def parse_environ(key): value = os.environ.get(key) if not value: return value = value.lower().strip() if value in ('1', 'true', 'on', 'yes'): return True elif value in ('0', 'false', 'off', 'no'): return False raise ValueError('Environment variable %r has invalid value %r. Please set it to 1, 0 or an empty string' % (key, value)) def get_config_value(key, defkey, path): value = parse_environ(key) if value is None: value = parse_environ(defkey) if value is not None: return value return os.path.exists(path) LIBEV_EMBED = get_config_value('LIBEV_EMBED', 'EMBED', 'libev') CARES_EMBED = get_config_value('CARES_EMBED', 'EMBED', 'c-ares') define_macros = [] libraries = [] # Configure libev in place; but cp the config.h to the old directory; # if we're building a CPython extension, the old directory will be # the build/temp.XXX/libev/ directory. If we're building from a # source checkout on pypy, OLDPWD will be the location of setup.py # and the PyPy branch will clean it up. libev_configure_command = ' '.join([ "(cd ", _quoted_abspath('libev/'), " && /bin/sh ./configure ", " && cp config.h \"$OLDPWD\"", ")", '> configure-output.txt' ]) # See #616, trouble building for a 32-bit python against a 64-bit platform _config_vars = distutils.sysconfig.get_config_var("CFLAGS") if _config_vars and "m32" in _config_vars: _m32 = 'CFLAGS="' + os.getenv('CFLAGS', '') + ' -m32" ' else: _m32 = '' ares_configure_command = ' '.join(["(cd ", _quoted_abspath('c-ares/'), " && if [ -e ares_build.h ]; then cp ares_build.h ares_build.h.orig; fi ", " && /bin/sh ./configure " + _m32 + "CONFIG_COMMANDS= CONFIG_FILES= ", " && cp ares_config.h ares_build.h \"$OLDPWD\" ", " && mv ares_build.h.orig ares_build.h)", "> configure-output.txt"]) if WIN: libraries += ['ws2_32'] define_macros += [('FD_SETSIZE', '1024'), ('_WIN32', '1')] def expand(*lst): result = [] for item in lst: for name in sorted(glob(item)): result.append(name) return result CORE = Extension(name='gevent.corecext', sources=['gevent/gevent.corecext.c'], include_dirs=['libev'] if LIBEV_EMBED else [], libraries=libraries, define_macros=define_macros, depends=expand('gevent/callbacks.*', 'gevent/stathelper.c', 'gevent/libev*.h', 'libev/*.*')) # QQQ libev can also use -lm, however it seems to be added implicitly ARES = Extension(name='gevent.ares', sources=['gevent/gevent.ares.c'], include_dirs=['c-ares'] if CARES_EMBED else [], libraries=libraries, define_macros=define_macros, depends=expand('gevent/dnshelper.c', 'gevent/cares_*.*')) ARES.optional = True def make_universal_header(filename, *defines): defines = [('#define %s ' % define, define) for define in defines] with open(filename, 'r') as f: lines = f.read().split('\n') ifdef = 0 with open(filename, 'w') as f: for line in lines: if line.startswith('#ifdef'): ifdef += 1 elif line.startswith('#endif'): ifdef -= 1 elif not ifdef: for prefix, define in defines: if line.startswith(prefix): line = '#ifdef __LP64__\n#define %s 8\n#else\n#define %s 4\n#endif' % (define, define) break print(line, file=f) def _system(cmd): sys.stdout.write('Running %r in %s\n' % (cmd, os.getcwd())) return check_call(cmd, shell=True) def system(cmd): if _system(cmd): sys.exit(1) def configure_libev(bext, ext): if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) return bdir = os.path.join(bext.build_temp, 'libev') ext.include_dirs.insert(0, bdir) if not os.path.isdir(bdir): os.makedirs(bdir) cwd = os.getcwd() os.chdir(bdir) try: if os.path.exists('config.h'): return rc = _system(libev_configure_command) if rc == 0 and sys.platform == 'darwin': make_universal_header('config.h', 'SIZEOF_LONG', 'SIZEOF_SIZE_T', 'SIZEOF_TIME_T') finally: os.chdir(cwd) def configure_ares(bext, ext): bdir = os.path.join(bext.build_temp, 'c-ares') ext.include_dirs.insert(0, bdir) if not os.path.isdir(bdir): os.makedirs(bdir) if WIN: shutil.copy("c-ares\\ares_build.h.dist", os.path.join(bdir, "ares_build.h")) return cwd = os.getcwd() os.chdir(bdir) try: if os.path.exists('ares_config.h') and os.path.exists('ares_build.h'): return rc = _system(ares_configure_command) if rc == 0 and sys.platform == 'darwin': make_universal_header('ares_build.h', 'CARES_SIZEOF_LONG') make_universal_header('ares_config.h', 'SIZEOF_LONG', 'SIZEOF_SIZE_T', 'SIZEOF_TIME_T') finally: os.chdir(cwd) if LIBEV_EMBED: CORE.define_macros += [('LIBEV_EMBED', '1'), ('EV_COMMON', ''), # we don't use void* data # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0')] CORE.configure = configure_libev if sys.platform == "darwin": os.environ["CPPFLAGS"] = ("%s %s" % (os.environ.get("CPPFLAGS", ""), "-U__llvm__")).lstrip() if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append(('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) else: CORE.libraries.append('ev') if CARES_EMBED: ARES.sources += expand('c-ares/*.c') ARES.configure = configure_ares if WIN: ARES.libraries += ['advapi32'] ARES.define_macros += [('CARES_STATICLIB', '')] else: ARES.define_macros += [('HAVE_CONFIG_H', '')] if sys.platform != 'darwin': ARES.libraries += ['rt'] ARES.define_macros += [('CARES_EMBED', '1')] else: ARES.libraries.append('cares') ARES.define_macros += [('HAVE_NETDB_H', '')] _ran_make = [] def make(targets=''): # NOTE: We have two copies of the makefile, one # for posix, one for windows. Our sdist command takes # care of renaming the posix one so it doesn't get into # the .tar.gz file (we don't want to re-run make in a released # file). We trigger off the presence/absence of that file altogether # to skip both posix and unix branches. # See https://github.com/gevent/gevent/issues/757 if not _ran_make: if os.path.exists('Makefile'): if WIN: # make.cmd handles checking for PyPy and only making the # right things, so we can ignore the targets system("appveyor\\make.cmd") else: if "PYTHON" not in os.environ: os.environ["PYTHON"] = sys.executable system('make ' + targets) _ran_make.append(1) class sdist(_sdist): def run(self): renamed = False if os.path.exists('Makefile'): make() os.rename('Makefile', 'Makefile.ext') renamed = True try: return _sdist.run(self) finally: if renamed: os.rename('Makefile.ext', 'Makefile') class my_build_ext(build_ext): def gevent_prepare(self, ext): configure = getattr(ext, 'configure', None) if configure: configure(self, ext) def build_extension(self, ext): self.gevent_prepare(ext) try: result = build_ext.build_extension(self, ext) except ext_errors: if getattr(ext, 'optional', False): raise BuildFailed else: raise if not PYPY: self.gevent_symlink(ext) return result def gevent_symlink(self, ext): # hack: create a symlink from build/../core.so to gevent/core.so # to prevent "ImportError: cannot import name core" failures try: fullname = self.get_ext_fullname(ext.name) modpath = fullname.split('.') filename = self.get_ext_filename(ext.name) filename = os.path.split(filename)[-1] if not self.inplace: filename = os.path.join(*modpath[:-1] + [filename]) path_to_build_core_so = os.path.join(self.build_lib, filename) path_to_core_so = join('gevent', basename(path_to_build_core_so)) link(path_to_build_core_so, path_to_core_so) except Exception: traceback.print_exc() def link(source, dest): source = abspath(source) dest = abspath(dest) if source == dest: return try: os.unlink(dest) except OSError: pass try: os.symlink(source, dest) sys.stdout.write('Linking %s to %s\n' % (source, dest)) except (OSError, AttributeError): sys.stdout.write('Copying %s to %s\n' % (source, dest)) shutil.copyfile(source, dest) class BuildFailed(Exception): pass def read(name, *args): try: with open(join(dirname(__file__), name)) as f: return f.read(*args) except OSError: return '' cffi_modules = ['gevent/_corecffi_build.py:ffi'] if PYPY: install_requires = [] else: install_requires = ['greenlet >= 0.4.9'] setup_kwds = {} try: cffi = __import__('cffi') except ImportError: setup_kwds = {} else: _min_cffi_version = (1, 3, 0) _cffi_version_is_supported = cffi.__version_info__ >= _min_cffi_version _kwds = {'cffi_modules': cffi_modules} # We already checked for PyPy on Windows above and excluded it if PYPY: if not _cffi_version_is_supported: raise Exception("PyPy 2.6.1 or higher is required") setup_kwds = _kwds elif LIBEV_EMBED and (not WIN or CFFI_WIN_BUILD_ANYWAY): if not _cffi_version_is_supported: print("WARNING: CFFI version 1.3.0 is required to build CFFI backend", file=sys.stderr) else: # If we're on CPython, we can only reliably build # the CFFI module if we're embedding libev (in some cases # we wind up embedding it anyway, which may not be what the # distributor wanted). setup_kwds = _kwds # If we are running info / help commands, or we're being imported by # tools like pyroma, we don't need to build anything if ((len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or sys.argv[1] in ('--help-commands', 'egg_info', '--version', 'clean', '--long-description'))) or __name__ != '__main__'): ext_modules = [] include_package_data = PYPY run_make = False elif PYPY: if not WIN: # We need to configure libev because the CORE Extension # won't do it (since we're not building it) system(libev_configure_command) # Then get rid of the extra copy created in place system('rm config.h') # NOTE that we're NOT adding the distutils extension module, as # doing so compiles the module already: import gevent._corecffi_build # imports gevent, which imports the hub, which imports the core, # which compiles the module in-place. Instead we use the setup-time # support of cffi_modules #from gevent import _corecffi_build ext_modules = [ #_corecffi_build.ffi.distutils_extension(), ARES, # By building the semaphore with Cython under PyPy, we get # atomic operations (specifically, exiting/releasing), at the # cost of some speed (one trivial semaphore micro-benchmark put the pure-python version # at around 1s and the compiled version at around 4s). Some clever subclassing # and having only the bare minimum be in cython might help reduce that penalty. # NOTE: You must use version 0.23.4 or later to avoid a memory leak. # https://mail.python.org/pipermail/cython-devel/2015-October/004571.html # However, that's all for naught on up to and including PyPy 4.0.1 which # have some serious crashing bugs with GC interacting with cython, # so this is disabled (would need to add gevent/gevent._semaphore.c back to # the run_make line) #Extension(name="gevent._semaphore", # sources=["gevent/gevent._semaphore.c"]), ] include_package_data = True run_make = 'gevent/gevent.ares.c' else: ext_modules = [ CORE, ARES, Extension(name="gevent._semaphore", sources=["gevent/gevent._semaphore.c"]), ] include_package_data = False run_make = True if run_make and os.path.exists("Makefile"): # The 'sdist' command renames our makefile after it # runs so we don't try to use it from a release tarball. # NOTE: This is effectively pointless and serves only for # documentation/metadata, because we run 'make' *before* we run # setup(), so installing cython happens too late. setup_requires = ['cython >= 0.23.4'] else: setup_requires = [] def run_setup(ext_modules, run_make): if run_make: if isinstance(run_make, str): make(run_make) else: make() setup( name='gevent', version=__version__, description='Coroutine-based network library', long_description=read('README.rst'), license='MIT', keywords='greenlet coroutine cooperative multitasking light threads monkey', author='Denis Bilenko', author_email='denis.bilenko@gmail.com', maintainer='Jason Madden', maintainer_email='jason@nextthought.com', url='http://www.gevent.org/', packages=['gevent'], include_package_data=include_package_data, ext_modules=ext_modules, cmdclass=dict(build_ext=my_build_ext, sdist=sdist), install_requires=install_requires, setup_requires=setup_requires, zip_safe=False, test_suite="greentest.testrunner", classifiers=[ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Operating System :: Microsoft :: Windows", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules", "Intended Audience :: Developers", "Development Status :: 4 - Beta"], **setup_kwds ) # Tools like pyroma expect the actual call to `setup` to be performed # at the top-level at import time, so don't stash it away behind 'if # __name__ == __main__' if os.getenv('READTHEDOCS'): # Sometimes RTD fails to put our virtualenv bin directory # on the PATH, meaning we can't run cython. Fix that. new_path = os.environ['PATH'] + os.pathsep + os.path.dirname(sys.executable) os.environ['PATH'] = new_path try: run_setup(ext_modules, run_make=run_make) except BuildFailed: if ARES not in ext_modules: raise ext_modules.remove(ARES) run_setup(ext_modules, run_make=run_make) if ARES not in ext_modules and __name__ == '__main__': sys.stderr.write('\nWARNING: The gevent.ares extension has been disabled.\n') gevent-1.1.0/TODO0000644000076500000000000000010712666555342014225 0ustar jmaddenwheel00000000000000The issue tracker is hosted at https://github.com/gevent/gevent/issues gevent-1.1.0/tox.ini0000644000076500000000000000114312666555342015051 0ustar jmaddenwheel00000000000000[tox] envlist = py26,py27,py33,py34,py35,py27-cffi,pypy,lint [testenv] deps = greenlet cython >= 0.23.4 coverage >= 4.0 psutil cffi whitelist_externals = * commands = make toxtest [testenv:py27-full] basepython = python2.7 commands = make fulltoxtest [testenv:pypy] deps = [testenv:lint] basepython = python2.7 deps = {[testenv]deps} pep8 pyflakes commands = make lint [testenv:py27-cffi] basepython = python2.7 setenv = GEVENT_CORE_CFFI_ONLY=1 commands = make toxtest [testenv:leak] basepython = python2.7 commands = make leaktest gevent-1.1.0/util/0000755000076500000000000000000012666555433014515 5ustar jmaddenwheel00000000000000gevent-1.1.0/util/cythonpp.py0000755000076500000000000006507612666555342016753 0ustar jmaddenwheel00000000000000#!/usr/bin/env python # Copyright (C) 2011-2012 Denis Bilenko (http://denisbilenko.com) import sys import os import re import traceback import datetime import pipes import difflib from hashlib import md5 from itertools import combinations, product do_exec = None if sys.version_info >= (3, 0): exec("def do_exec(co, loc): exec(co, loc)\n") else: exec("def do_exec(co, loc): exec co in loc\n") _ex = lambda: sys.exc_info()[1] CYTHON = os.environ.get('CYTHON') or 'cython' DEBUG = False WRITE_OUTPUT = False if os.getenv('READTHEDOCS'): # Sometimes RTD fails to put our virtualenv bin directory # on the PATH, meaning we can't run cython. Fix that. new_path = os.environ['PATH'] + os.pathsep + os.path.dirname(sys.executable) os.environ['PATH'] = new_path # Parameter name in macros must match this regex: param_name_re = re.compile('^[a-zA-Z_]\w*$') # First line of a definition of a new macro: define_re = re.compile(r'^#define\s+([a-zA-Z_]\w*)(\((?:[^,)]+,)*[^,)]+\))?\s+(.*)$') # Conditional directive: condition_re = re.compile(r'^#(ifdef\s+.+|if\s+.+|else\s*|endif\s*)$') # cython header: cython_header_re = re.compile(r'^/\* (generated by cython [^\s*]+)[^*]+\*/$', re.I) #assert cython_header_re.match('/* Generated by Cython 0.21.1 */').group(1) == 'Generated by Cython 0.21.1' #assert cython_header_re.match('/* Generated by Cython 0.19 on 55-555-555 */').group(1) == 'Generated by Cython 0.19' def match_condition(line): line = line.strip() if line.endswith(':'): return None return condition_re.match(line) newline_token = ' ' def process_filename(filename, output_filename=None): """Process the .ppyx file with preprocessor and compile it with cython. The algorithm is as following: 1) Identify all possible preprocessor conditions in *filename*. 2) Run preprocess_filename(*filename*) for each of these conditions. 3) Process the output of preprocessor with Cython (as many times as there are different sources generated for different preprocessor definitions. 4) Merge the output of different Cython runs using preprocessor conditions identified in (1). """ if output_filename is None: output_filename = filename.rsplit('.', 1)[0] + '.c' pyx_filename = filename.rsplit('.', 1)[0] + '.pyx' assert pyx_filename != filename timestamp = str(datetime.datetime.now().replace(microsecond=0)) banner = 'Generated by cythonpp.py on %s' % timestamp py_banner = '# %s\n' % banner preprocessed = {} for configuration in get_configurations(filename): preprocessed[configuration] = preprocess_filename(filename, Config(configuration)) preprocessed[None] = preprocess_filename(filename, None) preprocessed = expand_to_match(preprocessed.items()) reference_pyx = preprocessed.pop(None) sources = [] counter = 0 for configuration, lines in sorted(preprocessed.items()): counter += 1 value = ''.join(lines) sourcehash = md5(value.encode("utf-8")).hexdigest() comment = format_tag(set(configuration)) atomic_write(pyx_filename, py_banner + value) if WRITE_OUTPUT: atomic_write(pyx_filename + '.%s' % counter, '# %s (%s)\n%s' % (banner, comment, value)) output = run_cython(pyx_filename, sourcehash, output_filename, banner, comment) if WRITE_OUTPUT: atomic_write(output_filename + '.%s' % counter, output) sources.append(attach_tags(output, configuration)) sys.stderr.write('Generating %s ' % output_filename) result = generate_merged(output_filename, sources) atomic_write(output_filename, result) sys.stderr.write('%s bytes\n' % len(result)) if filename != pyx_filename: log('Saving %s', pyx_filename) atomic_write(pyx_filename, py_banner + ''.join(reference_pyx)) def generate_merged(output_filename, sources): result = [] for line in produce_preprocessor(merge(sources)): result.append(line.replace(newline_token, '\n')) return ''.join(result) def preprocess_filename(filename, config): """Process given .ppyx file with preprocessor. This does the following 1) Resolves "#if"s and "#ifdef"s using config 2) Expands macro definitions (#define) """ linecount = 0 current_name = None definitions = {} result = [] including_section = [] for line in open(filename): linecount += 1 rstripped = line.rstrip() stripped = rstripped.lstrip() try: if current_name is not None: name = current_name value = rstripped if value.endswith('\\'): value = value[:-1].rstrip() else: current_name = None definitions[name]['lines'].append(value) else: if not including_section or including_section[-1]: m = define_re.match(stripped) else: m = None if m is not None: name, params, value = m.groups() value = value.strip() if value.endswith('\\'): value = value[:-1].rstrip() current_name = name definitions[name] = {'lines': [value]} if params is None: dbg('Adding definition for %r', name) else: definitions[name]['params'] = parse_parameter_names(params) dbg('Adding definition for %r: %s', name, definitions[name]['params']) else: m = match_condition(stripped) if m is not None and config is not None: if stripped == '#else': if not including_section: raise SyntaxError('unexpected "#else"') if including_section[-1]: including_section.pop() including_section.append(False) else: including_section.pop() including_section.append(True) elif stripped == '#endif': if not including_section: raise SyntaxError('unexpected "#endif"') including_section.pop() else: including_section.append(config.is_condition_true(stripped)) else: if including_section and not including_section[-1]: pass # skip this line because last "#if" was false else: if stripped.startswith('#'): # leave comments as is result.append(Str_sourceline(line, linecount - 1)) else: lines = expand_definitions(line, definitions).split('\n') if lines and not lines[-1]: del lines[-1] lines = [x + '\n' for x in lines] lines = [Str_sourceline(x, linecount - 1) for x in lines] result.extend(lines) except BaseException: ex = _ex() log('%s:%s: %s', filename, linecount, ex) if type(ex) is SyntaxError: sys.exit(1) else: raise return result def merge(sources): r"""Merge different sources into a single one. Each line of the result is a subclass of string that maintains the information for each configuration it should appear in the result. >>> src1 = attach_tags('hello\nworld\n', set([('defined(hello)', True), ('defined(world)', True)])) >>> src2 = attach_tags('goodbye\nworld\n', set([('defined(hello)', False), ('defined(world)', True)])) >>> src3 = attach_tags('hello\neveryone\n', set([('defined(hello)', True), ('defined(world)', False)])) >>> src4 = attach_tags('goodbye\neveryone\n', set([('defined(hello)', False), ('defined(world)', False)])) >>> from pprint import pprint >>> pprint(merge([src1, src2, src3, src4])) [Str('hello\n', [set([('defined(hello)', True)])]), Str('goodbye\n', [set([('defined(hello)', False)])]), Str('world\n', [set([('defined(world)', True)])]), Str('everyone\n', [set([('defined(world)', False)])])] """ if len(sources) <= 1: return [Str(str(x), simplify_tags(x.tags)) for x in sources[0]] return merge([list(_merge(sources[0], sources[1]))] + sources[2:]) def _merge(a, b): for tag, i1, i2, j1, j2 in difflib.SequenceMatcher(None, a, b).get_opcodes(): if tag == 'equal': for line_a, line_b in zip(a[i1:i2], b[j1:j2]): tags = getattr(line_a, 'tags', []) + getattr(line_b, 'tags', []) yield Str(line_a, tags) else: for line in a[i1:i2]: yield line for line in b[j1:j2]: yield line def expand_to_match(items): """Insert empty lines so that all sources has matching line numbers for the same code""" cfg2newlines = {} # maps configuration -> list for configuration, lines in items: cfg2newlines[configuration] = [] maxguard = 2 ** 30 while True: minimalsourceline = maxguard for configuration, lines in items: if lines: minimalsourceline = min(minimalsourceline, lines[0].sourceline) if minimalsourceline == maxguard: break for configuration, lines in items: if lines and lines[0].sourceline <= minimalsourceline: cfg2newlines[configuration].append(lines[0]) del lines[0] number_of_lines = max(len(x) for x in cfg2newlines.values()) for newlines in cfg2newlines.values(): add = (number_of_lines - len(newlines)) newlines.extend(['\n'] * add) return cfg2newlines def produce_preprocessor(iterable): current_line = [0] def wrap(line, log=True): current_line[0] += 1 dbg('%5d: %s', current_line[0], repr(str(line))[1:-1]) return line state = None for line in iterable: key = line.tags or None if key == state: yield wrap(line, key) else: if exact_reverse(key, state): yield wrap('#else /* %s */\n' % format_tags(state)) else: if state: yield wrap('#endif /* %s */\n' % format_tags(state)) if key: yield wrap('#if %s\n' % format_tags(key)) yield wrap(line, key) state = key if state: yield wrap('#endif /* %s */\n' % format_tags(state)) def exact_reverse(tags1, tags2): if not tags1: return if not tags2: return if not isinstance(tags1, list): raise TypeError(repr(tags1)) if not isinstance(tags2, list): raise TypeError(repr(tags2)) if len(tags1) == 1 and len(tags2) == 1: tag1 = tags1[0] tag2 = tags2[0] assert isinstance(tag1, set), tag1 assert isinstance(tag2, set), tag2 if len(tag1) == 1 and len(tag2) == 1: tag1 = list(tag1)[0] tag2 = list(tag2)[0] if tag1[0] == tag2[0]: return sorted([tag1[1], tag2[1]]) == [False, True] def format_cond(cond): if isinstance(cond, tuple) and len(cond) == 2 and isinstance(cond[-1], bool): pass else: raise TypeError(repr(cond)) if cond[1]: return cond[0] else: return '!' + cond[0] def format_tag(tag): if not isinstance(tag, set): raise TypeError(repr(tag)) return ' && '.join([format_cond(x) for x in sorted(tag)]) def format_tags(tags): if not isinstance(tags, list): raise TypeError(repr(tags)) return ' || '.join('(%s)' % format_tag(x) for x in tags) def attach_tags(text, tags): result = [x for x in text.split('\n')] if result and not result[-1]: del result[-1] return [Str(x + '\n', set(tags)) for x in result] def is_tags_type(tags): if not isinstance(tags, list): return False for tag in tags: if not isinstance(tag, set): return False for item in tag: if isinstance(item, tuple) and len(item) == 2 and isinstance(item[1], bool) and isinstance(item[0], str): pass else: raise TypeError('Invalid item: %r\n%s' % (item, tags)) return True class Str(str): """This is a string subclass that has a set of tags attached to it. Used for merging the outputs. """ def __new__(cls, string, tags): if not isinstance(string, str): raise TypeError('string must be str: %s' % (type(string), )) if isinstance(tags, set): tags = [tags] if not is_tags_type(tags): raise TypeError('tags must be a list of sets of 2-tuples: %r' % (tags, )) self = str.__new__(cls, string) self.tags = tags return self def __repr__(self): return '%s(%s, %r)' % (self.__class__.__name__, str.__repr__(self), self.tags) def __add__(self, other): if not isinstance(other, str): raise TypeError return self.__class__(str.__add__(self, other), self.tags) def __radd__(self, other): if not isinstance(other, str): raise TypeError return self.__class__(str.__add__(other, self), self.tags) methods = ['__getslice__', '__getitem__', '__mul__', '__rmod__', '__rmul__', 'join', 'replace', 'upper', 'lower'] for method in methods: do_exec('''def %s(self, *args): return self.__class__(str.%s(self, *args), self.tags)''' % (method, method), locals()) def simplify_tags(tags): """ >>> simplify_tags([set([('defined(world)', True), ('defined(hello)', True)]), ... set([('defined(world)', False), ('defined(hello)', True)])]) [set([('defined(hello)', True)])] >>> simplify_tags([set([('defined(LIBEV_EMBED)', True), ('defined(_WIN32)', True)]), set([('defined(LIBEV_EMBED)', True), ... ('defined(_WIN32)', False)]), set([('defined(_WIN32)', False), ('defined(LIBEV_EMBED)', False)]), ... set([('defined(LIBEV_EMBED)', False), ('defined(_WIN32)', True)])]) [] """ if not isinstance(tags, list): raise TypeError for x in tags: if not x: tags.remove(x) return simplify_tags(tags) for tag1, tag2 in combinations(tags, 2): if tag1 == tag2: tags.remove(tag1) return simplify_tags(tags) for item in tag1: reverted_item = reverted(item) if reverted_item in tag2: tag1_copy = tag1.copy() tag1_copy.remove(item) tag2_copy = tag2.copy() tag2_copy.remove(reverted_item) if tag1_copy == tag2_copy: tags.remove(tag1) tags.remove(tag2) tags.append(tag1_copy) return simplify_tags(tags) return tags def reverted(item): if not isinstance(item, tuple): raise TypeError(repr(item)) if len(item) != 2: raise TypeError(repr(item)) if item[-1] is True: return (item[0], False) elif item[-1] is False: return (item[0], True) raise ValueError(repr(item)) def parse_parameter_names(x): assert x.startswith('(') and x.endswith(')'), repr(x) x = x[1:-1] result = [] for param in x.split(','): param = param.strip() if not param_name_re.match(param): raise SyntaxError('Invalid parameter name: %r' % param) result.append(param) return result def parse_parameter_values(x): assert x.startswith('(') and x.endswith(')'), repr(x) x = x[1:-1] result = [] for param in x.split(','): result.append(param.strip()) return result def expand_definitions(code, definitions): if not definitions: return code keys = list(definitions.keys()) keys.sort(key=lambda x: (-len(x), x)) keys = '|'.join(keys) # This regex defines a macro invocation re_macro = re.compile(r'(^|##|[^\w])(%s)(\([^)]+\)|$|##|[^w])' % keys) def repl(m): token = m.group(2) definition = definitions[token] params = definition.get('params', []) if params: arguments = m.group(3) if arguments.startswith('(') and arguments.endswith(')'): arguments = parse_parameter_values(arguments) else: arguments = None if arguments and len(params) == len(arguments): local_definitions = {} dbg('Macro %r params=%r arguments=%r source=%r', token, params, arguments, m.groups()) for key, value in zip(params, arguments): dbg('Adding argument %r=%r', key, value) local_definitions[key] = {'lines': [value]} result = expand_definitions('\n'.join(definition['lines']), local_definitions) else: msg = 'Invalid number of arguments for macro %s: expected %s, got %s' msg = msg % (token, len(params), len(arguments or [])) raise SyntaxError(msg) else: result = '\n'.join(definition['lines']) if m.group(3) != '##': result += m.group(3) if m.group(1) != '##': result = m.group(1) + result dbg('Replace %r with %r', m.group(0), result) return result for _ in range(20000): newcode, count = re_macro.subn(repl, code, count=1) if code == newcode: if count > 0: raise SyntaxError('Infinite recursion') return newcode code = newcode raise SyntaxError('Too many substitutions or internal error.') class Str_sourceline(str): def __new__(cls, source, sourceline): self = str.__new__(cls, source) self.sourceline = sourceline return self def atomic_write(filename, data): tmpname = filename + '.tmp.%s' % os.getpid() with open(tmpname, 'w') as f: f.write(data) f.flush() os.fsync(f.fileno()) if os.path.exists(filename): os.unlink(filename) os.rename(tmpname, filename) dbg('Wrote %s bytes to %s', len(data), filename) def run_cython(filename, sourcehash, output_filename, banner, comment, cache={}): result = cache.get(sourcehash) command = '%s -o %s %s' % (CYTHON, pipes.quote(output_filename), pipes.quote(filename)) if result is not None: log('Reusing %s # %s', command, comment) return result system(command, comment) result = postprocess_cython_output(output_filename, banner) cache[sourcehash] = result return result def system(command, comment): log('Running %s # %s', command, comment) result = os.system(command) if result: # debugging code log("Path: %s", os.getenv("PATH")) bin_dir = os.path.dirname(sys.executable) bin_files = os.listdir(bin_dir) bin_files.sort() log("Bin: %s files: %s", bin_dir, ' '.join(bin_files)) raise AssertionError('%r failed with code %s' % (command, result)) def postprocess_cython_output(filename, banner): # this does a few things: # 1) converts multiline C-style (/**/) comments with a single line comment by # replacing \n with newline_token # 2) adds our header # 3) remove timestamp in cython's header so that different timestamps do not # confuse merger result = ['/* %s */\n' % (banner)] with open(filename) as finput: firstline = finput.readline() m = cython_header_re.match(firstline.strip()) if m: result.append('/* %s */' % m.group(1)) else: result.append(firstline) in_comment = False for line in finput: if line.endswith('\n'): line = line[:-1].rstrip() + '\n' if in_comment: if '*/' in line: in_comment = False result.append(line) else: result.append(line.replace('\n', newline_token)) else: if line.lstrip().startswith('/* ') and '*/' not in line: line = line.lstrip() # cython adds space before /* for some reason line = line.replace('\n', newline_token) result.append(line) in_comment = True else: result.append(line) return ''.join(result) class Config(object): def __init__(self, configuration): self.conditions = set(configuration) def is_condition_true(self, directive): if directive.startswith('#if '): parameter = directive.split(' ', 1)[1] elif directive.startswith('#ifdef '): parameter = directive.split(' ', 1)[1] parameter = 'defined(%s)' % parameter else: raise AssertionError('Invalid directive: %r' % directive) cond = (parameter, True) return cond in self.conditions def get_conditions(filename): conditions = set() condition_stack = [] linecount = 0 for line in open(filename): linecount += 1 try: m = match_condition(line) if m is not None: split = m.group(1).strip().split(' ', 1) directive = split[0].strip() if len(split) == 1: parameter = None assert directive in ('else', 'endif'), directive else: parameter = split[1].strip() assert directive in ('if', 'ifdef'), directive if directive == 'ifdef': directive = 'if' parameter = 'defined(%s)' % parameter if directive == 'if': condition_stack.append((parameter, True)) elif directive == 'else': if not condition_stack: raise SyntaxError('Unexpected "#else"') last_cond, true = condition_stack.pop() assert true is True, true condition_stack.append((last_cond, not true)) elif directive == 'endif': if not condition_stack: raise SyntaxError('Unexpected "#endif"') condition_stack.pop() else: raise AssertionError('Internal error') else: conditions.add(tuple(condition_stack)) except BaseException: ex = _ex() log('%s:%s: %s', filename, linecount, ex) if type(ex) is SyntaxError: sys.exit(1) else: raise return conditions def flat_tuple(x): result = [] for item in x: for subitem in item: result.append(subitem) return tuple(result) def get_selections(items): return set([flat_tuple(sorted(set(x))) for x in product(items, repeat=len(items))]) def is_impossible(configuration): conds = {} for cond, flag in configuration: if cond in conds: if conds.get(cond) != flag: return True conds[cond] = flag def get_configurations(filename): conditions = get_conditions(filename) configurations = [] allconds = set() for configuration in get_selections(conditions): if not is_impossible(configuration): configurations.append(configuration) for cond, flag in configuration: allconds.add(cond) result = set() for configuration in configurations: conds = set(x[0] for x in configuration) missing_conds = allconds - conds for cond in missing_conds: configuration = configuration + ((cond, False), ) result.add(tuple(sorted(configuration))) return result def log(message, *args): try: string = message % args except Exception: try: prefix = 'Traceback (most recent call last):\n' lines = traceback.format_stack()[:-1] error_lines = traceback.format_exc().replace(prefix, '') last_length = len(lines[-1].strip().rsplit(' ', 1)[-1]) last_length = min(80, last_length) last_length = max(5, last_length) msg = '%s%s %s\n%s' % (prefix, ''.join(lines), '^' * last_length, error_lines) sys.stderr.write(msg) except Exception: traceback.print_exc() try: message = '%r %% %r\n\n' % (message, args) except Exception: pass try: sys.stderr.write(message) except Exception: traceback.print_exc() else: sys.stderr.write(string + '\n') def dbg(*args): if not DEBUG: return return log(*args) if __name__ == '__main__': import optparse parser = optparse.OptionParser() parser.add_option('--debug', action='store_true') parser.add_option('--list', action='store_true', help='Show the list of different conditions') parser.add_option('--list-cond', action='store_true') parser.add_option('--ignore-cond', action='store_true', help='Ignore conditional directives (only expand definitions)') parser.add_option('--write-intermediate', action='store_true', help='Save intermediate files produced by preprocessor and Cython') parser.add_option('-o', '--output-file', help='Specify name of generated C file') options, args = parser.parse_args() if len(args) != 1: sys.exit('Expected one argument (filename), got %r' % args) filename = args[0] if options.debug: DEBUG = True if options.write_intermediate: WRITE_OUTPUT = True run = True if options.list_cond: run = False for x in get_conditions(filename): sys.stdout.write('* %s\n' % (x, )) if options.list: run = False for x in get_configurations(filename): sys.stdout.write('* %s\n' % (x, )) if options.ignore_cond: run = False class FakeConfig(object): def is_condition_true(*args): return False sys.stdout.write(preprocess_filename(filename, FakeConfig())) if run: process_filename(filename, options.output_file) gevent-1.1.0/util/makedeb.sh0000755000076500000000000000051512666555342016444 0ustar jmaddenwheel00000000000000#!/bin/bash set -e CWD=`pwd` rm -fr /tmp/build_gevent_deb set -x mkdir /tmp/build_gevent_deb #util/makedist.py --dest /tmp/build_gevent_deb/gevent.tar.gz --version dev cd /tmp/build_gevent_deb tar -xf $CWD/dist/gevent-1.0.tar.gz fpm --no-python-dependencies -s python -t deb gevent*/setup.py mkdir -p $CWD/build mv *.deb $CWD/build/ gevent-1.1.0/util/makedist.py0000755000076500000000000000434312666555342016676 0ustar jmaddenwheel00000000000000#!/usr/bin/python # Copyright (C) 2012 Denis Bilenko (http://denisbilenko.com) """ Create a source distribution of gevent. Does the following: - Clones the repo into a temporary location. - Run set_version.py that will update gevent/__init__.py. - Run 'python setup.py sdist'. """ from __future__ import print_function import sys import os import glob import optparse from os.path import exists, join, abspath, basename from pipes import quote TMPDIR = '/tmp/gevent-make-dist' def system(cmd, noisy=True): if noisy: print(cmd) res = os.system(cmd) if res: sys.exit('%r failed with %s' % (cmd, res)) def makedist(*args, **kwargs): cwd = os.getcwd() try: return _makedist(*args, **kwargs) finally: os.chdir(cwd) def _makedist(version=None, dest=None): assert exists('gevent/__init__.py'), 'Where am I?' basedir = abspath(os.getcwd()) version = version or 'dev' set_version_command = 'util/set_version.py --version %s ./gevent/__init__.py' % version os.chdir('/tmp') system('rm -fr ' + TMPDIR) os.mkdir(TMPDIR) os.chdir(TMPDIR) system('git clone %s gevent' % basedir) directory = os.listdir('.') assert len(directory) == 1, directory os.chdir(directory[0]) system('git branch') system(set_version_command) system('git diff', noisy=False) system('python setup.py -q sdist') dist_filename = glob.glob('dist/gevent-*.tar.gz') assert len(dist_filename) == 1, dist_filename dist_path = abspath(dist_filename[0]) dist_filename = basename(dist_path) if dest: if os.path.isdir(dest): dest = join(dest, dist_filename) else: if not exists(join(basedir, 'dist')): os.mkdir(join(basedir, 'dist')) dest = join(basedir, 'dist', dist_filename) copy(dist_path, dest) return dist_path def main(): parser = optparse.OptionParser() parser.add_option('--dest') parser.add_option('--version') options, args = parser.parse_args() assert not args, 'Expected no arguments' return makedist(options.version, dest=options.dest) def copy(source, dest): system('cp -a %s %s' % (quote(source), quote(dest))) if __name__ == '__main__': main() gevent-1.1.0/util/pyflakes.py0000755000076500000000000000567712666555342016726 0ustar jmaddenwheel00000000000000#!/usr/bin/env python from __future__ import print_function import sys import re import subprocess import glob IGNORED = r""" examples/webchat/urls.py:1: 'from django.conf.urls.defaults import *' used; unable to detect undefined names gevent/_?ssl[23]?.py:\d+: undefined name gevent/__init__.py:\d+: redefinition of unused 'signal' from line gevent/__init__.py:\d+: redefinition of unused 'socket' from line gevent/__init__.py:\d+:.*imported but unused gevent/_socket[23].py:\d+: undefined name gevent/_socketcommon.py:\d+: .*imported but unused gevent/_socketcommon.py:\d+: undefined name gevent/_sslgte279.py:.* gevent/core.py:\d+: 'from gevent.corecext import *' used; unable to detect undefined names gevent/core.py:\d+: 'from gevent.corecffi import *' used; unable to detect undefined names gevent/coros.py:\d+: '__all__' imported but unused gevent/coros.py:\d+: 'from gevent.lock import *' used; unable to detect undefined names gevent/hub.py:\d+: 'reraise' imported but unused gevent/os.py:\d+: redefinition of unused 'fork' from line gevent/socket.py:\d+: undefined name gevent/subprocess.py:\d+: undefined name gevent/thread.py:\d+: '_local' imported but unused gevent/threading.py:\d+: '\w+' imported but unused gevent/wsgi.py:1: 'from gevent.pywsgi import *' used; unable to detect undefined names greentest/test__queue.py:\d+: undefined name 'GenericGetTestCase' greentest/test__server_pywsgi.py: """ # Travis runs this on Python 2, but this is only defined # and used, in Python 3 IGNORED += r""" gevent/server.py:\d+: undefined name 'BlockingIOError' """ IGNORED = IGNORED.strip().replace(' *', ' \\*').split('\n') def is_ignored(line): for pattern in IGNORED: if re.match(pattern, line): return True def pyflakes(args): popen = subprocess.Popen('%s `which pyflakes` %s' % (sys.executable, args), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, errors = popen.communicate() if errors: sys.stderr.write(errors.decode()) if popen.poll() != 1: sys.stderr.write(output + '\n') sys.exit('pyflakes returned %r' % popen.poll()) if errors: sys.exit(1) assert output output = output.decode('utf-8') output = output.strip().split('\n') failed = False for line in output: line = line.strip() if not is_ignored(line): print('E %s' % line) failed = True #else: # print('I %s' % line) if failed: sys.exit(1) pyflakes('examples/ greentest/*.py util/ *.py') if sys.version_info[0] == 3: ignored_files = ['gevent/_util_py2.py', 'gevent/_socket2.py', 'gevent/_fileobject2.py', 'gevent/builtins.py'] else: ignored_files = ['gevent/_socket3.py', 'gevent/_fileobject3.py'] ignored_files.append('gevent/wsgi.py') py = set(glob.glob('gevent/*.py')) - set(ignored_files) pyflakes(' '.join(py)) gevent-1.1.0/util/set_version.py0000755000076500000000000001075412666555342017440 0ustar jmaddenwheel00000000000000#!/usr/bin/python """Update __version__, version_info and add __changeset__. 'dev' in version_info should be replaced with alpha|beta|candidate|final 'dev' in __version__ should be replaced with a|b|rc| """ from __future__ import print_function import sys import os import re from optparse import OptionParser from distutils.version import LooseVersion version_re = re.compile("^__version__\s*=\s*'([^']+)'", re.M) version_info_re = re.compile(r"^version_info\s*=\s*([^\n]+)", re.M) strict_version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$', re.VERBOSE) def read(command): popen = os.popen(command) data = popen.read() retcode = popen.close() if retcode: sys.exit('Failed (%s) to run %r' % (retcode, command)) return data.strip() def get_changeset(): return read('git describe --tags --always --dirty --long') def get_version_info(version): """ >>> get_version_info('0.13.6') (0, 13, 6, 'final', 0) >>> get_version_info('1.1') (1, 1, 0, 'final', 0) >>> get_version_info('1') (1, 0, 0, 'final', 0) >>> get_version_info('1.0dev1') (1, 0, 0, 'dev', 1) >>> get_version_info('1.0a3') (1, 0, 0, 'alpha', 3) >>> get_version_info('1.0rc1') (1, 0, 0, 'candidate', 1) """ repl = {'a': 'alpha', 'b': 'beta', 'rc': 'candidate', 'dev': 'dev'} components = LooseVersion(version).version result = [] for component in components: if isinstance(component, int): result.append(component) else: while len(result) < 3: result.append(0) component = repl[component] result.append(component) while len(result) < 3: result.append(0) if len(result) == 3: result.append('final') result.append(0) return tuple(result) def modify_version(filename, new_version): # return (current_contents, modified_contents, is_match) original_data = open(filename).read() assert '__changeset__' not in original_data, 'Must revert the old update first' data = original_data if new_version: new_version_info = get_version_info(new_version) def repl_version_info(m): return 'version_info = %s' % (new_version_info, ) data, count = version_info_re.subn(repl_version_info, data) if not count: raise AssertionError('version_info not found in %s' % filename) if count != 1: raise AssertionError('version_info found more than once in %s' % filename) def repl_version(m): result = m.group(0).replace(m.group(1), new_version or m.group(1)) result += "\n__changeset__ = '%s'" % get_changeset() return result data, count = version_re.subn(repl_version, data) if not count: raise AssertionError('__version__ not found in %s' % filename) if count != 1: raise AssertionError('__version__ found more than once in %s' % filename) return original_data, data def unlink(path): try: os.unlink(path) except OSError as ex: if ex.errno == 2: # No such file or directory return raise def write(filename, data): # intentionally breaking links here so that util/makedist.py can use "cp --link" tmpname = filename + '.tmp.%s' % os.getpid() f = open(tmpname, 'w') try: f.write(data) f.flush() os.fsync(f.fileno()) f.close() os.rename(tmpname, filename) except: unlink(tmpname) raise def main(): global options parser = OptionParser() parser.add_option('--version', default='dev') parser.add_option('--dry-run', action='store_true') options, args = parser.parse_args() assert len(args) == 1, 'One argument is expected, got %s' % len(args) version = options.version if version.lower() == 'dev': version = '' if version and strict_version_re.match(version) is None: sys.stderr.write('WARNING: Not a strict version: %r (bdist_msi will fail)' % version) filename = args[0] original_content, new_content = modify_version(filename, version) if options.dry_run: tmpname = '/tmp/' + os.path.basename(filename) + '.set_version' write(tmpname, new_content) if not os.system('diff -u %s %s' % (filename, tmpname)): sys.exit('No differences applied') else: write(filename, new_content) print('Updated %s' % filename) if __name__ == '__main__': main() gevent-1.1.0/util/wintest.py0000755000076500000000000000521012666555342016564 0ustar jmaddenwheel00000000000000#!/usr/bin/python -u """ Unix utilities must be installed on target machine for this to work: http://unxutils.sourceforge.net/ """ import sys import os import optparse def system(cmd, exit=True): sys.stderr.write('+ %s\n' % cmd) retcode = os.system(cmd) if retcode: if exit: sys.exit('%r failed' % cmd) return retcode parser = optparse.OptionParser() parser.add_option('--host') parser.add_option('--username', default='Administrator') parser.add_option('--source') parser.add_option('--dist', action='store_true') parser.add_option('--python', default='27') options, args = parser.parse_args() def prepare(): source_name = args[1] tar_name = source_name.rsplit('.', 1)[0] dir_name = tar_name.rsplit('.', 1)[0] system('rm -fr %s %s' % (tar_name, dir_name)) system('gzip -d %s && tar -xf %s' % (source_name, tar_name)) os.chdir(dir_name) os.environ.setdefault('VS90COMNTOOLS', 'C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\Tools\\') if args[0:1] == ['test']: prepare() system('%s setup.py build' % sys.executable) os.chdir('greentest') os.environ['PYTHONPATH'] = '.;..;../..' system('%s testrunner.py --config ../known_failures.py' % sys.executable) elif args[0:1] == ['dist']: prepare() success = 0 for command in ['bdist_egg', 'bdist_wininst', 'bdist_msi']: cmd = sys.executable + ' setup.py ' + command if not system(cmd, exit=False): success += 1 if not success: sys.exit('bdist_egg bdist_wininst and bdist_msi all failed') elif not args: assert options.host if not options.source: import makedist options.source = makedist.makedist() options.source_name = os.path.basename(options.source) options.script_path = os.path.abspath(__file__) options.script_name = os.path.basename(__file__) if options.python.isdigit(): options.python = 'C:/Python' + options.python + '/python.exe' tar_name = options.source_name.rsplit('.', 1)[0] dir_name = tar_name.rsplit('.', 1)[0] options.dir_name = dir_name system('scp %(source)s %(script_path)s %(username)s@%(host)s:' % options.__dict__) if options.dist: system('ssh %(username)s@%(host)s %(python)s -u %(script_name)s dist %(source_name)s' % options.__dict__) try: os.mkdir('dist') except OSError: pass system('scp -r %(username)s@%(host)s:%(dir_name)s/dist/ dist' % options.__dict__) else: system('ssh %(username)s@%(host)s C:/Python27/python.exe -u %(script_name)s test %(source_name)s' % options.__dict__) else: sys.exit('Invalid args: %r' % (args, ))